/* ==========================================================================
   Embalatges Prats · Management panel
   ========================================================================== */
:root {
  --bg: #f3f5f9; --surface: #fff; --surface-2: #f7f9fc; --line: #e3e8ef; --line-2: #eef1f6;
  --text: #0f1a2b; --text-2: #4a5566; --text-3: #8591a3;
  --blue: #2a6fd1; --blue-600: #1f5aa6; --blue-50: #eaf2ff; --navy: #0b1526; --navy-2: #10203a;
  --wood: #d9a35b; --ok: #16a34a; --warn: #d97706; --bad: #dc2626;
  --radius: 16px; --shadow: 0 1px 2px rgba(15,26,43,.04), 0 8px 24px -12px rgba(15,26,43,.12);
  --side: 256px; --top: 64px;
  --font-head: 'Exo 2', system-ui, sans-serif; --font-body: 'Inter', system-ui, sans-serif;
  color-scheme: light;
}
:root[data-theme="dark"] {
  --bg: #080f1c; --surface: #0f1b2e; --surface-2: #13223a; --line: #1e2f4a; --line-2: #182842;
  --text: #e6edf7; --text-2: #a9b6c9; --text-3: #71819a; --blue-50: rgba(42,111,209,.16);
  --shadow: 0 1px 2px rgba(0,0,0,.3), 0 10px 30px -14px rgba(0,0,0,.6);
  color-scheme: dark;
}
*, *::before, *::after { box-sizing: border-box; }
html, body { margin: 0; overflow-x: clip; }
body { font-family: var(--font-body); background: var(--bg); color: var(--text); font-size: 14.5px; line-height: 1.5; -webkit-font-smoothing: antialiased; }
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
a { color: inherit; text-decoration: none; }
svg { flex: none; }
:focus-visible { outline: 2px solid var(--blue); outline-offset: 2px; border-radius: 6px; }

/* ---------- login ---------- */
.login { position: fixed; inset: 0; z-index: 1000; display: grid; background: var(--navy); overflow-y: auto; }
@media (min-width: 960px) { .login { grid-template-columns: 1.1fr 1fr; } }
.login.hide { display: none; }
.login-art { position: relative; display: none; background: url('../assets/img/storage.jpg') center/cover; }
.login-art::after { content: ''; position: absolute; inset: 0; background: linear-gradient(135deg, rgba(11,21,38,.9), rgba(31,90,166,.55)); }
.login-art .quote { position: absolute; left: 48px; right: 48px; bottom: 48px; z-index: 1; color: #fff; }
.login-art .quote h2 { font-family: var(--font-head); font-size: 40px; line-height: 1.1; margin: 0 0 10px; }
.login-art .quote p { color: #c7d5ea; margin: 0; max-width: 460px; }
@media (min-width: 960px) { .login-art { display: block; } }
.login-box { display: flex; flex-direction: column; justify-content: center; padding: 40px 20px; max-width: 460px; width: 100%; margin: 0 auto; color: #fff; }
.login-box .brand { margin-bottom: 36px; }
.login-box h1 { font-family: var(--font-head); font-size: 30px; margin: 0 0 6px; }
.login-box > p { color: #9fb0c8; margin: 0 0 28px; }
.login-box label { display: block; font-size: 13px; color: #9fb0c8; margin: 14px 0 6px; font-weight: 600; }
.login-box input { width: 100%; min-height: 50px; border-radius: 12px; border: 1px solid #243a5c; background: #0f1d33; color: #fff; padding: 0 14px; }
.login-box input:focus { outline: none; border-color: var(--blue); box-shadow: 0 0 0 4px rgba(42,111,209,.25); }
.login-box .row { display: flex; justify-content: space-between; align-items: center; margin: 14px 0 22px; font-size: 13px; color: #9fb0c8; }
.login-box .row label { margin: 0; display: flex; gap: 8px; align-items: center; font-weight: 500; }
.login-box .row input { width: auto; min-height: 0; accent-color: var(--blue); }
.login-box .demo-note { margin-top: 18px; font-size: 12.5px; color: #7f93b0; text-align: center; }
.login-box .back { margin-top: 24px; text-align: center; font-size: 13px; color: #9fb0c8; }
.login-box .back a { color: var(--wood); }

/* ---------- brand ---------- */
.brand { display: flex; align-items: center; gap: 10px; }
.brand svg { width: 40px; }
.brand span { font-family: var(--font-head); font-weight: 500; font-size: 18px; color: #fff; line-height: 1; }
.brand span b { color: #4d93f0; }
.brand small { display: block; font-size: 10px; letter-spacing: .22em; color: #7f93b0; margin-top: 4px; text-transform: uppercase; }

/* ---------- layout ---------- */
.app { min-height: 100vh; }
.sidebar { position: fixed; inset: 0 auto 0 0; width: var(--side); background: var(--navy); color: #c2cee0; z-index: 60; display: flex; flex-direction: column; transform: translateX(-100%); transition: transform .35s cubic-bezier(.2,.8,.2,1); }
.sidebar .brand { padding: 18px 20px; border-bottom: 1px solid rgba(255,255,255,.06); }
.side-nav { padding: 14px 12px; display: flex; flex-direction: column; gap: 2px; overflow-y: auto; flex: 1; }
.side-nav .grp { font-size: 11px; letter-spacing: .14em; text-transform: uppercase; color: #5f7291; margin: 14px 10px 6px; font-weight: 600; }
.side-nav a { display: flex; align-items: center; gap: 12px; padding: 10px 12px; border-radius: 10px; font-weight: 500; color: #b7c4d8; transition: background .2s, color .2s; position: relative; }
.side-nav a svg { width: 19px; height: 19px; opacity: .85; }
.side-nav a:hover { background: rgba(255,255,255,.05); color: #fff; }
.side-nav a.on { background: linear-gradient(90deg, rgba(42,111,209,.35), rgba(42,111,209,.08)); color: #fff; }
.side-nav a.on::before { content: ''; position: absolute; left: -12px; top: 8px; bottom: 8px; width: 3px; border-radius: 3px; background: #4d93f0; }
.side-nav .count { margin-left: auto; background: var(--wood); color: var(--navy); font-size: 11px; font-weight: 700; border-radius: 999px; padding: 1px 7px; }
.side-foot { padding: 14px; border-top: 1px solid rgba(255,255,255,.06); }
.side-user { display: flex; gap: 10px; align-items: center; padding: 8px; border-radius: 12px; background: rgba(255,255,255,.04); }
.avatar { width: 36px; height: 36px; border-radius: 10px; background: linear-gradient(135deg, var(--blue), #4d93f0); color: #fff; display: grid; place-items: center; font-weight: 700; font-size: 13px; flex: none; }
.side-user b { display: block; color: #fff; font-size: 13.5px; }
.side-user small { color: #7f93b0; font-size: 12px; }
.side-user button { margin-left: auto; border: 0; background: none; color: #7f93b0; padding: 6px; border-radius: 8px; }
.side-user button:hover { color: #fff; background: rgba(255,255,255,.08); }
.scrim { position: fixed; inset: 0; background: rgba(7,13,24,.5); z-index: 55; opacity: 0; visibility: hidden; transition: .3s; }
body.side-open .sidebar { transform: none; }
body.side-open .scrim { opacity: 1; visibility: visible; }
@media (min-width: 1100px) {
  .sidebar { transform: none; }
  .main { margin-left: var(--side); }
  .scrim, .menu-btn { display: none !important; }
}

.topbar { position: sticky; top: 0; z-index: 40; height: var(--top); background: color-mix(in srgb, var(--bg) 82%, transparent); backdrop-filter: blur(14px); -webkit-backdrop-filter: blur(14px); border-bottom: 1px solid var(--line); display: flex; align-items: center; gap: 10px; padding: 0 16px; }
@media (min-width: 768px) { .topbar { padding: 0 28px; } }
.topbar h1 { font-family: var(--font-head); font-size: 20px; margin: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.topbar .spacer { flex: 1; }
.icon-btn { width: 40px; height: 40px; border-radius: 11px; border: 1px solid var(--line); background: var(--surface); display: grid; place-items: center; position: relative; color: var(--text-2); transition: .2s; flex: none; }
.icon-btn:hover { color: var(--text); border-color: var(--text-3); }
.icon-btn svg { width: 19px; height: 19px; }
.icon-btn .dot { position: absolute; top: -4px; right: -4px; min-width: 18px; height: 18px; border-radius: 9px; background: var(--bad); color: #fff; font-size: 10.5px; font-weight: 700; display: grid; place-items: center; padding: 0 4px; border: 2px solid var(--bg); }
.gsearch { display: none; align-items: center; gap: 8px; background: var(--surface); border: 1px solid var(--line); border-radius: 11px; padding: 0 12px; height: 40px; width: 300px; color: var(--text-3); }
.gsearch input { border: 0; background: none; outline: none; width: 100%; color: var(--text); }
.gsearch kbd { font-size: 11px; border: 1px solid var(--line); border-radius: 5px; padding: 1px 5px; }
@media (min-width: 900px) { .gsearch { display: flex; } }
.topbar .to-site { display: none; }
@media (min-width: 640px) { .topbar .to-site { display: inline-flex; } }

.content { padding: 18px 14px 100px; max-width: 1600px; }
@media (min-width: 768px) { .content { padding: 26px 28px 60px; } }
.view { display: none; animation: vin .35s cubic-bezier(.2,.8,.2,1); }
.view.on { display: block; }
@keyframes vin { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }

/* bottom nav (mobile) */
.bnav { position: fixed; left: 0; right: 0; bottom: 0; z-index: 50; background: var(--surface); border-top: 1px solid var(--line); display: grid; grid-template-columns: repeat(5, 1fr); padding: 6px 4px calc(6px + env(safe-area-inset-bottom)); }
.bnav a { display: flex; flex-direction: column; align-items: center; gap: 2px; font-size: 10.5px; font-weight: 600; color: var(--text-3); padding: 4px 0; position: relative; }
.bnav a svg { width: 22px; height: 22px; }
.bnav a.on { color: var(--blue); }
.bnav .count { position: absolute; top: 0; left: 55%; background: var(--bad); color: #fff; font-size: 10px; border-radius: 8px; padding: 0 5px; }
@media (min-width: 768px) { .bnav { display: none; } }

/* ---------- common UI ---------- */
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); }
.card-h { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 16px 18px 0; flex-wrap: wrap; }
.card-h h3 { margin: 0; font-family: var(--font-head); font-size: 16px; }
.card-h small { color: var(--text-3); }
.card-b { padding: 16px 18px 18px; }
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; height: 40px; padding: 0 16px; border-radius: 11px; border: 1px solid transparent; background: var(--blue); color: #fff; font-weight: 600; font-size: 14px; white-space: nowrap; transition: .2s; }
.btn:hover { background: var(--blue-600); }
.btn svg { width: 17px; height: 17px; }
.btn--ghost { background: var(--surface); color: var(--text); border-color: var(--line); }
.btn--ghost:hover { background: var(--surface-2); border-color: var(--text-3); }
.btn--wood { background: var(--wood); color: var(--navy); }
.btn--wood:hover { background: #c98f45; }
.btn--danger { background: transparent; color: var(--bad); border-color: color-mix(in srgb, var(--bad) 40%, transparent); }
.btn--danger:hover { background: color-mix(in srgb, var(--bad) 10%, transparent); }
.btn--sm { height: 34px; padding: 0 12px; font-size: 13px; }
.btn--block { width: 100%; }
.chip { display: inline-flex; align-items: center; gap: 6px; font-size: 12px; font-weight: 600; padding: 3px 9px; border-radius: 999px; background: var(--surface-2); color: var(--text-2); border: 1px solid var(--line); white-space: nowrap; }
.chip i { width: 7px; height: 7px; border-radius: 50%; background: currentColor; }
.chip.web { color: #7c3aed; background: rgba(124,58,237,.1); border-color: transparent; }
.chip.alta { color: var(--bad); background: rgba(220,38,38,.1); border-color: transparent; }
.chip.media { color: var(--warn); background: rgba(217,119,6,.1); border-color: transparent; }
.chip.baja { color: var(--ok); background: rgba(22,163,74,.1); border-color: transparent; }
.chip.new { background: var(--wood); color: var(--navy); border-color: transparent; animation: glow 1.8s infinite; }
@keyframes glow { 50% { box-shadow: 0 0 0 4px rgba(217,163,91,.25); } }
.input, .select { height: 40px; border-radius: 11px; border: 1px solid var(--line); background: var(--surface); padding: 0 12px; min-width: 0; color: var(--text); }
.input:focus, .select:focus, textarea.input:focus { outline: none; border-color: var(--blue); box-shadow: 0 0 0 3px rgba(42,111,209,.18); }
textarea.input { height: auto; min-height: 90px; padding: 10px 12px; resize: vertical; width: 100%; }
.search-box { display: flex; align-items: center; gap: 8px; height: 42px; border-radius: 12px; border: 1px solid var(--line); background: var(--surface); padding: 0 12px; color: var(--text-3); flex: 1 1 240px; min-width: 0; }
.search-box input { border: 0; outline: none; background: none; width: 100%; color: var(--text); }
.search-box:focus-within { border-color: var(--blue); box-shadow: 0 0 0 3px rgba(42,111,209,.18); }
.toolbar { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; margin-bottom: 16px; }
.toolbar .select { flex: 0 1 auto; }
.muted { color: var(--text-3); }
.pos { color: var(--ok); } .neg { color: var(--bad); }
.empty { text-align: center; padding: 40px 16px; color: var(--text-3); }

/* ---------- dashboard ---------- */
.greet { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: flex-end; gap: 12px; margin-bottom: 18px; }
.greet h2 { font-family: var(--font-head); font-size: clamp(22px, 3vw, 28px); margin: 0; }
.greet p { margin: 2px 0 0; color: var(--text-2); }
.seg { display: inline-flex; background: var(--surface); border: 1px solid var(--line); border-radius: 11px; padding: 3px; }
.seg button { border: 0; background: none; padding: 6px 12px; border-radius: 8px; font-size: 13px; font-weight: 600; color: var(--text-2); }
.seg button.on { background: var(--blue); color: #fff; }
.kpis { display: grid; grid-template-columns: repeat(2, 1fr); gap: 12px; margin-bottom: 16px; }
@media (min-width: 900px) { .kpis { grid-template-columns: repeat(3, 1fr); } }
@media (min-width: 1400px) { .kpis { grid-template-columns: repeat(6, 1fr); } }
.kpi { padding: 16px; position: relative; overflow: hidden; }
.kpi .k-top { display: flex; justify-content: space-between; align-items: center; gap: 8px; }
.kpi .k-ico { width: 36px; height: 36px; border-radius: 10px; display: grid; place-items: center; background: var(--blue-50); color: var(--blue); }
.kpi .k-ico svg { width: 18px; height: 18px; }
.kpi small { display: block; color: var(--text-3); font-size: 12.5px; font-weight: 500; margin-top: 12px; }
.kpi b { display: block; font-family: var(--font-head); font-size: clamp(20px, 2.4vw, 26px); line-height: 1.2; letter-spacing: -.01em; }
.kpi .delta { font-size: 12px; font-weight: 700; padding: 2px 7px; border-radius: 999px; }
.kpi .delta.up { color: var(--ok); background: rgba(22,163,74,.1); }
.kpi .delta.down { color: var(--bad); background: rgba(220,38,38,.1); }
.kpi canvas.spark { position: absolute; right: 0; bottom: 0; width: 55% !important; height: 38px !important; opacity: .9; pointer-events: none; }
.dgrid { display: grid; gap: 16px; grid-template-columns: minmax(0, 1fr); }
.dgrid > * { min-width: 0; }
@media (min-width: 1100px) {
  .dgrid { grid-template-columns: repeat(12, 1fr); }
  .c-8 { grid-column: span 8; } .c-4 { grid-column: span 4; } .c-6 { grid-column: span 6; } .c-12 { grid-column: span 12; } .c-5 { grid-column: span 5; } .c-7 { grid-column: span 7; }
}
.chart-box { position: relative; height: 280px; }
.chart-box.sm { height: 220px; }
.chart-box.lg { height: 320px; }
.legend-inline { display: flex; gap: 14px; flex-wrap: wrap; font-size: 12.5px; color: var(--text-2); }
.legend-inline span { display: inline-flex; align-items: center; gap: 6px; }
.legend-inline i { width: 10px; height: 10px; border-radius: 3px; }
.list { list-style: none; margin: 0; padding: 0; }
.list li { display: flex; align-items: center; gap: 12px; padding: 10px 0; border-bottom: 1px solid var(--line-2); }
.list li:last-child { border-bottom: 0; }
.list .grow { flex: 1; min-width: 0; }
.list .grow b { display: block; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.list .grow small { color: var(--text-3); }
.list .clickable { cursor: pointer; }
.list .clickable:hover b { color: var(--blue); }
.bar-row { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 4px 10px; padding: 8px 0; cursor: pointer; }
.bar-row b { font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.bar-row .v { font-weight: 700; font-variant-numeric: tabular-nums; }
.bar-row .track { grid-column: 1 / -1; height: 6px; border-radius: 6px; background: var(--line-2); overflow: hidden; }
.bar-row .track i { display: block; height: 100%; border-radius: 6px; background: linear-gradient(90deg, var(--blue), #4d93f0); transform-origin: left; animation: grow 1s cubic-bezier(.2,.8,.2,1); }
@keyframes grow { from { transform: scaleX(0); } }
.alert-item { display: flex; gap: 10px; align-items: flex-start; padding: 10px 12px; border-radius: 12px; margin-bottom: 8px; font-size: 13.5px; }
.alert-item.warn { background: rgba(217,119,6,.1); color: var(--text); }
.alert-item.bad { background: rgba(220,38,38,.1); }
.alert-item.info { background: var(--blue-50); }
.alert-item svg { width: 18px; height: 18px; margin-top: 1px; }
.alert-item.warn svg { color: var(--warn); } .alert-item.bad svg { color: var(--bad); } .alert-item.info svg { color: var(--blue); }
.alert-item b { cursor: pointer; }
.funnel { display: grid; gap: 8px; }
.funnel div { display: flex; justify-content: space-between; align-items: center; padding: 10px 14px; border-radius: 10px; color: #fff; font-weight: 600; font-size: 13.5px; margin: 0 auto; transition: width 1s; min-width: 58%; }

/* ---------- kanban ---------- */
.kanban-wrap { margin: 0 -14px; }
@media (min-width: 768px) { .kanban-wrap { margin: 0; } }
.kanban { display: grid; grid-auto-flow: column; grid-auto-columns: minmax(84vw, 1fr); gap: 12px; overflow-x: auto; padding: 0 14px 16px; scroll-snap-type: x mandatory; scroll-padding: 14px; align-items: start; min-height: 60vh; }
@media (min-width: 600px) { .kanban { grid-auto-columns: minmax(300px, 1fr); } }
@media (min-width: 768px) { .kanban { padding: 0 0 16px; scroll-padding: 0; } }
@media (min-width: 1100px) { .kanban { grid-auto-columns: minmax(268px, 1fr); } }
@media (min-width: 1700px) { .kanban { grid-auto-columns: minmax(240px, 1fr); } }
.kcol { background: var(--surface-2); border: 1px solid var(--line); border-radius: 16px; display: flex; flex-direction: column; max-height: calc(100vh - 220px); scroll-snap-align: start; min-height: 200px; transition: background .2s, border-color .2s; }
.kcol.over { background: var(--blue-50); border-color: var(--blue); border-style: dashed; }
.kcol-h { display: flex; align-items: center; gap: 8px; padding: 12px 14px; border-bottom: 1px solid var(--line); position: sticky; top: 0; }
.kcol-h i { width: 10px; height: 10px; border-radius: 3px; }
.kcol-h b { font-family: var(--font-head); font-size: 14.5px; }
.kcol-h .n { margin-left: auto; font-size: 12px; font-weight: 700; color: var(--text-2); background: var(--surface); border: 1px solid var(--line); border-radius: 999px; padding: 1px 8px; }
.kcol-sum { font-size: 12px; color: var(--text-3); padding: 6px 14px 0; }
.kcol-body { padding: 10px; display: flex; flex-direction: column; gap: 10px; overflow-y: auto; flex: 1; min-height: 80px; }
.kcard { background: var(--surface); border: 1px solid var(--line); border-radius: 13px; padding: 12px; cursor: grab; box-shadow: 0 1px 2px rgba(15,26,43,.05); transition: box-shadow .2s, transform .2s, border-color .2s; user-select: none; -webkit-user-select: none; position: relative; touch-action: pan-y; }
.kcard:hover { box-shadow: 0 8px 22px -12px rgba(15,26,43,.35); border-color: color-mix(in srgb, var(--blue) 40%, var(--line)); }
.kcard::before { content: ''; position: absolute; left: 0; top: 12px; bottom: 12px; width: 3px; border-radius: 0 3px 3px 0; background: var(--c, var(--blue)); }
.kcard .kc-top { display: flex; justify-content: space-between; gap: 6px; align-items: center; }
.kcard .code { font-family: var(--font-head); font-weight: 700; font-size: 13px; color: var(--blue); }
.kcard h4 { margin: 6px 0 2px; font-size: 14px; font-weight: 600; line-height: 1.3; }
.kcard p { margin: 0; font-size: 12.5px; color: var(--text-3); }
.kcard .kc-meta { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 10px; align-items: center; }
.kcard .kc-foot { display: flex; justify-content: space-between; align-items: center; margin-top: 10px; padding-top: 10px; border-top: 1px dashed var(--line); font-size: 12.5px; }
.kcard .kc-foot b { font-family: var(--font-head); font-size: 15px; }
.kcard .late { color: var(--bad); font-weight: 600; }
.kcard.ghost { opacity: .35; }
.kcard.dragging { position: fixed; z-index: 999; pointer-events: none; transform: rotate(3deg) scale(1.03); box-shadow: 0 24px 50px -12px rgba(7,13,24,.45); cursor: grabbing; }
.kcard.flash { animation: flash 1.2s; }
@keyframes flash { 0%, 40% { box-shadow: 0 0 0 3px var(--wood); } }
.drop-ph { border: 2px dashed var(--blue); border-radius: 13px; background: var(--blue-50); flex: none; }
.kanban-hint { font-size: 12.5px; color: var(--text-3); margin: -6px 0 12px; }
body.dragging-card { cursor: grabbing; user-select: none; }

/* ---------- tables ---------- */
.table-wrap { overflow-x: auto; }
table.t { width: 100%; border-collapse: collapse; font-size: 13.5px; }
table.t th { text-align: left; font-size: 12px; font-weight: 600; text-transform: uppercase; letter-spacing: .05em; color: var(--text-3); padding: 10px 12px; border-bottom: 1px solid var(--line); white-space: nowrap; background: var(--surface-2); }
table.t td { padding: 12px; border-bottom: 1px solid var(--line-2); vertical-align: middle; }
table.t tbody tr { transition: background .15s; }
table.t tbody tr:hover { background: var(--surface-2); }
table.t tr.click { cursor: pointer; }
table.t .num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
@media (max-width: 767px) {
  table.t.stack thead { display: none; }
  table.t.stack, table.t.stack tbody, table.t.stack tr, table.t.stack td { display: block; width: 100%; }
  table.t.stack tr { border: 1px solid var(--line); border-radius: 14px; margin: 0 0 10px; padding: 8px 12px; background: var(--surface); }
  table.t.stack td { border: 0; padding: 5px 0; display: flex; justify-content: space-between; gap: 12px; text-align: right; }
  table.t.stack td::before { content: attr(data-l); color: var(--text-3); font-size: 12px; font-weight: 600; text-align: left; }
  table.t.stack td.num { text-align: right; }
  table.t.stack td.head { font-size: 15px; font-weight: 600; text-align: left; }
  table.t.stack td.head::before { display: none; }
  .table-wrap.cardless { border: 0; background: none; box-shadow: none; }
}

/* ---------- clients ---------- */
.client-grid { display: grid; gap: 12px; grid-template-columns: 1fr; }
@media (min-width: 700px) { .client-grid { grid-template-columns: repeat(2, 1fr); } }
@media (min-width: 1300px) { .client-grid { grid-template-columns: repeat(3, 1fr); } }
.ccard { padding: 16px; cursor: pointer; transition: transform .2s, box-shadow .2s, border-color .2s; }
.ccard:hover { transform: translateY(-2px); border-color: color-mix(in srgb, var(--blue) 40%, var(--line)); }
.ccard .cc-top { display: flex; gap: 12px; align-items: center; }
.ccard .avatar { width: 44px; height: 44px; border-radius: 12px; font-size: 15px; }
.ccard h4 { margin: 0; font-size: 15px; line-height: 1.25; }
.ccard .cc-top small { color: var(--text-3); }
.ccard .cc-stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin-top: 14px; }
.ccard .cc-stats div { background: var(--surface-2); border-radius: 10px; padding: 8px; }
.ccard .cc-stats small { display: block; font-size: 11px; color: var(--text-3); }
.ccard .cc-stats b { font-size: 14px; font-family: var(--font-head); }
.tier { font-family: var(--font-head); font-weight: 800; font-size: 12px; width: 24px; height: 24px; border-radius: 7px; display: grid; place-items: center; margin-left: auto; flex: none; }
.tier.A { background: rgba(217,163,91,.2); color: #a86b1f; } .tier.B { background: var(--blue-50); color: var(--blue); } .tier.C { background: var(--surface-2); color: var(--text-3); }
mark { background: rgba(217,163,91,.35); color: inherit; border-radius: 3px; padding: 0 1px; }

/* ---------- inventory ---------- */
.stock-bar { width: 100%; min-width: 90px; height: 8px; border-radius: 6px; background: var(--line-2); overflow: hidden; }
.stock-bar i { display: block; height: 100%; border-radius: 6px; background: var(--ok); }
.stock-bar i.low { background: var(--bad); } .stock-bar i.mid { background: var(--warn); }
.qty-ctrl { display: inline-flex; align-items: center; border: 1px solid var(--line); border-radius: 10px; overflow: hidden; }
.qty-ctrl button { border: 0; background: var(--surface-2); width: 32px; height: 32px; font-size: 16px; font-weight: 700; color: var(--text-2); }
.qty-ctrl button:hover { background: var(--blue-50); color: var(--blue); }
.qty-ctrl span { min-width: 56px; text-align: center; font-weight: 700; font-variant-numeric: tabular-nums; }

/* ---------- drawer / modal ---------- */
.drawer { position: fixed; inset: 0; z-index: 200; visibility: hidden; }
.drawer.on { visibility: visible; }
.drawer .ov { position: absolute; inset: 0; background: rgba(7,13,24,.45); opacity: 0; transition: opacity .3s; }
.drawer.on .ov { opacity: 1; }
.drawer .panel { position: absolute; right: 0; top: 0; bottom: 0; width: min(560px, 100%); background: var(--bg); box-shadow: -20px 0 60px -20px rgba(7,13,24,.4); transform: translateX(100%); transition: transform .38s cubic-bezier(.2,.8,.2,1); display: flex; flex-direction: column; }
.drawer.on .panel { transform: none; }
.drawer .p-h { display: flex; align-items: center; gap: 10px; padding: 16px 18px; border-bottom: 1px solid var(--line); background: var(--surface); }
.drawer .p-h h3 { margin: 0; font-family: var(--font-head); font-size: 18px; flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.drawer .p-b { flex: 1; overflow-y: auto; padding: 18px; overscroll-behavior: contain; }
.drawer .p-f { padding: 12px 18px calc(12px + env(safe-area-inset-bottom)); border-top: 1px solid var(--line); background: var(--surface); display: flex; gap: 8px; flex-wrap: wrap; }
.drawer .p-f .btn { flex: 1 1 140px; }
@media (max-width: 767px) {
  .drawer .panel { top: auto; height: 92vh; width: 100%; border-radius: 20px 20px 0 0; transform: translateY(100%); }
  .drawer .p-h { border-radius: 20px 20px 0 0; }
  .drawer .p-h::before { content: ''; position: absolute; left: 50%; top: 6px; width: 40px; height: 4px; margin-left: -20px; border-radius: 4px; background: var(--line); }
}
.sec { margin-bottom: 18px; }
.sec h5 { margin: 0 0 8px; font-size: 12px; letter-spacing: .08em; text-transform: uppercase; color: var(--text-3); font-weight: 700; }
.kv { display: grid; grid-template-columns: repeat(2, 1fr); gap: 8px; }
.kv div { background: var(--surface); border: 1px solid var(--line); border-radius: 12px; padding: 10px 12px; min-width: 0; }
.kv small { display: block; font-size: 11.5px; color: var(--text-3); }
.kv b { font-weight: 600; word-break: break-word; }
.kv .wide { grid-column: 1 / -1; }
.status-steps { display: flex; gap: 4px; overflow-x: auto; padding-bottom: 4px; }
.status-steps button { flex: 1 0 auto; border: 1px solid var(--line); background: var(--surface); border-radius: 10px; font-size: 12px; font-weight: 600; padding: 8px 10px; color: var(--text-2); white-space: nowrap; }
.status-steps button.done { background: color-mix(in srgb, var(--c) 14%, var(--surface)); color: var(--text); border-color: transparent; }
.status-steps button.cur { background: var(--c); color: #fff; border-color: var(--c); }
.hist { list-style: none; margin: 0; padding: 0; position: relative; }
.hist li { position: relative; padding: 0 0 12px 22px; font-size: 13.5px; }
.hist li::before { content: ''; position: absolute; left: 4px; top: 6px; width: 9px; height: 9px; border-radius: 50%; background: var(--c, var(--blue)); }
.hist li::after { content: ''; position: absolute; left: 8px; top: 16px; bottom: 0; width: 1px; background: var(--line); }
.hist li:last-child::after { display: none; }
.hist small { color: var(--text-3); margin-left: 6px; }
.attach { display: flex; flex-wrap: wrap; gap: 6px; }
.attach span { display: inline-flex; gap: 6px; align-items: center; font-size: 13px; padding: 6px 10px; border-radius: 10px; background: var(--surface); border: 1px solid var(--line); }
.price-big { font-family: var(--font-head); font-size: 30px; font-weight: 800; letter-spacing: -.01em; }

.modal { position: fixed; inset: 0; z-index: 300; background: rgba(7,13,24,.5); display: none; align-items: flex-end; justify-content: center; }
.modal.on { display: flex; animation: fadein .25s; }
@keyframes fadein { from { opacity: 0; } }
.modal .m-card { background: var(--surface); width: 100%; max-height: 92vh; overflow-y: auto; border-radius: 20px 20px 0 0; padding: 20px; animation: up .35s cubic-bezier(.2,.8,.2,1); }
@keyframes up { from { transform: translateY(40px); } }
@media (min-width: 700px) { .modal { align-items: center; padding: 20px; } .modal .m-card { max-width: 620px; border-radius: 20px; padding: 26px; } }
.modal h3 { margin: 0 0 16px; font-family: var(--font-head); font-size: 20px; }
.fgrid { display: grid; gap: 12px; grid-template-columns: 1fr 1fr; }
.fgrid .full { grid-column: 1 / -1; }
@media (max-width: 480px) { .fgrid { grid-template-columns: 1fr; } }
.fld { display: flex; flex-direction: column; gap: 5px; min-width: 0; }
.fld label { font-size: 12.5px; font-weight: 600; color: var(--text-2); }
.fld .input, .fld .select { width: 100%; }
.m-actions { display: flex; gap: 8px; justify-content: flex-end; margin-top: 18px; flex-wrap: wrap; }
.m-actions .btn { flex: 0 1 auto; }
@media (max-width: 480px) { .m-actions .btn { flex: 1 1 auto; } }
.checks { display: flex; flex-wrap: wrap; gap: 8px 16px; }
.checks label { display: flex; align-items: center; gap: 6px; font-size: 13.5px; }
.checks input { accent-color: var(--blue); width: 16px; height: 16px; }
.quote-preview { margin-top: 14px; padding: 14px; border-radius: 12px; background: var(--blue-50); display: flex; justify-content: space-between; align-items: center; gap: 10px; flex-wrap: wrap; }
.quote-preview b { font-family: var(--font-head); font-size: 22px; color: var(--blue); }

/* notifications */
.notif { position: absolute; top: calc(var(--top) - 6px); right: 12px; width: min(380px, calc(100vw - 24px)); z-index: 80; display: none; }
.notif.on { display: block; animation: vin .25s; }
.notif .list li { padding: 10px 14px; cursor: pointer; }
.notif .list li:hover { background: var(--surface-2); }

/* toast */
.toast { position: fixed; left: 50%; bottom: 84px; transform: translate(-50%, 30px); opacity: 0; z-index: 900; background: var(--navy); color: #fff; padding: 11px 16px; border-radius: 12px; font-size: 14px; box-shadow: 0 16px 40px -12px rgba(7,13,24,.5); transition: .35s cubic-bezier(.2,.8,.2,1); display: flex; gap: 10px; align-items: center; max-width: calc(100% - 24px); }
.toast.on { opacity: 1; transform: translate(-50%, 0); }
.toast button { border: 0; background: none; color: var(--wood); font-weight: 700; padding: 0 0 0 6px; }
@media (min-width: 768px) { .toast { bottom: 24px; } }

/* settings / rates */
.rates-grid { display: grid; gap: 12px; grid-template-columns: 1fr; }
@media (min-width: 700px) { .rates-grid { grid-template-columns: repeat(2, 1fr); } }
@media (min-width: 1200px) { .rates-grid { grid-template-columns: repeat(3, 1fr); } }
.rate { display: flex; justify-content: space-between; align-items: center; gap: 12px; padding: 12px 14px; }
.rate label { font-weight: 600; font-size: 13.5px; }
.rate small { display: block; color: var(--text-3); font-size: 12px; font-weight: 400; }
.rate input { width: 110px; text-align: right; }

/* messages */
.msg { padding: 14px 16px; border-bottom: 1px solid var(--line-2); }
.msg.unread { background: var(--blue-50); }
.msg b { font-weight: 600; }
.msg p { margin: 6px 0 0; color: var(--text-2); }

/* print (budget) */
.print-doc { display: none; }
@media print {
  body > *:not(.print-doc) { display: none !important; }
  .print-doc { display: block !important; color: #000; font-family: var(--font-body); padding: 10mm; }
  .print-doc h1 { font-family: var(--font-head); }
  .print-doc table { width: 100%; border-collapse: collapse; }
  .print-doc td, .print-doc th { border-bottom: 1px solid #ccc; padding: 6px 4px; text-align: left; }
}
.drawer.on ~ .toast { bottom: calc(96px + env(safe-area-inset-bottom)); }
