/* ============================================================
   STOCKWISE — Design System
   Pure CSS3 · No frameworks · Themeable via CSS variables
   ============================================================ */
:root {
  --bg: #f5f6f8; /* app background          */
  --surface: #ffffff; /* cards, tables           */
  --surface-2: #f9fafb; /* inset areas             */
  --ink: #182230; /* primary text            */
  --ink-2: #475467; /* secondary text          */
  --muted: #667085; /* tertiary text           */
  --faint: #98a2b3; /* placeholders, captions  */
  --line: #e8ebf0; /* borders                 */
  --line-2: #eff1f4; /* hairlines               */

  --accent: #0e9f80;
  --accent-strong: #0b8568;
  --accent-soft: #e3f5ef;
  --accent-ink: #0a7a5f;
  --accent-ring: rgba(14, 159, 128, 0.16);

  --green: #12b76a;
  --green-soft: #e7f8f0;
  --amber: #f79009;
  --amber-soft: #fef3e2;
  --red: #f04438;
  --red-soft: #feecea;
  --blue: #2e90fa;
  --blue-soft: #eaf3fe;
  --violet: #7a5af8;
  --violet-soft: #f0edfe;

  --r-sm: 8px;
  --r-md: 12px;
  --r-lg: 16px;
  --r-xl: 20px;
  --sh-sm: 0 1px 2px rgba(16, 24, 40, 0.05);
  --sh-md:
    0 1px 2px rgba(16, 24, 40, 0.04), 0 8px 24px -12px rgba(16, 24, 40, 0.12);
  --sh-lg: 0 12px 32px -8px rgba(16, 24, 40, 0.18);
  --font: "Inter", system-ui, -apple-system, "Segoe UI", sans-serif;
  --ease: cubic-bezier(0.4, 0, 0.2, 1);
  --topbar-h: 68px;
  --side-w: 266px;
  --side-w-min: 80px;
}
[data-theme="dark"] {
  --bg: #0b1017;
  --surface: #121926;
  --surface-2: #171f2c;
  --ink: #ecf0f5;
  --ink-2: #c5cdd9;
  --muted: #96a2b2;
  --faint: #7a8798;
  --line: #222d3c;
  --line-2: #1b2532;
  --accent-soft: rgba(14, 159, 128, 0.14);
  --accent-ink: #3bd6b2;
  --accent-ring: rgba(14, 159, 128, 0.28);
  --green-soft: rgba(18, 183, 106, 0.13);
  --amber-soft: rgba(247, 144, 9, 0.14);
  --red-soft: rgba(240, 68, 56, 0.13);
  --blue-soft: rgba(46, 144, 250, 0.14);
  --violet-soft: rgba(122, 90, 248, 0.15);
  --sh-sm: 0 1px 2px rgba(0, 0, 0, 0.3);
  --sh-md: 0 8px 24px -12px rgba(0, 0, 0, 0.5);
  --sh-lg: 0 16px 40px -8px rgba(0, 0, 0, 0.6);
}
html {
  scroll-behavior: smooth;
}
body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--font);
  font-size: 14px;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
}
h1,
h2,
h3,
h4,
h5,
p,
figure {
  margin: 0;
}
ul,
ol {
  margin: 0;
  padding: 0;
  list-style: none;
}
a {
  color: inherit;
  text-decoration: none;
}
button {
  font-family: inherit;
}
img {
  display: block;
  max-width: 100%;
}
::selection {
  background: var(--accent);
  color: #fff;
}
::-webkit-scrollbar {
  width: 10px;
  height: 10px;
}
::-webkit-scrollbar-thumb {
  background: #cbd2db;
  border-radius: 8px;
  border: 3px solid var(--bg);
}
[data-theme="dark"] ::-webkit-scrollbar-thumb {
  background: #2a3646;
}
.i {
  width: 20px;
  height: 20px;
  stroke-width: 1.9;
  flex: none;
}

/* ---------- Brand ---------- */
.brand {
  display: flex;
  align-items: center;
  gap: 11px;
}
.brand-mark {
  width: 38px;
  height: 38px;
  border-radius: 11px;
  background: linear-gradient(135deg, var(--accent), var(--accent-strong));
  display: grid;
  place-items: center;
  color: #fff;
  box-shadow: 0 4px 10px -2px var(--accent-ring);
  flex: none;
}
.brand-mark .i {
  width: 20px;
  height: 20px;
}
.brand-name {
  font-size: 15.5px;
  font-weight: 800;
  letter-spacing: 0.04em;
  line-height: 1.15;
}
.brand-sub {
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.14em;
  color: var(--faint);
  text-transform: uppercase;
}

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 0 16px;
  height: 40px;
  border-radius: 10px;
  border: 1px solid transparent;
  font-size: 13.5px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.16s var(--ease);
  white-space: nowrap;
  color: var(--ink);
  background: transparent;
}
.btn .i {
  width: 17px;
  height: 17px;
}
.btn:active {
  transform: translateY(1px);
}
.btn.sm {
  height: 34px;
  padding: 0 12px;
  font-size: 12.5px;
  border-radius: 9px;
}
.btn.sm .i {
  width: 15px;
  height: 15px;
}
.btn.pri {
  background: var(--accent);
  color: #fff;
  box-shadow:
    0 1px 2px rgba(16, 24, 40, 0.1),
    inset 0 1px 0 rgba(255, 255, 255, 0.16);
}
.btn.pri:hover {
  background: var(--accent-strong);
}
.btn.soft {
  background: var(--accent-soft);
  color: var(--accent-ink);
}
.btn.soft:hover {
  filter: brightness(0.97);
}
.btn.ghost {
  border-color: var(--line);
  background: var(--surface);
  color: var(--ink-2);
}
.btn.ghost:hover {
  border-color: #cfd5dd;
  color: var(--ink);
}
[data-theme="dark"] .btn.ghost:hover {
  border-color: #33415a;
}
.btn.danger {
  background: var(--red);
  color: #fff;
}
.btn.danger:hover {
  background: #d92d20;
}
.btn.danger-soft {
  background: var(--red-soft);
  color: var(--red);
}
.btn.block {
  width: 100%;
}
.btn:disabled {
  opacity: 0.55;
  cursor: not-allowed;
  transform: none;
}
.icon-btn {
  width: 40px;
  height: 40px;
  border-radius: 10px;
  border: 1px solid var(--line);
  background: var(--surface);
  color: var(--muted);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all 0.16s var(--ease);
  position: relative;
  flex: none;
}
.icon-btn:hover {
  color: var(--ink);
  border-color: #cfd5dd;
}
[data-theme="dark"] .icon-btn:hover {
  border-color: #33415a;
}
.icon-btn .dot {
  position: absolute;
  top: 9px;
  right: 10px;
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--red);
  border: 2px solid var(--surface);
}
.act-btn {
  width: 30px;
  height: 30px;
  border-radius: 8px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 1px solid transparent;
  background: transparent;
  color: var(--faint);
  cursor: pointer;
  transition: all 0.15s;
}
.act-btn:hover {
  background: var(--surface-2);
  color: var(--ink-2);
  border-color: var(--line);
}
.act-btn.danger:hover {
  background: var(--red-soft);
  color: var(--red);
  border-color: transparent;
}
.act-btn .i {
  width: 16px;
  height: 16px;
}

/* ---------- Forms ---------- */
.field {
  margin-bottom: 16px;
}
.label {
  display: block;
  font-size: 12.5px;
  font-weight: 600;
  color: var(--ink-2);
  margin-bottom: 6px;
}
.label .req {
  color: var(--red);
}
.input,
.select,
.textarea {
  width: 100%;
  height: 40px;
  padding: 0 13px;
  border-radius: 10px;
  border: 1px solid var(--line);
  background: var(--surface);
  color: var(--ink);
  font-family: inherit;
  font-size: 13.5px;
  transition:
    border-color 0.15s,
    box-shadow 0.15s;
  outline: none;
  box-sizing: border-box;
}
.textarea {
  height: auto;
  min-height: 96px;
  padding: 10px 13px;
  resize: vertical;
  line-height: 1.5;
}
.input::placeholder,
.textarea::placeholder {
  color: var(--faint);
}
.input:focus,
.select:focus,
.textarea:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3.5px var(--accent-ring);
}
.select {
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='14' height='14' viewBox='0 0 24 24' fill='none' stroke='%2398A2B3' stroke-width='2.4' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 12px center;
  padding-right: 34px;
  cursor: pointer;
}
.input-wrap {
  position: relative;
}
.input-wrap .i {
  position: absolute;
  left: 12px;
  top: 50%;
  transform: translateY(-50%);
  width: 17px;
  height: 17px;
  color: var(--faint);
  pointer-events: none;
}
.input-wrap .input {
  padding-left: 38px;
}
.input-wrap .trail {
  position: absolute;
  right: 8px;
  top: 50%;
  transform: translateY(-50%);
  pointer-events: auto;
  background: none;
  border: none;
  color: var(--faint);
  cursor: pointer;
  display: flex;
  padding: 6px;
  border-radius: 7px;
}
.input-wrap .trail:hover {
  color: var(--ink-2);
  background: var(--surface-2);
}
.err-msg {
  display: none;
  font-size: 12px;
  color: var(--red);
  margin-top: 5px;
  font-weight: 500;
}
.field.invalid .input,
.field.invalid .select,
.field.invalid .textarea {
  border-color: var(--red);
}
.field.invalid .err-msg {
  display: flex;
  align-items: center;
  gap: 5px;
}
.hint {
  font-size: 12px;
  color: var(--faint);
  margin-top: 5px;
}
.form-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0 16px;
}
.checkbox {
  display: flex;
  align-items: center;
  gap: 9px;
  font-size: 13px;
  color: var(--ink-2);
  cursor: pointer;
  user-select: none;
}
.checkbox input {
  width: 16px;
  height: 16px;
  accent-color: var(--accent);
  cursor: pointer;
}
/* switch */
.switch {
  position: relative;
  width: 40px;
  height: 22px;
  flex: none;
  cursor: pointer;
}
.switch input {
  opacity: 0;
  width: 0;
  height: 0;
}
.switch .track {
  position: absolute;
  inset: 0;
  background: #d5dae1;
  border-radius: 99px;
  transition: 0.2s;
}
[data-theme="dark"] .switch .track {
  background: #2a3646;
}
.switch .track:before {
  content: "";
  position: absolute;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: #fff;
  top: 3px;
  left: 3px;
  transition: 0.2s;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.25);
}
.switch input:checked + .track {
  background: var(--accent);
}
.switch input:checked + .track:before {
  transform: translateX(18px);
}
.switch-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  padding: 13px 0;
  border-bottom: 1px solid var(--line-2);
}
.switch-row:last-child {
  border-bottom: none;
  padding-bottom: 2px;
}
.switch-row .t1 {
  font-size: 13.5px;
  font-weight: 600;
}
.switch-row .t2 {
  font-size: 12.5px;
  color: var(--muted);
  margin-top: 2px;
}

/* ---------- Pills / badges ---------- */
.pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  height: 24px;
  padding: 0 10px;
  border-radius: 99px;
  font-size: 11.5px;
  font-weight: 600;
  letter-spacing: 0.01em;
  white-space: nowrap;
}
.pill .dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: currentColor;
}
.pill.green {
  background: var(--green-soft);
  color: #0e9b5e;
}
.pill.amber {
  background: var(--amber-soft);
  color: #c77408;
}
.pill.red {
  background: var(--red-soft);
  color: #d92d20;
}
.pill.blue {
  background: var(--blue-soft);
  color: #1570cd;
}
.pill.gray {
  background: var(--surface-2);
  color: var(--muted);
  border: 1px solid var(--line-2);
}
.pill.violet {
  background: var(--violet-soft);
  color: #6941c6;
}
[data-theme="dark"] .pill.green {
  color: #3bd68b;
}
[data-theme="dark"] .pill.amber {
  color: #f5a93b;
}
[data-theme="dark"] .pill.red {
  color: #f97066;
}
[data-theme="dark"] .pill.blue {
  color: #62a9f7;
}
[data-theme="dark"] .pill.violet {
  color: #9b8afb;
}
[data-theme="dark"] .pill.gray {
  border-color: var(--line);
}

/* ---------- Layout shell ---------- */
.app {
  display: flex;
  min-height: 100vh;
}
.sidebar {
  width: var(--side-w);
  background: var(--surface);
  border-right: 1px solid var(--line);
  position: fixed;
  top: 0;
  bottom: 0;
  left: 0;
  z-index: 60;
  display: flex;
  flex-direction: column;
  transition:
    width 0.25s var(--ease),
    transform 0.25s var(--ease);
}
.side-head {
  padding: 18px 20px 14px;
  border-bottom: 1px solid var(--line-2);
}
.side-nav {
  flex: 1;
  overflow-y: auto;
  padding: 14px 14px 10px;
}
.side-nav::-webkit-scrollbar {
  width: 4px;
}
.side-cap {
  font-size: 10.5px;
  font-weight: 700;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--faint);
  padding: 16px 10px 7px;
  white-space: nowrap;
}
.side-link {
  display: flex;
  align-items: center;
  gap: 11px;
  padding: 9.5px 10px;
  border-radius: 10px;
  color: var(--ink-2);
  font-size: 13.5px;
  font-weight: 550;
  margin-bottom: 2px;
  cursor: pointer;
  transition:
    background 0.15s,
    color 0.15s;
  position: relative;
  white-space: nowrap;
}
.side-link .i {
  width: 19px;
  height: 19px;
  color: var(--faint);
  transition: color 0.15s;
}
.side-link:hover {
  background: var(--surface-2);
  color: var(--ink);
}
.side-link.active {
  background: var(--accent-soft);
  color: var(--accent-ink);
  font-weight: 650;
}
.side-link.active .i {
  color: var(--accent);
}
.side-link.active:before {
  content: "";
  position: absolute;
  left: -14px;
  top: 8px;
  bottom: 8px;
  width: 3.5px;
  border-radius: 0 4px 4px 0;
  background: var(--accent);
}
.side-badge {
  margin-left: auto;
  background: var(--red);
  color: #fff;
  font-size: 10.5px;
  font-weight: 700;
  min-width: 19px;
  height: 19px;
  border-radius: 99px;
  display: grid;
  place-items: center;
  padding: 0 5px;
}
.side-foot {
  padding: 14px;
  border-top: 1px solid var(--line-2);
}
.storage-card {
  background: var(--surface-2);
  border: 1px solid var(--line-2);
  border-radius: 12px;
  padding: 13px;
}
.storage-card .t {
  font-size: 12.5px;
  font-weight: 650;
  display: flex;
  justify-content: space-between;
}
.storage-bar {
  height: 6px;
  border-radius: 99px;
  background: var(--line-2);
  margin: 9px 0 7px;
  overflow: hidden;
}
.storage-bar i {
  display: block;
  height: 100%;
  border-radius: 99px;
  background: linear-gradient(90deg, var(--accent), #34d3ae);
}
.storage-card .s {
  font-size: 11.5px;
  color: var(--muted);
}
.user-chip {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px;
  border-radius: 11px;
  cursor: pointer;
  transition: background 0.15s;
  margin-bottom: 10px;
}
.user-chip:hover {
  background: var(--surface-2);
}
.avatar {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: linear-gradient(135deg, #0e9f80, #0b6e5c);
  color: #fff;
  font-size: 12.5px;
  font-weight: 700;
  display: grid;
  place-items: center;
  flex: none;
}
.avatar.lg {
  width: 52px;
  height: 52px;
  font-size: 17px;
}
.user-chip .n {
  font-size: 13px;
  font-weight: 650;
  line-height: 1.25;
}
.user-chip .r {
  font-size: 11.5px;
  color: var(--muted);
}
.main {
  flex: 1;
  margin-left: var(--side-w);
  min-width: 0;
  display: flex;
  flex-direction: column;
  transition: margin-left 0.25s var(--ease);
}
/* collapsed */
.app.collapsed .sidebar {
  width: var(--side-w-min);
}
.app.collapsed .main {
  margin-left: var(--side-w-min);
}
.app.collapsed .side-cap,
.app.collapsed .brand-text,
.app.collapsed .side-link span,
.app.collapsed .side-badge,
.app.collapsed .storage-card,
.app.collapsed .user-meta,
.app.collapsed .side-foot .btn {
  display: none;
}
.app.collapsed .side-head {
  padding: 18px 0 14px;
  display: flex;
  justify-content: center;
}
.app.collapsed .side-link {
  justify-content: center;
  padding: 10.5px 0;
}
.app.collapsed .side-nav {
  padding: 14px 13px;
}
.app.collapsed .user-chip {
  justify-content: center;
}
/* topbar */
.topbar {
  height: var(--topbar-h);
  background: color-mix(in srgb, var(--surface) 82%, transparent);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--line);
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 0 26px;
  position: sticky;
  top: 0;
  z-index: 50;
}
.topbar .tb-title {
  font-size: 16.5px;
  font-weight: 750;
  letter-spacing: -0.01em;
}
.topbar .tb-crumb {
  font-size: 12px;
  color: var(--faint);
  margin-top: 1px;
}
.top-spacer {
  flex: 1;
}
.top-search {
  width: 270px;
  position: relative;
}
.top-search svg {
  position: absolute;
  top: 50%;
  left: 12px;
  transform: translateY(-50%);
  width: 16px;
  height: 16px;
  color: var(--faint);
}
.theme-btn .moon-i {
  display: none;
}
[data-theme="dark"] .theme-btn .sun-i {
  display: none;
}
[data-theme="dark"] .theme-btn .moon-i {
  display: block;
}
/* dropdown */
.dropdown {
  position: absolute;
  top: calc(100% + 9px);
  right: 0;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 14px;
  box-shadow: var(--sh-lg);
  min-width: 230px;
  opacity: 0;
  transform: translateY(-6px) scale(0.98);
  pointer-events: none;
  transition: all 0.18s var(--ease);
  z-index: 80;
  overflow: hidden;
}
.dropdown.open {
  opacity: 1;
  transform: none;
  pointer-events: auto;
}
.dd-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 15px;
  font-size: 13px;
  font-weight: 550;
  color: var(--ink-2);
  cursor: pointer;
  transition: background 0.13s;
}
.dd-item .i {
  width: 16px;
  height: 16px;
  color: var(--faint);
}
.dd-item:hover {
  background: var(--surface-2);
  color: var(--ink);
}
.dd-item.danger {
  color: var(--red);
}
.dd-item.danger .i {
  color: var(--red);
}
.dd-sep {
  height: 1px;
  background: var(--line-2);
  margin: 4px 0;
}
.dd-head {
  padding: 13px 15px;
  border-bottom: 1px solid var(--line-2);
  font-size: 13px;
  font-weight: 700;
  display: flex;
  justify-content: space-between;
  align-items: center;
}
.dd-head a {
  font-size: 11.5px;
  color: var(--accent-ink);
  font-weight: 600;
  cursor: pointer;
}
.notif-item {
  display: flex;
  gap: 11px;
  padding: 12px 15px;
  border-bottom: 1px solid var(--line-2);
  font-size: 12.5px;
  transition: background 0.13s;
  cursor: pointer;
}
.notif-item:hover {
  background: var(--surface-2);
}
.notif-item:last-child {
  border: none;
}
.notif-item .b {
  font-weight: 600;
  color: var(--ink);
}
.notif-item .s {
  color: var(--muted);
  font-size: 12px;
  margin-top: 1px;
}
.notif-ic {
  width: 32px;
  height: 32px;
  border-radius: 9px;
  display: grid;
  place-items: center;
  flex: none;
}
.notif-ic .i {
  width: 16px;
  height: 16px;
}
/* view */
.view {
  padding: 26px;
  max-width: 1560px;
  width: 100%;
  margin: 0 auto;
  box-sizing: border-box;
  animation: viewIn 0.3s var(--ease);
}
@keyframes viewIn {
  from {
    opacity: 0;
    transform: translateY(7px);
  }
  to {
    opacity: 1;
    transform: none;
  }
}
.page-head {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 22px;
  flex-wrap: wrap;
}
.page-head h1 {
  font-size: 22px;
  font-weight: 800;
  letter-spacing: -0.025em;
}
.page-head .sub {
  color: var(--muted);
  font-size: 13.5px;
  margin-top: 3px;
}
.page-actions {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}

/* ---------- Cards & grid ---------- */
.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r-lg);
  box-shadow: var(--sh-sm);
}
.card-h {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 18px 20px 0;
}
.card-h h3 {
  font-size: 14.5px;
  font-weight: 750;
  letter-spacing: -0.01em;
}
.card-h .s {
  font-size: 12.5px;
  color: var(--muted);
  margin-top: 2px;
}
.card-b {
  padding: 18px 20px 20px;
}
.grid {
  display: grid;
  grid-template-columns: repeat(12, 1fr);
  gap: 18px;
}
.c3 {
  grid-column: span 3;
}
.c4 {
  grid-column: span 4;
}
.c5 {
  grid-column: span 5;
}
.c6 {
  grid-column: span 6;
}
.c7 {
  grid-column: span 7;
}
.c8 {
  grid-column: span 8;
}
.c9 {
  grid-column: span 9;
}
.c12 {
  grid-column: span 12;
}
.hover-lift {
  transition:
    transform 0.2s var(--ease),
    box-shadow 0.2s var(--ease);
}
.hover-lift:hover {
  transform: translateY(-3px);
  box-shadow: var(--sh-md);
}

/* ---------- KPI stat ---------- */
.stat {
  padding: 19px 20px;
  position: relative;
  overflow: hidden;
}
.stat .top {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 10px;
}
.stat .ic {
  width: 42px;
  height: 42px;
  border-radius: 12px;
  display: grid;
  place-items: center;
  flex: none;
}
.stat .ic .i {
  width: 20px;
  height: 20px;
}
.stat .lb {
  font-size: 12.5px;
  font-weight: 600;
  color: var(--muted);
}
.stat .vl {
  font-size: 26px;
  font-weight: 800;
  letter-spacing: -0.03em;
  margin-top: 8px;
  font-variant-numeric: tabular-nums;
  line-height: 1.1;
}
.stat .ft {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 11px;
  font-size: 12px;
  color: var(--muted);
}
.delta {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  font-size: 11.5px;
  font-weight: 700;
  padding: 2.5px 8px;
  border-radius: 99px;
}
.delta .i {
  width: 13px;
  height: 13px;
}
.delta.up {
  background: var(--green-soft);
  color: #0e9b5e;
}
.delta.down {
  background: var(--red-soft);
  color: #d92d20;
}
.delta.warn {
  background: var(--amber-soft);
  color: #c77408;
}
[data-theme="dark"] .delta.up {
  color: #3bd68b;
}
[data-theme="dark"] .delta.down {
  color: #f97066;
}
[data-theme="dark"] .delta.warn {
  color: #f5a93b;
}
.spark {
  position: absolute;
  right: 16px;
  bottom: 14px;
  opacity: 0.9;
}

/* ---------- Tables ---------- */
.tbl-wrap {
  overflow-x: auto;
  border-radius: 0 0 var(--r-lg) var(--r-lg);
}
.tbl {
  width: 100%;
  border-collapse: collapse;
  font-size: 13.2px;
  min-width: 640px;
}
.tbl th {
  text-align: left;
  font-size: 11.5px;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--faint);
  padding: 11px 16px;
  border-bottom: 1px solid var(--line);
  background: var(--surface-2);
  white-space: nowrap;
  user-select: none;
}
.tbl th.right,
.tbl td.right {
  text-align: right;
}
.tbl th.sortable {
  cursor: pointer;
}
.tbl th.sortable:hover {
  color: var(--ink-2);
}
.tbl th .s-arr {
  display: inline-block;
  margin-left: 4px;
  font-size: 10px;
}
.tbl td {
  padding: 12px 16px;
  border-bottom: 1px solid var(--line-2);
  vertical-align: middle;
  white-space: nowrap;
}
.tbl tbody tr {
  transition: background 0.12s;
}
.tbl tbody tr:hover {
  background: var(--surface-2);
}
.tbl tbody tr:last-child td {
  border-bottom: none;
}
.tbl .b {
  font-weight: 650;
}
.tbl .muted {
  color: var(--muted);
}
.cell-prod {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 220px;
}
.thumb {
  width: 42px;
  height: 42px;
  border-radius: 10px;
  overflow: hidden;
  background: var(--surface-2);
  border: 1px solid var(--line-2);
  display: grid;
  place-items: center;
  flex: none;
  position: relative;
}
.thumb img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}
.thumb .i {
  width: 18px;
  height: 18px;
  color: var(--faint);
}
.thumb.lg {
  width: 64px;
  height: 64px;
  border-radius: 12px;
}
.cell-prod .n {
  font-weight: 650;
  line-height: 1.3;
}
.cell-prod .s {
  font-size: 11.8px;
  color: var(--muted);
}
.stock-cell {
  min-width: 120px;
}
.stock-num {
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}
.stock-bar {
  height: 5px;
  width: 74px;
  border-radius: 99px;
  background: var(--line-2);
  margin-top: 5px;
  overflow: hidden;
}
.stock-bar i {
  display: block;
  height: 100%;
  border-radius: 99px;
}
.tbl-foot {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  padding: 13px 16px;
  border-top: 1px solid var(--line);
  font-size: 12.5px;
  color: var(--muted);
  flex-wrap: wrap;
}
.pager {
  display: flex;
  gap: 6px;
}
.pg-btn {
  min-width: 32px;
  height: 32px;
  padding: 0 8px;
  border-radius: 9px;
  border: 1px solid var(--line);
  background: var(--surface);
  color: var(--ink-2);
  font-size: 12.5px;
  font-weight: 600;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: all 0.14s;
}
.pg-btn:hover {
  border-color: #cfd5dd;
  color: var(--ink);
}
.pg-btn.active {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}
.pg-btn:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}
/* filter bar */
.filters {
  display: flex;
  gap: 10px;
  align-items: center;
  padding: 16px 20px;
  border-bottom: 1px solid var(--line-2);
  flex-wrap: wrap;
}
.filters .input-wrap {
  width: 250px;
}
.filters .select {
  width: auto;
  min-width: 150px;
}
.chip-row {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}
.chip {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  height: 34px;
  padding: 0 14px;
  border-radius: 99px;
  border: 1px solid var(--line);
  background: var(--surface);
  font-size: 12.5px;
  font-weight: 600;
  color: var(--ink-2);
  cursor: pointer;
  transition: all 0.15s;
}
.chip:hover {
  border-color: #cfd5dd;
}
.chip.active {
  background: var(--ink);
  border-color: var(--ink);
  color: var(--bg);
}
.chip .n {
  background: var(--surface-2);
  border: 1px solid var(--line-2);
  color: var(--muted);
  font-size: 10.5px;
  font-weight: 700;
  padding: 1.5px 7px;
  border-radius: 99px;
}
.chip.active .n {
  background: rgba(255, 255, 255, 0.16);
  border-color: transparent;
  color: #fff;
}
[data-theme="dark"] .chip.active .n {
  background: rgba(255, 255, 255, 0.12);
  color: var(--ink);
}
.empty {
  text-align: center;
  padding: 52px 20px;
  color: var(--muted);
}
.empty .ic {
  width: 52px;
  height: 52px;
  border-radius: 14px;
  background: var(--surface-2);
  border: 1px solid var(--line-2);
  display: grid;
  place-items: center;
  margin: 0 auto 14px;
  color: var(--faint);
}
.empty h4 {
  font-size: 14.5px;
  font-weight: 700;
  color: var(--ink-2);
  margin-bottom: 4px;
}
.empty p {
  font-size: 12.8px;
}

/* ---------- Modal ---------- */
.modal-bk {
  position: fixed;
  inset: 0;
  background: rgba(11, 16, 23, 0.5);
  backdrop-filter: blur(3px);
  z-index: 100;
  display: grid;
  place-items: center;
  padding: 20px;
  opacity: 0;
  transition: opacity 0.2s;
  overflow-y: auto;
}
.modal-bk.show {
  opacity: 1;
}
.modal {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 18px;
  width: 100%;
  max-width: 560px;
  box-shadow: var(--sh-lg);
  transform: translateY(14px) scale(0.97);
  transition: transform 0.22s cubic-bezier(0.32, 0.9, 0.35, 1.05);
  max-height: calc(100vh - 40px);
  display: flex;
  flex-direction: column;
}
.modal-bk.show .modal {
  transform: none;
}
.modal.lg {
  max-width: 760px;
}
.modal-h {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 19px 22px 0;
}
.modal-h h3 {
  font-size: 16px;
  font-weight: 750;
  letter-spacing: -0.01em;
}
.modal-h .s {
  font-size: 12.5px;
  color: var(--muted);
  margin-top: 2px;
}
.modal-x {
  width: 32px;
  height: 32px;
  border-radius: 9px;
  border: none;
  background: transparent;
  color: var(--faint);
  cursor: pointer;
  display: grid;
  place-items: center;
  transition: all 0.14s;
}
.modal-x:hover {
  background: var(--surface-2);
  color: var(--ink);
}
.modal-b {
  padding: 18px 22px;
  overflow-y: auto;
}
.modal-f {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  padding: 15px 22px;
  border-top: 1px solid var(--line-2);
  background: var(--surface-2);
  border-radius: 0 0 18px 18px;
}

/* ---------- Toasts ---------- */
.toasts {
  position: fixed;
  top: 18px;
  right: 18px;
  z-index: 200;
  display: flex;
  flex-direction: column;
  gap: 10px;
  pointer-events: none;
}
.toast {
  pointer-events: auto;
  display: flex;
  gap: 11px;
  align-items: flex-start;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 13px;
  box-shadow: var(--sh-lg);
  padding: 13px 15px;
  min-width: 290px;
  max-width: 360px;
  animation: toastIn 0.32s cubic-bezier(0.3, 1.1, 0.4, 1.05);
  position: relative;
  overflow: hidden;
}
.toast.out {
  animation: toastOut 0.25s forwards;
}
@keyframes toastIn {
  from {
    opacity: 0;
    transform: translateX(40px) scale(0.96);
  }
  to {
    opacity: 1;
    transform: none;
  }
}
@keyframes toastOut {
  to {
    opacity: 0;
    transform: translateX(30px) scale(0.96);
  }
}
.toast .tic {
  width: 32px;
  height: 32px;
  border-radius: 9px;
  display: grid;
  place-items: center;
  flex: none;
}
.toast .tic .i {
  width: 17px;
  height: 17px;
}
.toast.success .tic {
  background: var(--green-soft);
  color: #0e9b5e;
}
.toast.error .tic {
  background: var(--red-soft);
  color: #d92d20;
}
.toast.info .tic {
  background: var(--blue-soft);
  color: #1570cd;
}
.toast .tt {
  font-size: 13px;
  font-weight: 700;
}
.toast .ts {
  font-size: 12.4px;
  color: var(--muted);
  margin-top: 1px;
}
.toast .tx {
  margin-left: auto;
  color: var(--faint);
  cursor: pointer;
  background: none;
  border: none;
  padding: 2px;
}
.toast .tp {
  position: absolute;
  left: 0;
  bottom: 0;
  height: 2.5px;
  background: var(--accent);
  animation: tp linear forwards;
}
@keyframes tp {
  from {
    width: 100%;
  }
  to {
    width: 0;
  }
}

/* ---------- Tabs ---------- */
.tabs {
  display: flex;
  gap: 4px;
  border-bottom: 1px solid var(--line);
  margin-bottom: 22px;
  overflow-x: auto;
}
.tab {
  padding: 10px 15px;
  font-size: 13.5px;
  font-weight: 600;
  color: var(--muted);
  cursor: pointer;
  border: none;
  background: none;
  border-bottom: 2.5px solid transparent;
  margin-bottom: -1px;
  white-space: nowrap;
  transition: color 0.15s;
  display: inline-flex;
  align-items: center;
  gap: 8px;
}
.tab .i {
  width: 16px;
  height: 16px;
}
.tab:hover {
  color: var(--ink);
}
.tab.active {
  color: var(--accent-ink);
  border-bottom-color: var(--accent);
}

/* ---------- Feeds / lists ---------- */
.feed-item {
  display: flex;
  gap: 12px;
  padding: 11px 0;
  border-bottom: 1px solid var(--line-2);
}
.feed-item:last-child {
  border: none;
  padding-bottom: 2px;
}
.feed-dot {
  width: 32px;
  height: 32px;
  border-radius: 10px;
  display: grid;
  place-items: center;
  flex: none;
}
.feed-dot .i {
  width: 15px;
  height: 15px;
}
.list-row {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 0;
  border-bottom: 1px solid var(--line-2);
}
.list-row:last-child {
  border: none;
}
.rank {
  width: 24px;
  font-size: 12px;
  font-weight: 800;
  color: var(--faint);
  text-align: center;
  flex: none;
}
.mini-bar {
  height: 5px;
  border-radius: 99px;
  background: var(--line-2);
  overflow: hidden;
  flex: 1;
}
.mini-bar i {
  display: block;
  height: 100%;
  border-radius: 99px;
  background: var(--accent);
}
.kv {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  font-size: 13px;
  padding: 7.5px 0;
  border-bottom: 1px dashed var(--line-2);
}
.kv:last-child {
  border: none;
}
.kv .k {
  color: var(--muted);
}
.kv .v {
  font-weight: 650;
  font-variant-numeric: tabular-nums;
}
.chart-box {
  position: relative;
  height: 290px;
}
.chart-box.sm {
  height: 230px;
}
.chart-box.xs {
  height: 190px;
}
.legend {
  display: flex;
  flex-wrap: wrap;
  gap: 7px 16px;
  font-size: 12px;
  color: var(--muted);
}
.legend b {
  color: var(--ink);
  font-weight: 650;
}
.lg-dot {
  width: 9px;
  height: 9px;
  border-radius: 3px;
  display: inline-block;
  margin-right: 6px;
  vertical-align: -1px;
}

/* ---------- Login ---------- */
.login-wrap {
  min-height: 100vh;
  display: grid;
  grid-template-columns: 1.05fr 1fr;
  position: fixed;
  inset: 0;
  z-index: 120;
  background: var(--surface);
}
.login-side {
  position: relative;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  padding: 44px;
  color: #fff;
}
.login-side .bgimg {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  filter: saturate(0.85);
}
.login-side .scrim {
  position: absolute;
  inset: 0;
  background: linear-gradient(
    160deg,
    rgba(6, 46, 36, 0.88) 0%,
    rgba(6, 32, 27, 0.72) 45%,
    rgba(4, 22, 19, 0.9) 100%
  );
}
.login-side > * {
  position: relative;
  z-index: 2;
}
.ls-quote {
  font-size: clamp(21px, 2.4vw, 30px);
  font-weight: 750;
  letter-spacing: -0.02em;
  line-height: 1.32;
  max-width: 480px;
  margin-top: 34px;
}
.ls-stats {
  display: flex;
  gap: 14px;
  flex-wrap: wrap;
  margin-top: 36px;
}
.ls-stat {
  background: rgba(255, 255, 255, 0.09);
  border: 1px solid rgba(255, 255, 255, 0.16);
  backdrop-filter: blur(8px);
  border-radius: 14px;
  padding: 14px 18px;
  min-width: 128px;
}
.ls-stat .v {
  font-size: 20px;
  font-weight: 800;
  font-variant-numeric: tabular-nums;
}
.ls-stat .k {
  font-size: 11.5px;
  opacity: 0.75;
  margin-top: 2px;
}
.ls-foot {
  font-size: 12px;
  opacity: 0.7;
}
.login-main {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 32px;
  overflow-y: auto;
}
.login-card {
  width: 100%;
  max-width: 400px;
  animation: viewIn 0.4s var(--ease);
}
.login-card h1 {
  font-size: 24px;
  font-weight: 800;
  letter-spacing: -0.025em;
  margin: 26px 0 6px;
}
.login-card .sub {
  color: var(--muted);
  font-size: 13.8px;
  margin-bottom: 28px;
}
.demo-box {
  display: flex;
  gap: 10px;
  align-items: center;
  background: var(--blue-soft);
  border: 1px solid color-mix(in srgb, var(--blue) 22%, transparent);
  border-radius: 11px;
  padding: 11px 13px;
  font-size: 12.3px;
  color: #1570cd;
  margin-top: 18px;
  line-height: 1.45;
}
[data-theme="dark"] .demo-box {
  color: #62a9f7;
}
.demo-box .i {
  width: 16px;
  height: 16px;
  flex: none;
}
.demo-box code {
  background: rgba(46, 144, 250, 0.12);
  padding: 1px 6px;
  border-radius: 5px;
  font-weight: 600;
  font-family: inherit;
}
.login-alt {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin: 16px 0 22px;
}
.spin {
  width: 16px;
  height: 16px;
  border: 2px solid rgba(255, 255, 255, 0.35);
  border-top-color: #fff;
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
}
@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}
/* image uploader */
.up-zone {
  border: 1.6px dashed var(--line);
  border-radius: 14px;
  padding: 20px;
  display: flex;
  gap: 16px;
  align-items: center;
  cursor: pointer;
  transition: all 0.16s;
  background: var(--surface-2);
}
.up-zone:hover {
  border-color: var(--accent);
  background: var(--accent-soft);
}
.up-zone .prev {
  width: 78px;
  height: 78px;
  border-radius: 12px;
  background: var(--surface);
  border: 1px solid var(--line);
  display: grid;
  place-items: center;
  color: var(--faint);
  overflow: hidden;
  flex: none;
}
.up-zone .prev img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}
.up-zone b {
  font-size: 13px;
}
.up-zone span {
  font-size: 12px;
  color: var(--muted);
  display: block;
  margin-top: 3px;
}

/* ---------- Docs ---------- */
.docs-layout {
  display: grid;
  grid-template-columns: 230px 1fr;
  gap: 30px;
  align-items: start;
}
.docs-nav {
  position: sticky;
  top: calc(var(--topbar-h) + 24px);
  font-size: 13px;
}
.docs-nav a {
  display: block;
  padding: 7px 12px;
  border-radius: 8px;
  color: var(--muted);
  font-weight: 550;
  cursor: pointer;
}
.docs-nav a:hover {
  background: var(--surface-2);
  color: var(--ink);
}
.docs-nav a.on {
  color: var(--accent-ink);
  background: var(--accent-soft);
  font-weight: 650;
}
.docs-sec {
  margin-bottom: 38px;
}
.docs-sec h2 {
  font-size: 18px;
  font-weight: 800;
  letter-spacing: -0.02em;
  margin-bottom: 10px;
  display: flex;
  align-items: center;
  gap: 10px;
}
.docs-sec h2 .i {
  width: 19px;
  height: 19px;
  color: var(--accent);
}
.docs-sec h3 {
  font-size: 14px;
  font-weight: 750;
  margin: 18px 0 8px;
}
.docs-sec p {
  color: var(--ink-2);
  font-size: 13.6px;
  margin-bottom: 10px;
  max-width: 72ch;
}
.docs-sec li {
  color: var(--ink-2);
  font-size: 13.4px;
  margin: 5px 0 5px 18px;
  list-style: disc;
}
pre.code {
  background: #101828;
  color: #d3e0ee;
  border-radius: 12px;
  padding: 15px 17px;
  font-size: 12.3px;
  line-height: 1.65;
  overflow-x: auto;
  margin: 10px 0 14px;
  font-family: ui-monospace, "SF Mono", Menlo, Consolas, monospace;
}
pre.code .c {
  color: #64748b;
}
pre.code .k {
  color: #7dd3fc;
}
pre.code .s {
  color: #86efac;
}
code.inl {
  background: var(--surface-2);
  border: 1px solid var(--line-2);
  padding: 1px 6px;
  border-radius: 6px;
  font-size: 12px;
  font-family: ui-monospace, Menlo, monospace;
  color: var(--accent-ink);
}
.doc-tree {
  font-family: ui-monospace, Menlo, monospace;
  font-size: 12.6px;
  line-height: 1.8;
  color: var(--ink-2);
}

/* ---------- Print ---------- */
#print-area {
  display: none;
}
@media print {
  body > * {
    display: none !important;
  }
  #print-area {
    display: block !important;
    color: #000;
    font-family: var(--font);
  }
  .inv {
    max-width: 760px;
    margin: 0 auto;
    padding: 34px;
  }
  .inv-head {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    border-bottom: 2.5px solid #000;
    padding-bottom: 18px;
    margin-bottom: 20px;
  }
  .inv h1 {
    font-size: 26px;
    letter-spacing: -0.02em;
  }
  .inv table {
    width: 100%;
    border-collapse: collapse;
    font-size: 13px;
    margin: 18px 0;
  }
  .inv th {
    text-align: left;
    border-bottom: 1.5px solid #000;
    padding: 8px 10px;
    text-transform: uppercase;
    font-size: 11px;
    letter-spacing: 0.05em;
  }
  .inv td {
    border-bottom: 1px solid #ddd;
    padding: 9px 10px;
  }
  .inv .tot {
    margin-left: auto;
    width: 280px;
  }
  .inv .tot div {
    display: flex;
    justify-content: space-between;
    padding: 5px 10px;
    font-size: 13.5px;
  }
  .inv .grand {
    font-weight: 800;
    font-size: 17px;
    border-top: 2px solid #000;
  }
}

/* ---------- Overlay ---------- */
.overlay {
  position: fixed;
  inset: 0;
  background: rgba(11, 16, 23, 0.45);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.22s;
  z-index: 55;
}
.overlay.show {
  opacity: 1;
  pointer-events: auto;
}

/* ============ Responsive ============ */
@media (max-width: 1240px) {
  .c8,
  .c7 {
    grid-column: span 12;
  }
  .c4,
  .c5,
  .c3 {
    grid-column: span 6;
  }
  .c9 {
    grid-column: span 12;
  }
  .c6 {
    grid-column: span 12;
  }
  .top-search {
    width: 200px;
  }
}
@media (max-width: 1024px) {
  .docs-layout {
    grid-template-columns: 1fr;
  }
  .docs-nav {
    position: static;
    display: flex;
    flex-wrap: wrap;
    gap: 4px;
  }
  .login-wrap {
    grid-template-columns: 1fr;
  }
  .login-side {
    display: none;
  }
}
@media (max-width: 992px) {
  .sidebar {
    transform: translateX(-105%);
    width: 272px !important;
  }
  .sidebar .side-cap,
  .sidebar .brand-text,
  .sidebar .side-link span,
  .sidebar .side-badge,
  .sidebar .storage-card,
  .sidebar .user-meta {
    display: block;
  }
  .sidebar .side-badge {
    display: grid;
  }
  .sidebar .side-foot .btn {
    display: inline-flex;
  }
  .sidebar .side-head {
    padding: 18px 20px 14px;
    display: flex;
  }
  .sidebar .side-link {
    justify-content: flex-start;
    padding: 9.5px 10px;
  }
  .app.open .sidebar {
    transform: none;
    box-shadow: var(--sh-lg);
  }
  .main,
  .app.collapsed .main {
    margin-left: 0;
  }
  .app.collapsed .sidebar {
    width: 272px;
  }
  .top-search {
    display: none;
  }
  .view {
    padding: 20px 16px;
  }
  .topbar {
    padding: 0 16px;
  }
}
@media (max-width: 640px) {
  .grid {
    gap: 13px;
  }
  .c3,
  .c4,
  .c5 {
    grid-column: span 12;
  }
  .form-grid {
    grid-template-columns: 1fr;
  }
  .page-head h1 {
    font-size: 19px;
  }
  .stat .vl {
    font-size: 22px;
  }
  .filters .input-wrap {
    width: 100%;
  }
  .filters .select {
    flex: 1;
    min-width: 0;
  }
  .chart-box {
    height: 230px;
  }
  .hide-sm {
    display: none;
  }
  .login-main {
    padding: 22px 18px;
  }
  .modal-bk {
    padding: 10px;
  }
  .toasts {
    left: 14px;
    right: 14px;
  }
  .toast {
    min-width: 0;
  }
}
