/* ============ Tokens ============ */
:root {
  --bg: #f6f7fb;
  --surface: #ffffff;
  --surface-2: #f1f3f9;
  --surface-hover: #f5f6fb;
  --border: #e4e7ef;
  --border-strong: #d4d8e3;
  --text: #111827;
  --text-2: #4b5563;
  --text-3: #8a92a3;
  --accent: #4f46e5;
  --accent-2: #6366f1;
  --accent-soft: #eef0ff;
  --accent-text: #4338ca;
  --green: #059669;  --green-soft: #e7f8f1;
  --blue: #2563eb;   --blue-soft: #e8f0ff;
  --amber: #b45309;  --amber-soft: #fdf3e1;
  --red: #dc2626;    --red-soft: #fdecec;
  --slate: #64748b;  --slate-soft: #eef1f5;
  --shadow-sm: 0 1px 2px rgba(16, 24, 40, .05);
  --shadow: 0 1px 3px rgba(16, 24, 40, .06), 0 6px 16px -4px rgba(16, 24, 40, .08);
  --shadow-lg: 0 24px 48px -12px rgba(16, 24, 40, .25);
  --radius: 14px;
  --radius-sm: 9px;
  --ease: cubic-bezier(.2, .8, .2, 1);
  --sidebar: 248px;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0b0d14; --surface: #12151f; --surface-2: #181c28; --surface-hover: #1a1f2c;
    --border: #232838; --border-strong: #2f3548;
    --text: #eef0f6; --text-2: #a9b0c2; --text-3: #6f7790;
    --accent: #818cf8; --accent-2: #6366f1; --accent-soft: #1e2140; --accent-text: #a5b4fc;
    --green: #34d399; --green-soft: #0f2a22; --blue: #60a5fa; --blue-soft: #13223d;
    --amber: #fbbf24; --amber-soft: #2d2410; --red: #f87171; --red-soft: #321719;
    --slate: #94a3b8; --slate-soft: #1d2230;
    --shadow: 0 1px 2px rgba(0,0,0,.4), 0 8px 24px -8px rgba(0,0,0,.5);
    --shadow-lg: 0 24px 60px -12px rgba(0,0,0,.7);
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #0b0d14; --surface: #12151f; --surface-2: #181c28; --surface-hover: #1a1f2c;
  --border: #232838; --border-strong: #2f3548;
  --text: #eef0f6; --text-2: #a9b0c2; --text-3: #6f7790;
  --accent: #818cf8; --accent-2: #6366f1; --accent-soft: #1e2140; --accent-text: #a5b4fc;
  --green: #34d399; --green-soft: #0f2a22; --blue: #60a5fa; --blue-soft: #13223d;
  --amber: #fbbf24; --amber-soft: #2d2410; --red: #f87171; --red-soft: #321719;
  --slate: #94a3b8; --slate-soft: #1d2230;
  --shadow: 0 1px 2px rgba(0,0,0,.4), 0 8px 24px -8px rgba(0,0,0,.5);
  --shadow-lg: 0 24px 60px -12px rgba(0,0,0,.7);
  color-scheme: dark;
}

/* ============ Base ============ */
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body {
  background: var(--bg); color: var(--text);
  font: 14px/1.5 "Inter", ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  -webkit-font-smoothing: antialiased;
  font-feature-settings: "cv11", "ss01", "tnum";
}
svg { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; flex-shrink: 0; }
a { color: inherit; text-decoration: none; }
button { font: inherit; color: inherit; cursor: pointer; }
input, select, textarea { font: inherit; color: inherit; }
::selection { background: var(--accent-soft); color: var(--accent-text); }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

/* ============ Shell ============ */
.shell { display: flex; min-height: 100vh; }
.sidebar {
  width: var(--sidebar); flex-shrink: 0; position: sticky; top: 0; height: 100vh;
  display: flex; flex-direction: column; gap: 8px; padding: 18px 14px;
  background: var(--surface); border-right: 1px solid var(--border);
  transition: transform .3s var(--ease);
  z-index: 30;
}
.brand { display: flex; align-items: center; gap: 11px; padding: 6px 8px 18px; }
.brand-logo {
  width: 36px; height: 36px; border-radius: 10px; display: grid; place-items: center; color: #fff;
  background: linear-gradient(135deg, #6366f1, #4f46e5 60%, #7c3aed);
  box-shadow: 0 6px 14px -4px rgba(79, 70, 229, .55);
}
.brand-text { font-weight: 700; font-size: 15px; letter-spacing: -.01em; line-height: 1.2; }
.brand-text small { display: block; font-weight: 500; font-size: 11.5px; color: var(--text-3); letter-spacing: 0; }
.nav { display: flex; flex-direction: column; gap: 2px; }
.nav a {
  display: flex; align-items: center; gap: 11px; padding: 9px 11px; border-radius: var(--radius-sm);
  color: var(--text-2); font-weight: 500; transition: background .15s, color .15s;
}
.nav a:hover { background: var(--surface-hover); color: var(--text); }
.nav a.active { background: var(--accent-soft); color: var(--accent-text); }
.sidebar-foot { margin-top: auto; display: flex; flex-direction: column; gap: 2px; }
.user-box { display: flex; align-items: center; gap: 10px; padding: 10px; margin-bottom: 6px; border-radius: 12px; background: var(--surface-2); }
.user-box img, .user-box .avatar { width: 32px; height: 32px; border-radius: 99px; flex-shrink: 0; }
.user-box .grow { min-width: 0; line-height: 1.3; }
.user-box b { display: block; font-size: 13px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.user-box span { display: block; font-size: 11.5px; color: var(--text-3); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.ghost-btn {
  display: flex; align-items: center; gap: 11px; padding: 9px 11px; border-radius: var(--radius-sm);
  border: 0; background: none; color: var(--text-2); font-weight: 500; text-align: left;
}
.ghost-btn:hover { background: var(--surface-hover); color: var(--text); }
.i-moon { display: none; }
:root[data-theme="dark"] .i-sun { display: none; }
:root[data-theme="dark"] .i-moon { display: block; }

.main { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.topbar {
  position: sticky; top: 0; z-index: 20; display: flex; align-items: center; gap: 12px;
  padding: 14px 32px; background: color-mix(in srgb, var(--bg) 82%, transparent);
  backdrop-filter: saturate(1.6) blur(12px); -webkit-backdrop-filter: saturate(1.6) blur(12px);
  border-bottom: 1px solid transparent;
}
.topbar.scrolled { border-bottom-color: var(--border); }
.search-trigger {
  flex: 1; max-width: 520px; display: flex; align-items: center; gap: 10px;
  padding: 9px 12px; border-radius: 11px; border: 1px solid var(--border);
  background: var(--surface); color: var(--text-3); box-shadow: var(--shadow-sm);
  transition: border-color .15s, box-shadow .15s;
}
.search-trigger:hover { border-color: var(--border-strong); }
.search-trigger span { flex: 1; text-align: left; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
kbd {
  font: 500 11px/1 ui-monospace, SFMono-Regular, Menlo, monospace; padding: 4px 6px; border-radius: 6px;
  background: var(--surface-2); border: 1px solid var(--border); color: var(--text-3);
}
.topbar .btn.primary { margin-left: auto; }
.icon-btn.menu-btn { display: none; }
[hidden] { display: none !important; }

.view { padding: 8px 32px 48px; max-width: 1440px; width: 100%; margin: 0 auto; }
.view > * { animation: rise .35s var(--ease) both; }
.view > *:nth-child(2) { animation-delay: .03s; }
.view > *:nth-child(3) { animation-delay: .06s; }
.view > *:nth-child(4) { animation-delay: .09s; }
@keyframes rise { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }

/* ============ Page header ============ */
.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; flex-wrap: wrap; margin: 18px 0 22px; }
.page-head h1 { margin: 0; font-size: 26px; font-weight: 700; letter-spacing: -.025em; }
.page-head p { margin: 4px 0 0; color: var(--text-2); }
.crumbs { display: flex; align-items: center; gap: 6px; color: var(--text-3); font-size: 13px; margin-bottom: 6px; }
.crumbs a:hover { color: var(--accent); }
.actions { display: flex; gap: 8px; flex-wrap: wrap; }

/* ============ Buttons ============ */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 7px;
  padding: 8px 14px; border-radius: 10px; border: 1px solid var(--border);
  background: var(--surface); font-weight: 600; font-size: 13.5px; white-space: nowrap;
  box-shadow: var(--shadow-sm); transition: background .15s, border-color .15s, transform .1s, box-shadow .15s;
}
.btn svg { width: 16px; height: 16px; }
.btn:hover { background: var(--surface-hover); border-color: var(--border-strong); }
.btn:active { transform: scale(.97); }
.btn.primary {
  background: var(--accent-2); border-color: transparent; color: #fff;
  box-shadow: 0 1px 2px rgba(79,70,229,.3), inset 0 1px 0 rgba(255,255,255,.15);
}
.btn.primary:hover { background: #4f46e5; box-shadow: 0 4px 14px -2px rgba(79,70,229,.45); }
.btn.danger { color: var(--red); }
.btn.danger:hover { background: var(--red-soft); border-color: transparent; }
.btn.danger-solid { background: var(--red); color: #fff; border-color: transparent; }
.btn.sm { padding: 6px 10px; font-size: 12.5px; border-radius: 8px; }
.btn[disabled] { opacity: .55; pointer-events: none; }
.icon-btn {
  width: 34px; height: 34px; display: inline-grid; place-items: center; border-radius: 9px;
  border: 1px solid transparent; background: none; color: var(--text-2); transition: background .15s;
}
.icon-btn:hover { background: var(--surface-2); color: var(--text); }

/* ============ Cards & KPIs ============ */
.card {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
}
.card-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 16px 20px 0; }
.card-head h2 { margin: 0; font-size: 15px; font-weight: 650; letter-spacing: -.01em; }
.card-head .muted { font-size: 12.5px; }
.card-body { padding: 16px 20px 20px; }

.kpis { display: grid; grid-template-columns: repeat(4, 1fr); gap: 16px; margin-bottom: 16px; }
.kpi { padding: 18px 20px; position: relative; overflow: hidden; transition: transform .2s var(--ease), box-shadow .2s; }
.kpi:hover { transform: translateY(-2px); box-shadow: var(--shadow); }
.kpi-top { display: flex; align-items: center; justify-content: space-between; color: var(--text-2); font-weight: 500; font-size: 13px; }
.kpi-icon { width: 34px; height: 34px; border-radius: 10px; display: grid; place-items: center; }
.kpi-value { font-size: 30px; font-weight: 700; letter-spacing: -.03em; margin-top: 8px; line-height: 1.1; }
.kpi-sub { color: var(--text-3); font-size: 12.5px; margin-top: 4px; }
.tone-accent { background: var(--accent-soft); color: var(--accent-text); }
.tone-green  { background: var(--green-soft); color: var(--green); }
.tone-blue   { background: var(--blue-soft);  color: var(--blue); }
.tone-amber  { background: var(--amber-soft); color: var(--amber); }
.tone-red    { background: var(--red-soft);   color: var(--red); }
.tone-slate  { background: var(--slate-soft); color: var(--slate); }

.grid-2 { display: grid; grid-template-columns: 1.15fr 1fr; gap: 16px; margin-bottom: 16px; }
.grid-3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 16px; margin-bottom: 16px; }
.grid-side { display: grid; grid-template-columns: minmax(0, 1fr) 360px; gap: 16px; align-items: start; }

/* ============ Charts ============ */
.donut-wrap { display: flex; align-items: center; gap: 28px; flex-wrap: wrap; }
.donut { width: 168px; height: 168px; position: relative; flex-shrink: 0; }
.donut svg { width: 100%; height: 100%; transform: rotate(-90deg); stroke-linecap: butt; }
.donut circle { transition: stroke-dasharray .8s var(--ease), stroke-dashoffset .8s var(--ease); }
.donut-center { position: absolute; inset: 0; display: grid; place-content: center; text-align: center; }
.donut-center b { font-size: 28px; letter-spacing: -.03em; line-height: 1; }
.donut-center span { color: var(--text-3); font-size: 12px; }
.legend { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 9px; flex: 1; min-width: 180px; }
.legend li { display: flex; align-items: center; gap: 10px; font-size: 13px; cursor: pointer; padding: 3px 6px; margin: -3px -6px; border-radius: 6px; }
.legend li:hover { background: var(--surface-2); }
.legend .dot { width: 9px; height: 9px; border-radius: 3px; }
.legend .val { margin-left: auto; font-weight: 600; }
.legend .pct { color: var(--text-3); width: 42px; text-align: right; font-size: 12px; }

.bars { display: flex; flex-direction: column; gap: 11px; }
.bar-row { display: grid; grid-template-columns: 140px 1fr 32px; align-items: center; gap: 12px; font-size: 13px; cursor: pointer; }
.bar-row:hover .bar-fill { filter: brightness(1.1); }
.bar-label { color: var(--text-2); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.bar-track { height: 8px; border-radius: 99px; background: var(--surface-2); overflow: hidden; }
.bar-fill { height: 100%; border-radius: 99px; background: linear-gradient(90deg, var(--accent-2), #8b5cf6); width: 0; transition: width .9s var(--ease); }
.bar-val { font-weight: 600; text-align: right; }

/* ============ Lists / activity ============ */
.list { display: flex; flex-direction: column; }
.list-item { display: flex; align-items: center; gap: 12px; padding: 11px 20px; border-top: 1px solid var(--border); transition: background .15s; }
.list-item:first-child { border-top: 0; }
a.list-item:hover { background: var(--surface-hover); }
.list-item .grow { flex: 1; min-width: 0; }
.list-item .title { font-weight: 550; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.list-item .sub { color: var(--text-3); font-size: 12.5px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.empty { padding: 36px 20px; text-align: center; color: var(--text-3); }
.empty svg { width: 36px; height: 36px; stroke-width: 1.4; margin-bottom: 8px; opacity: .6; }

.timeline { list-style: none; margin: 0; padding: 0; position: relative; }
.timeline li { position: relative; padding: 0 0 18px 34px; }
.timeline li::before { content: ""; position: absolute; left: 13px; top: 28px; bottom: 0; width: 1.5px; background: var(--border); }
.timeline li:last-child::before { display: none; }
.timeline .t-icon { position: absolute; left: 0; top: 0; width: 28px; height: 28px; border-radius: 99px; display: grid; place-items: center; }
.timeline .t-icon svg { width: 14px; height: 14px; }
.timeline .t-msg { font-weight: 500; padding-top: 3px; }
.timeline .t-meta { color: var(--text-3); font-size: 12.5px; }

/* ============ Badges & avatars ============ */
.badge {
  display: inline-flex; align-items: center; gap: 6px; padding: 3px 9px 3px 8px; border-radius: 99px;
  font-size: 12px; font-weight: 600; white-space: nowrap;
}
.badge::before { content: ""; width: 6px; height: 6px; border-radius: 99px; background: currentColor; }
.badge.plain::before { display: none; }
.avatar {
  width: 30px; height: 30px; border-radius: 99px; display: inline-grid; place-items: center; flex-shrink: 0;
  font-size: 11.5px; font-weight: 700; letter-spacing: .02em; color: #fff;
}
.avatar.lg { width: 56px; height: 56px; font-size: 19px; }
.type-icon { width: 34px; height: 34px; border-radius: 10px; display: grid; place-items: center; flex-shrink: 0; background: var(--surface-2); color: var(--text-2); }
.type-icon.lg { width: 56px; height: 56px; border-radius: 14px; }
.type-icon.lg svg { width: 26px; height: 26px; }
.person-chip { display: inline-flex; align-items: center; gap: 8px; }
.person-chip .avatar { width: 24px; height: 24px; font-size: 10px; }
.muted { color: var(--text-3); }
.mono { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 12.5px; }

/* ============ Toolbar & table ============ */
.toolbar { display: flex; align-items: center; gap: 10px; padding: 14px; flex-wrap: wrap; border-bottom: 1px solid var(--border); }
.input-icon { position: relative; flex: 1; min-width: 220px; }
.input-icon svg { position: absolute; left: 11px; top: 50%; transform: translateY(-50%); color: var(--text-3); width: 16px; height: 16px; }
.input-icon input { padding-left: 34px; }
.input, .select, textarea.input {
  width: 100%; padding: 8px 11px; border-radius: 10px; border: 1px solid var(--border); background: var(--surface);
  transition: border-color .15s, box-shadow .15s; outline: none;
}
.input:focus, .select:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.select {
  width: auto; padding-right: 30px; appearance: none; cursor: pointer;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%238a92a3' stroke-width='2' stroke-linecap='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 9px center; background-size: 15px;
}
.toolbar .select.active { border-color: var(--accent); color: var(--accent-text); background-color: var(--accent-soft); }
.segmented { display: inline-flex; padding: 3px; background: var(--surface-2); border-radius: 10px; gap: 2px; }
.segmented button { border: 0; background: none; padding: 5px 9px; border-radius: 7px; color: var(--text-3); display: grid; place-items: center; }
.segmented button.on { background: var(--surface); color: var(--text); box-shadow: var(--shadow-sm); }
.segmented svg { width: 16px; height: 16px; }

.chips { display: flex; gap: 6px; flex-wrap: wrap; padding: 12px 14px 0; }
.chip {
  display: inline-flex; align-items: center; gap: 6px; padding: 5px 11px; border-radius: 99px; font-size: 12.5px; font-weight: 550;
  border: 1px solid var(--border); background: var(--surface); color: var(--text-2); transition: all .15s;
}
.chip:hover { border-color: var(--border-strong); color: var(--text); }
.chip.on { background: var(--text); color: var(--surface); border-color: var(--text); }
.chip .count { opacity: .6; font-weight: 500; }

.table-wrap { overflow-x: auto; }
table.table { width: 100%; border-collapse: collapse; font-size: 13.5px; }
.table th {
  text-align: left; font-weight: 550; font-size: 12px; color: var(--text-3); padding: 10px 14px;
  border-bottom: 1px solid var(--border); white-space: nowrap; user-select: none; background: var(--surface);
}
.table th[data-sort] { cursor: pointer; }
.table th[data-sort]:hover { color: var(--text); }
.table th .arrow { opacity: 0; display: inline-block; margin-left: 4px; transition: transform .2s, opacity .2s; }
.table th.sorted .arrow { opacity: 1; }
.table th.sorted.desc .arrow { transform: rotate(180deg); }
.table td { padding: 11px 14px; border-bottom: 1px solid var(--border); white-space: nowrap; vertical-align: middle; }
.table tbody tr { cursor: pointer; transition: background .12s; }
.table tbody tr:hover { background: var(--surface-hover); }
.table tbody tr:last-child td { border-bottom: 0; }
.table .asset-cell { display: flex; align-items: center; gap: 11px; }
.table .asset-cell b { font-weight: 600; display: block; }
.table .asset-cell span { color: var(--text-3); font-size: 12.5px; }
.table-foot { display: flex; justify-content: space-between; align-items: center; padding: 12px 16px; color: var(--text-3); font-size: 12.5px; border-top: 1px solid var(--border); }

.cards-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 14px; padding: 14px; }
.asset-card {
  padding: 16px; border-radius: 12px; border: 1px solid var(--border); background: var(--surface);
  display: flex; flex-direction: column; gap: 12px; transition: transform .2s var(--ease), box-shadow .2s, border-color .2s;
}
.asset-card:hover { transform: translateY(-2px); box-shadow: var(--shadow); border-color: var(--border-strong); }
.asset-card .top { display: flex; gap: 12px; align-items: flex-start; }
.asset-card .top .grow { flex: 1; min-width: 0; }
.asset-card b { display: block; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.asset-card .foot { display: flex; justify-content: space-between; align-items: center; gap: 8px; padding-top: 12px; border-top: 1px dashed var(--border); font-size: 12.5px; }

.people-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 14px; }
.person-card { padding: 18px; display: flex; flex-direction: column; gap: 14px; transition: transform .2s var(--ease), box-shadow .2s; }
.person-card:hover { transform: translateY(-2px); box-shadow: var(--shadow); }
.person-card .top { display: flex; align-items: center; gap: 12px; }
.person-card .top b { display: block; font-weight: 600; font-size: 14.5px; }
.person-card .stats { display: flex; gap: 8px; }
.person-card .stat { flex: 1; padding: 9px 11px; background: var(--surface-2); border-radius: 10px; }
.person-card .stat b { display: block; font-size: 16px; }
.person-card .stat span { font-size: 11.5px; color: var(--text-3); }
.person-card.inactive { opacity: .6; }

/* ============ Detail ============ */
.hero { padding: 22px; display: flex; gap: 18px; align-items: center; flex-wrap: wrap; }
.hero .grow { flex: 1; min-width: 220px; }
.hero h1 { margin: 0; font-size: 22px; letter-spacing: -.02em; }
.hero .meta { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; margin-top: 6px; color: var(--text-3); }
.props { display: grid; grid-template-columns: repeat(2, 1fr); gap: 0; }
.prop { padding: 13px 20px; border-top: 1px solid var(--border); }
.prop:nth-child(odd) { border-right: 1px solid var(--border); }
.prop:nth-child(-n+2) { border-top: 0; }
.prop dt { font-size: 12px; color: var(--text-3); margin-bottom: 2px; }
.prop dd { margin: 0; font-weight: 500; }
.assign-box { padding: 18px 20px; display: flex; flex-direction: column; gap: 14px; }
.assign-box .who { display: flex; align-items: center; gap: 12px; }
.warranty-bar { height: 6px; border-radius: 99px; background: var(--surface-2); overflow: hidden; margin-top: 8px; }
.warranty-bar div { height: 100%; border-radius: 99px; transition: width .9s var(--ease); }
.note-form { display: flex; gap: 8px; padding: 14px 20px; border-top: 1px solid var(--border); }

/* ============ Overlay / drawer / modal ============ */
.overlay {
  position: fixed; inset: 0; background: rgba(10, 12, 20, .42); backdrop-filter: blur(3px);
  opacity: 0; pointer-events: none; transition: opacity .25s var(--ease); z-index: 40;
}
.overlay.on { opacity: 1; pointer-events: auto; }
.drawer {
  position: fixed; top: 0; right: 0; bottom: 0; width: min(560px, 100vw); z-index: 50;
  background: var(--surface); box-shadow: var(--shadow-lg); display: flex; flex-direction: column;
  transform: translateX(104%); transition: transform .38s var(--ease);
}
.drawer.on { transform: none; }
.drawer-head { display: flex; align-items: center; justify-content: space-between; padding: 18px 22px; border-bottom: 1px solid var(--border); }
.drawer-head h2 { margin: 0; font-size: 17px; letter-spacing: -.01em; }
.drawer-body { flex: 1; overflow-y: auto; padding: 20px 22px; }
.drawer-foot { display: flex; justify-content: flex-end; gap: 8px; padding: 14px 22px; border-top: 1px solid var(--border); background: var(--surface-2); }

.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 14px 14px; }
.form-grid .full { grid-column: 1 / -1; }
.form-section { grid-column: 1 / -1; font-size: 11.5px; font-weight: 650; text-transform: uppercase; letter-spacing: .06em; color: var(--text-3); margin-top: 8px; padding-bottom: 6px; border-bottom: 1px solid var(--border); }
.form-section:first-child { margin-top: 0; }
.field { display: flex; flex-direction: column; gap: 6px; }
.field label { font-size: 12.5px; font-weight: 550; color: var(--text-2); }
.field label .req { color: var(--red); }
.field .select { width: 100%; }
textarea.input { resize: vertical; min-height: 84px; }
.check { display: flex; align-items: center; gap: 8px; font-weight: 500; cursor: pointer; }
.check input { width: 16px; height: 16px; accent-color: var(--accent-2); }

.modal {
  position: fixed; left: 50%; top: 50%; z-index: 60; width: min(440px, calc(100vw - 32px));
  background: var(--surface); border-radius: 16px; box-shadow: var(--shadow-lg); border: 1px solid var(--border);
  transform: translate(-50%, -46%) scale(.96); opacity: 0; pointer-events: none;
  transition: transform .25s var(--ease), opacity .2s var(--ease);
}
.modal.on { transform: translate(-50%, -50%); opacity: 1; pointer-events: auto; }
.modal-body { padding: 22px; }
.modal-body h3 { margin: 0 0 6px; font-size: 17px; }
.modal-body p { margin: 0 0 14px; color: var(--text-2); }
.modal-foot { display: flex; justify-content: flex-end; gap: 8px; padding: 14px 22px; border-top: 1px solid var(--border); }

/* ============ Command palette ============ */
.palette {
  position: fixed; left: 50%; top: 12vh; z-index: 70; width: min(620px, calc(100vw - 32px));
  background: var(--surface); border-radius: 16px; box-shadow: var(--shadow-lg); border: 1px solid var(--border);
  transform: translateX(-50%) translateY(-8px) scale(.98); opacity: 0; pointer-events: none;
  transition: transform .2s var(--ease), opacity .15s; overflow: hidden;
}
.palette.on { transform: translateX(-50%); opacity: 1; pointer-events: auto; }
.palette-input { display: flex; align-items: center; gap: 10px; padding: 14px 18px; border-bottom: 1px solid var(--border); }
.palette-input input { flex: 1; border: 0; outline: none; background: none; font-size: 16px; }
.palette-input svg { color: var(--text-3); }
.palette-results { max-height: 52vh; overflow-y: auto; padding: 6px; }
.palette-group { font-size: 11.5px; font-weight: 600; color: var(--text-3); padding: 10px 12px 4px; text-transform: uppercase; letter-spacing: .05em; }
.palette-item { display: flex; align-items: center; gap: 12px; padding: 9px 12px; border-radius: 10px; cursor: pointer; }
.palette-item.sel { background: var(--accent-soft); }
.palette-item .grow { flex: 1; min-width: 0; }
.palette-item .sub { color: var(--text-3); font-size: 12.5px; }
.palette-foot { display: flex; gap: 14px; padding: 10px 16px; border-top: 1px solid var(--border); font-size: 12px; color: var(--text-3); }

/* ============ Toasts ============ */
.toasts { position: fixed; right: 20px; bottom: 20px; z-index: 90; display: flex; flex-direction: column; gap: 8px; }
.toast {
  display: flex; align-items: center; gap: 10px; padding: 11px 14px 11px 12px; border-radius: 12px; min-width: 260px; max-width: 380px;
  background: var(--text); color: var(--surface); box-shadow: var(--shadow-lg); font-weight: 500;
  animation: toastIn .35s var(--ease);
}
.toast.out { animation: toastOut .25s var(--ease) forwards; }
.toast .t-ico { width: 22px; height: 22px; border-radius: 99px; display: grid; place-items: center; }
.toast .t-ico svg { width: 13px; height: 13px; stroke-width: 2.4; }
.toast.ok .t-ico { background: #10b981; color: #fff; }
.toast.err .t-ico { background: #ef4444; color: #fff; }
@keyframes toastIn { from { opacity: 0; transform: translateY(12px) scale(.96); } }
@keyframes toastOut { to { opacity: 0; transform: translateX(24px); } }

/* ============ Login ============ */
.login {
  position: fixed; inset: 0; z-index: 100; display: grid; place-items: center; padding: 16px;
  background: radial-gradient(1200px 600px at 20% 0%, rgba(99,102,241,.18), transparent 60%), radial-gradient(900px 500px at 100% 100%, rgba(139,92,246,.14), transparent 60%), var(--bg);
}
.login form { width: min(380px, 100%); padding: 30px; display: flex; flex-direction: column; gap: 16px; animation: rise .4s var(--ease); }
.login h1 { margin: 0; font-size: 21px; letter-spacing: -.02em; }
.login .err { color: var(--red); font-size: 13px; min-height: 18px; margin: -6px 0 0; }

/* ============ Skeleton ============ */
.skeleton { background: linear-gradient(90deg, var(--surface-2) 0%, var(--surface-hover) 50%, var(--surface-2) 100%); background-size: 200% 100%; animation: shimmer 1.2s infinite; border-radius: 8px; }
@keyframes shimmer { to { background-position: -200% 0; } }

/* ============ Responsive ============ */
@media (max-width: 1180px) {
  .kpis { grid-template-columns: repeat(2, 1fr); }
  .grid-side { grid-template-columns: 1fr; }
}
@media (max-width: 920px) {
  .grid-2, .grid-3 { grid-template-columns: 1fr; }
  .sidebar { position: fixed; left: 0; transform: translateX(-100%); box-shadow: var(--shadow-lg); }
  .sidebar.open { transform: none; }
  .icon-btn.menu-btn { display: inline-grid; }
  .topbar { padding: 12px 16px; }
  .view { padding: 4px 16px 40px; }
  .hide-md { display: none; }
}
@media (max-width: 600px) {
  .kpis { grid-template-columns: 1fr 1fr; gap: 10px; }
  .kpi { padding: 14px; }
  .kpi-value { font-size: 24px; }
  .search-trigger kbd, .search-trigger span, .topbar .btn.primary span { display: none; }
  .search-trigger { flex: 0 0 auto; }
  .form-grid { grid-template-columns: 1fr; }
  .props { grid-template-columns: 1fr; }
  .prop:nth-child(odd) { border-right: 0; }
  .prop:nth-child(2) { border-top: 1px solid var(--border); }
  .bar-row { grid-template-columns: 100px 1fr 28px; }
  .hide-sm { display: none; }
  .page-head h1 { font-size: 22px; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; transition-duration: .01ms !important; }
}
