/* ============================================================
   Orbit ERP · Design System
   ============================================================ */
:root {
  --bg: #f4f6fb;
  --surface: #ffffff;
  --surface-2: #f8fafc;
  --surface-3: #f1f5f9;
  --border: #e6eaf3;
  --border-strong: #d5dcea;
  --text: #0f172a;
  --text-2: #334155;
  --muted: #64748b;
  --faint: #94a3b8;
  --primary: #4f46e5;
  --primary-strong: #4338ca;
  --primary-soft: #eef2ff;
  --primary-ring: rgba(79, 70, 229, 0.16);
  --success: #0f9f6e;
  --success-soft: #e9f9f2;
  --warning: #d97706;
  --warning-soft: #fff7e6;
  --danger: #e11d48;
  --danger-soft: #fff1f2;
  --info: #0284c7;
  --info-soft: #eff8ff;
  --violet: #7c3aed;
  --violet-soft: #f5f3ff;
  --sidebar: #0b1220;
  --sidebar-2: #111a2e;
  --sidebar-text: #8fa0b8;
  --radius: 14px;
  --radius-sm: 10px;
  --radius-lg: 20px;
  --shadow-xs: 0 1px 2px rgba(15, 23, 42, 0.04);
  --shadow-sm: 0 2px 6px -2px rgba(15, 23, 42, 0.08);
  --shadow: 0 10px 30px -18px rgba(15, 23, 42, 0.28);
  --shadow-lg: 0 30px 70px -28px rgba(15, 23, 42, 0.35);
  --font: "Segoe UI", -apple-system, BlinkMacSystemFont, "Inter", Roboto, "Helvetica Neue", Arial, sans-serif;
  --mono: "Cascadia Code", "SF Mono", Consolas, "Liberation Mono", monospace;
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  font-family: var(--font);
  font-size: 14px;
  line-height: 1.5;
  color: var(--text);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}
#root { min-height: 100%; }
a { color: inherit; text-decoration: none; }
button, input, select, textarea { font: inherit; color: inherit; }
h1, h2, h3, h4, p { margin: 0; }
::selection { background: rgba(79, 70, 229, 0.16); }

::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-thumb { background: #cfd6e4; border-radius: 10px; border: 3px solid transparent; background-clip: content-box; }
::-webkit-scrollbar-thumb:hover { background: #b4bfd2; background-clip: content-box; }
::-webkit-scrollbar-track { background: transparent; }

/* ------------------------------- boot / splash ------------------------------ */
.boot {
  position: fixed; inset: 0; display: grid; place-items: center;
  background: var(--sidebar); color: #fff; gap: 16px;
}
.boot-logo { display: flex; align-items: center; gap: 10px; font-weight: 700; font-size: 20px; letter-spacing: -0.02em; }
.boot-spinner { width: 22px; height: 22px; border: 2px solid rgba(255,255,255,.2); border-top-color: #fff; border-radius: 50%; animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.spinner {
  width: 18px; height: 18px; border: 2px solid rgba(0,0,0,.12); border-top-color: var(--primary);
  border-radius: 50%; animation: spin .7s linear infinite; display: inline-block;
}
.spinner.light { border-color: rgba(255,255,255,.35); border-top-color: #fff; }
.boot-splash { display: flex; flex-direction: column; align-items: center; gap: 18px; }

/* ---------------------------------- layout --------------------------------- */
.shell { display: flex; min-height: 100vh; }
.sidebar {
  width: 252px; flex: 0 0 252px; background: var(--sidebar);
  color: var(--sidebar-text); display: flex; flex-direction: column;
  position: sticky; top: 0; height: 100vh; z-index: 40;
  background-image: radial-gradient(120% 80% at 0% 0%, rgba(79,70,229,.22), transparent 55%),
                    radial-gradient(90% 60% at 100% 100%, rgba(14,165,233,.10), transparent 60%);
  transition: transform .25s ease;
}
.sidebar-head { display: flex; align-items: center; gap: 10px; padding: 22px 20px 14px; }
.brand { display: flex; align-items: center; gap: 12px; color: #fff; }
.brand-mark {
  width: 36px; height: 36px; border-radius: 11px; display: grid; place-items: center;
  background: linear-gradient(135deg, #6366f1, #8b5cf6 60%, #0ea5e9);
  box-shadow: 0 4px 10px -7px rgba(99,102,241,.85); flex: 0 0 auto;
}
.brand-name { display: block; font-weight: 700; font-size: 17px; letter-spacing: -0.03em; line-height: 1; }
.brand-tag { display: block; font-size: 9.5px; text-transform: uppercase; letter-spacing: .1em; color: #64748b; margin-top: 4px; white-space: nowrap; }
.sidebar-close { display: none !important; margin-left: auto; }

.company-card {
  margin: 6px 14px 10px; padding: 10px 12px; border-radius: 12px;
  background: rgba(255,255,255,.035); border: 1px solid rgba(255,255,255,.06);
  display: flex; align-items: center; gap: 10px;
}
.company-avatar {
  width: 32px; height: 32px; border-radius: 9px; background: linear-gradient(135deg,#1e293b,#334155);
  display: grid; place-items: center; font-weight: 700; font-size: 12px; color: #c7d2fe; flex: 0 0 auto;
}
.company-name { color: #e2e8f0; font-size: 12.5px; font-weight: 600; line-height: 1.2; }
.company-plan { font-size: 10.5px; color: #6b7c96; margin-top: 2px; }

.nav { flex: 1; overflow-y: auto; padding: 6px 12px 12px; }
.nav::-webkit-scrollbar-thumb { background: rgba(255,255,255,.12); background-clip: content-box; }
.nav-section { font-size: 10px; letter-spacing: .14em; text-transform: uppercase; color: #55647c; padding: 16px 10px 6px; font-weight: 600; }
.nav-item {
  display: flex; align-items: center; gap: 11px; padding: 9px 10px; border-radius: 9px;
  color: var(--sidebar-text); font-size: 13px; font-weight: 500; cursor: pointer;
  transition: background .15s, color .15s; position: relative; margin-bottom: 1px;
}
.nav-item:hover { background: rgba(255,255,255,.05); color: #e2e8f0; }
.nav-item.active { background: rgba(99,102,241,.16); color: #fff; }
.nav-item.active::before {
  content: ""; position: absolute; left: -12px; top: 8px; bottom: 8px; width: 3px;
  background: linear-gradient(#818cf8, #38bdf8); border-radius: 0 3px 3px 0;
}
.nav-item .icon { color: #6b7c96; }
.nav-item.active .icon, .nav-item:hover .icon { color: #c7d2fe; }
.nav-label { flex: 1; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.nav-badge {
  min-width: 20px; height: 19px; padding: 0 6px; border-radius: 6px; display: grid; place-items: center;
  font-size: 10.5px; font-weight: 700; background: rgba(244,63,94,.18); color: #fb7185;
}
.nav-badge.neutral { background: rgba(148,163,184,.14); color: #94a3b8; }

.sidebar-foot { padding: 12px; border-top: 1px solid rgba(255,255,255,.06); }
.user-chip {
  display: flex; align-items: center; gap: 10px; padding: 8px; border-radius: 10px; cursor: pointer;
  transition: background .15s; width: 100%; border: 0; background: transparent; text-align: left;
}
.user-chip:hover { background: rgba(255,255,255,.05); }
.user-chip-name { color: #e2e8f0; font-size: 12.5px; font-weight: 600; line-height: 1.2; }
.user-chip-role { color: #64748b; font-size: 11px; margin-top: 1px; }

.main { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.topbar {
  height: 66px; background: rgba(255,255,255,.86); backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--border); display: flex; align-items: center; gap: 16px;
  padding: 0 26px; position: sticky; top: 0; z-index: 30;
}
.menu-toggle { display: none !important; }
.topbar-search { position: relative; width: min(440px, 42vw); }
.topbar-search .icon { position: absolute; left: 12px; top: 50%; transform: translateY(-50%); color: var(--faint); }
.topbar-search input {
  width: 100%; height: 38px; border-radius: 10px; border: 1px solid var(--border);
  background: var(--surface-2); padding: 0 12px 0 38px; font-size: 13px; outline: none;
  transition: border .15s, box-shadow .15s, background .15s;
}
.topbar-search input:focus { border-color: #c7d2fe; background: #fff; box-shadow: 0 0 0 4px var(--primary-ring); }
.topbar-search input::placeholder { color: var(--faint); }
.topbar-right { margin-left: auto; display: flex; align-items: center; gap: 8px; }
.topbar-divider { width: 1px; height: 26px; background: var(--border); margin: 0 4px; }
.icon-btn {
  width: 36px; height: 36px; border-radius: 10px; border: 1px solid transparent; background: transparent;
  display: grid; place-items: center; cursor: pointer; color: var(--muted); position: relative;
  transition: background .15s, color .15s, border-color .15s;
}
.icon-btn:hover { background: var(--surface-3); color: var(--text); }
.icon-btn.has-dot::after {
  content: ""; position: absolute; top: 7px; right: 8px; width: 7px; height: 7px; border-radius: 50%;
  background: var(--danger); border: 2px solid #fff;
}
.user-button {
  display: flex; align-items: center; gap: 9px; height: 40px; padding: 0 8px 0 4px;
  border: 1px solid var(--border); background: #fff; border-radius: 11px; cursor: pointer;
}
.user-button:hover { background: var(--surface-2); }
.user-button-name { display: block; font-size: 12.5px; font-weight: 600; line-height: 1.1; text-align: left; }
.user-button-role { display: block; font-size: 10.5px; color: var(--muted); text-align: left; }

.content { padding: 26px 28px 44px; max-width: 1560px; width: 100%; margin: 0 auto; }
.page-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 18px; margin-bottom: 22px; flex-wrap: wrap; }
.breadcrumb { display: flex; align-items: center; gap: 6px; font-size: 12px; color: var(--faint); margin-bottom: 6px; }
.breadcrumb a:hover { color: var(--primary); }
.page-title { font-size: 24px; font-weight: 700; letter-spacing: -0.03em; line-height: 1.2; display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.page-sub { color: var(--muted); font-size: 13px; margin-top: 5px; max-width: 720px; }
.page-actions { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }

/* --------------------------------- buttons --------------------------------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 7px;
  height: 38px; padding: 0 14px; border-radius: 10px; border: 1px solid var(--border-strong);
  background: #fff; color: var(--text-2); font-weight: 600; font-size: 13px; cursor: pointer;
  transition: background .15s, border-color .15s, box-shadow .15s, transform .05s; white-space: nowrap;
  box-shadow: var(--shadow-xs);
}
.btn:hover { background: var(--surface-2); border-color: #c3ccdd; }
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: .55; cursor: not-allowed; }
.btn .icon { flex: 0 0 auto; }
.btn-primary {
  background: linear-gradient(180deg, #5b52ea, #4f46e5); border-color: #4f46e5; color: #fff;
  box-shadow: 0 6px 16px -8px rgba(79,70,229,.8), inset 0 1px 0 rgba(255,255,255,.18);
}
.btn-primary:hover { background: linear-gradient(180deg, #5148e0, #4338ca); border-color: #4338ca; }
.btn-danger { color: var(--danger); border-color: #fecdd3; background: #fff; }
.btn-danger:hover { background: var(--danger-soft); border-color: #fda4af; }
.btn-ghost { background: transparent; border-color: transparent; box-shadow: none; color: var(--muted); }
.btn-ghost:hover { background: var(--surface-3); color: var(--text); border-color: transparent; }
.btn-soft { background: var(--primary-soft); border-color: transparent; color: var(--primary-strong); box-shadow: none; }
.btn-soft:hover { background: #e3e8ff; border-color: transparent; }
.btn-sm { height: 32px; padding: 0 10px; font-size: 12px; border-radius: 8px; gap: 5px; }
.btn-lg { height: 44px; padding: 0 20px; font-size: 14px; border-radius: 11px; }
.btn-icon { width: 34px; padding: 0; }
.btn-block { width: 100%; }
.btn-link { background: none; border: 0; color: var(--primary); font-weight: 600; cursor: pointer; padding: 0; display: inline-flex; align-items: center; gap: 5px; }
.btn-link:hover { color: var(--primary-strong); text-decoration: underline; text-underline-offset: 3px; }

/* ---------------------------------- cards ---------------------------------- */
.card {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  box-shadow: var(--shadow-xs); min-width: 0;
}
.card-head { display: flex; align-items: center; gap: 12px; padding: 16px 18px 0; }
.card-head.has-border { padding-bottom: 14px; border-bottom: 1px solid var(--border); }
.card-title { font-size: 14px; font-weight: 700; letter-spacing: -0.01em; display: flex; align-items: center; gap: 8px; }
.card-sub { font-size: 12px; color: var(--muted); margin-top: 2px; }
.card-actions { margin-left: auto; display: flex; align-items: center; gap: 6px; }
.card-body { padding: 16px 18px; }
.card-body.tight { padding: 12px 14px; }
.card-body.flush { padding: 0; }
.card-foot { padding: 12px 18px; border-top: 1px solid var(--border); display: flex; align-items: center; gap: 10px; }

.grid { display: grid; gap: 16px; }
.grid-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.grid-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.grid-4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.grid-2-1 { grid-template-columns: minmax(0, 2fr) minmax(0, 1fr); }
.grid-1-2 { grid-template-columns: minmax(0, 1fr) minmax(0, 2fr); }
.stack { display: flex; flex-direction: column; gap: 16px; }
.row { display: flex; align-items: center; gap: 10px; }
.row-between { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.wrap { flex-wrap: wrap; }
.grow { flex: 1; min-width: 0; }
.muted { color: var(--muted); }
.faint { color: var(--faint); }
.small { font-size: 12px; }
.xs { font-size: 11px; }
.mono { font-family: var(--mono); font-size: .92em; }
.strong { font-weight: 600; }
.bold { font-weight: 700; }
.nowrap { white-space: nowrap; }
.truncate { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.right { text-align: right; }
.center { text-align: center; }
.mt-0 { margin-top: 0; } .mt-1 { margin-top: 6px; } .mt-2 { margin-top: 12px; } .mt-3 { margin-top: 18px; } .mt-4 { margin-top: 24px; }
.mb-1 { margin-bottom: 6px; } .mb-2 { margin-bottom: 12px; } .mb-3 { margin-bottom: 18px; }
.gap-1 { gap: 6px; } .gap-2 { gap: 12px; } .gap-3 { gap: 18px; }

/* ----------------------------------- KPI ----------------------------------- */
.kpis { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 16px; }
.stat {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 16px 18px 14px; position: relative; overflow: hidden; box-shadow: var(--shadow-xs);
}
.stat::after {
  content: ""; position: absolute; inset: 0 0 auto auto; width: 120px; height: 120px;
  background: radial-gradient(circle at 80% 0%, var(--stat-glow, rgba(79,70,229,.10)), transparent 70%);
  pointer-events: none;
}
.stat-top { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.stat-label { font-size: 12px; color: var(--muted); font-weight: 600; letter-spacing: .01em; }
.stat-icon {
  width: 32px; height: 32px; border-radius: 9px; display: grid; place-items: center;
  background: var(--primary-soft); color: var(--primary);
}
.stat-value { font-size: 25px; font-weight: 700; letter-spacing: -0.035em; margin-top: 10px; line-height: 1.15; font-variant-numeric: tabular-nums; }
.stat-foot { display: flex; align-items: center; gap: 7px; margin-top: 7px; font-size: 11.5px; color: var(--muted); flex-wrap: wrap; }
.delta { display: inline-flex; align-items: center; gap: 2px; font-weight: 700; font-size: 11.5px; padding: 2px 6px; border-radius: 6px; }
.delta.up { color: var(--success); background: var(--success-soft); }
.delta.down { color: var(--danger); background: var(--danger-soft); }
.delta.flat { color: var(--muted); background: var(--surface-3); }
.stat-spark { position: absolute; right: 14px; bottom: 12px; opacity: .9; }

/* --------------------------------- badges ---------------------------------- */
.badge {
  display: inline-flex; align-items: center; gap: 5px; height: 22px; padding: 0 8px;
  border-radius: 7px; font-size: 11px; font-weight: 600; white-space: nowrap;
  background: var(--surface-3); color: var(--text-2); border: 1px solid transparent;
}
.badge .dot, .dot { width: 6px; height: 6px; border-radius: 50%; background: currentColor; flex: 0 0 auto; }
.badge-neutral { background: #f1f5f9; color: #475569; }
.badge-success { background: var(--success-soft); color: var(--success); }
.badge-warning { background: var(--warning-soft); color: var(--warning); }
.badge-danger { background: var(--danger-soft); color: var(--danger); }
.badge-info { background: var(--info-soft); color: var(--info); }
.badge-violet { background: var(--violet-soft); color: var(--violet); }
.badge-primary { background: var(--primary-soft); color: var(--primary-strong); }
.badge-outline { background: transparent; border-color: var(--border-strong); color: var(--muted); }
.badge-sm { height: 19px; font-size: 10px; padding: 0 6px; }

.chip {
  display: inline-flex; align-items: center; gap: 7px; height: 26px; padding: 0 9px 0 5px;
  border-radius: 8px; background: var(--surface-2); border: 1px solid var(--border);
  font-size: 12px; font-weight: 600; color: var(--text-2); white-space: nowrap;
}
.chip-logo {
  width: 18px; height: 18px; border-radius: 5px; display: grid; place-items: center;
  font-size: 8.5px; font-weight: 800; color: #fff; letter-spacing: -0.02em;
}
.chip.plain { padding-left: 9px; }

.avatar {
  border-radius: 50%; display: grid; place-items: center; color: #fff; font-weight: 700;
  flex: 0 0 auto; letter-spacing: -0.02em; background: #6366f1;
}
.avatar.square { border-radius: 10px; }
.avatar-soft { color: var(--text-2); background: var(--surface-3); }

/* --------------------------------- tables ---------------------------------- */
.table-wrap { overflow-x: auto; border-radius: 0 0 var(--radius) var(--radius); }
table.table { width: 100%; border-collapse: separate; border-spacing: 0; font-size: 13px; }
.table thead th {
  text-align: left; font-size: 10.5px; text-transform: uppercase; letter-spacing: .07em;
  color: var(--faint); font-weight: 700; padding: 10px 14px; background: var(--surface-2);
  border-bottom: 1px solid var(--border); border-top: 1px solid var(--border); white-space: nowrap;
}
.table thead th:first-child { padding-left: 18px; }
.table tbody td { padding: 11px 14px; border-bottom: 1px solid var(--border); vertical-align: middle; }
.table tbody td:first-child { padding-left: 18px; }
.table tbody tr:last-child td { border-bottom: 0; }
.table tbody tr { transition: background .12s; }
.table tbody tr:hover { background: #fafbff; }
.table tbody tr.clickable { cursor: pointer; }
.table .right, .table th.right { text-align: right; }
.cell-main { font-weight: 600; color: var(--text); display: flex; align-items: center; gap: 9px; }
.cell-sub { font-size: 11.5px; color: var(--muted); margin-top: 2px; }
.cell-sub.mono { letter-spacing: -0.02em; }
.th-sort { cursor: pointer; user-select: none; }
.th-sort:hover { color: var(--text-2); }
.num { font-variant-numeric: tabular-nums; white-space: nowrap; }
.row-actions { display: flex; align-items: center; gap: 4px; justify-content: flex-end; }
.product-emoji {
  width: 34px; height: 34px; border-radius: 9px; display: grid; place-items: center;
  font-size: 17px; flex: 0 0 auto; border: 1px solid rgba(15,23,42,.04);
}
.cell-actions { width: 1%; white-space: nowrap; }

/* --------------------------------- forms ----------------------------------- */
.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px; }
.form-grid .full { grid-column: 1 / -1; }
.field { display: flex; flex-direction: column; gap: 5px; min-width: 0; }
.label { font-size: 11.5px; font-weight: 600; color: var(--text-2); display: flex; align-items: center; gap: 5px; }
.label .req { color: var(--danger); }
.input, .select, .textarea {
  width: 100%; height: 38px; border-radius: 9px; border: 1px solid var(--border-strong);
  background: #fff; padding: 0 11px; font-size: 13px; outline: none; transition: border .15s, box-shadow .15s;
  color: var(--text);
}
.textarea { height: auto; min-height: 82px; padding: 9px 11px; resize: vertical; line-height: 1.5; }
.input:focus, .select:focus, .textarea:focus { border-color: #a5b4fc; box-shadow: 0 0 0 4px var(--primary-ring); }
.input::placeholder, .textarea::placeholder { color: var(--faint); }
.input:disabled, .select:disabled { background: var(--surface-3); color: var(--muted); }
.input.error, .select.error { border-color: #fda4af; }
.select {
  appearance: none; padding-right: 30px; cursor: pointer;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%2364748b' stroke-width='2.4' stroke-linecap='round'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 10px center;
}
.input-group { display: flex; align-items: center; }
.input-group .input { border-radius: 9px 0 0 9px; }
.input-group .input:last-child { border-radius: 0 9px 9px 0; }
.input-suffix {
  height: 38px; display: grid; place-items: center; padding: 0 10px; border: 1px solid var(--border-strong);
  border-left: 0; border-radius: 0 9px 9px 0; background: var(--surface-2); color: var(--muted); font-size: 12px;
}
.hint { font-size: 11px; color: var(--faint); }
.error-text { font-size: 11.5px; color: var(--danger); }
.check { display: flex; align-items: flex-start; gap: 9px; cursor: pointer; font-size: 13px; }
.check input { width: 16px; height: 16px; margin: 2px 0 0; accent-color: var(--primary); cursor: pointer; }
.switch { position: relative; width: 38px; height: 22px; flex: 0 0 auto; }
.switch input { opacity: 0; width: 0; height: 0; }
.switch span {
  position: absolute; inset: 0; border-radius: 999px; background: #d6dce8; transition: .18s; cursor: pointer;
}
.switch span::before {
  content: ""; position: absolute; width: 16px; height: 16px; border-radius: 50%; background: #fff;
  top: 3px; left: 3px; transition: .18s; box-shadow: 0 1px 3px rgba(0,0,0,.2);
}
.switch input:checked + span { background: var(--primary); }
.switch input:checked + span::before { transform: translateX(16px); }
.switch input:disabled + span { opacity: .6; cursor: not-allowed; }
.toggle-row { display: flex; align-items: center; justify-content: space-between; gap: 16px; padding: 13px 0; border-bottom: 1px solid var(--border); }
.toggle-row:last-child { border-bottom: 0; }
.toggle-title { font-weight: 600; font-size: 13px; }
.toggle-desc { font-size: 12px; color: var(--muted); margin-top: 2px; }

/* ------------------------------- toolbar/filters --------------------------- */
.toolbar { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; padding: 12px 14px; border-bottom: 1px solid var(--border); }
.toolbar .grow { flex: 1; }
.search { position: relative; min-width: 220px; flex: 1; max-width: 380px; }
.search .icon { position: absolute; left: 11px; top: 50%; transform: translateY(-50%); color: var(--faint); }
.search .input { padding-left: 34px; height: 36px; background: var(--surface-2); }
.search .input:focus { background: #fff; }
.toolbar .select { width: auto; min-width: 130px; height: 36px; }
.toolbar .input { height: 36px; }
.filter-count { font-size: 11.5px; color: var(--muted); }
.active-filters { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; padding: 0 14px 12px; }

/* ---------------------------------- tabs ----------------------------------- */
.tabs { display: flex; align-items: center; gap: 2px; border-bottom: 1px solid var(--border); padding: 0 14px; overflow-x: auto; }
.tabs::-webkit-scrollbar { height: 0; }
.tab {
  display: inline-flex; align-items: center; gap: 6px; height: 42px; padding: 0 11px; border: 0; background: none;
  font-size: 12.5px; font-weight: 600; color: var(--muted); cursor: pointer; position: relative; white-space: nowrap;
}
.tab:hover { color: var(--text); }
.tab.active { color: var(--primary-strong); }
.tab.active::after {
  content: ""; position: absolute; left: 8px; right: 8px; bottom: -1px; height: 2px;
  background: var(--primary); border-radius: 2px 2px 0 0;
}
.tab-count {
  min-width: 19px; height: 17px; padding: 0 5px; border-radius: 5px; display: grid; place-items: center;
  font-size: 10px; font-weight: 700; background: var(--surface-3); color: var(--muted);
}
.tab.active .tab-count { background: var(--primary-soft); color: var(--primary-strong); }
.segmented { display: inline-flex; background: var(--surface-3); padding: 3px; border-radius: 9px; gap: 2px; }
.segmented button {
  border: 0; background: transparent; height: 28px; padding: 0 11px; border-radius: 7px;
  font-size: 12px; font-weight: 600; color: var(--muted); cursor: pointer;
}
.segmented button.active { background: #fff; color: var(--text); box-shadow: var(--shadow-xs); }

/* -------------------------------- pagination -------------------------------- */
.pagination { display: flex; align-items: center; gap: 6px; justify-content: space-between; padding: 11px 16px; border-top: 1px solid var(--border); flex-wrap: wrap; }
.pagination-info { font-size: 12px; color: var(--muted); }
.page-btns { display: flex; align-items: center; gap: 3px; }
.page-btn {
  min-width: 30px; height: 30px; padding: 0 7px; border: 1px solid transparent; background: transparent;
  border-radius: 7px; font-size: 12px; font-weight: 600; color: var(--muted); cursor: pointer;
  display: inline-grid; place-items: center;
}
.page-btn:hover:not(:disabled) { background: var(--surface-3); color: var(--text); }
.page-btn.active { background: var(--primary-soft); color: var(--primary-strong); }
.page-btn:disabled { opacity: .4; cursor: not-allowed; }

/* ---------------------------------- modal ----------------------------------- */
.modal-backdrop {
  position: fixed; inset: 0; background: rgba(15, 23, 42, 0.45); backdrop-filter: blur(3px);
  z-index: 100; display: flex; align-items: flex-start; justify-content: center; padding: 6vh 16px 24px;
  overflow-y: auto; animation: fadeIn .18s ease;
}
.modal {
  background: #fff; border-radius: 18px; width: 100%; max-width: 560px; box-shadow: var(--shadow-lg);
  animation: modalIn .22s cubic-bezier(.16,1,.3,1); margin: auto 0 24px; border: 1px solid rgba(255,255,255,.6);
  display: flex; flex-direction: column; max-height: 88vh;
}
.modal.wide { max-width: 800px; }
.modal.xwide { max-width: 1040px; }
.modal.narrow { max-width: 430px; }
.modal-head { display: flex; align-items: flex-start; gap: 12px; padding: 20px 22px 14px; border-bottom: 1px solid var(--border); }
.modal-title { font-size: 16px; font-weight: 700; letter-spacing: -0.02em; }
.modal-sub { font-size: 12.5px; color: var(--muted); margin-top: 3px; }
.modal-close { margin-left: auto; }
.modal-body { padding: 18px 22px; overflow-y: auto; }
.modal-body.flush { padding: 0; }
.modal-foot { padding: 14px 22px; border-top: 1px solid var(--border); display: flex; align-items: center; gap: 8px; justify-content: flex-end; background: var(--surface-2); border-radius: 0 0 18px 18px; }
.modal-foot .left { margin-right: auto; }
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }
@keyframes modalIn { from { opacity: 0; transform: translateY(10px) scale(.99); } to { opacity: 1; transform: none; } }

/* --------------------------------- dropdown --------------------------------- */
.menu-wrap { position: relative; }
.menu {
  position: absolute; z-index: 90; min-width: 220px; background: #fff; border: 1px solid var(--border);
  border-radius: 12px; box-shadow: var(--shadow-lg); padding: 6px; animation: modalIn .15s ease;
}
.menu.right { right: 0; top: calc(100% + 8px); }
.menu.left { left: 0; top: calc(100% + 8px); }
.menu-item {
  display: flex; align-items: center; gap: 9px; width: 100%; padding: 8px 10px; border-radius: 8px;
  border: 0; background: none; cursor: pointer; font-size: 12.5px; color: var(--text-2); text-align: left;
}
.menu-item:hover { background: var(--surface-3); color: var(--text); }
.menu-item.danger { color: var(--danger); }
.menu-item.danger:hover { background: var(--danger-soft); }
.menu-sep { height: 1px; background: var(--border); margin: 5px 4px; }
.menu-label { font-size: 10px; text-transform: uppercase; letter-spacing: .08em; color: var(--faint); padding: 7px 10px 4px; font-weight: 700; }

/* -------------------------------- notifications ----------------------------- */
.notif-list { max-height: 380px; overflow-y: auto; }
.notif-item { display: flex; gap: 10px; padding: 11px 12px; border-radius: 9px; cursor: pointer; border: 0; background: none; width: 100%; text-align: left; }
.notif-item:hover { background: var(--surface-2); }
.notif-item.unread { background: #fafaff; }
.notif-icon { width: 30px; height: 30px; border-radius: 8px; display: grid; place-items: center; flex: 0 0 auto; }
.notif-title { font-size: 12.5px; font-weight: 600; line-height: 1.35; }
.notif-msg { font-size: 11.5px; color: var(--muted); margin-top: 2px; line-height: 1.45; }
.notif-time { font-size: 10.5px; color: var(--faint); margin-top: 4px; }

/* ---------------------------------- toast ----------------------------------- */
.toast-stack { position: fixed; right: 22px; bottom: 22px; z-index: 200; display: flex; flex-direction: column; gap: 8px; max-width: 380px; }
.toast {
  display: flex; align-items: flex-start; gap: 10px; padding: 12px 14px; border-radius: 11px; background: #0f172a;
  color: #e2e8f0; box-shadow: var(--shadow-lg); font-size: 12.5px; line-height: 1.45;
  animation: toastIn .25s cubic-bezier(.16,1,.3,1); border: 1px solid rgba(255,255,255,.08);
}
.toast.success { background: #064e3b; border-color: rgba(16,185,129,.3); }
.toast.error { background: #4c0519; border-color: rgba(244,63,94,.3); }
.toast.warning { background: #451a03; border-color: rgba(245,158,11,.3); }
.toast-icon { flex: 0 0 auto; margin-top: 1px; }
.toast-close { margin-left: auto; background: none; border: 0; color: inherit; opacity: .6; cursor: pointer; padding: 0; }
@keyframes toastIn { from { opacity: 0; transform: translateY(10px) scale(.98); } to { opacity: 1; transform: none; } }

/* ---------------------------------- empty ----------------------------------- */
.empty { display: flex; flex-direction: column; align-items: center; justify-content: center; text-align: center; padding: 46px 20px; gap: 8px; }
.empty-icon { width: 46px; height: 46px; border-radius: 13px; display: grid; place-items: center; background: var(--surface-3); color: var(--faint); margin-bottom: 4px; }
.empty-title { font-weight: 700; font-size: 14px; }
.empty-desc { font-size: 12.5px; color: var(--muted); max-width: 340px; }
.empty-action { margin-top: 8px; }

.skeleton { background: linear-gradient(90deg, #eef1f7 25%, #f7f9fc 37%, #eef1f7 63%); background-size: 400% 100%; animation: shimmer 1.3s infinite; border-radius: 7px; }
@keyframes shimmer { 0% { background-position: 100% 0; } 100% { background-position: -100% 0; } }
.loading-block { display: grid; place-items: center; padding: 50px; gap: 10px; color: var(--muted); font-size: 12.5px; }

/* ---------------------------------- charts ---------------------------------- */
.chart-wrap { position: relative; width: 100%; }
.chart-svg { display: block; width: 100%; overflow: visible; }
.chart-grid line { stroke: #eef1f7; stroke-width: 1; }
.chart-axis text { fill: var(--faint); font-size: 10px; font-family: var(--font); }
.chart-tooltip {
  position: absolute; pointer-events: none; background: #0f172a; color: #fff; padding: 7px 9px;
  border-radius: 8px; font-size: 11px; line-height: 1.45; box-shadow: var(--shadow-lg); transform: translate(-50%, -110%);
  white-space: nowrap; z-index: 5; opacity: 0; transition: opacity .12s;
}
.chart-tooltip.visible { opacity: 1; }
.chart-tooltip b { font-size: 12px; }
.legend { display: flex; flex-direction: column; gap: 9px; }
.legend-item { display: flex; align-items: center; gap: 9px; font-size: 12px; }
.legend-dot { width: 9px; height: 9px; border-radius: 3px; flex: 0 0 auto; }
.legend-value { margin-left: auto; font-weight: 600; font-variant-numeric: tabular-nums; }
.donut-center { font-size: 18px; font-weight: 700; letter-spacing: -0.03em; }
.donut-center-sub { font-size: 10px; fill: var(--muted); }

/* -------------------------------- status list ------------------------------- */
.status-bars { display: flex; flex-direction: column; gap: 11px; }
.status-bar { display: grid; grid-template-columns: 84px 1fr 34px; align-items: center; gap: 10px; font-size: 12px; }
.status-bar-track { height: 8px; background: var(--surface-3); border-radius: 99px; overflow: hidden; }
.status-bar-fill { height: 100%; border-radius: 99px; transition: width .4s ease; }
.status-bar-count { text-align: right; font-weight: 700; font-size: 12px; font-variant-numeric: tabular-nums; }

/* --------------------------------- timeline --------------------------------- */
.timeline { display: flex; flex-direction: column; }
.timeline-item { display: flex; gap: 12px; position: relative; padding-bottom: 18px; }
.timeline-item:last-child { padding-bottom: 0; }
.timeline-item::before {
  content: ""; position: absolute; left: 11px; top: 24px; bottom: 0; width: 2px; background: var(--border);
}
.timeline-item:last-child::before { display: none; }
.timeline-dot {
  width: 24px; height: 24px; border-radius: 50%; display: grid; place-items: center; flex: 0 0 auto;
  background: var(--primary-soft); color: var(--primary); z-index: 1; border: 3px solid #fff;
}
.timeline-title { font-weight: 600; font-size: 12.5px; }
.timeline-desc { font-size: 12px; color: var(--muted); margin-top: 1px; }
.timeline-time { font-size: 10.5px; color: var(--faint); margin-top: 3px; }

/* ---------------------------------- misc ------------------------------------ */
.callout { display: flex; gap: 10px; padding: 12px 14px; border-radius: 10px; background: var(--info-soft); color: #075985; font-size: 12.5px; line-height: 1.5; border: 1px solid #dbeefe; }
.callout.warning { background: var(--warning-soft); color: #92400e; border-color: #fde8c0; }
.callout.danger { background: var(--danger-soft); color: #9f1239; border-color: #fecdd3; }
.callout.success { background: var(--success-soft); color: #065f46; border-color: #c7f0e0; }
.callout .icon { flex: 0 0 auto; margin-top: 1px; }

.quick-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
.quick-card {
  display: flex; align-items: center; gap: 11px; padding: 12px; border-radius: 11px; border: 1px solid var(--border);
  background: #fff; cursor: pointer; transition: .15s; text-align: left;
}
.quick-card:hover { border-color: #c7d2fe; background: #fbfbff; transform: translateY(-1px); box-shadow: var(--shadow-sm); }
.quick-icon { width: 34px; height: 34px; border-radius: 9px; display: grid; place-items: center; flex: 0 0 auto; }
.quick-title { font-size: 12.5px; font-weight: 600; }
.quick-sub { font-size: 11px; color: var(--muted); margin-top: 1px; }

.split { display: grid; grid-template-columns: 360px minmax(0, 1fr); gap: 0; min-height: 580px; }
@media (max-width: 1100px) { .split { grid-template-columns: 1fr; } }
.list-pane { border-right: 1px solid var(--border); display: flex; flex-direction: column; min-height: 0; }
.list-scroll { overflow-y: auto; max-height: 520px; }
.ticket-item { display: block; width: 100%; text-align: left; border: 0; border-bottom: 1px solid var(--border); background: #fff; padding: 13px 16px; cursor: pointer; }
.ticket-item:hover { background: var(--surface-2); }
.ticket-item.active { background: var(--primary-soft); border-left: 3px solid var(--primary); padding-left: 13px; }
.ticket-subject { font-size: 12.5px; font-weight: 600; line-height: 1.35; }
.ticket-preview { font-size: 11.5px; color: var(--muted); margin-top: 3px; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.ticket-meta { display: flex; align-items: center; gap: 6px; margin-top: 6px; font-size: 10.5px; color: var(--faint); }

.thread { display: flex; flex: 1; flex-direction: column; gap: 14px; padding: 18px; overflow-y: auto; min-height: 320px; background: var(--surface-2); }
.bubble { max-width: 78%; padding: 10px 13px; border-radius: 13px; font-size: 12.5px; line-height: 1.5; box-shadow: var(--shadow-xs); }
.bubble.cliente { background: #fff; border: 1px solid var(--border); border-top-left-radius: 4px; align-self: flex-start; }
.bubble.agente { background: #eef2ff; border: 1px solid #dbe2ff; border-top-right-radius: 4px; align-self: flex-end; }
.bubble-meta { font-size: 10px; color: var(--faint); margin-top: 4px; }
.bubble-wrap { display: flex; flex-direction: column; }
.bubble-wrap.agente { align-items: flex-end; }
.composer { border-top: 1px solid var(--border); padding: 12px 14px; display: flex; gap: 8px; align-items: flex-end; background: #fff; }
.composer .textarea { min-height: 42px; max-height: 120px; }

.dre-table { width: 100%; border-collapse: collapse; font-size: 13px; }
.dre-table td { padding: 9px 14px; border-bottom: 1px solid var(--border); }
.dre-table tr.section td { font-weight: 700; background: var(--surface-2); font-size: 12px; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); }
.dre-table tr.total td { font-weight: 700; border-top: 2px solid var(--border-strong); }
.dre-table td.val { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; font-weight: 600; }
.dre-table td.pct { text-align: right; font-size: 11px; color: var(--muted); width: 70px; }
.dre-table tr.highlight td { background: #f6f7ff; }

.two-col { display: grid; grid-template-columns: minmax(0, 1.6fr) minmax(0, 1fr); gap: 16px; align-items: start; }
.sticky-col { position: sticky; top: 86px; display: flex; flex-direction: column; gap: 16px; }
@media (max-width: 1100px) { .two-col { grid-template-columns: 1fr; } .sticky-col { position: static; } }

.kv { display: flex; align-items: flex-start; justify-content: space-between; gap: 14px; padding: 6px 0; font-size: 12.5px; }
.kv .k { color: var(--muted); flex: 0 0 auto; }
.kv .v { text-align: right; font-weight: 600; }
.kv.total { border-top: 1px solid var(--border); margin-top: 6px; padding-top: 10px; font-size: 14px; }
.kv.total .v { font-size: 16px; }

.section-title { font-size: 13px; font-weight: 700; display: flex; align-items: center; gap: 8px; margin-bottom: 10px; }
.section-title .icon { color: var(--faint); }

.print-only { display: none; }

/* ---------------------------------- login ----------------------------------- */
.login { min-height: 100vh; display: grid; grid-template-columns: minmax(0, 1.05fr) minmax(0, .95fr); }
.login-brand {
  background: var(--sidebar); color: #fff; padding: 48px 56px; display: flex; flex-direction: column;
  position: relative; overflow: hidden;
  background-image: radial-gradient(90% 70% at 15% 10%, rgba(79,70,229,.45), transparent 60%),
                    radial-gradient(70% 60% at 90% 90%, rgba(14,165,233,.28), transparent 60%);
}
.login-brand::after {
  content: ""; position: absolute; inset: 0;
  background-image: linear-gradient(rgba(255,255,255,.035) 1px, transparent 1px), linear-gradient(90deg, rgba(255,255,255,.035) 1px, transparent 1px);
  background-size: 46px 46px; mask-image: radial-gradient(70% 60% at 50% 40%, #000, transparent);
}
.login-brand > * { position: relative; z-index: 1; }
.login-logo { display: flex; align-items: center; gap: 11px; font-weight: 700; font-size: 19px; letter-spacing: -0.03em; }
.login-hero { margin-top: auto; }
.login-hero h1 { font-size: 38px; line-height: 1.12; letter-spacing: -0.04em; font-weight: 700; max-width: 520px; }
.login-hero h1 span { background: linear-gradient(90deg, #a5b4fc, #67e8f9); -webkit-background-clip: text; background-clip: text; color: transparent; }
.login-hero p { color: #a9b7cc; font-size: 14px; margin-top: 16px; max-width: 460px; line-height: 1.6; }
.login-stats { display: flex; gap: 34px; margin-top: 34px; }
.login-stat-value { font-size: 22px; font-weight: 700; letter-spacing: -0.03em; }
.login-stat-label { font-size: 11px; color: #7d8ba4; margin-top: 2px; }
.login-features { display: grid; gap: 12px; margin-top: 40px; grid-template-columns: repeat(2, minmax(0, 1fr)); max-width: 480px; }
.login-feature { display: flex; align-items: center; gap: 9px; font-size: 12.5px; color: #c6d2e2; }
.login-feature .icon { color: #818cf8; }
.login-foot { margin-top: auto; font-size: 11px; color: #64748b; padding-top: 32px; }
.login-form-side { display: flex; align-items: center; justify-content: center; padding: 32px; background: #fff; }
.login-card { width: 100%; max-width: 380px; }
.login-card h2 { font-size: 24px; font-weight: 700; letter-spacing: -0.03em; }
.login-card .sub { color: var(--muted); font-size: 13px; margin-top: 6px; margin-bottom: 26px; }
.login-options { display: flex; align-items: center; justify-content: space-between; margin: 2px 0 18px; font-size: 12.5px; }
.demo-box { margin-top: 26px; border: 1px dashed var(--border-strong); border-radius: 12px; padding: 13px; background: var(--surface-2); }
.demo-title { font-size: 10.5px; text-transform: uppercase; letter-spacing: .09em; color: var(--faint); font-weight: 700; margin-bottom: 8px; }
.demo-btns { display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px; }
.demo-btn { border: 1px solid var(--border); background: #fff; border-radius: 8px; padding: 8px 4px; cursor: pointer; text-align: center; transition: .15s; }
.demo-btn:hover { border-color: #c7d2fe; background: #fafaff; }
.demo-btn b { display: block; font-size: 11px; }
.demo-btn span { display: block; font-size: 9.5px; color: var(--faint); margin-top: 2px; }
.login-error { display: flex; gap: 8px; align-items: center; padding: 10px 12px; border-radius: 9px; background: var(--danger-soft); color: #9f1239; font-size: 12.5px; margin-bottom: 14px; border: 1px solid #fecdd3; }

/* -------------------------------- responsive -------------------------------- */
@media (max-width: 1280px) {
  .kpis { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .grid-4 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .grid-3 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 1100px) {
  .sidebar { position: fixed; left: 0; top: 0; bottom: 0; transform: translateX(-100%); box-shadow: var(--shadow-lg); }
  .sidebar.open { transform: none; }
  .sidebar-close { display: grid !important; }
  .menu-toggle { display: grid !important; }
  .shell { display: block; }
  .content { padding: 20px 18px 40px; }
  .topbar { padding: 0 16px; }
  .grid-2-1, .grid-1-2 { grid-template-columns: 1fr; }
}
@media (max-width: 860px) {
  .grid-2, .grid-3, .grid-4, .form-grid { grid-template-columns: 1fr; }
  .kpis { grid-template-columns: 1fr; }
  .page-title { font-size: 21px; }
  .topbar-search { width: auto; flex: 1; }
  .user-button-name, .user-button-role { display: none; }
  .login { grid-template-columns: 1fr; }
  .login-brand { display: none; }
  .login-form-side { background: var(--bg); }
  .login-card { background: #fff; padding: 28px; border-radius: 18px; box-shadow: var(--shadow); }
  .split { grid-template-columns: 1fr; }
}
@media (max-width: 560px) {
  .content { padding: 16px 12px 32px; }
  .topbar { gap: 8px; }
  .page-actions { width: 100%; }
  .page-actions .btn { flex: 1; }
  .modal { max-height: 92vh; }
  .modal-body { padding: 16px; }
  .modal-head, .modal-foot { padding-left: 16px; padding-right: 16px; }
  .stat-value { font-size: 22px; }
}

/* ---------------------------------- print ----------------------------------- */
@media print {
  .sidebar, .topbar, .page-actions, .btn, .tabs, .toast-stack, .modal-backdrop { display: none !important; }
  body { background: #fff; }
  .content { padding: 0; max-width: none; }
  .card { box-shadow: none; border-color: #ddd; break-inside: avoid; }
  .two-col { grid-template-columns: 1fr; }
  .print-only { display: block; }
}
