/* Ink Inventory — base styles */
@import url('https://fonts.googleapis.com/css2?family=IBM+Plex+Sans+Thai+Looped:wght@300;400;500;600;700&family=IBM+Plex+Mono:wght@400;500;600&display=swap');

:root {
  --bg: #eef4fa;
  --surface: #ffffff;
  --surface-2: #f4f8fc;
  --border: #dbe6f0;
  --border-strong: #c4d4e3;
  --text: #0f1d2e;
  --text-2: #4a5b6e;
  --text-3: #8294a8;
  --ink: #1a78c2;
  --ink-soft: #3d8fd1;
  --amber: #b25e09;
  --amber-bg: #fbf0dc;
  --green: #2d6a4f;
  --green-bg: #e3efe6;
  --red: #a63232;
  --red-bg: #f5dede;
  --blue: #1a78c2;
  --blue-bg: #dbecf7;
  --shadow-sm: 0 1px 2px rgba(20,17,15,0.04);
  --shadow-md: 0 4px 12px rgba(20,17,15,0.06), 0 1px 3px rgba(20,17,15,0.04);
  --shadow-lg: 0 18px 40px rgba(20,17,15,0.14);
  --radius: 10px;
  --radius-sm: 6px;
  --radius-lg: 14px;
  --density: 1;
}

[data-density="compact"] { --density: 0.85; }
[data-density="comfy"] { --density: 1.15; }

[data-theme="dark"] {
  --bg: #0d1620;
  --surface: #18222e;
  --surface-2: #1f2a37;
  --border: #2a3744;
  --border-strong: #3a4756;
  --text: #e9f1f9;
  --text-2: #9eb0c4;
  --text-3: #6c7d91;
  --ink: #5fb0e6;
  --ink-soft: #7cc2ed;
  --amber: #e1a14a;
  --amber-bg: #2c2316;
  --green: #7fbf95;
  --green-bg: #1a2820;
  --red: #d77777;
  --red-bg: #2c1a1a;
  --blue: #5fb0e6;
  --blue-bg: #1a2c3c;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font-family: 'IBM Plex Sans Thai Looped', 'IBM Plex Sans Thai', system-ui, sans-serif;
  background: var(--bg);
  color: var(--text);
  font-size: 14px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  font-feature-settings: "cv11";
}

.ico { width: 16px; height: 16px; flex-shrink: 0; }
.search svg, .search .ico { width: 16px; height: 16px; flex-shrink: 0; }
.btn .ico, .pill .ico, .tab .ico { width: 14px; height: 14px; flex-shrink: 0; }
.kpi-label .ico { width: 14px; height: 14px; }
.nav-item .ico { width: 18px; height: 18px; flex-shrink: 0; }

.mono { font-family: 'IBM Plex Mono', ui-monospace, monospace; font-feature-settings: "zero", "tnum"; }
.num { font-variant-numeric: tabular-nums; }

/* ====== App shell ====== */
.app {
  display: grid;
  grid-template-columns: 232px 1fr;
  min-height: 100vh;
}

.sidebar {
  background: var(--surface);
  border-right: 1px solid var(--border);
  padding: 20px 14px;
  display: flex;
  flex-direction: column;
  gap: 4px;
  position: sticky;
  top: 0;
  height: 100vh;
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 4px 8px 16px;
  border-bottom: 1px solid var(--border);
  margin-bottom: 12px;
}
.brand-logo {
  width: 32px; height: 32px;
  border-radius: 9px;
  display: grid;
  place-items: center;
  position: relative;
  overflow: hidden;
  box-shadow: 0 2px 6px color-mix(in oklab, var(--ink) 35%, transparent), 0 1px 0 rgba(255,255,255,0.15) inset;
}
.brand-logo svg { display: block; }
.brand-name {
  font-weight: 600;
  font-size: 14px;
  letter-spacing: -0.01em;
}
.brand-sub {
  font-size: 11px;
  color: var(--text-3);
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.nav-section {
  font-size: 10.5px;
  color: var(--text-3);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  padding: 14px 10px 6px;
  font-weight: 500;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 10px;
  border-radius: 8px;
  cursor: pointer;
  font-size: 13.5px;
  color: var(--text-2);
  user-select: none;
  border: none;
  background: transparent;
  width: 100%;
  text-align: left;
  font-family: inherit;
  transition: background 0.12s;
}
.nav-item:hover { background: var(--surface-2); color: var(--text); }
.nav-item.active {
  background: var(--bg);
  color: var(--text);
  font-weight: 500;
}
.nav-item .ico { width: 18px; height: 18px; flex-shrink: 0; color: var(--text-3); }
.nav-item.active .ico { color: var(--ink); }
.nav-item .badge {
  margin-left: auto;
  font-size: 11px;
  background: var(--amber-bg);
  color: var(--amber);
  padding: 1px 7px;
  border-radius: 999px;
  font-weight: 600;
}

.sidebar-foot {
  margin-top: auto;
  padding: 12px 8px;
  border-top: 1px solid var(--border);
  display: flex;
  align-items: center;
  gap: 10px;
}
.avatar {
  width: 30px; height: 30px;
  border-radius: 50%;
  background: var(--ink-soft);
  color: #ffffff;
  display: grid;
  place-items: center;
  font-size: 12px;
  font-weight: 600;
}
.user-name { font-size: 13px; font-weight: 500; }
.user-role { font-size: 11px; color: var(--text-3); }

/* ====== Main area ====== */
.main {
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.topbar {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 14px 28px;
  border-bottom: 1px solid var(--border);
  background: color-mix(in oklab, var(--bg) 78%, transparent);
  backdrop-filter: saturate(160%) blur(14px);
  -webkit-backdrop-filter: saturate(160%) blur(14px);
  position: sticky;
  top: 0;
  z-index: 10;
}
.page-title {
  font-size: 18px;
  font-weight: 600;
  letter-spacing: -0.01em;
  margin: 0;
}
.page-sub {
  font-size: 12px;
  color: var(--text-3);
  margin-top: 2px;
}
.topbar-spacer { flex: 1; }

/* Breadcrumb chip */
.crumbs {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 6px 12px 6px 10px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 999px;
  font-size: 13px;
  box-shadow: var(--shadow-sm);
}
.crumbs .crumb-dot {
  width: 6px; height: 6px;
  border-radius: 50%;
  background: var(--ink);
  box-shadow: 0 0 0 3px color-mix(in oklab, var(--ink) 18%, transparent);
}
.crumbs .crumb-sep { color: var(--text-3); font-size: 12px; }
.crumbs .crumb-root { color: var(--text-3); }
.crumbs .crumb-leaf { color: var(--text); font-weight: 600; }

/* Topbar utility group + divider */
.topbar-group {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}
.topbar-divider {
  width: 1px;
  height: 22px;
  background: var(--border);
  margin: 0 4px;
}

/* Modern notification button */
.notif-btn {
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 34px;
  height: 34px;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text-2);
  cursor: pointer;
  transition: all 0.15s ease;
}
.notif-btn:hover {
  background: var(--surface-2);
  color: var(--text);
  border-color: var(--border-strong);
}
.notif-btn .ico { width: 17px; height: 17px; }
.notif-badge {
  position: absolute;
  top: -5px;
  right: -5px;
  min-width: 17px;
  height: 17px;
  padding: 0 4px;
  border-radius: 999px;
  background: var(--red);
  color: #fff;
  font-size: 10px;
  font-weight: 700;
  font-family: 'IBM Plex Mono', monospace;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 2px solid var(--bg);
  letter-spacing: -0.02em;
}
.notif-badge.is-dot {
  min-width: 9px; width: 9px; height: 9px;
  padding: 0;
  top: -2px; right: -2px;
}

/* Notification popover */
.notif-wrap { position: relative; display: inline-flex; }
.notif-btn.is-open {
  background: var(--surface-2);
  color: var(--text);
  border-color: var(--border-strong);
}
.notif-scrim {
  position: fixed;
  inset: 0;
  z-index: 40;
}
.notif-pop {
  position: absolute;
  top: calc(100% + 10px);
  right: 0;
  z-index: 50;
  width: 360px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 14px;
  box-shadow: 0 18px 40px rgba(20,17,15,0.14), 0 2px 6px rgba(20,17,15,0.06);
  overflow: hidden;
  animation: notif-in 0.16s ease;
}
@keyframes notif-in {
  from { opacity: 0; transform: translateY(-6px); }
  to { opacity: 1; transform: translateY(0); }
}
.notif-pop-head {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 14px;
  border-bottom: 1px solid var(--border);
  background: var(--surface-2);
}
.notif-pop-title { font-weight: 600; font-size: 14px; }
.notif-pop-sub { font-size: 11.5px; color: var(--text-3); margin-top: 2px; }
.notif-pop-list { max-height: 360px; overflow-y: auto; }
.notif-item {
  all: unset;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 14px;
  cursor: pointer;
  border-bottom: 1px solid var(--border);
  font-family: inherit;
  transition: background 0.12s;
  width: 100%;
  box-sizing: border-box;
}
.notif-item:last-child { border-bottom: none; }
.notif-item:hover { background: var(--surface-2); }
.notif-dot {
  width: 8px; height: 8px;
  border-radius: 50%;
  flex-shrink: 0;
}
.notif-dot.is-low { background: var(--amber); box-shadow: 0 0 0 3px color-mix(in oklab, var(--amber) 22%, transparent); }
.notif-dot.is-out { background: var(--red); box-shadow: 0 0 0 3px color-mix(in oklab, var(--red) 22%, transparent); }
.notif-item-body { flex: 1; min-width: 0; }
.notif-item-title { font-size: 13px; font-weight: 500; color: var(--text); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.notif-item-sub { font-size: 11.5px; color: var(--text-3); margin-top: 2px; }
.notif-empty {
  padding: 28px 14px;
  text-align: center;
  color: var(--text-3);
  font-size: 13px;
}

.search {
  display: flex;
  align-items: center;
  gap: 8px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 6px 10px;
  width: 240px;
  color: var(--text-3);
}
.search input {
  border: none;
  background: transparent;
  outline: none;
  flex: 1;
  font-family: inherit;
  font-size: 13px;
  color: var(--text);
}

/* ====== Select / Input ====== */
.input, select {
  display: inline-flex;
  align-items: center;
  padding: 7px 10px;
  border-radius: 8px;
  font-family: inherit;
  font-size: 13px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  cursor: pointer;
  transition: all 0.15s ease;
}
.input:hover, select:hover {
  border-color: var(--border-strong);
}
.input:focus, select:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(26, 120, 194, 0.1);
}
select {
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg width='12' height='8' viewBox='0 0 12 8' fill='none' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath d='M1 1.5L6 6.5L11 1.5' stroke='%23666' stroke-width='1.5' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 8px center;
  padding-right: 28px;
}

.select-mono {
  font-family: 'IBM Plex Mono', ui-monospace, 'SF Mono', 'Menlo', monospace;
  font-feature-settings: "zero", "tnum";
  font-size: 13px;
  letter-spacing: 0;
}
.select-mono option {
  font-family: 'IBM Plex Mono', ui-monospace, 'SF Mono', 'Menlo', monospace;
  font-size: 13px;
  padding: 6px 8px;
}

/* ===== Custom Product Picker ===== */
.pp-wrap {
  position: relative;
  width: 100%;
}
.pp-trigger {
  all: unset;
  position: relative;
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  padding: 7px 32px 7px 10px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  cursor: pointer;
  font-family: inherit;
  font-size: 13px;
  box-sizing: border-box;
  min-height: 36px;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}
.pp-trigger:hover { border-color: var(--border-strong); }
.pp-wrap.is-open .pp-trigger {
  border-color: var(--ink);
  box-shadow: 0 0 0 3px color-mix(in oklab, var(--ink) 14%, transparent);
}
.pp-caret {
  position: absolute;
  right: 10px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--text-3);
  display: inline-flex;
  align-items: center;
  transition: transform 0.15s ease;
}
.pp-wrap.is-open .pp-caret { transform: translateY(-50%) rotate(180deg); }

.pp-listbox {
  position: absolute;
  z-index: 50;
  top: calc(100% + 6px);
  left: 0;
  right: 0;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  box-shadow: 0 18px 40px rgba(20,17,15,0.14), 0 2px 6px rgba(20,17,15,0.06);
  padding: 0;
  max-height: 320px;
  overflow-y: auto;
  animation: pp-in 0.14s ease forwards;
}
@keyframes pp-in {
  from { opacity: 0; transform: translateY(-4px); }
  to { opacity: 1; transform: translateY(0); }
}
.pp-option {
  all: unset;
  display: block;
  width: 100%;
  padding: 7px 32px 7px 10px;
  border-radius: 0;
  cursor: pointer;
  font-family: inherit;
  box-sizing: border-box;
  transition: background 0.1s ease;
  border-bottom: 1px solid var(--border);
}
.pp-option:last-child { border-bottom: none; }
.pp-option:hover { background: var(--surface-2); }
.pp-option.is-selected { background: color-mix(in oklab, var(--ink) 12%, transparent); }
.pp-option.is-selected .pp-col-sku,
.pp-option.is-selected .pp-col-name,
.pp-option.is-selected .pp-stock-num { color: var(--ink); }

.pp-row {
  display: grid;
  grid-template-columns: var(--pp-sku-w, 8ch) auto 1fr auto var(--pp-stock-w, max-content);
  align-items: center;
  gap: 12px;
  font-family: 'IBM Plex Mono', ui-monospace, 'SF Mono', 'Menlo', monospace;
  font-size: 13px;
  font-feature-settings: "zero", "tnum";
}
.pp-col-sku {
  font-weight: 600;
  color: var(--text);
  white-space: nowrap;
}
.pp-col-name {
  text-align: center;
  font-family: 'IBM Plex Sans Thai Looped', system-ui, sans-serif;
  font-weight: 500;
  color: var(--text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.pp-sep { color: var(--border-strong); user-select: none; }
.pp-col-stock {
  display: inline-flex;
  align-items: baseline;
  gap: 4px;
  white-space: nowrap;
  font-family: 'IBM Plex Sans Thai Looped', system-ui, sans-serif;
  color: var(--text-2);
  font-size: 13px;
}
.pp-stock-label { color: var(--text-3); }
.pp-stock-num {
  font-weight: 600;
  color: var(--text);
  font-variant-numeric: tabular-nums;
  min-width: 2.5ch;
  text-align: right;
}
.pp-stock-unit { color: var(--text-3); }
.pp-empty {
  padding: 18px;
  text-align: center;
  color: var(--text-3);
  font-size: 13px;
}

.kbd {
  font-family: 'IBM Plex Mono', monospace;
  font-size: 10.5px;
  background: var(--bg);
  border: 1px solid var(--border);
  padding: 1px 5px;
  border-radius: 4px;
  color: var(--text-3);
}

.content { padding: 24px 28px 80px; }

/* ====== Buttons ====== */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 8px 14px;
  border-radius: 10px;
  font-family: inherit;
  font-size: 13px;
  font-weight: 500;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  cursor: pointer;
  transition: transform 0.12s ease, background 0.15s ease, border-color 0.15s ease, box-shadow 0.15s ease;
  white-space: nowrap;
  box-shadow: var(--shadow-sm);
}
.btn:hover { background: var(--surface-2); border-color: var(--border-strong); }
.btn:active { transform: translateY(1px); }
.btn-primary {
  background: linear-gradient(180deg, var(--ink-soft) 0%, var(--ink) 100%);
  color: #ffffff;
  border-color: color-mix(in oklab, var(--ink) 70%, #000 0%);
  box-shadow: 0 1px 0 rgba(255,255,255,0.18) inset, 0 1px 2px rgba(20,17,15,0.18), 0 4px 10px color-mix(in oklab, var(--ink) 22%, transparent);
}
.btn-primary:hover { background: linear-gradient(180deg, var(--ink-soft) 0%, var(--ink-soft) 100%); border-color: var(--ink-soft); }
.btn-ghost { background: transparent; border-color: transparent; color: var(--text-2); box-shadow: none; }
.btn-ghost:hover { background: var(--surface-2); }
.btn-sm { padding: 4px 9px; font-size: 12px; box-shadow: none; }
.btn-icon { padding: 6px; width: 30px; height: 30px; justify-content: center; }

/* ====== Cards ====== */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
}
.card-pad { padding: 18px; }
.card-head {
  padding: 14px 18px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  gap: 12px;
}
.card-title {
  font-size: 13.5px;
  font-weight: 600;
  margin: 0;
  letter-spacing: -0.005em;
}
.card-sub { font-size: 12px; color: var(--text-3); }

/* ====== KPI cards ====== */
.kpi-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 14px;
  margin-bottom: 18px;
}
.kpi {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px 18px;
  position: relative;
  overflow: hidden;
}
.kpi-label {
  font-size: 12px;
  color: var(--text-3);
  display: flex;
  align-items: center;
  gap: 6px;
  margin-bottom: 10px;
  font-weight: 500;
}
.kpi-label .ico { width: 14px; height: 14px; }
.kpi-value {
  font-family: 'IBM Plex Sans Thai Looped', sans-serif;
  font-size: 28px;
  font-weight: 600;
  letter-spacing: -0.02em;
  line-height: 1;
  font-variant-numeric: tabular-nums;
}
.kpi-unit { font-size: 14px; color: var(--text-3); margin-left: 4px; font-weight: 400; }
.kpi-foot {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 11.5px;
  color: var(--text-3);
  margin-top: 10px;
}
.delta-up { color: var(--green); font-weight: 600; }
.delta-down { color: var(--red); font-weight: 600; }
.delta-warn { color: var(--amber); font-weight: 600; }

/* ====== Grid layouts ====== */
.grid-2 { display: grid; grid-template-columns: 1.6fr 1fr; gap: 14px; }
.grid-2-eq { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.grid-3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 14px; }
.row-gap { display: flex; flex-direction: column; gap: 14px; }

/* ====== Tables ====== */
table.tbl {
  width: 100%;
  border-collapse: separate;
  border-spacing: 0;
  font-size: 13px;
}
.tbl th {
  text-align: left;
  font-weight: 500;
  color: var(--text-3);
  font-size: 11.5px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  padding: 10px 14px;
  border-bottom: 1px solid var(--border);
  background: var(--surface-2);
}
.tbl td {
  padding: 11px 14px;
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
}
.tbl tr:last-child td { border-bottom: none; }
.tbl tr:hover td { background: var(--surface-2); }
.tbl .num { text-align: right; }

/* Sortable headers */
.tbl-sortable th:has(.th-sort) { padding: 0; }
.th-sort {
  all: unset;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  width: 100%;
  padding: 10px 14px;
  cursor: pointer;
  color: var(--text-3);
  font-size: 11.5px;
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  font-family: inherit;
  transition: color 0.12s ease, background 0.12s ease;
  box-sizing: border-box;
  user-select: none;
}
.th-sort.th-right { justify-content: flex-end; }
.th-sort:hover { color: var(--text); background: color-mix(in oklab, var(--ink) 6%, transparent); }
.th-sort.active { color: var(--ink); }
.th-sort-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

/* ====== Pills & badges ====== */
.pill {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 11.5px;
  padding: 2px 8px;
  border-radius: 999px;
  font-weight: 500;
  background: var(--bg);
  color: var(--text-2);
  border: 1px solid var(--border);
}
.pill-amber { background: var(--amber-bg); color: var(--amber); border-color: transparent; }
.pill-green { background: var(--green-bg); color: var(--green); border-color: transparent; }
.pill-red { background: var(--red-bg); color: var(--red); border-color: transparent; }
.pill-blue { background: var(--blue-bg); color: var(--blue); border-color: transparent; }
.pill-ink { background: var(--ink); color: #ffffff; border-color: var(--ink); }

.dot { width: 6px; height: 6px; border-radius: 50%; display: inline-block; }

/* ====== Chart ====== */
.chart-wrap { position: relative; }
.chart-bar-group { transition: opacity 0.15s; }
.chart-bar-group:hover { opacity: 1; }
.chart-bar-buy { fill: var(--ink); }
.chart-bar-use { fill: var(--amber); }
.chart-axis-text { font-size: 11px; fill: var(--text-3); font-family: 'IBM Plex Mono', monospace; }
.chart-grid { stroke: var(--border); stroke-dasharray: 2 3; }

/* ====== Stock bar ====== */
.stock-bar {
  height: 6px;
  background: var(--bg);
  border-radius: 999px;
  overflow: hidden;
  position: relative;
}
.stock-bar-fill {
  height: 100%;
  background: var(--ink);
  border-radius: 999px;
  transition: width 0.3s ease;
}
.stock-bar-fill.low { background: var(--amber); }
.stock-bar-fill.crit { background: var(--red); }

/* ====== Modal ====== */
.modal-back {
  position: fixed; inset: 0;
  background: rgba(20,17,15,0.4);
  z-index: 2147483647;
  display: grid;
  place-items: center;
  animation: fadeIn 0.15s;
}
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }
.modal {
  background: var(--surface);
  border-radius: 14px;
  width: 520px;
  max-width: 92vw;
  max-height: 86vh;
  overflow: auto;
  box-shadow: var(--shadow-lg);
  border: 1px solid var(--border);
  animation: slideUp 0.2s;
}
@keyframes slideUp { from { transform: translateY(8px); opacity: 0; } to { transform: translateY(0); opacity: 1; } }
.modal-head {
  padding: 18px 22px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
}
.modal-head h3 { margin: 0; font-size: 15px; font-weight: 600; }
.modal-body { padding: 20px 22px; }
.modal-foot {
  padding: 14px 22px;
  border-top: 1px solid var(--border);
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  background: var(--surface-2);
  border-radius: 0 0 14px 14px;
}

/* ====== Forms ====== */
.field { display: flex; flex-direction: column; gap: 6px; margin-bottom: 14px; }
.field label {
  font-size: 12px;
  color: var(--text-2);
  font-weight: 500;
}
.field input, .field select, .field textarea {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 7px;
  padding: 8px 10px;
  font-size: 13.5px;
  font-family: inherit;
  color: var(--text);
  outline: none;
  transition: border-color 0.12s, box-shadow 0.12s;
}
.field input:focus, .field select:focus, .field textarea:focus {
  border-color: var(--ink);
  box-shadow: 0 0 0 3px rgba(26,37,64,0.08);
}
.field-row { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.field-hint { font-size: 11px; color: var(--text-3); }

/* ====== Toast ====== */
.toasts {
  position: fixed;
  bottom: 22px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 2147483647;
  display: flex;
  flex-direction: column;
  gap: 8px;
  pointer-events: none;
}
.toast {
  background: var(--ink);
  color: #ffffff;
  padding: 10px 16px;
  border-radius: 8px;
  font-size: 13px;
  box-shadow: var(--shadow-lg);
  animation: toastIn 0.2s;
  pointer-events: auto;
}
@keyframes toastIn { from { transform: translateY(8px); opacity: 0; } to { transform: translateY(0); opacity: 1; } }

/* ====== Tabs ====== */
.tabs {
  display: flex;
  gap: 2px;
  border-bottom: 1px solid var(--border);
  margin-bottom: 16px;
}
.tab {
  background: none;
  border: none;
  padding: 9px 14px;
  font-family: inherit;
  font-size: 13px;
  color: var(--text-3);
  cursor: pointer;
  border-bottom: 2px solid transparent;
  margin-bottom: -1px;
  font-weight: 500;
}
.tab:hover { color: var(--text); }
.tab.active { color: var(--text); border-bottom-color: var(--ink); }
.tab .count {
  background: var(--bg);
  font-size: 11px;
  padding: 0 6px;
  border-radius: 999px;
  margin-left: 5px;
  color: var(--text-3);
  font-weight: 500;
}

/* ====== Department bar ====== */
.dept-row {
  display: grid;
  grid-template-columns: 90px 1fr 60px;
  gap: 10px;
  align-items: center;
  font-size: 12.5px;
  padding: 5px 0;
}
.dept-bar-bg {
  height: 8px;
  background: var(--bg);
  border-radius: 999px;
  overflow: hidden;
}
.dept-bar-fill {
  height: 100%;
  background: var(--ink);
  border-radius: 999px;
  transition: width 0.4s ease;
}

/* ====== Greeting / hero ====== */
.hero {
  display: flex;
  align-items: flex-start;
  gap: 16px;
  margin-bottom: 18px;
}
.hero h2 {
  margin: 0;
  font-size: 26px;
  font-weight: 600;
  letter-spacing: -0.02em;
}
.hero .sub {
  margin-top: 4px;
  font-size: 13px;
  color: var(--text-2);
  display: flex;
  align-items: center;
  gap: 8px;
}
.hero .live-dot {
  width: 7px; height: 7px;
  border-radius: 50%;
  background: #2db84d;
  box-shadow: 0 0 0 3px rgba(45,184,77,0.18);
  animation: pulse 2s infinite;
}
@keyframes pulse {
  0%, 100% { box-shadow: 0 0 0 3px rgba(45,184,77,0.18); }
  50% { box-shadow: 0 0 0 5px rgba(45,184,77,0.06); }
}
.hero-actions { margin-left: auto; display: flex; gap: 8px; }

/* ====== Colorful KPI ====== */
.kpi-color {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px;
  position: relative;
  overflow: hidden;
  cursor: pointer;
  transition: all 0.15s ease;
}
.kpi-color:hover {
  border-color: var(--border-strong);
  transform: translateY(-1px);
  box-shadow: 0 2px 8px rgba(0,0,0,0.06);
}
.kpi-chip {
  width: 42px; height: 42px;
  border-radius: 11px;
  display: grid;
  place-items: center;
  color: #fff;
  margin-bottom: 14px;
  box-shadow: 0 4px 12px rgba(0,0,0,0.08);
}
.kpi-chip svg { width: 20px; height: 20px; }
.kpi-chip.blue   { background: linear-gradient(135deg, #4a9ee0, #1a78c2); }
.kpi-chip.green  { background: linear-gradient(135deg, #5ec787, #2d9d5b); }
.kpi-chip.purple { background: linear-gradient(135deg, #a78bdc, #7a5fbf); }
.kpi-chip.orange { background: linear-gradient(135deg, #f0a967, #d97a1f); }
.kpi-chip.rose   { background: linear-gradient(135deg, #e88aa0, #c4566f); }
.kpi-color .kpi-label {
  font-size: 12.5px;
  color: var(--text-2);
  margin-bottom: 6px;
  font-weight: 500;
}
.kpi-color .kpi-value {
  font-size: 28px;
  font-weight: 600;
  letter-spacing: -0.02em;
  line-height: 1.1;
  font-variant-numeric: tabular-nums;
}
.kpi-color .kpi-foot {
  margin-top: 10px;
  font-size: 11.5px;
  color: var(--text-2);
  display: flex;
  align-items: center;
  gap: 4px;
}
.kpi-spark {
  position: absolute;
  right: 8px;
  bottom: 8px;
  opacity: 0.42;
  pointer-events: none;
}
.delta-up   { color: #2d9d5b; font-weight: 600; }
.delta-down { color: #c4566f; font-weight: 600; }
.delta-warn { color: #d97a1f; font-weight: 600; }

/* ====== See-all link ====== */
.see-all {
  font-size: 12.5px;
  color: var(--ink);
  font-weight: 500;
  text-decoration: none;
  background: none;
  border: none;
  cursor: pointer;
  padding: 4px 8px;
  border-radius: 6px;
  font-family: inherit;
  display: inline-flex;
  align-items: center;
  gap: 4px;
}
.see-all:hover { background: var(--blue-bg); }

/* ====== Empty state ====== */
.empty {
  text-align: center;
  padding: 40px 20px;
  color: var(--text-3);
  font-size: 13px;
}

/* ====== Misc ====== */
.divider { height: 1px; background: var(--border); margin: 12px 0; }
.flex { display: flex; align-items: center; gap: 10px; }

/* ====== Login Screen ====== */
.login-bg {
  position: fixed;
  inset: 0;
  background: linear-gradient(135deg, #1a78c2 0%, #0c5fb3 50%, #1c6fa8 100%);
  display: grid;
  place-items: center;
  padding: 24px;
}
.login-bg::before {
  content: '';
  position: absolute;
  inset: 0;
  background-image:
    radial-gradient(circle at 20% 30%, rgba(255,255,255,0.08) 0, transparent 40%),
    radial-gradient(circle at 80% 70%, rgba(255,255,255,0.06) 0, transparent 40%);
  pointer-events: none;
}
.login-card {
  background: var(--surface);
  border-radius: 20px;
  padding: 36px 36px 28px;
  width: 100%;
  max-width: 420px;
  box-shadow: 0 24px 64px rgba(0,0,0,0.25);
  position: relative;
  z-index: 1;
}
.login-brand {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 32px;
}
.login-name {
  font-size: 18px;
  font-weight: 600;
  letter-spacing: -0.01em;
}
.login-sub {
  font-size: 12px;
  color: var(--text-3);
  letter-spacing: 0.04em;
}
.login-title {
  font-size: 22px;
  font-weight: 600;
  margin: 0 0 6px;
  letter-spacing: -0.02em;
}
.login-hint {
  font-size: 13px;
  color: var(--text-2);
  margin-bottom: 24px;
}
.login-field { margin-bottom: 20px; }
.login-field label {
  display: block;
  font-size: 12px;
  font-weight: 500;
  color: var(--text-2);
  margin-bottom: 8px;
}
.login-input-wrap { position: relative; }
.login-input-wrap input {
  width: 100%;
  padding: 12px 44px 12px 14px;
  font-size: 14px;
  border: 1.5px solid var(--border);
  border-radius: 10px;
  background: var(--surface);
  color: var(--text);
  outline: none;
  transition: all 0.15s;
  font-family: 'IBM Plex Mono', monospace;
  letter-spacing: 0.02em;
}
.login-input-wrap input:focus {
  border-color: #1a78c2;
  box-shadow: 0 0 0 3px rgba(26,120,194,0.12);
}
.login-eye {
  position: absolute;
  right: 8px;
  top: 50%;
  transform: translateY(-50%);
  background: none;
  border: none;
  cursor: pointer;
  padding: 4px 8px;
  font-size: 14px;
  color: var(--text-3);
}
.login-error {
  color: var(--red);
  font-size: 12px;
  margin-top: 6px;
}
.login-btn {
  width: 100%;
  padding: 12px;
  font-size: 14px;
  font-weight: 600;
  justify-content: center;
  border-radius: 10px;
}
.login-foot {
  text-align: center;
  margin-top: 18px;
  font-size: 11.5px;
  color: var(--text-3);
}
@keyframes shake {
  0%, 100% { transform: translateX(0); }
  25% { transform: translateX(-6px); }
  75% { transform: translateX(6px); }
}
.user-key-info {
  font-size: 10.5px;
  color: var(--text-3);
}
/* Logout button */
.logout-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: var(--bg);
  border: 1px solid var(--border);
  color: var(--text-2);
  cursor: pointer;
  padding: 0;
  width: 32px;
  height: 32px;
  border-radius: 8px;
  font-size: 0;
  transition: all 0.18s ease;
  position: relative;
  overflow: hidden;
  flex-shrink: 0;
}
.logout-btn svg {
  width: 16px;
  height: 16px;
  transition: transform 0.18s ease;
}
.logout-btn:hover {
  background: var(--red-bg);
  border-color: var(--red);
  color: var(--red);
}
.logout-btn:hover svg {
  transform: translateX(2px);
}
.logout-btn:active {
  transform: scale(0.95);
}
.flex-between { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.gap-4 { gap: 4px; }
.gap-6 { gap: 6px; }
.gap-8 { gap: 8px; }
.gap-12 { gap: 12px; }
.muted { color: var(--text-3); }
.text-sm { font-size: 12px; }
.text-xs { font-size: 11px; }
.fw-500 { font-weight: 500; }
.fw-600 { font-weight: 600; }

/* Tweaks panel position override is in starter */
