/* ==========================================================
   IWB CRM — Innovative Website Builds
   Glass UI · 3D shapes · Brand: navy #071C40 / blue #1167D4
   ========================================================== */
:root {
  --navy: #071c40;
  --navy-2: #0d2a5c;
  --blue: #1167d4;
  --blue-2: #2f86f6;
  --sky: #6fb4ff;
  --ink: #0b1733;
  --muted: #5b6b8c;
  --line: rgba(7, 28, 64, 0.08);
  --bg: #eef3fb;
  --glass: rgba(255, 255, 255, 0.62);
  --glass-strong: rgba(255, 255, 255, 0.82);
  --glass-border: rgba(255, 255, 255, 0.75);
  --shadow: 0 10px 40px rgba(7, 28, 64, 0.10), 0 2px 6px rgba(7, 28, 64, 0.05);
  --shadow-lg: 0 30px 80px rgba(7, 28, 64, 0.18);
  --green: #10a37f;
  --amber: #e59b13;
  --red: #e0414f;
  --violet: #6b5cff;
  --radius: 20px;
  --radius-sm: 12px;
  --sidebar: 264px;
  --font: "Manrope", "Inter", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}
[data-theme="dark"] {
  --ink: #e8eefc;
  --muted: #93a3c4;
  --line: rgba(255, 255, 255, 0.08);
  --bg: #050d20;
  --glass: rgba(17, 32, 66, 0.55);
  --glass-strong: rgba(17, 32, 66, 0.85);
  --glass-border: rgba(120, 160, 255, 0.14);
  --shadow: 0 10px 40px rgba(0, 0, 0, 0.35);
  --shadow-lg: 0 30px 80px rgba(0, 0, 0, 0.5);
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body {
  font-family: var(--font);
  color: var(--ink);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
}
a { color: var(--blue); text-decoration: none; }
button, input, select, textarea { font: inherit; color: inherit; }
h1, h2, h3, h4 { margin: 0; letter-spacing: -0.02em; }
.hidden { display: none !important; }

/* ---------- Background scene with 3D shapes ---------- */
.scene { position: fixed; inset: 0; z-index: 0; pointer-events: none; overflow: hidden; perspective: 1200px; }
.scene::before {
  content: ""; position: absolute; inset: -20%;
  background:
    radial-gradient(40% 40% at 15% 10%, rgba(47, 134, 246, 0.22), transparent 70%),
    radial-gradient(35% 35% at 90% 20%, rgba(107, 92, 255, 0.14), transparent 70%),
    radial-gradient(45% 45% at 80% 95%, rgba(17, 103, 212, 0.18), transparent 70%);
}
.sphere {
  position: absolute; border-radius: 50%;
  background: radial-gradient(circle at 30% 28%, #ffffff 0%, #9cc8ff 18%, #2f86f6 48%, #0d2a5c 88%);
  box-shadow: inset -18px -24px 50px rgba(7, 28, 64, 0.45), 0 40px 80px rgba(17, 103, 212, 0.25);
  animation: float 14s ease-in-out infinite;
}
.sphere.s1 { width: 220px; height: 220px; top: -60px; right: 8%; }
.sphere.s2 { width: 110px; height: 110px; bottom: 8%; left: 18%; animation-delay: -5s; opacity: .9; }
.sphere.s3 { width: 60px; height: 60px; top: 40%; right: 3%; animation-delay: -9s; }
.ring {
  position: absolute; width: 260px; height: 260px; bottom: -80px; right: 22%;
  border-radius: 50%; border: 26px solid transparent;
  background: linear-gradient(135deg, #6fb4ff, #1167d4 45%, #071c40) border-box;
  -webkit-mask: linear-gradient(#000 0 0) padding-box, linear-gradient(#000 0 0);
  -webkit-mask-composite: xor; mask-composite: exclude;
  transform: rotateX(62deg) rotateZ(20deg);
  animation: spinRing 30s linear infinite; opacity: .55;
}
.cube {
  position: absolute; width: 56px; height: 56px; transform-style: preserve-3d;
  animation: spinCube 18s linear infinite;
}
.cube.c1 { top: 18%; left: 42%; }
.cube.c2 { top: 70%; right: 6%; width: 38px; height: 38px; animation-duration: 24s; }
.cube.c3 { top: 8%; left: 6%; width: 30px; height: 30px; animation-duration: 20s; animation-direction: reverse; }
.cube span {
  position: absolute; inset: 0; border-radius: 6px;
  background: linear-gradient(135deg, rgba(111, 180, 255, .95), rgba(17, 103, 212, .9));
  border: 1px solid rgba(255, 255, 255, .5);
}
.cube span:nth-child(1) { transform: translateZ(calc(var(--s, 28px))); }
.cube span:nth-child(2) { transform: rotateY(180deg) translateZ(var(--s, 28px)); background: #0d2a5c; }
.cube span:nth-child(3) { transform: rotateY(90deg) translateZ(var(--s, 28px)); background: linear-gradient(135deg, #2f86f6, #0d2a5c); }
.cube span:nth-child(4) { transform: rotateY(-90deg) translateZ(var(--s, 28px)); background: #1167d4; }
.cube span:nth-child(5) { transform: rotateX(90deg) translateZ(var(--s, 28px)); background: #6fb4ff; }
.cube span:nth-child(6) { transform: rotateX(-90deg) translateZ(var(--s, 28px)); background: #071c40; }
.cube.c2 { --s: 19px; } .cube.c3 { --s: 15px; }
@keyframes float { 0%,100% { transform: translateY(0) } 50% { transform: translateY(-26px) } }
@keyframes spinCube { from { transform: rotateX(0) rotateY(0) } to { transform: rotateX(360deg) rotateY(720deg) } }
@keyframes spinRing { from { transform: rotateX(62deg) rotateZ(0) } to { transform: rotateX(62deg) rotateZ(360deg) } }
@media (prefers-reduced-motion: reduce) { .sphere, .cube, .ring { animation: none; } }

/* ---------- Glass primitives ---------- */
.glass {
  background: var(--glass);
  backdrop-filter: blur(22px) saturate(160%);
  -webkit-backdrop-filter: blur(22px) saturate(160%);
  border: 1px solid var(--glass-border);
  box-shadow: var(--shadow);
  border-radius: var(--radius);
}

/* ---------- Login ---------- */
.login-wrap { position: relative; z-index: 1; min-height: 100vh; display: grid; place-items: center; padding: 24px; }
.login-card { width: 100%; max-width: 420px; padding: 40px 34px 32px; text-align: center; }
.login-card img { width: 150px; margin-bottom: 18px; }
.login-card h1 { font-size: 22px; margin-bottom: 6px; }
.login-card p.sub { color: var(--muted); margin: 0 0 24px; font-size: 14px; }
.login-card form { text-align: left; display: grid; gap: 14px; }
.login-hint { margin-top: 18px; font-size: 12.5px; color: var(--muted); background: rgba(17,103,212,.07); border-radius: 10px; padding: 10px 12px; text-align: left; }
.login-error { color: var(--red); font-size: 13px; min-height: 18px; }
[data-theme="dark"] .logo-plate { background: rgba(255,255,255,.92); border-radius: 14px; padding: 8px 12px; }

/* ---------- App shell ---------- */
.app { position: relative; z-index: 1; display: flex; min-height: 100vh; }
.sidebar {
  position: fixed; top: 16px; bottom: 16px; left: 16px; width: var(--sidebar);
  display: flex; flex-direction: column; padding: 22px 16px; z-index: 30;
  transition: transform .3s ease;
}
.brand { display: flex; align-items: center; justify-content: center; padding: 4px 8px 18px; border-bottom: 1px solid var(--line); margin-bottom: 14px; }
.brand img { width: 128px; display: block; }
.nav { display: grid; gap: 4px; overflow-y: auto; flex: 1; align-content: start; }
.nav a {
  display: flex; align-items: center; gap: 12px; padding: 11px 14px; border-radius: 12px;
  color: var(--muted); font-weight: 600; font-size: 14.5px; transition: .2s;
}
.nav a svg { width: 20px; height: 20px; flex: none; }
.nav a:hover { background: rgba(17, 103, 212, .08); color: var(--ink); }
.nav a.active {
  color: #fff; background: linear-gradient(135deg, var(--blue-2), var(--blue) 50%, var(--navy-2));
  box-shadow: 0 8px 22px rgba(17, 103, 212, .35), inset 0 1px 0 rgba(255,255,255,.3);
}
.nav .badge { margin-left: auto; background: var(--red); color: #fff; font-size: 11px; padding: 2px 7px; border-radius: 20px; }
.nav a.active .badge { background: rgba(255,255,255,.25); }
.side-user { display: flex; align-items: center; gap: 10px; padding: 12px 8px 0; border-top: 1px solid var(--line); margin-top: 12px; }
.side-user .meta { flex: 1; min-width: 0; }
.side-user .meta b { display: block; font-size: 14px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.side-user .meta span { font-size: 12px; color: var(--muted); }

.main { flex: 1; margin-left: calc(var(--sidebar) + 32px); padding: 16px 20px 40px 0; min-width: 0; }
.topbar { display: flex; align-items: center; gap: 12px; padding: 14px 18px; margin-bottom: 20px; position: sticky; top: 16px; z-index: 20; }
.topbar h2 { font-size: 20px; flex: 1; }
.topbar .crumb { color: var(--muted); font-size: 13px; font-weight: 500; display: block; }
.icon-btn {
  width: 40px; height: 40px; display: grid; place-items: center; border-radius: 12px;
  border: 1px solid var(--line); background: var(--glass-strong); cursor: pointer; transition: .2s;
}
.icon-btn:hover { transform: translateY(-1px); box-shadow: var(--shadow); }
.icon-btn svg { width: 19px; height: 19px; }
.menu-btn { display: none; }
.search { display: flex; align-items: center; gap: 8px; background: var(--glass-strong); border: 1px solid var(--line); border-radius: 12px; padding: 0 12px; height: 40px; width: 260px; }
.search input { border: 0; outline: 0; background: transparent; width: 100%; font-size: 14px; }
.search svg { width: 17px; height: 17px; color: var(--muted); }

.avatar {
  width: 38px; height: 38px; border-radius: 12px; display: grid; place-items: center; flex: none;
  color: #fff; font-weight: 700; font-size: 14px;
  background: linear-gradient(135deg, var(--blue-2), var(--navy));
  box-shadow: inset 0 1px 0 rgba(255,255,255,.3), 0 6px 14px rgba(17,103,212,.3);
}

/* ---------- Layout helpers ---------- */
.grid { display: grid; gap: 18px; }
.kpis { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.cols-2 { grid-template-columns: 1.6fr 1fr; }
.cols-2e { grid-template-columns: 1fr 1fr; }
.cols-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.card { padding: 22px; }
.card-head { display: flex; align-items: center; gap: 10px; margin-bottom: 16px; }
.card-head h3 { font-size: 16px; flex: 1; }
.card-head .sub { color: var(--muted); font-size: 13px; }
.section-gap { margin-top: 18px; }
.row { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.spacer { flex: 1; }
.muted { color: var(--muted); }
.small { font-size: 12.5px; }
.right { text-align: right; }
.mono { font-variant-numeric: tabular-nums; }

/* KPI tile with 3D gem */
.kpi { position: relative; padding: 20px 20px 18px; overflow: hidden; }
.kpi .label { color: var(--muted); font-size: 13px; font-weight: 600; }
.kpi .value { font-size: 28px; font-weight: 800; margin: 8px 0 6px; letter-spacing: -0.03em; font-variant-numeric: tabular-nums; }
.kpi .foot { font-size: 12.5px; color: var(--muted); }
.kpi .foot b { color: var(--green); }
.kpi .gem {
  position: absolute; right: -14px; top: -14px; width: 92px; height: 92px; border-radius: 28px;
  transform: rotate(18deg);
  background: linear-gradient(145deg, rgba(255,255,255,.9), rgba(111,180,255,.75) 30%, rgba(17,103,212,.9) 70%, rgba(7,28,64,.95));
  box-shadow: inset -10px -12px 24px rgba(7,28,64,.4), inset 8px 8px 18px rgba(255,255,255,.5), 0 18px 30px rgba(17,103,212,.25);
  opacity: .9;
}
.kpi .gem.g2 { background: linear-gradient(145deg, #fff, #9be7d0 30%, #10a37f 70%, #064d3c); box-shadow: inset -10px -12px 24px rgba(6,77,60,.4), inset 8px 8px 18px rgba(255,255,255,.5), 0 18px 30px rgba(16,163,127,.25); border-radius: 50%; }
.kpi .gem.g3 { background: linear-gradient(145deg, #fff, #ffd98a 30%, #e59b13 70%, #7a4c00); box-shadow: inset -10px -12px 24px rgba(122,76,0,.4), inset 8px 8px 18px rgba(255,255,255,.5), 0 18px 30px rgba(229,155,19,.25); border-radius: 22px 50% 22px 50%; }
.kpi .gem.g4 { background: linear-gradient(145deg, #fff, #c2baff 30%, #6b5cff 70%, #2a1f8f); box-shadow: inset -10px -12px 24px rgba(42,31,143,.4), inset 8px 8px 18px rgba(255,255,255,.5), 0 18px 30px rgba(107,92,255,.25); }
.kpi .gem svg { position: absolute; left: 24px; bottom: 22px; width: 24px; height: 24px; color: #fff; transform: rotate(-18deg); }

/* ---------- Buttons / forms ---------- */
.btn {
  display: inline-flex; align-items: center; gap: 8px; height: 40px; padding: 0 16px; border-radius: 12px;
  border: 1px solid var(--line); background: var(--glass-strong); cursor: pointer; font-weight: 700; font-size: 14px;
  transition: .2s; white-space: nowrap;
}
.btn svg { width: 17px; height: 17px; }
.btn:hover { transform: translateY(-1px); box-shadow: var(--shadow); }
.btn.primary {
  color: #fff; border: 0;
  background: linear-gradient(135deg, var(--blue-2), var(--blue) 55%, var(--navy-2));
  box-shadow: 0 10px 24px rgba(17, 103, 212, .35), inset 0 1px 0 rgba(255,255,255,.3);
}
.btn.danger { color: var(--red); }
.btn.sm { height: 32px; padding: 0 11px; font-size: 13px; border-radius: 10px; }
.btn.block { width: 100%; justify-content: center; height: 46px; }
.btn:disabled { opacity: .5; cursor: not-allowed; transform: none; }

.field { display: grid; gap: 6px; }
.field label { font-size: 12.5px; font-weight: 700; color: var(--muted); }
.input, select.input, textarea.input {
  width: 100%; height: 42px; border-radius: 12px; border: 1px solid var(--line);
  background: var(--glass-strong); padding: 0 12px; outline: none; transition: .2s; font-size: 14px;
}
textarea.input { height: auto; min-height: 84px; padding: 10px 12px; resize: vertical; }
.input:focus { border-color: var(--blue-2); box-shadow: 0 0 0 4px rgba(47, 134, 246, .15); }
.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px; }
.form-grid .full { grid-column: 1 / -1; }
.form-section { font-size: 13px; font-weight: 800; text-transform: uppercase; letter-spacing: .06em; color: var(--blue); margin: 22px 0 10px; display: flex; align-items: center; gap: 10px; }
.form-section:first-child { margin-top: 0; }
.form-section::after { content: ""; flex: 1; height: 1px; background: var(--line); }
.line-item { display: grid; grid-template-columns: 1.3fr 2fr 1fr 36px; gap: 8px; margin-bottom: 8px; align-items: center; }
.line-item.inv { grid-template-columns: 2.6fr .7fr 1fr 36px; }
.line-item.asset { grid-template-columns: 1fr 1.3fr 1.4fr 1.2fr .9fr 36px; }

/* ---------- Tables ---------- */
.table-wrap { overflow-x: auto; }
table.table { width: 100%; border-collapse: collapse; font-size: 14px; }
.table th { text-align: left; font-size: 12px; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); font-weight: 700; padding: 10px 12px; border-bottom: 1px solid var(--line); white-space: nowrap; }
.table td { padding: 13px 12px; border-bottom: 1px solid var(--line); vertical-align: middle; }
.table tr:last-child td { border-bottom: 0; }
.table tbody tr { transition: background .15s; }
.table tbody tr:hover { background: rgba(17, 103, 212, .045); }
.table tr.click { cursor: pointer; }
.cell-client { display: flex; align-items: center; gap: 10px; }
.cell-client b { display: block; }
.cell-client span { font-size: 12.5px; color: var(--muted); }
.empty { text-align: center; padding: 40px 20px; color: var(--muted); }
.empty .ico { width: 70px; height: 70px; margin: 0 auto 12px; border-radius: 22px; transform: rotate(12deg); background: linear-gradient(145deg, #fff, #9cc8ff 35%, #1167d4 75%, #071c40); box-shadow: inset -8px -10px 20px rgba(7,28,64,.35), 0 14px 26px rgba(17,103,212,.2); }

/* Pills */
.pill { display: inline-flex; align-items: center; gap: 6px; padding: 4px 10px; border-radius: 30px; font-size: 12px; font-weight: 700; white-space: nowrap; }
.pill::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.pill.blue { color: var(--blue); background: rgba(17, 103, 212, .1); }
.pill.green { color: var(--green); background: rgba(16, 163, 127, .12); }
.pill.amber { color: #b97700; background: rgba(229, 155, 19, .14); }
.pill.red { color: var(--red); background: rgba(224, 65, 79, .11); }
.pill.violet { color: var(--violet); background: rgba(107, 92, 255, .12); }
.pill.gray { color: var(--muted); background: rgba(91, 107, 140, .12); }
[data-theme="dark"] .pill.amber { color: #ffc24d; }

/* Progress */
.progress { height: 8px; border-radius: 10px; background: rgba(17, 103, 212, .1); overflow: hidden; }
.progress > i { display: block; height: 100%; border-radius: 10px; background: linear-gradient(90deg, var(--sky), var(--blue)); }

/* Tabs / segmented */
.tabs { display: inline-flex; background: var(--glass-strong); border: 1px solid var(--line); border-radius: 12px; padding: 4px; gap: 2px; flex-wrap: wrap; }
.tabs button { border: 0; background: transparent; padding: 7px 13px; border-radius: 9px; font-weight: 700; font-size: 13px; color: var(--muted); cursor: pointer; }
.tabs button.on { background: linear-gradient(135deg, var(--blue-2), var(--blue)); color: #fff; box-shadow: 0 6px 14px rgba(17,103,212,.3); }

/* ---------- Pipeline / Kanban ---------- */
.board { display: grid; grid-auto-flow: column; grid-auto-columns: minmax(250px, 1fr); gap: 14px; overflow-x: auto; padding-bottom: 8px; }
.col { padding: 14px; min-height: 300px; display: flex; flex-direction: column; }
.col-head { display: flex; align-items: center; gap: 8px; margin-bottom: 12px; font-weight: 800; font-size: 14px; }
.col-head .count { margin-left: auto; font-size: 12px; background: rgba(17,103,212,.1); color: var(--blue); padding: 2px 9px; border-radius: 20px; }
.col-head .dot { width: 10px; height: 10px; border-radius: 4px; }
.col-sum { font-size: 12px; color: var(--muted); margin: -6px 0 12px; }
.col-body { display: grid; gap: 10px; align-content: start; flex: 1; border-radius: 12px; transition: background .2s; min-height: 80px; }
.col-body.over { background: rgba(17,103,212,.08); outline: 2px dashed rgba(17,103,212,.35); }
.deal { padding: 13px 14px; border-radius: 14px; background: var(--glass-strong); border: 1px solid var(--line); cursor: grab; box-shadow: 0 4px 14px rgba(7,28,64,.06); transition: .2s; }
.deal:hover { transform: translateY(-2px); box-shadow: var(--shadow); }
.deal.dragging { opacity: .5; }
.deal b { font-size: 14px; display: block; }
.deal .meta { display: flex; justify-content: space-between; margin-top: 8px; font-size: 12.5px; color: var(--muted); }
.deal select { margin-top: 10px; height: 32px; font-size: 12.5px; }

/* Mini pipeline bars (dashboard) */
.stage-row { display: grid; grid-template-columns: 120px 1fr 70px; align-items: center; gap: 12px; margin-bottom: 11px; font-size: 13.5px; }
.stage-row .bar { height: 10px; border-radius: 10px; background: rgba(17,103,212,.08); overflow: hidden; }
.stage-row .bar i { display: block; height: 100%; border-radius: 10px; }

/* Charts */
.chart svg { width: 100%; height: auto; display: block; overflow: visible; }
.chart .axis { stroke: var(--line); }
.chart text { fill: var(--muted); font-size: 11px; font-family: var(--font); }
.legend { display: flex; gap: 14px; flex-wrap: wrap; font-size: 12.5px; color: var(--muted); }
.legend i { display: inline-block; width: 10px; height: 10px; border-radius: 3px; margin-right: 6px; vertical-align: -1px; }
.donut-wrap { display: flex; align-items: center; gap: 20px; flex-wrap: wrap; }
.donut-wrap svg { width: 150px; height: 150px; flex: none; }

/* Lists */
.list { display: grid; gap: 4px; }
.list-item { display: flex; align-items: center; gap: 12px; padding: 10px 6px; border-bottom: 1px solid var(--line); }
.list-item:last-child { border-bottom: 0; }
.list-item .grow { flex: 1; min-width: 0; }
.list-item .grow b { display: block; font-size: 14px; }
.list-item .grow span { font-size: 12.5px; color: var(--muted); }
.date-chip { width: 48px; height: 50px; border-radius: 12px; display: grid; place-items: center; text-align: center; line-height: 1.05; flex: none; background: rgba(17,103,212,.08); color: var(--blue); font-weight: 800; }
.date-chip small { font-size: 10px; font-weight: 700; text-transform: uppercase; display: block; }
.date-chip.red { background: rgba(224,65,79,.1); color: var(--red); }
.date-chip.amber { background: rgba(229,155,19,.13); color: #b97700; }

/* Detail */
.detail-head { display: flex; gap: 16px; align-items: center; flex-wrap: wrap; }
.detail-head .avatar { width: 58px; height: 58px; border-radius: 18px; font-size: 20px; }
.kv { display: grid; grid-template-columns: 130px 1fr; gap: 8px 12px; font-size: 14px; }
.kv dt { color: var(--muted); font-weight: 600; }
.kv dd { margin: 0; word-break: break-word; }

/* ---------- Modal / drawer ---------- */
.overlay { position: fixed; inset: 0; background: rgba(5, 13, 32, .45); backdrop-filter: blur(4px); z-index: 100; display: flex; justify-content: flex-end; animation: fade .2s; }
.overlay.center { justify-content: center; align-items: center; padding: 20px; }
.drawer { width: min(760px, 100%); height: 100%; background: var(--glass-strong); backdrop-filter: blur(30px); border-left: 1px solid var(--glass-border); display: flex; flex-direction: column; animation: slideIn .28s ease; }
[data-theme="dark"] .drawer, [data-theme="dark"] .modal { background: rgba(10, 22, 48, .96); }
.drawer-head, .modal-head { display: flex; align-items: center; gap: 12px; padding: 20px 24px; border-bottom: 1px solid var(--line); }
.drawer-head h3, .modal-head h3 { flex: 1; font-size: 18px; }
.drawer-body { flex: 1; overflow-y: auto; padding: 22px 24px; }
.drawer-foot { padding: 16px 24px; border-top: 1px solid var(--line); display: flex; gap: 10px; justify-content: flex-end; }
.modal { width: min(480px, 100%); background: var(--glass-strong); backdrop-filter: blur(30px); border-radius: var(--radius); box-shadow: var(--shadow-lg); animation: pop .22s ease; max-height: 92vh; display: flex; flex-direction: column; }
.modal .drawer-body { padding: 20px 24px; }
@keyframes fade { from { opacity: 0 } }
@keyframes slideIn { from { transform: translateX(40px); opacity: 0 } }
@keyframes pop { from { transform: scale(.96); opacity: 0 } }

/* Toast */
.toast-host { position: fixed; bottom: 22px; left: 50%; transform: translateX(-50%); z-index: 200; display: grid; gap: 8px; }
.toast { padding: 12px 18px; border-radius: 14px; background: var(--navy); color: #fff; font-weight: 600; font-size: 14px; box-shadow: var(--shadow-lg); animation: pop .2s; }
.toast.err { background: var(--red); }

/* ---------- Invoice document ---------- */
.invoice-doc { background: #fff; color: #0b1733; border-radius: 16px; padding: 44px; max-width: 820px; margin: 0 auto; box-shadow: var(--shadow-lg); }
.invoice-doc .inv-top { display: flex; justify-content: space-between; gap: 20px; align-items: flex-start; padding-bottom: 26px; border-bottom: 3px solid #071c40; }
.invoice-doc .inv-top img { width: 150px; }
.invoice-doc h1 { font-size: 34px; color: #071c40; letter-spacing: .04em; }
.invoice-doc .inv-meta { text-align: right; font-size: 13.5px; color: #5b6b8c; line-height: 1.7; }
.invoice-doc .inv-meta b { color: #0b1733; }
.invoice-doc .parties { display: grid; grid-template-columns: 1fr 1fr; gap: 24px; margin: 26px 0; font-size: 14px; line-height: 1.6; }
.invoice-doc .parties h4 { font-size: 11.5px; text-transform: uppercase; letter-spacing: .08em; color: #1167d4; margin-bottom: 6px; }
.invoice-doc table { width: 100%; border-collapse: collapse; font-size: 14px; }
.invoice-doc th { background: #071c40; color: #fff; text-align: left; padding: 11px 12px; font-size: 12px; text-transform: uppercase; letter-spacing: .05em; }
.invoice-doc th:first-child { border-radius: 8px 0 0 8px; } .invoice-doc th:last-child { border-radius: 0 8px 8px 0; }
.invoice-doc td { padding: 12px; border-bottom: 1px solid #e6ebf5; }
.invoice-doc .totals { margin-left: auto; width: 300px; margin-top: 18px; font-size: 14px; }
.invoice-doc .totals div { display: flex; justify-content: space-between; padding: 7px 0; }
.invoice-doc .totals .grand { border-top: 2px solid #071c40; margin-top: 6px; padding-top: 12px; font-size: 18px; font-weight: 800; color: #071c40; }
.invoice-doc .totals .due { background: #eef4ff; color: #1167d4; padding: 10px 12px; border-radius: 10px; font-weight: 800; margin-top: 8px; }
.invoice-doc .inv-foot { margin-top: 34px; padding-top: 18px; border-top: 1px solid #e6ebf5; font-size: 13px; color: #5b6b8c; display: grid; grid-template-columns: 1fr 1fr; gap: 20px; }
.invoice-doc .stamp { display: inline-block; padding: 6px 14px; border: 2px solid; border-radius: 8px; font-weight: 800; letter-spacing: .1em; font-size: 13px; transform: rotate(-4deg); margin-top: 8px; }
.invoice-doc .r { text-align: right; }

/* Permissions grid */
.perm-table select { height: 34px; font-size: 13px; padding: 0 8px; }

/* ---------- Responsive ---------- */
@media (max-width: 1200px) {
  .kpis { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .cols-2, .cols-3 { grid-template-columns: 1fr; }
  .search { width: 200px; }
}
@media (max-width: 920px) {
  .sidebar { transform: translateX(calc(-100% - 30px)); top: 10px; bottom: 10px; left: 10px; }
  body.nav-open .sidebar { transform: none; }
  .main { margin-left: 0; padding: 10px 12px 30px; }
  .menu-btn { display: grid; }
  .topbar { top: 10px; padding: 10px 12px; }
  .search { display: none; }
  .cols-2e { grid-template-columns: 1fr; }
}
@media (max-width: 600px) {
  .kpis { grid-template-columns: 1fr 1fr; gap: 12px; }
  .kpi { padding: 16px; } .kpi .value { font-size: 21px; } .kpi .label { padding-right: 34px; font-size: 12px; } .kpi .gem { width: 50px; height: 50px; right: -10px; top: -10px; border-radius: 16px; }
  .kpi .gem svg { left: 12px; bottom: 11px; width: 16px; height: 16px; }
  .card { padding: 16px; }
  .form-grid { grid-template-columns: 1fr; }
  .line-item, .line-item.inv, .line-item.asset { grid-template-columns: 1fr 1fr; padding: 10px; border: 1px solid var(--line); border-radius: 12px; }
  .line-item > :last-child { justify-self: end; }
  .topbar h2 { font-size: 17px; }
  .topbar .hide-sm { display: none; }
  .invoice-doc { padding: 22px; }
  .invoice-doc .parties, .invoice-doc .inv-foot { grid-template-columns: 1fr; }
  .invoice-doc .totals { width: 100%; }
  .kv { grid-template-columns: 1fr; gap: 2px; } .kv dd { margin-bottom: 8px; }
  .stage-row { grid-template-columns: 96px 1fr 58px; }
  /* tables → cards */
  table.table.responsive thead { display: none; }
  table.table.responsive tr { display: block; padding: 12px 4px; border-bottom: 1px solid var(--line); }
  table.table.responsive td { display: flex; justify-content: space-between; gap: 10px; border: 0; padding: 5px 6px; }
  table.table.responsive td::before { content: attr(data-l); color: var(--muted); font-size: 12px; font-weight: 700; }
  table.table.responsive td.nolabel::before { display: none; }
}

/* ---------- Print (invoice) ---------- */
@media print {
  body { background: #fff; }
  .scene, .sidebar, .topbar, .no-print, .toast-host { display: none !important; }
  .main { margin: 0; padding: 0; }
  .invoice-doc { box-shadow: none; padding: 0; max-width: none; border-radius: 0; }
  .overlay { position: static; background: none; backdrop-filter: none; }
}

@media (max-width: 600px) { .sphere.s1 { width: 140px; height: 140px; top: -70px; right: -30px; opacity: .6; } .cube.c1 { display: none; } }
@media (max-width: 600px) {
  table.table.responsive, table.table.responsive tbody { display: block; width: 100%; }
  table.table.responsive td { min-width: 0 !important; flex-wrap: wrap; align-items: center; text-align: right; }
  table.table.responsive td > * { max-width: 70%; }
  table.table.responsive td .progress { flex-basis: 100%; max-width: 100%; }
  table.table.responsive td.nolabel > * { max-width: 100%; }
  .toast-host { width: calc(100% - 32px); } .toast { text-align: center; }
}

/* Profile photos */
.avatar { overflow: hidden; }
.avatar img { width: 100%; height: 100%; object-fit: cover; display: block; }
.avatar.sm { width: 28px; height: 28px; border-radius: 9px; font-size: 11px; }
.avatar.xs { width: 22px; height: 22px; border-radius: 7px; font-size: 9px; }
.avatar.xl { width: 84px; height: 84px; border-radius: 24px; font-size: 28px; }
.avatar-btn { border: 0; padding: 0; background: none; cursor: pointer; border-radius: 12px; }
.avatar-btn:hover .avatar { box-shadow: 0 0 0 3px rgba(47,134,246,.35); }
.photo-edit { display: flex; align-items: center; gap: 16px; padding-bottom: 4px; }

/* =========================================================
   3D coding / website shapes (background)
   ========================================================= */
.s3d { position: absolute; transform: var(--r); animation: drift 16s ease-in-out infinite; will-change: transform; }
@keyframes drift { 0%,100% { transform: var(--r) translateY(0) } 50% { transform: var(--r) translateY(-22px) } }

/* floating browser window */
.browser {
  --r: perspective(1000px) rotateY(-26deg) rotateX(14deg) rotateZ(3deg);
  top: 52%; left: 26%; width: 290px; height: 196px; border-radius: 16px; overflow: hidden;
  background: linear-gradient(160deg, rgba(255,255,255,.95), rgba(224,236,255,.9));
  border: 1px solid rgba(255,255,255,.9);
  box-shadow: 8px 10px 0 -2px rgba(17,103,212,.55), 16px 20px 0 -4px rgba(7,28,64,.25), 30px 40px 60px rgba(7,28,64,.22);
  opacity: .9;
}
.bw-bar { height: 28px; display: flex; align-items: center; gap: 6px; padding: 0 12px; background: linear-gradient(90deg, #071c40, #1167d4); }
.bw-bar i { width: 8px; height: 8px; border-radius: 50%; background: rgba(255,255,255,.55); }
.bw-bar i:first-child { background: #6fb4ff; }
.bw-bar span { flex: 1; height: 12px; margin-left: 10px; border-radius: 6px; background: rgba(255,255,255,.2); }
.bw-body { padding: 12px; display: grid; gap: 8px; }
.bw-hero { height: 52px; border-radius: 10px; background: linear-gradient(120deg, #2f86f6, #6fb4ff 60%, #c9e2ff); }
.bw-body b { display: block; height: 8px; border-radius: 6px; background: #c5d6f2; }
.bw-body b.c2 { background: #9cc8ff; }
.bw-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.bw-grid u { height: 34px; border-radius: 8px; background: #e3edfb; border: 1px solid #d0def5; }

/* extruded code glyphs */
.glyph {
  font-family: "JetBrains Mono", "Fira Code", Consolas, monospace; font-weight: 800; line-height: 1; letter-spacing: -.04em;
  color: #e9f2ff;
  text-shadow: 1px 1px 0 #9cc8ff, 2px 2px 0 #6fb4ff, 3px 3px 0 #4f9bff, 4px 4px 0 #2f86f6, 5px 5px 0 #1f76e6, 6px 6px 0 #1167d4,
               7px 7px 0 #0d55b3, 8px 8px 0 #0b4593, 9px 9px 0 #0a3572, 10px 10px 0 #071c40, 18px 24px 30px rgba(7,28,64,.35);
}
.g-tag { --r: perspective(800px) rotateY(-22deg) rotateX(10deg) rotateZ(-8deg); top: 22%; right: 5%; font-size: 92px; animation-duration: 13s; }
.g-brace { --r: perspective(800px) rotateY(24deg) rotateX(-8deg) rotateZ(10deg); bottom: 5%; left: 23%; font-size: 76px; animation-duration: 18s; animation-delay: -6s; }

/* code snippet card */
.codecard {
  --r: perspective(900px) rotateY(20deg) rotateX(8deg) rotateZ(-4deg);
  top: 9%; left: 40%; padding: 14px 18px; border-radius: 14px;
  font: 600 13px/1.75 "JetBrains Mono", Consolas, monospace; color: #cfe1ff;
  background: linear-gradient(150deg, #0d2a5c, #071c40);
  box-shadow: 8px 10px 0 -2px rgba(47,134,246,.6), 26px 34px 50px rgba(7,28,64,.3);
  animation-duration: 20s; animation-delay: -3s; opacity: .92;
}
.codecard p { margin: 0; white-space: nowrap; }
.codecard em { color: #6fb4ff; font-style: normal; }
.codecard s { color: #9be7d0; text-decoration: none; }
.codecard q { color: #ffd98a; quotes: none; }
.codecard .dim { color: #6f86b3; }

/* phone mockup */
.phone {
  --r: perspective(900px) rotateY(-30deg) rotateX(10deg) rotateZ(8deg);
  bottom: 12%; right: 14%; width: 96px; height: 186px; border-radius: 22px; padding: 8px;
  background: linear-gradient(160deg, #1167d4, #071c40);
  box-shadow: 7px 9px 0 -2px rgba(7,28,64,.45), 24px 30px 44px rgba(7,28,64,.3);
  animation-duration: 15s; animation-delay: -8s;
}
.ph-notch { width: 30px; height: 5px; border-radius: 4px; background: rgba(255,255,255,.35); margin: 2px auto 6px; }
.ph-screen { height: calc(100% - 13px); border-radius: 15px; background: linear-gradient(180deg, #ffffff, #dfeaff); padding: 10px 8px; display: grid; gap: 7px; align-content: start; }
.ph-screen b { height: 7px; border-radius: 5px; background: #c5d6f2; }
.ph-screen b.c2 { width: 60%; background: #6fb4ff; }
.ph-screen span { height: 48px; border-radius: 9px; background: linear-gradient(120deg, #2f86f6, #9cc8ff); margin-top: 4px; }

/* cursor */
.cursor { --r: rotate(-8deg); top: 46%; right: 30%; width: 44px; animation-duration: 11s; }
.cursor svg { width: 44px; height: 44px; fill: #fff; stroke: #071c40; stroke-width: 1.6; stroke-linejoin: round; filter: drop-shadow(4px 6px 0 #1167d4) drop-shadow(10px 14px 14px rgba(7,28,64,.3)); }

[data-theme="dark"] .browser { background: linear-gradient(160deg, rgba(30,55,105,.95), rgba(13,42,92,.9)); border-color: rgba(120,160,255,.2); }
[data-theme="dark"] .bw-body b, [data-theme="dark"] .bw-grid u { background: rgba(111,180,255,.18); border-color: transparent; }
[data-theme="dark"] .ph-screen { background: linear-gradient(180deg, #13305f, #0b1f45); }
[data-theme="dark"] .glyph { color: #9cc8ff; }
@media (prefers-reduced-motion: reduce) { .s3d { animation: none; } }
@media (max-width: 1200px) { .codecard { display: none; } .browser { left: 30%; } }

/* =========================================================
   Mobile app experience (≤ 920px)
   ========================================================= */
.tabbar { display: none; }
@media (max-width: 920px) {
  html { -webkit-text-size-adjust: 100%; }
  body { -webkit-tap-highlight-color: transparent; }
  .menu-btn { display: none !important; }
  .main { padding: 0 12px calc(104px + env(safe-area-inset-bottom)); }
  .topbar {
    top: 0; margin: 0 -12px 16px; border-radius: 0 0 24px 24px; border-top: 0;
    padding: calc(12px + env(safe-area-inset-top)) 16px 12px;
  }
  .topbar h2 { font-size: 22px; }
  .topbar .crumb { font-size: 12px; }

  /* bottom tab bar */
  .tabbar {
    display: grid; grid-auto-flow: column; grid-auto-columns: 1fr; position: fixed; z-index: 40;
    left: 10px; right: 10px; bottom: calc(10px + env(safe-area-inset-bottom));
    height: 68px; padding: 6px; border-radius: 24px; background: var(--glass-strong);
  }
  .tabbar a, .tabbar button {
    position: relative; border: 0; background: none; color: var(--muted); display: flex; flex-direction: column;
    align-items: center; justify-content: center; gap: 3px; border-radius: 18px; font-size: 11px; font-weight: 700; cursor: pointer; padding: 0;
  }
  .tabbar svg { width: 23px; height: 23px; }
  .tabbar .on { color: #fff; background: linear-gradient(135deg, var(--blue-2), var(--blue) 55%, var(--navy-2)); box-shadow: 0 8px 20px rgba(17,103,212,.35); }
  .tabbar em { position: absolute; top: 4px; right: calc(50% - 22px); min-width: 18px; height: 18px; padding: 0 5px; border-radius: 10px; background: var(--red); color: #fff; font: 700 10.5px/18px var(--font); font-style: normal; text-align: center; }

  /* side menu opens as a sheet from "More" */
  .sidebar { top: 10px; bottom: calc(88px + env(safe-area-inset-bottom)); width: min(300px, calc(100% - 20px)); }

  /* comfortable touch sizes; 16px inputs stop iOS zoom */
  .input, select.input, textarea.input { font-size: 16px; height: 48px; border-radius: 14px; }
  textarea.input { height: auto; }
  .btn { height: 46px; padding: 0 18px; font-size: 15px; border-radius: 14px; }
  .btn.sm { height: 38px; font-size: 13.5px; }
  .icon-btn { width: 44px; height: 44px; border-radius: 14px; }
  .field label { font-size: 13px; }

  /* filter tabs scroll sideways instead of wrapping */
  .tabs { flex-wrap: nowrap; overflow-x: auto; max-width: 100%; scrollbar-width: none; }
  .tabs::-webkit-scrollbar { display: none; }
  .tabs button { padding: 9px 14px; font-size: 13.5px; white-space: nowrap; flex: none; }

  /* page toolbars: tabs full width, search full width, buttons share a row */
  .card > .row:first-child, .row:has(> .tabs) { gap: 10px; }
  .row > .tabs { flex: 1 1 100%; }
  .row > .search { display: flex !important; flex: 1 1 100%; width: 100% !important; height: 48px; order: 2; }
  .row > .search input { font-size: 16px; }
  .row > .spacer { display: none; }
  .row > .btn { order: 3; flex: 1 1 auto; justify-content: center; }

  /* pipeline: swipe between stages */
  .board { grid-auto-columns: 84%; scroll-snap-type: x mandatory; margin: 0 -12px; padding: 0 12px 8px; scrollbar-width: none; }
  .board .col { scroll-snap-align: center; }

  /* drawers become full-screen pages, dialogs become bottom sheets */
  .drawer { width: 100%; }
  .drawer-head, .modal-head { padding: calc(14px + env(safe-area-inset-top)) 18px 14px; }
  .drawer-body { padding: 18px; }
  .drawer-foot { padding: 12px 18px calc(12px + env(safe-area-inset-bottom)); }
  .drawer-foot .btn { flex: 1; justify-content: center; }
  .drawer-foot .btn.danger { flex: 0 0 auto; }
  .overlay.center { align-items: flex-end; padding: 0; }
  .modal { width: 100%; max-height: 92vh; border-radius: 26px 26px 0 0; animation: sheetUp .28s ease; }
  .modal .modal-head { padding-top: 18px; }
  .modal .modal-head::before { content: ""; position: absolute; left: 50%; top: 7px; width: 40px; height: 5px; margin-left: -20px; border-radius: 4px; background: var(--line); }
  .modal { position: relative; }
  @keyframes sheetUp { from { transform: translateY(40px); opacity: 0 } }

  .toast-host { bottom: calc(92px + env(safe-area-inset-bottom)); }

  /* background shapes: fewer and smaller on mobile */
  .codecard, .cursor, .g-brace, .cube.c1, .cube.c3, .sphere.s2, .ring { display: none; }
  .browser { top: auto; bottom: 16%; left: -60px; transform-origin: left; scale: .65; opacity: .55; }
  .g-tag { top: 38%; right: -10px; font-size: 64px; opacity: .55; }
  .phone { bottom: 30%; right: -20px; scale: .7; opacity: .55; }
}
@media (max-width: 600px) {
  body { font-size: 15px; }
  .kpis { gap: 10px; }
  .kpi { padding: 16px 14px; border-radius: 20px; }
  .kpi .value { font-size: 22px; }
  .card { padding: 16px; border-radius: 22px; }
  .card-head h3 { font-size: 17px; }
  .grid { gap: 14px; }
  .section-gap { margin-top: 14px; }

  /* table rows become tappable cards */
  table.table.responsive tr { background: var(--glass-strong); border: 1px solid var(--line); border-radius: 18px; padding: 12px 10px; margin-bottom: 10px; }
  table.table.responsive tbody tr:hover { background: var(--glass-strong); }
  table.table.responsive td { padding: 6px 6px; font-size: 14.5px; }
  .table-wrap { overflow: visible; }

  .list-item { padding: 12px 4px; }
  .list-item .grow b { font-size: 15px; }
  .stage-row { font-size: 14px; }
  .detail-head .row { width: 100%; }
  .detail-head .row .btn { flex: 1; justify-content: center; padding: 0 10px; }
  .photo-edit { flex-direction: column; text-align: center; }
  .login-card { padding: 32px 22px 26px; border-radius: 26px; }
}
/* refinements */
.glass { backdrop-filter: blur(12px) saturate(150%); -webkit-backdrop-filter: blur(12px) saturate(150%); }
:root { --glass: rgba(255, 255, 255, 0.56); }
[data-theme="dark"] { --glass: rgba(17, 32, 66, 0.52); }
@media (max-width: 600px) {
  .hide-sm { display: none !important; }
  table.table.responsive td.nolabel { text-align: left; justify-content: flex-start; }
  .chart text { font-size: 19px; }
  .col { min-height: 0; }
  .col-body { min-height: 120px; }
}
.codecard { top: auto; bottom: 7%; left: 52%; }
.g-tag { top: 64%; right: 3%; }
.browser { top: 30%; left: 24%; }
.phone { bottom: 5%; right: 22%; }
.cube.c2 { top: 14%; right: 26%; }

/* mobile menu backdrop (lives inside .app so it stacks below the menu) */
.nav-backdrop { display: none; }
@media (max-width: 920px) {
  body.nav-open .nav-backdrop { display: block; position: fixed; inset: 0; z-index: 28; background: rgba(5,13,32,.45); backdrop-filter: blur(3px); cursor: pointer; animation: fade .2s; }
  .sidebar { z-index: 35; background: var(--glass-strong); overscroll-behavior: contain; }
  body.nav-open { overflow: hidden; }
  .nav a { padding: 14px 14px; font-size: 15.5px; }
}
