/* ==========================================================================
   TSCO ERP — design system
   Warm glass cards on a soft gradient, accent = TSCO orange (#F14725)
   ========================================================================== */

:root {
  --accent: #F14725;
  --accent-600: #D9391A;
  --accent-700: #B52E14;
  --accent-50: #FFF4F0;
  --accent-100: #FDE4DB;
  --accent-200: #FAC9B8;
  --accent-300: #F6AB93;

  --bg: #F4ECE9;
  --surface: rgba(255, 255, 255, 0.72);
  --surface-strong: rgba(255, 255, 255, 0.9);
  --surface-soft: rgba(255, 255, 255, 0.5);
  --surface-solid: #FFFFFF;
  --glass-border: rgba(255, 255, 255, 0.95);
  --line: #EEE4E0;
  --line-strong: #E2D6D1;

  --text: #1E1A18;
  --text-2: #4E4642;
  --muted: #8F8580;
  --muted-2: #B3A9A4;

  --success: #17955C;
  --success-bg: #E3F5EB;
  --warning: #C77105;
  --warning-bg: #FFF1DC;
  --danger: #D5342A;
  --danger-bg: #FDE6E3;
  --info: #2D6AE3;
  --info-bg: #E5EDFD;
  --neutral: #6F6560;
  --neutral-bg: #F1ECE9;
  --neutral-400: #C9BFBA;

  --radius-lg: 22px;
  --radius: 18px;
  --radius-sm: 12px;
  --radius-xs: 8px;
  --shadow-sm: 0 1px 2px rgba(90, 45, 30, 0.05);
  --shadow: 0 1px 2px rgba(90, 45, 30, 0.04), 0 10px 30px rgba(120, 60, 40, 0.07);
  --shadow-lg: 0 20px 60px rgba(80, 35, 20, 0.18);
  --ring: 0 0 0 4px rgba(241, 71, 37, 0.14);

  --font: "IBM Plex Sans", ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, Arial, sans-serif;
  --mono: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  --display: "IBM Plex Sans", ui-sans-serif, system-ui, sans-serif;

  --sidebar-w: 252px;
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; background: #F2E9E5; }
body {
  margin: 0;
  font-family: var(--font);
  font-size: 14px;
  line-height: 1.5;
  color: var(--text);
  background:
    radial-gradient(1100px 620px at -5% -10%, #FADBCF 0%, rgba(250, 219, 207, 0) 60%),
    radial-gradient(900px 520px at 105% -5%, #F2DCE3 0%, rgba(242, 220, 227, 0) 58%),
    radial-gradient(800px 600px at 50% 110%, #F6E2D8 0%, rgba(246, 226, 216, 0) 60%),
    linear-gradient(180deg, #F7F0ED 0%, #F0E6E2 100%);
  background-color: #F2E9E5;
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
}
img { max-width: 100%; display: block; }
a { color: inherit; text-decoration: none; }
a.link, .link { color: var(--accent-600); font-weight: 600; }
a.link:hover, .link:hover { text-decoration: underline; }
h1, h2, h3, h4, .brand-name, .card-title, .stat-value { font-family: var(--display); }
h1, h2, h3, h4 { margin: 0; line-height: 1.25; font-weight: 700; letter-spacing: -0.01em; }
table, .stat-value, .num { font-variant-numeric: tabular-nums; }
p { margin: 0; }
hr { border: 0; border-top: 1px solid var(--line); margin: 16px 0; }
code, .mono { font-family: var(--mono); font-size: 12.5px; }
::selection { background: var(--accent-200); }

.icon { width: 18px; height: 18px; flex: none; stroke: currentColor; fill: none; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.icon-sm { width: 15px; height: 15px; }
.icon-lg { width: 22px; height: 22px; }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0; }

/* ---------- App shell ---------------------------------------------------- */
.app {
  display: grid;
  grid-template-columns: var(--sidebar-w) minmax(0, 1fr);
  gap: 16px;
  padding: 16px;
  min-height: 100vh;
}
.sidebar {
  position: sticky; top: 16px;
  height: calc(100vh - 32px);
  height: calc(100dvh - 32px);
  display: flex; flex-direction: column;
  background: var(--surface);
  border: 1px solid var(--glass-border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow);
  backdrop-filter: blur(18px); -webkit-backdrop-filter: blur(18px);
  padding: 18px 14px;
  overflow: hidden;
}
/* Brand and footer card stay put; only the menu scrolls. */
.sidebar > .brand, .sidebar-footer { flex-shrink: 0; }
.sidebar-scroll {
  flex: 1 1 auto; min-height: 0;
  overflow-y: auto; overscroll-behavior: contain;
  margin: 0 -6px; padding: 0 6px 8px;
  scrollbar-width: thin; scrollbar-color: rgba(120, 60, 40, .25) transparent;
}
.sidebar-scroll::-webkit-scrollbar { width: 6px; }
.sidebar-scroll::-webkit-scrollbar-thumb { background: rgba(120, 60, 40, .25); border-radius: 99px; }
.sidebar-footer { padding-top: 12px; }
.brand { display: flex; align-items: center; gap: 10px; padding: 2px 8px 18px; }
.brand img { width: 36px; height: 36px; border-radius: 10px; object-fit: cover; }
.brand-name { font-weight: 800; font-size: 18px; letter-spacing: -0.02em; }
.brand-sub { font-size: 11px; color: var(--muted); font-weight: 600; text-transform: uppercase; letter-spacing: .08em; }
.nav-section { font-size: 11px; font-weight: 700; color: var(--muted-2); text-transform: uppercase; letter-spacing: .08em; padding: 14px 12px 6px; }
.nav { display: flex; flex-direction: column; gap: 2px; }
.nav a {
  display: flex; align-items: center; gap: 11px;
  padding: 9px 12px; border-radius: 12px;
  color: var(--text-2); font-weight: 600; font-size: 13.5px;
  transition: background .15s, color .15s, box-shadow .15s;
}
.nav a .icon { color: var(--muted); }
.nav a:hover { background: rgba(255, 255, 255, .7); color: var(--text); }
.nav a.active { background: var(--surface-solid); color: var(--text); box-shadow: var(--shadow-sm), 0 4px 14px rgba(120, 60, 40, .06); }
.nav a.active .icon { color: var(--accent); }
.nav .count { margin-left: auto; font-size: 11px; font-weight: 700; padding: 1px 8px; border-radius: 999px; background: var(--accent); color: #fff; }
.promo {
  position: relative; overflow: hidden;
  border-radius: 16px; padding: 18px 16px 16px;
  color: #FFF3EE;
  background:
    radial-gradient(160px 120px at 85% 0%, rgba(241, 71, 37, .55), transparent 70%),
    linear-gradient(160deg, #6B2A18 0%, #3E1A10 100%);
  box-shadow: 0 10px 24px rgba(70, 25, 10, .25);
}
.promo-logo { width: 38px; height: 38px; border-radius: 10px; margin-bottom: 10px; }
.promo p { font-size: 12.5px; line-height: 1.45; opacity: .92; margin-bottom: 12px; }
.promo strong { display: block; font-size: 14px; margin-bottom: 4px; }
.promo .btn { width: 100%; justify-content: center; }
/* Short screens: compact card so the menu keeps most of the height. */
@media (max-height: 820px) {
  .promo { padding: 12px 14px; }
  .promo-logo, .promo p { display: none; }
  .promo strong { margin-bottom: 8px; }
}
@media (max-height: 560px) {
  .sidebar-footer { display: none; }
}

.main { min-width: 0; display: flex; flex-direction: column; gap: 16px; }
.topbar {
  display: flex; align-items: center; gap: 12px;
  padding: 12px 14px 12px 22px;
  background: var(--surface);
  border: 1px solid var(--glass-border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow);
  backdrop-filter: blur(18px); -webkit-backdrop-filter: blur(18px);
  position: sticky; top: 16px; z-index: 20;
}
.topbar h1 { font-size: 22px; font-weight: 700; flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.topbar-actions { display: flex; align-items: center; gap: 10px; }
.icon-btn {
  width: 40px; height: 40px; border-radius: 999px;
  display: inline-grid; place-items: center;
  background: var(--surface-solid); border: 1px solid var(--line);
  color: var(--text-2); cursor: pointer; position: relative;
  transition: border-color .15s, color .15s;
}
.icon-btn:hover { border-color: var(--accent-200); color: var(--accent); }
.icon-btn .dot { position: absolute; top: 9px; right: 10px; width: 8px; height: 8px; border-radius: 50%; background: var(--accent); border: 2px solid #fff; }
.menu-toggle { display: none; }
.user-chip { display: flex; align-items: center; gap: 10px; padding: 4px 6px 4px 4px; border-radius: 999px; cursor: pointer; background: none; border: 0; font: inherit; color: inherit; text-align: left; }
.user-chip:hover { background: rgba(255, 255, 255, .7); }
.user-chip .who { line-height: 1.2; }
.user-chip .who strong { display: block; font-size: 13.5px; }
.user-chip .who small { color: var(--muted); font-size: 12px; }

.avatar {
  width: 40px; height: 40px; border-radius: 50%;
  display: inline-grid; place-items: center; flex: none;
  font-weight: 700; font-size: 13px; color: var(--accent-700);
  background: linear-gradient(135deg, var(--accent-100), #FFE9D6);
  border: 2px solid #fff; box-shadow: var(--shadow-sm);
}
.avatar-sm { width: 32px; height: 32px; font-size: 11.5px; }
.avatar-lg { width: 56px; height: 56px; font-size: 18px; border-radius: 16px; }
.avatar img { width: 100%; height: 100%; border-radius: inherit; object-fit: cover; }

/* ---------- Dropdown ------------------------------------------------------ */
.dropdown { position: relative; }
.dropdown-menu {
  position: absolute; right: 0; top: calc(100% + 8px);
  min-width: 220px; padding: 6px;
  background: var(--surface-solid); border: 1px solid var(--line);
  border-radius: 14px; box-shadow: var(--shadow-lg);
  display: none; z-index: 50;
}
.dropdown.open .dropdown-menu { display: block; }
.dropdown-menu a, .dropdown-menu button {
  display: flex; align-items: center; gap: 10px; width: 100%;
  padding: 9px 10px; border-radius: 10px; border: 0; background: none;
  font: inherit; font-weight: 600; font-size: 13px; color: var(--text-2); cursor: pointer; text-align: left;
}
.dropdown-menu a:hover, .dropdown-menu button:hover { background: var(--accent-50); color: var(--text); }
.dropdown-menu .danger { color: var(--danger); }
.dropdown-head { padding: 10px 10px 8px; border-bottom: 1px solid var(--line); margin-bottom: 6px; }
.dropdown-head small { color: var(--muted); display: block; }

/* ---------- Cards & layout ----------------------------------------------- */
.card {
  background: var(--surface);
  border: 1px solid var(--glass-border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  backdrop-filter: blur(18px); -webkit-backdrop-filter: blur(18px);
  padding: 20px;
  min-width: 0;
}
.card-flush { padding: 0; overflow: hidden; }
.card-header { display: flex; align-items: center; gap: 12px; margin-bottom: 16px; flex-wrap: wrap; }
.card-flush .card-header { padding: 18px 20px 0; }
.card-title { font-size: 16px; font-weight: 700; flex: 1; min-width: 0; }
.card-sub { color: var(--muted); font-size: 12.5px; margin-top: 2px; }
.inset {
  background: var(--surface-soft); border: 1px solid rgba(255, 255, 255, .9);
  border-radius: var(--radius-sm); padding: 14px;
}
.grid { display: grid; gap: 16px; }
.grid-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.grid-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.grid-4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.layout-main-side { display: grid; grid-template-columns: minmax(0, 1fr) 340px; gap: 16px; align-items: start; }
.layout-side-main { display: grid; grid-template-columns: 300px minmax(0, 1fr); gap: 16px; align-items: start; }
.stack { display: flex; flex-direction: column; gap: 16px; }
.stack-sm { display: flex; flex-direction: column; gap: 8px; }
.row { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.row-between { display: flex; align-items: center; justify-content: space-between; gap: 10px; flex-wrap: wrap; }
.grow { flex: 1; min-width: 0; }
.muted { color: var(--muted); }
.small { font-size: 12.5px; }
.tiny { font-size: 11.5px; }
.strong { font-weight: 700; }
.nowrap { white-space: nowrap; }
.right { text-align: right; }
.truncate { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.mt-0 { margin-top: 0; } .mt-1 { margin-top: 6px; } .mt-2 { margin-top: 12px; } .mt-3 { margin-top: 20px; }
.mb-1 { margin-bottom: 6px; } .mb-2 { margin-bottom: 12px; } .mb-3 { margin-bottom: 20px; }

.page-header { display: flex; align-items: flex-end; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
.page-header .lead { color: var(--muted); margin-top: 4px; }
.breadcrumbs { display: flex; align-items: center; gap: 6px; font-size: 12.5px; color: var(--muted); font-weight: 600; margin-bottom: 4px; }
.breadcrumbs a:hover { color: var(--accent); }

/* ---------- Stat cards ----------------------------------------------------- */
.stat { display: flex; flex-direction: column; gap: 14px; }
.stat-top { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.stat-label { font-weight: 600; font-size: 13.5px; color: var(--text-2); display: flex; align-items: center; gap: 8px; }
.stat-icon { width: 34px; height: 34px; border-radius: 10px; display: grid; place-items: center; background: var(--accent-50); color: var(--accent); }
.stat-bottom { display: flex; align-items: flex-end; justify-content: space-between; gap: 8px; flex-wrap: wrap; }
.stat-value { font-size: 30px; font-weight: 700; letter-spacing: -0.02em; line-height: 1; }
.delta { display: inline-flex; align-items: center; gap: 4px; font-size: 12px; font-weight: 700; padding: 3px 9px; border-radius: 999px; border: 1px solid; }
.delta-up { color: var(--success); background: var(--success-bg); border-color: #C6EBD6; }
.delta-down { color: var(--danger); background: var(--danger-bg); border-color: #F7CBC6; }
.delta-flat { color: var(--warning); background: var(--warning-bg); border-color: #F8DDB4; }
a.card.stat:hover { border-color: var(--accent-200); }

/* ---------- Buttons ------------------------------------------------------- */
.btn {
  display: inline-flex; align-items: center; gap: 8px;
  height: 40px; padding: 0 16px; border-radius: 12px;
  font: inherit; font-weight: 700; font-size: 13.5px; white-space: nowrap;
  border: 1px solid transparent; cursor: pointer;
  transition: background .15s, border-color .15s, color .15s, box-shadow .15s, transform .05s;
}
.btn:active { transform: translateY(1px); }
.btn:focus-visible { outline: none; box-shadow: var(--ring); }
.btn-primary { background: var(--accent); color: #fff; box-shadow: 0 6px 16px rgba(241, 71, 37, .28); }
.btn-primary:hover { background: var(--accent-600); }
.btn-secondary { background: var(--surface-solid); color: var(--text); border-color: var(--line-strong); }
.btn-secondary:hover { border-color: var(--accent-300); color: var(--accent-700); }
.btn-outline { background: transparent; color: var(--accent-600); border-color: var(--accent-300); }
.btn-outline:hover { background: var(--accent-50); }
.btn-ghost { background: transparent; color: var(--text-2); }
.btn-ghost:hover { background: rgba(255, 255, 255, .8); color: var(--text); }
.btn-success { background: var(--success); color: #fff; box-shadow: 0 6px 16px rgba(23, 149, 92, .22); }
.btn-success:hover { background: #12804E; }
.btn-danger { background: var(--surface-solid); color: var(--danger); border-color: #F3C2BD; }
.btn-danger:hover { background: var(--danger-bg); }
.btn-danger-solid { background: var(--danger); color: #fff; }
.btn-danger-solid:hover { background: #B92A21; }
.btn-light { background: rgba(255, 255, 255, .95); color: var(--accent-700); }
.btn-sm { height: 32px; padding: 0 12px; font-size: 12.5px; border-radius: 10px; gap: 6px; }
.btn-xs { height: 28px; padding: 0 10px; font-size: 12px; border-radius: 8px; gap: 5px; }
.btn-icon { width: 34px; padding: 0; justify-content: center; }
.btn-block { width: 100%; justify-content: center; }
.btn[disabled], .btn.disabled { opacity: .5; pointer-events: none; }
.inline-form { display: inline; }

/* ---------- Segmented control / tabs ------------------------------------- */
.segmented { display: inline-flex; padding: 4px; gap: 2px; background: var(--surface-solid); border: 1px solid var(--line); border-radius: 12px; flex-wrap: wrap; }
.segmented a, .segmented button {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 6px 12px; border-radius: 9px; border: 0; background: none;
  font: inherit; font-size: 12.5px; font-weight: 700; color: var(--text-2); cursor: pointer;
}
.segmented a:hover, .segmented button:hover { color: var(--text); background: var(--accent-50); }
.segmented .active { background: var(--accent); color: #fff; box-shadow: 0 4px 12px rgba(241, 71, 37, .25); }
.segmented .active:hover { background: var(--accent-600); color: #fff; }
.segmented .n { font-size: 11px; padding: 0 6px; border-radius: 999px; background: var(--neutral-bg); color: var(--text-2); }
.segmented .active .n { background: rgba(255, 255, 255, .25); color: #fff; }

.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--line); margin-bottom: 18px; overflow-x: auto; }
.tabs a { padding: 10px 14px; font-weight: 700; font-size: 13.5px; color: var(--muted); border-bottom: 2px solid transparent; margin-bottom: -1px; white-space: nowrap; display: flex; align-items: center; gap: 8px; }
.tabs a:hover { color: var(--text); }
.tabs a.active { color: var(--accent-600); border-bottom-color: var(--accent); }
.tabs .n { font-size: 11px; padding: 0 7px; border-radius: 999px; background: var(--neutral-bg); color: var(--text-2); }

/* ---------- Badges -------------------------------------------------------- */
.badge {
  display: inline-flex; align-items: center; gap: 5px;
  font-size: 11.5px; font-weight: 700; line-height: 1;
  padding: 5px 10px; border-radius: 7px; white-space: nowrap; border: 1px solid transparent;
}
.badge::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.badge-success { color: var(--success); background: var(--success-bg); border-color: #C9EDD9; }
.badge-warning { color: var(--warning); background: var(--warning-bg); border-color: #F9DFB8; }
.badge-danger { color: var(--danger); background: var(--danger-bg); border-color: #F6CCC7; }
.badge-info { color: var(--info); background: var(--info-bg); border-color: #CADBFB; }
.badge-accent { color: var(--accent-700); background: var(--accent-100); border-color: var(--accent-200); }
.badge-neutral { color: var(--neutral); background: var(--neutral-bg); border-color: #E6DEDA; }
.badge-muted { color: var(--muted); background: #F6F3F1; border-color: #ECE6E3; }
.badge.plain::before { display: none; }
.chip { display: inline-flex; align-items: center; gap: 6px; padding: 4px 10px; border-radius: 999px; background: var(--surface-solid); border: 1px solid var(--line); font-size: 12px; font-weight: 600; color: var(--text-2); }

/* ---------- Tables -------------------------------------------------------- */
.table-wrap { overflow-x: auto; border-radius: 14px; border: 1px solid var(--line); background: var(--surface-strong); }
.card-flush .table-wrap { border: 0; border-radius: 0; border-top: 1px solid var(--line); background: transparent; }
table.table { width: 100%; border-collapse: collapse; font-size: 13.5px; }
.table th {
  text-align: left; font-size: 11px; font-weight: 700; color: var(--muted);
  text-transform: uppercase; letter-spacing: .06em;
  padding: 12px 16px; background: rgba(250, 245, 243, .9); border-bottom: 1px solid var(--line); white-space: nowrap;
}
.table td { padding: 13px 16px; border-bottom: 1px solid var(--line); vertical-align: middle; }
.table tr:last-child td { border-bottom: 0; }
.table tbody tr { transition: background .12s; }
.table tbody tr:hover { background: rgba(255, 255, 255, .85); }
.table .num { text-align: right; font-variant-numeric: tabular-nums; }
.table .actions { text-align: right; white-space: nowrap; }
.table .actions .row { justify-content: flex-end; flex-wrap: nowrap; }
.cell-main { display: flex; align-items: center; gap: 12px; min-width: 220px; }
.cell-main strong { display: block; font-weight: 700; }
.cell-main small { color: var(--muted); font-size: 12px; }
.thumb { width: 44px; height: 44px; border-radius: 10px; object-fit: cover; background: #fff; border: 1px solid var(--line); flex: none; display: grid; place-items: center; color: var(--muted-2); overflow: hidden; }
.thumb img { width: 100%; height: 100%; object-fit: contain; }
.thumb-lg { width: 64px; height: 64px; border-radius: 14px; }

/* ---------- Lists --------------------------------------------------------- */
.list { display: flex; flex-direction: column; gap: 8px; }
.list-item {
  display: flex; align-items: center; gap: 12px;
  padding: 10px 12px; border-radius: 14px;
  background: var(--surface-soft); border: 1px solid rgba(255, 255, 255, .95);
  transition: background .12s, border-color .12s;
}
a.list-item:hover { background: var(--surface-solid); border-color: var(--accent-100); }
.list-item .meta { margin-left: auto; text-align: right; }
.list-item .title { font-weight: 700; font-size: 13.5px; }
.list-item .sub { color: var(--muted); font-size: 12px; }

/* ---------- Forms --------------------------------------------------------- */
.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px 16px; }
.form-grid-3 { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 14px 16px; }
.span-2 { grid-column: span 2; }
.span-all { grid-column: 1 / -1; }
.field { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.field > label, .label { font-weight: 700; font-size: 12.5px; color: var(--text-2); }
.req { color: var(--accent); margin-left: 2px; }
.input {
  width: 100%; height: 42px; padding: 0 13px;
  font: inherit; font-size: 14px; color: var(--text);
  background: var(--surface-solid); border: 1px solid var(--line-strong); border-radius: 11px;
  transition: border-color .15s, box-shadow .15s;
}
textarea.input { height: auto; min-height: 90px; padding: 10px 13px; resize: vertical; line-height: 1.5; }
select.input { appearance: none; padding-right: 36px; background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%238F8580' stroke-width='2' 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; }
select.input[multiple] { height: auto; min-height: 120px; background-image: none; padding: 6px; }
.input:hover { border-color: var(--accent-200); }
.input:focus { outline: none; border-color: var(--accent); box-shadow: var(--ring); }
.input::placeholder { color: var(--muted-2); }
.input[readonly], .input:disabled { background: var(--neutral-bg); color: var(--muted); }
.file-input { height: auto; padding: 9px 10px; }
.file-input::file-selector-button { font: inherit; font-weight: 700; font-size: 12.5px; border: 0; border-radius: 8px; padding: 6px 12px; margin-right: 10px; background: var(--accent-100); color: var(--accent-700); cursor: pointer; }
.has-error .input { border-color: var(--danger); }
.help { color: var(--muted); font-size: 12px; }
.error, .errorlist { color: var(--danger); font-size: 12px; font-weight: 600; }
.errorlist { list-style: none; padding: 0; margin: 0; }
.input-group { display: flex; align-items: stretch; }
.input-group .addon { display: grid; place-items: center; padding: 0 12px; background: var(--neutral-bg); border: 1px solid var(--line-strong); border-right: 0; border-radius: 11px 0 0 11px; font-weight: 700; font-size: 12.5px; color: var(--muted); }
.input-group .input { border-radius: 0 11px 11px 0; }
.check { display: inline-flex; align-items: center; gap: 10px; font-weight: 600; cursor: pointer; }
.check-input { width: 18px; height: 18px; accent-color: var(--accent); cursor: pointer; }
.choice-list { display: flex; flex-direction: column; gap: 8px; list-style: none; padding: 0; margin: 0; }
.choice-list div, .choice-list li { display: block; }
.choice-list label { display: flex; align-items: center; gap: 10px; padding: 10px 12px; border-radius: 11px; background: var(--surface-solid); border: 1px solid var(--line); font-weight: 600; cursor: pointer; }
.choice-list label:hover { border-color: var(--accent-200); }
.choice-list input { width: 17px; height: 17px; accent-color: var(--accent); }
.form-section { padding-bottom: 6px; }
.form-section + .form-section { border-top: 1px solid var(--line); padding-top: 20px; margin-top: 8px; }
.form-section-title { font-size: 14.5px; font-weight: 700; margin-bottom: 4px; }
.form-section-sub { color: var(--muted); font-size: 12.5px; margin-bottom: 14px; }
.form-actions { display: flex; align-items: center; justify-content: flex-end; gap: 10px; flex-wrap: wrap; }
.side-sticky { position: sticky; top: 104px; }
@media (max-width: 1080px) { .side-sticky { position: static; } }
.search-box { position: relative; min-width: 220px; flex: 1; max-width: 360px; }
.search-box .icon { position: absolute; left: 12px; top: 50%; transform: translateY(-50%); color: var(--muted); }
.search-box .input { padding-left: 38px; height: 40px; }
.filters { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.filters .input { height: 40px; width: auto; min-width: 160px; }

/* ---------- Alerts / messages -------------------------------------------- */
.messages { display: flex; flex-direction: column; gap: 10px; }
.alert {
  display: flex; align-items: flex-start; gap: 10px;
  padding: 12px 14px; border-radius: 14px; border: 1px solid;
  font-weight: 600; font-size: 13.5px;
  background: var(--surface-strong);
  animation: slide-in .25s ease-out;
}
.alert .icon { margin-top: 1px; }
.alert .grow { line-height: 1.45; }
.alert-close { background: none; border: 0; color: inherit; opacity: .6; cursor: pointer; padding: 0; }
.alert-close:hover { opacity: 1; }
.alert-success { color: #0F6E43; border-color: #BFE8D2; background: #F0FAF4; }
.alert-info { color: #1F4FB0; border-color: #C9D9FA; background: #F2F6FE; }
.alert-warning { color: #8F5203; border-color: #F6D9AA; background: #FFF8EC; }
.alert-danger { color: #A7261E; border-color: #F4C4BF; background: #FEF2F1; }
@keyframes slide-in { from { opacity: 0; transform: translateY(-4px); } to { opacity: 1; transform: none; } }

/* ---------- Empty state --------------------------------------------------- */
.empty { text-align: center; padding: 40px 20px; color: var(--muted); }
.empty-icon { width: 56px; height: 56px; margin: 0 auto 12px; border-radius: 16px; display: grid; place-items: center; background: var(--accent-50); color: var(--accent); }
.empty h3 { color: var(--text); font-size: 15px; margin-bottom: 4px; }
.empty p { max-width: 380px; margin: 0 auto 14px; font-size: 13px; }

/* ---------- Pagination ---------------------------------------------------- */
.pagination { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 14px 16px; flex-wrap: wrap; }
.pagination .pages { display: flex; gap: 4px; }
.pagination a, .pagination span.cur { min-width: 34px; height: 34px; padding: 0 10px; display: inline-grid; place-items: center; border-radius: 10px; font-weight: 700; font-size: 13px; border: 1px solid var(--line); background: var(--surface-solid); }
.pagination a:hover { border-color: var(--accent-300); color: var(--accent-700); }
.pagination span.cur { background: var(--accent); color: #fff; border-color: var(--accent); }

/* ---------- Key/value & timeline ----------------------------------------- */
.kv { display: grid; grid-template-columns: 150px minmax(0, 1fr); gap: 10px 16px; font-size: 13.5px; margin: 0; }
.kv dt { color: var(--muted); font-weight: 600; }
.kv dd { margin: 0; font-weight: 600; word-break: break-word; }
.timeline { list-style: none; margin: 0; padding: 0; position: relative; }
.timeline li { position: relative; padding: 0 0 18px 28px; }
.timeline li::before { content: ""; position: absolute; left: 7px; top: 18px; bottom: 0; width: 2px; background: var(--line); }
.timeline li:last-child::before { display: none; }
.timeline .tl-dot { position: absolute; left: 0; top: 3px; width: 16px; height: 16px; border-radius: 50%; background: #fff; border: 3px solid var(--accent-200); }
.timeline .tl-dot.success { border-color: var(--success); }
.timeline .tl-dot.danger { border-color: var(--danger); }
.timeline .tl-dot.warning { border-color: var(--warning); }
.timeline .tl-title { font-weight: 700; font-size: 13px; display: flex; gap: 6px; align-items: center; flex-wrap: wrap; }
.timeline .tl-meta { color: var(--muted); font-size: 12px; }
.timeline .tl-note { margin-top: 6px; font-size: 12.5px; background: var(--surface-solid); border: 1px solid var(--line); border-radius: 10px; padding: 8px 10px; color: var(--text-2); white-space: pre-line; }

/* ---------- Charts -------------------------------------------------------- */
.bar-chart { display: grid; grid-template-columns: 34px minmax(0, 1fr); gap: 10px; height: 230px; }
.bar-axis { display: flex; flex-direction: column; justify-content: space-between; font-size: 11px; color: var(--muted); text-align: right; padding-bottom: 24px; }
.bar-area { position: relative; display: flex; align-items: flex-end; gap: 10px; padding-bottom: 24px; }
.bar-area::before { content: ""; position: absolute; inset: 0 0 24px 0; background: repeating-linear-gradient(to bottom, transparent 0, transparent calc(25% - 1px), var(--line) calc(25% - 1px), var(--line) 25%); pointer-events: none; }
.bar-col { position: relative; flex: 1; height: 100%; display: flex; align-items: flex-end; justify-content: center; gap: 4px; }
.bar {
  position: relative; width: 100%; max-width: 26px; min-height: 3px;
  border-radius: 8px 8px 6px 6px; background: var(--accent-200);
  transition: background .15s;
}
.bar.alt { background: #F3D9CF; max-width: 18px; }
.bar.peak { background: repeating-linear-gradient(135deg, var(--accent) 0 6px, #F2603F 6px 12px); box-shadow: 0 8px 18px rgba(241, 71, 37, .3); }
.bar-col:hover .bar { background: var(--accent-300); }
.bar-col:hover .bar.peak { background: repeating-linear-gradient(135deg, var(--accent-600) 0 6px, var(--accent) 6px 12px); }
.bar-label { position: absolute; bottom: -22px; left: 0; right: 0; text-align: center; font-size: 11.5px; color: var(--muted); font-weight: 600; }
.bar-tip { position: absolute; bottom: calc(100% + 8px); left: 50%; transform: translateX(-50%); font-size: 11.5px; font-weight: 700; white-space: nowrap; color: var(--text); background: var(--surface-solid); border: 1px solid var(--line); padding: 3px 8px; border-radius: 8px; box-shadow: var(--shadow-sm); opacity: 0; pointer-events: none; transition: opacity .12s; z-index: 2; }
.bar-col.is-peak .bar-tip { opacity: 1; }
.bar-area:hover .bar-col .bar-tip { opacity: 0; }
.bar-area:hover .bar-col:hover .bar-tip { opacity: 1; }
.legend { display: flex; gap: 14px; flex-wrap: wrap; font-size: 12px; color: var(--muted); font-weight: 600; }
.legend span { display: inline-flex; align-items: center; gap: 6px; }
.legend i { width: 10px; height: 10px; border-radius: 3px; display: inline-block; }

.donut-wrap { display: grid; place-items: center; padding: 6px 0; }
.donut { width: 210px; height: 210px; border-radius: 50%; display: grid; place-items: center; position: relative; }
.donut::after { content: ""; position: absolute; inset: 22px; border-radius: 50%; background: var(--surface-solid); box-shadow: inset 0 0 0 10px #FBF5F3; }
.donut-center { position: relative; z-index: 1; text-align: center; }
.donut-center strong { display: block; font-size: 28px; font-weight: 700; letter-spacing: -0.02em; }
.donut-center span { color: var(--muted); font-size: 12.5px; font-weight: 600; }
.mini-stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; text-align: center; }
.mini-stats small { display: block; color: var(--muted); font-size: 11.5px; font-weight: 600; }
.mini-stats strong { font-size: 16px; }
.progress { height: 8px; border-radius: 999px; background: var(--neutral-bg); overflow: hidden; }
.progress > span { display: block; height: 100%; border-radius: inherit; background: linear-gradient(90deg, var(--accent-300), var(--accent)); }

/* ---------- Modal (native <dialog>) --------------------------------------- */
dialog.modal {
  width: min(520px, calc(100vw - 32px)); padding: 0; border: 0;
  border-radius: 20px; box-shadow: var(--shadow-lg); background: var(--surface-solid); color: var(--text);
}
dialog.modal::backdrop { background: rgba(40, 20, 12, .4); backdrop-filter: blur(3px); }
.modal-head { display: flex; align-items: center; gap: 10px; padding: 18px 20px 0; }
.modal-head h3 { font-size: 17px; flex: 1; }
.modal-body { padding: 14px 20px; }
.modal-foot { display: flex; justify-content: flex-end; gap: 10px; padding: 0 20px 20px; }

/* ---------- Gallery ------------------------------------------------------- */
.gallery-main { aspect-ratio: 4 / 3; border-radius: 16px; background: #fff; border: 1px solid var(--line); display: grid; place-items: center; overflow: hidden; }
.gallery-main img { width: 100%; height: 100%; object-fit: contain; }
.gallery-thumbs { display: flex; gap: 8px; margin-top: 10px; flex-wrap: wrap; }
.gallery-thumbs button { width: 64px; height: 64px; padding: 0; border-radius: 12px; border: 2px solid var(--line); background: #fff; cursor: pointer; overflow: hidden; }
.gallery-thumbs button.active { border-color: var(--accent); }
.gallery-thumbs img { width: 100%; height: 100%; object-fit: contain; }

/* ---------- Auth pages ---------------------------------------------------- */
.auth { min-height: 100vh; display: grid; grid-template-columns: minmax(0, 1.05fr) minmax(0, 1fr); gap: 16px; padding: 16px; }
.auth-hero {
  position: relative; overflow: hidden; border-radius: 26px; padding: 40px;
  display: flex; flex-direction: column; justify-content: space-between; color: #FFF4EF;
  background:
    radial-gradient(500px 360px at 90% 10%, rgba(255, 140, 100, .55), transparent 65%),
    radial-gradient(500px 400px at 0% 100%, rgba(241, 71, 37, .55), transparent 60%),
    linear-gradient(150deg, #7A2E19 0%, #3B170D 100%);
  box-shadow: var(--shadow-lg);
}
.auth-hero::after { content: ""; position: absolute; inset: 0; background-image: radial-gradient(rgba(255,255,255,.08) 1px, transparent 1px); background-size: 22px 22px; pointer-events: none; }
.auth-hero > * { position: relative; z-index: 1; }
.auth-hero .brand-name { color: #fff; font-size: 22px; }
.auth-hero h2 { font-size: 36px; line-height: 1.15; max-width: 460px; letter-spacing: -0.02em; }
.auth-hero p { opacity: .85; max-width: 440px; margin-top: 14px; font-size: 15px; }
.auth-points { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; }
.auth-point { background: rgba(255, 255, 255, .1); border: 1px solid rgba(255, 255, 255, .16); border-radius: 16px; padding: 14px; backdrop-filter: blur(6px); }
.auth-point strong { display: block; font-size: 20px; }
.auth-point span { font-size: 12px; opacity: .8; }
.auth-panel { display: grid; place-items: center; padding: 24px; }
.auth-card { width: 100%; max-width: 420px; }
.auth-card h1 { font-size: 28px; letter-spacing: -0.02em; }
.auth-card .lead { color: var(--muted); margin: 6px 0 24px; }
.auth-card .card { padding: 28px; }
.auth-foot { text-align: center; color: var(--muted); font-size: 12.5px; margin-top: 18px; }

/* ---------- Error pages --------------------------------------------------- */
.error-page { min-height: 70vh; display: grid; place-items: center; text-align: center; }
.error-code { font-size: 72px; font-weight: 800; letter-spacing: -0.04em; color: var(--accent); line-height: 1; }

/* ---------- Responsive ---------------------------------------------------- */
@media (max-width: 1280px) {
  .grid-4 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .layout-main-side { grid-template-columns: minmax(0, 1fr) 300px; }
}
@media (max-width: 1080px) {
  .layout-main-side, .layout-side-main { grid-template-columns: minmax(0, 1fr); }
  .grid-3 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 920px) {
  .app { grid-template-columns: minmax(0, 1fr); padding: 12px; }
  .sidebar {
    position: fixed; top: 0; left: 0; bottom: 0; height: 100vh; height: 100dvh; width: 280px; z-index: 60;
    border-radius: 0 22px 22px 0; transform: translateX(-105%); transition: transform .25s ease;
    background: rgba(255, 250, 248, .97);
  }
  body.sidebar-open .sidebar { transform: none; }
  body.sidebar-open::after { content: ""; position: fixed; inset: 0; background: rgba(40, 20, 12, .35); z-index: 55; }
  .menu-toggle { display: inline-grid; }
  .topbar { top: 12px; padding-left: 12px; }
  .auth { grid-template-columns: minmax(0, 1fr); }
  .auth-hero { display: none; }
}
@media (max-width: 680px) {
  body { font-size: 14px; }
  .app { padding: 10px; gap: 12px; }
  .main { gap: 12px; }
  .grid-2, .grid-3, .grid-4, .form-grid, .form-grid-3 { grid-template-columns: minmax(0, 1fr); }
  .span-2 { grid-column: auto; }
  .card { padding: 16px; }
  .topbar h1 { font-size: 18px; }
  .user-chip .who { display: none; }
  .kv { grid-template-columns: minmax(0, 1fr); gap: 2px 0; }
  .kv dd { margin-bottom: 8px; }
  .stat-value { font-size: 26px; }
  .search-box { max-width: none; min-width: 0; width: 100%; }
  .filters .input { min-width: 0; flex: 1; }
  .bar-area { gap: 5px; }
  .hide-sm { display: none !important; }
}

/* ---------- Dashboard grid ------------------------------------------------ */
.dash { display: grid; gap: 16px; grid-template-columns: repeat(3, minmax(0, 1fr)) 340px; align-items: stretch; }
.dash .span-3 { grid-column: span 3; }
.dash .span-2c { grid-column: span 2; }
.dash .side { grid-column: 4; grid-row: span 2; }
.dash .side-1 { grid-column: 4; }
@media (max-width: 1280px) {
  .dash { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .dash .side, .dash .side-1 { grid-column: auto; grid-row: auto; }
  .dash .span-3 { grid-column: 1 / -1; }
}
@media (max-width: 920px) {
  .dash { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .dash .span-2c, .dash .span-3 { grid-column: 1 / -1; }
}
@media (max-width: 680px) {
  .dash { grid-template-columns: minmax(0, 1fr); }
  .dash > * { grid-column: auto !important; }
}
@media (max-width: 680px) {
  .bar-col.is-peak .bar-tip { opacity: 0; }
  .bar-tip { left: auto; right: 0; transform: none; }
}

/* ---------- Notifications ------------------------------------------------- */
.notif-menu { width: 360px; max-width: calc(100vw - 24px); padding: 6px; }
.notif-menu form { margin: 0; }
.notif-item { display: flex !important; align-items: flex-start !important; gap: 10px; white-space: normal; text-align: left; }
.notif-item.unread { background: var(--accent-50); }
.notif-dot { width: 8px; height: 8px; border-radius: 50%; margin-top: 6px; flex: none; background: var(--muted-2); }
.lvl-success { background: var(--success); } .lvl-warning { background: var(--warning); } .lvl-danger { background: var(--danger); } .lvl-info { background: var(--info); }
.notif-title { display: block; font-weight: 700; color: var(--text); font-size: 13px; }
.notif-body { display: block; color: var(--text-2); font-weight: 500; font-size: 12px; }
.notif-time { display: block; color: var(--muted); font-weight: 500; font-size: 11px; margin-top: 2px; }
.sum-row td { font-weight: 700; background: rgba(250, 245, 243, .9); }
.money-big { font-size: 26px; font-weight: 700; letter-spacing: -0.02em; }
.totals { width: 100%; max-width: 340px; margin-left: auto; font-size: 13.5px; }
.totals div { display: flex; justify-content: space-between; padding: 6px 0; }
.totals .grand { border-top: 1px solid var(--line); margin-top: 4px; padding-top: 10px; font-size: 16px; font-weight: 800; }
.picker { position: relative; }
.picker-results { position: absolute; left: 0; right: 0; top: calc(100% + 4px); z-index: 40; background: var(--surface-solid); border: 1px solid var(--line); border-radius: 12px; box-shadow: var(--shadow-lg); max-height: 320px; overflow-y: auto; display: none; }
.picker.open .picker-results { display: block; }
.picker-option { display: flex; gap: 10px; padding: 9px 12px; cursor: pointer; border-bottom: 1px solid var(--line); }
.picker-option:last-child { border-bottom: 0; }
.picker-option:hover, .picker-option.active { background: var(--accent-50); }
.picker-option strong { display: block; font-size: 13px; }
.picker-option small { color: var(--muted); font-size: 11.5px; }
.picker-chosen { display: none; align-items: center; gap: 10px; padding: 9px 12px; border-radius: 11px; background: var(--accent-50); border: 1px solid var(--accent-100); }
.picker.chosen .picker-chosen { display: flex; }
.picker.chosen .picker-input { display: none; }
.step-list { display: flex; gap: 6px; flex-wrap: wrap; }
.step { display: flex; align-items: center; gap: 6px; font-size: 12px; font-weight: 700; color: var(--muted); padding: 6px 10px; border-radius: 999px; background: var(--neutral-bg); }
.step.done { color: var(--success); background: var(--success-bg); }
.step.current { color: #fff; background: var(--accent); }
