:root {
  --brand: #123832;
  --brand-2: #0b2420;
  --brand-3: #1d4a42;
  --accent: #d9a441;
  --accent-2: #c48f2c;
  --accent-soft: #fbf1dc;

  --bg: #f5f4ef;
  --surface: #ffffff;
  --surface-2: #faf9f5;
  --ink: #17211e;
  --ink-2: #4b5a55;
  --ink-3: #87938e;
  --line: #e6e2d8;
  --line-2: #f0ede6;

  --green: #2f7a55;
  --green-soft: #dcefe4;
  --red: #b0432e;
  --red-soft: #f8dcd5;
  --yellow: #e4c05c;
  --yellow-soft: #fbf0cc;
  --peach: #e3b98c;
  --peach-soft: #f8e6d1;
  --blue: #3c6e9e;
  --blue-soft: #dde8f3;

  --radius-sm: 8px;
  --radius: 12px;
  --radius-lg: 16px;
  --shadow-sm: 0 1px 2px rgba(16, 40, 35, 0.06);
  --shadow: 0 1px 2px rgba(16, 40, 35, 0.05), 0 6px 20px rgba(16, 40, 35, 0.06);
  --shadow-lg: 0 20px 60px rgba(8, 28, 24, 0.28);
  --ring: 0 0 0 3px rgba(217, 164, 65, 0.22);

  --sidebar-w: 268px;
  --sidebar-w-collapsed: 78px;
  --header-h: 64px;
  --ease: cubic-bezier(0.2, 0.7, 0.2, 1);
}

* {
  box-sizing: border-box;
}
html,
body {
  margin: 0;
  padding: 0;
}
body {
  font-family: "Inter", system-ui, -apple-system, "Segoe UI", sans-serif;
  font-feature-settings: "cv11", "ss01";
  background: var(--bg);
  color: var(--ink);
  display: flex;
  min-height: 100vh;
  min-height: 100dvh;
  -webkit-font-smoothing: antialiased;
  font-size: 14px;
  line-height: 1.45;
}
h1,
h2,
h3 {
  letter-spacing: -0.02em;
}
button {
  font-family: inherit;
  -webkit-tap-highlight-color: transparent;
}
.i {
  width: 18px;
  height: 18px;
  flex-shrink: 0;
  stroke: currentColor;
  fill: none;
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
}

/* =====================================================
   SIDEBAR
   ===================================================== */
.sidebar {
  width: var(--sidebar-w);
  flex-shrink: 0;
  background:
    radial-gradient(120% 60% at 0% 0%, rgba(217, 164, 65, 0.1) 0%, transparent 55%),
    linear-gradient(180deg, var(--brand) 0%, var(--brand-2) 100%);
  color: #e8f1ec;
  display: flex;
  flex-direction: column;
  position: sticky;
  top: 0;
  height: 100vh;
  height: 100dvh;
  z-index: 30;
  transition: width 0.25s var(--ease);
  border-right: 1px solid rgba(255, 255, 255, 0.04);
}
.sidebar-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  height: var(--header-h);
  padding: 0 16px 0 18px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
  flex-shrink: 0;
}
.brand {
  display: flex;
  align-items: center;
  gap: 11px;
  cursor: pointer;
  min-width: 0;
  border-radius: 10px;
  padding: 4px;
  margin-left: -4px;
}
.brand-mark {
  height: 30px;
  display: flex;
  align-items: center;
  flex-shrink: 0;
}
.brand-mark img {
  height: 100%;
  width: auto;
  display: block;
}
.brand-text {
  line-height: 1.2;
  min-width: 0;
  white-space: nowrap;
}
.brand-text .name {
  font-weight: 700;
  font-size: 15px;
  color: #fff;
  overflow: hidden;
  text-overflow: ellipsis;
}
.brand-text .sub {
  font-size: 11px;
  color: #8fb0a3;
  font-weight: 500;
}
.sidebar-close {
  display: none;
  width: 34px;
  height: 34px;
  border: 0;
  border-radius: 9px;
  background: rgba(255, 255, 255, 0.08);
  color: #fff;
  cursor: pointer;
  place-items: center;
  flex-shrink: 0;
}
.sidebar-close:hover {
  background: rgba(255, 255, 255, 0.16);
}

.sidebar-nav {
  flex: 1;
  overflow-y: auto;
  overflow-x: hidden;
  padding: 14px 12px;
  scrollbar-width: thin;
  scrollbar-color: rgba(255, 255, 255, 0.15) transparent;
}
.nav-section + .nav-section {
  margin-top: 18px;
}
.nav-group-label {
  font-size: 10.5px;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: #6f9385;
  font-weight: 700;
  padding: 0 12px 8px;
  white-space: nowrap;
  overflow: hidden;
}
.nav-item {
  position: relative;
  display: flex;
  align-items: center;
  gap: 12px;
  width: 100%;
  height: 42px;
  padding: 0 12px;
  margin-bottom: 2px;
  border: 0;
  border-radius: 10px;
  background: transparent;
  font-size: 14px;
  font-weight: 500;
  color: #c8dad2;
  cursor: pointer;
  text-align: left;
  user-select: none;
  white-space: nowrap;
  transition:
    background 0.15s ease,
    color 0.15s ease;
}
.nav-item .i {
  width: 19px;
  height: 19px;
  opacity: 0.85;
}
.nav-label {
  flex: 1;
  overflow: hidden;
  text-overflow: ellipsis;
}
.nav-item:hover {
  background: rgba(255, 255, 255, 0.06);
  color: #fff;
}
.nav-item.active {
  background: rgba(255, 255, 255, 0.1);
  color: #fff;
  font-weight: 600;
}
.nav-item.active .i {
  color: var(--accent);
  opacity: 1;
}
.nav-item.active::before {
  content: "";
  position: absolute;
  left: -12px;
  top: 9px;
  bottom: 9px;
  width: 3px;
  border-radius: 0 3px 3px 0;
  background: var(--accent);
}
.nav-badge {
  min-width: 22px;
  height: 20px;
  padding: 0 7px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.1);
  color: #e8f1ec;
  font-size: 11px;
  font-weight: 700;
  display: inline-grid;
  place-items: center;
  font-variant-numeric: tabular-nums;
}
.nav-badge:empty {
  display: none;
}
.nav-badge.warn {
  background: var(--accent);
  color: #2b1f05;
}
.nav-item.danger:hover {
  background: rgba(176, 67, 46, 0.18);
  color: #ffd9d0;
}

.sidebar-foot {
  flex-shrink: 0;
  padding: 12px;
  border-top: 1px solid rgba(255, 255, 255, 0.08);
}
.user-card {
  display: flex;
  align-items: center;
  gap: 11px;
  padding: 10px;
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid rgba(255, 255, 255, 0.06);
}
.avatar {
  width: 36px;
  height: 36px;
  border-radius: 10px;
  background: linear-gradient(135deg, var(--accent) 0%, #e9c27a 100%);
  color: #2b1f05;
  font-weight: 800;
  font-size: 14px;
  display: grid;
  place-items: center;
  flex-shrink: 0;
}
.user-meta {
  flex: 1;
  min-width: 0;
  line-height: 1.25;
}
.user-meta strong {
  display: block;
  font-size: 13px;
  color: #fff;
  font-weight: 600;
}
.admin-user {
  font-size: 11.5px;
  color: #8fb0a3;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.logout-btn {
  width: 34px;
  height: 34px;
  border: 0;
  border-radius: 9px;
  background: transparent;
  color: #a9c3b8;
  display: grid;
  place-items: center;
  cursor: pointer;
  flex-shrink: 0;
  transition:
    background 0.15s ease,
    color 0.15s ease;
}
.logout-btn:hover {
  background: rgba(176, 67, 46, 0.22);
  color: #ffd9d0;
}

/* collapsed sidebar (desktop) */
@media (min-width: 961px) {
  body.sb-collapsed .sidebar {
    width: var(--sidebar-w-collapsed);
  }
  body.sb-collapsed .brand-text,
  body.sb-collapsed .nav-label,
  body.sb-collapsed .nav-badge,
  body.sb-collapsed .user-meta,
  body.sb-collapsed .avatar {
    display: none;
  }
  body.sb-collapsed .sidebar-head {
    justify-content: center;
    padding: 0;
  }
  body.sb-collapsed .brand {
    margin: 0;
  }
  body.sb-collapsed .nav-group-label {
    text-align: center;
    padding: 0 0 8px;
    font-size: 0;
  }
  body.sb-collapsed .nav-group-label::after {
    content: "";
    display: block;
    width: 20px;
    height: 1px;
    margin: 6px auto 0;
    background: rgba(255, 255, 255, 0.15);
  }
  body.sb-collapsed .nav-item {
    justify-content: center;
    padding: 0;
  }
  body.sb-collapsed .user-card {
    justify-content: center;
    padding: 8px 0;
    background: transparent;
    border-color: transparent;
  }
  body.sb-collapsed .nav-item[data-tip]:hover::after {
    content: attr(data-tip);
    position: absolute;
    left: calc(100% + 12px);
    top: 50%;
    transform: translateY(-50%);
    background: var(--ink);
    color: #fff;
    font-size: 12px;
    font-weight: 600;
    padding: 6px 10px;
    border-radius: 7px;
    white-space: nowrap;
    box-shadow: var(--shadow);
    pointer-events: none;
    z-index: 50;
  }
  body.sb-collapsed .sidebar-nav {
    overflow: visible;
  }
}

.sidebar-backdrop {
  display: none;
  position: fixed;
  inset: 0;
  z-index: 29;
  background: rgba(8, 24, 21, 0.5);
  backdrop-filter: blur(2px);
  -webkit-backdrop-filter: blur(2px);
}
.sidebar-backdrop.show {
  display: block;
  animation: fadeIn 0.2s ease;
}
body.sidebar-locked {
  overflow: hidden;
}

/* =====================================================
   MAIN + HEADER
   ===================================================== */
.main {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
}
.app-header {
  position: sticky;
  top: 0;
  z-index: 20;
  height: var(--header-h);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 0 32px;
  background: rgba(245, 244, 239, 0.86);
  backdrop-filter: saturate(160%) blur(10px);
  -webkit-backdrop-filter: saturate(160%) blur(10px);
  border-bottom: 1px solid var(--line);
}
.header-left,
.header-right {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 0;
}
.icon-btn {
  width: 38px;
  height: 38px;
  border-radius: 10px;
  border: 1px solid var(--line);
  background: var(--surface);
  color: var(--ink-2);
  display: grid;
  place-items: center;
  cursor: pointer;
  flex-shrink: 0;
  transition:
    background 0.15s ease,
    color 0.15s ease,
    border-color 0.15s ease;
}
.icon-btn:hover {
  background: var(--surface-2);
  color: var(--ink);
  border-color: #d8d3c6;
}
.menu-toggle {
  display: none;
}
.crumbs {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13.5px;
  color: var(--ink-3);
  min-width: 0;
  white-space: nowrap;
}
.crumbs .sep {
  opacity: 0.5;
}
.crumbs strong {
  color: var(--ink);
  font-weight: 600;
  overflow: hidden;
  text-overflow: ellipsis;
}
.save-chip {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  height: 34px;
  padding: 0 12px;
  border-radius: 999px;
  background: var(--surface);
  border: 1px solid var(--line);
  font-size: 12.5px;
  font-weight: 500;
  color: var(--ink-2);
  white-space: nowrap;
}
.dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--green);
  box-shadow: 0 0 0 3px var(--green-soft);
}
.dot.saving {
  background: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
  animation: pulse 1s infinite;
}
.today-chip {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  height: 36px;
  padding: 0 14px;
  border-radius: 999px;
  background: var(--surface);
  border: 1px solid var(--line);
  font-size: 13px;
  color: var(--ink);
  font-weight: 500;
  white-space: nowrap;
  font-variant-numeric: tabular-nums;
}
.today-chip .i {
  width: 16px;
  height: 16px;
  color: var(--accent-2);
}
.today-chip .d-short {
  display: none;
}
.chip-sep {
  width: 1px;
  height: 16px;
  background: var(--line);
  margin: 0 2px;
}
.save-chip[hidden] {
  display: none;
}
@keyframes pulse {
  0%,
  100% {
    opacity: 1;
  }
  50% {
    opacity: 0.35;
  }
}

.content {
  width: 100%;
  max-width: 1480px;
  margin: 0 auto;
  padding: 28px 32px 64px;
}

/* page head */
.topbar {
  display: flex;
  justify-content: space-between;
  align-items: flex-end;
  gap: 16px;
  flex-wrap: wrap;
  margin-bottom: 22px;
}
.topbar h1 {
  font-size: 26px;
  font-weight: 700;
  margin: 0 0 4px;
  line-height: 1.2;
}
.topbar p {
  margin: 0;
  color: var(--ink-2);
  font-size: 14px;
}
.topbar-actions {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}

/* buttons */
.add-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  height: 40px;
  padding: 0 16px;
  border: 1px solid transparent;
  border-radius: 10px;
  background: var(--brand);
  color: #fff;
  font-size: 13.5px;
  font-weight: 600;
  cursor: pointer;
  white-space: nowrap;
  box-shadow:
    0 1px 2px rgba(16, 40, 35, 0.2),
    inset 0 1px 0 rgba(255, 255, 255, 0.08);
  transition:
    background 0.15s ease,
    transform 0.12s ease,
    box-shadow 0.15s ease;
}
.add-btn .i {
  width: 17px;
  height: 17px;
}
.add-btn:hover {
  background: var(--brand-3);
}
.add-btn:active {
  transform: translateY(1px);
}
.ghost-btn {
  background: var(--surface);
  color: var(--ink);
  border-color: var(--line);
  box-shadow: var(--shadow-sm);
}
.ghost-btn:hover {
  background: var(--surface-2);
  border-color: #d8d3c6;
}
.danger-btn {
  background: var(--surface);
  color: var(--red);
  border-color: #efc8bf;
  box-shadow: none;
}
.danger-btn:hover {
  background: var(--red);
  color: #fff;
  border-color: var(--red);
}

/* =====================================================
   STAT CARDS
   ===================================================== */
.stats {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(190px, 1fr));
  gap: 14px;
  margin-bottom: 22px;
}
.stat-card {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 16px 18px;
  box-shadow: var(--shadow-sm);
  min-width: 0;
  transition:
    box-shadow 0.18s ease,
    transform 0.18s ease;
}
.stat-card:hover {
  box-shadow: var(--shadow);
  transform: translateY(-1px);
}
.stat-body {
  min-width: 0;
}
.stat-card .lab {
  font-size: 12.5px;
  color: var(--ink-2);
  font-weight: 500;
  margin-bottom: 8px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.stat-card .val {
  font-size: 24px;
  font-weight: 700;
  letter-spacing: -0.02em;
  color: var(--ink);
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.stat-card .val small {
  font-size: 13px;
  font-weight: 600;
  color: var(--ink-3);
}
.stat-ic {
  width: 38px;
  height: 38px;
  border-radius: 10px;
  display: grid;
  place-items: center;
  flex-shrink: 0;
}
.stat-ic .i {
  width: 19px;
  height: 19px;
}
.tone-brand {
  background: #e1ece7;
  color: var(--brand);
}
.tone-accent {
  background: var(--accent-soft);
  color: #9a6c14;
}
.tone-peach {
  background: var(--peach-soft);
  color: #95592a;
}
.tone-green {
  background: var(--green-soft);
  color: var(--green);
}
.tone-blue {
  background: var(--blue-soft);
  color: var(--blue);
}
.tone-red {
  background: var(--red-soft);
  color: var(--red);
}

/* =====================================================
   TABLES
   ===================================================== */
.table-card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  overflow: hidden;
  box-shadow: var(--shadow-sm);
}
.table-scroll {
  overflow-x: auto;
}
table {
  width: 100%;
  border-collapse: collapse;
  min-width: 920px;
}
thead th {
  background: var(--surface-2);
  color: var(--ink-3);
  text-align: left;
  font-size: 11.5px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  font-weight: 600;
  padding: 12px 14px;
  white-space: nowrap;
  border-bottom: 1px solid var(--line);
}
tbody tr {
  border-bottom: 1px solid var(--line-2);
  transition: background 0.12s ease;
}
tbody tr:last-child {
  border-bottom: 0;
}
tbody tr:hover {
  background: #fbfaf6;
}
tbody td {
  padding: 8px 14px;
  font-size: 13.5px;
  vertical-align: middle;
}
#custBody td {
  padding: 14px;
}
#custBody td:first-child {
  font-weight: 600;
}
td.date-cell {
  white-space: nowrap;
  color: var(--ink-2);
}
td input[type="text"],
td input[type="date"],
td input[type="number"] {
  width: 100%;
  height: 36px;
  border: 1px solid transparent;
  background: transparent;
  font-family: inherit;
  font-size: 13.5px;
  padding: 0 10px;
  border-radius: 8px;
  color: var(--ink);
  transition:
    border-color 0.12s ease,
    background 0.12s ease,
    box-shadow 0.12s ease;
}
td input::placeholder {
  color: #b5bdb9;
}
td input:hover {
  border-color: var(--line);
  background: var(--surface);
}
td input:focus {
  outline: none;
  border-color: var(--accent);
  background: #fff;
  box-shadow: var(--ring);
}
td.price-cell {
  white-space: nowrap;
}
td.price-cell input {
  width: calc(100% - 16px);
  min-width: 72px;
  text-align: right;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
}
.cur {
  color: var(--ink-3);
  font-size: 12px;
  margin-left: 4px;
}

select.tag-select {
  appearance: none;
  -webkit-appearance: none;
  border: 1px solid transparent;
  border-radius: 999px;
  height: 30px;
  padding: 0 28px 0 12px;
  font-family: inherit;
  font-size: 12.5px;
  font-weight: 600;
  cursor: pointer;
  background-repeat: no-repeat;
  background-position: right 10px center;
  background-size: 9px;
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='10' height='6' viewBox='0 0 10 6'><path d='M1 1l4 4 4-4' stroke='%23000' stroke-opacity='.45' stroke-width='1.6' fill='none' stroke-linecap='round'/></svg>");
  width: 100%;
  min-width: 104px;
}
select.pay-kredit {
  background-color: var(--peach-soft);
  color: #85501f;
  border-color: #efd3b3;
}
select.pay-nagd {
  background-color: var(--green-soft);
  color: #1f5c3e;
  border-color: #bfe0cd;
}
select.chan-gulzar {
  background-color: var(--red-soft);
  color: #8e3423;
  border-color: #f0c2b7;
}
select.chan-azmall {
  background-color: var(--yellow-soft);
  color: #6e560f;
  border-color: #f0dd9e;
}
select.chan-empty {
  background-color: #eef0ee;
  color: var(--ink-2);
  border-color: #e0e3e0;
}
.custom-channel,
.custom-payment {
  margin-top: 6px;
  border-color: var(--line) !important;
  background: var(--surface) !important;
}
td.payment-cell {
  min-width: 150px;
}
td.channel-cell {
  min-width: 160px;
}
thead th,
tbody td {
  padding-left: 10px;
  padding-right: 10px;
}
td.payment-cell select,
td.channel-cell select {
  width: max-content;
  min-width: 0;
}
td.name-cell {
  min-width: 170px;
}
td.name-cell input {
  min-width: 150px;
  font-weight: 500;
}
td.phone-cell {
  min-width: 150px;
}
td.bike-field {
  min-width: 110px;
}
td.qty-cell input {
  text-align: center;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}

.status-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  height: 26px;
  padding: 0 10px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 600;
  white-space: nowrap;
}
.status-badge::before {
  content: "";
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: currentColor;
}
.status-ok {
  background: var(--green-soft);
  color: #1f5c3e;
}
.status-low {
  background: var(--yellow-soft);
  color: #7a5c0e;
}
.status-out {
  background: var(--red-soft);
  color: #8e3423;
}

.row-actions {
  text-align: center;
  width: 52px;
}
.del-btn {
  width: 34px;
  height: 34px;
  border: 0;
  background: transparent;
  color: var(--ink-3);
  cursor: pointer;
  border-radius: 8px;
  display: inline-grid;
  place-items: center;
  transition:
    background 0.12s ease,
    color 0.12s ease;
}
.del-btn .i {
  width: 17px;
  height: 17px;
}
.del-btn:hover {
  background: var(--red-soft);
  color: var(--red);
}
tbody tr.row-new {
  animation: rowFlash 1.6s ease;
}
@keyframes rowFlash {
  0%,
  40% {
    background: var(--accent-soft);
    box-shadow: 0 0 0 2px var(--accent);
  }
  100% {
    box-shadow: 0 0 0 0 transparent;
  }
}
.empty-row td {
  text-align: center;
  padding: 56px 16px !important;
  color: var(--ink-3);
  font-size: 14px;
}
.empty-row:hover {
  background: transparent !important;
}

/* =====================================================
   PANELS (stats + settings)
   ===================================================== */
.panel-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 16px;
}
.panel-card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  padding: 22px 24px;
  box-shadow: var(--shadow-sm);
  min-width: 0;
}
.panel-card h3 {
  display: flex;
  align-items: center;
  gap: 10px;
  margin: 0 0 18px;
  font-size: 15px;
  font-weight: 650;
  color: var(--ink);
}
.panel-card h3 .i {
  color: var(--ink-3);
}
.panel-wide {
  grid-column: 1 / -1;
}
.bar-row {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 14px;
}
.bar-row:last-child {
  margin-bottom: 0;
}
.bar-row .bar-label {
  width: 130px;
  font-size: 13px;
  font-weight: 500;
  color: var(--ink-2);
  flex-shrink: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.bar-track {
  flex: 1;
  height: 10px;
  background: var(--line-2);
  border-radius: 999px;
  overflow: hidden;
}
.bar-fill {
  height: 100%;
  border-radius: 999px;
  transition: width 0.5s var(--ease);
}
.bar-fill.fill-kredit {
  background: var(--peach);
}
.bar-fill.fill-nagd {
  background: var(--green);
}
.bar-fill.fill-custom,
.bar-fill.fill-model {
  background: var(--accent);
}
.bar-fill.fill-gulzar {
  background: var(--red);
}
.bar-fill.fill-azmall {
  background: var(--yellow);
}
.bar-row .bar-val {
  width: 40px;
  text-align: right;
  font-size: 13px;
  font-weight: 700;
  color: var(--ink);
  flex-shrink: 0;
  font-variant-numeric: tabular-nums;
}
.bar-empty {
  color: var(--ink-3);
  font-size: 13px;
  padding: 18px 0;
  text-align: center;
}

/* filters / inputs */
.search-wrap {
  position: relative;
}
.search-wrap .i {
  position: absolute;
  left: 12px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--ink-3);
  width: 17px;
  height: 17px;
  pointer-events: none;
}
.search-input {
  height: 40px;
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 0 14px 0 38px;
  font-size: 13.5px;
  font-family: inherit;
  min-width: 260px;
  background: var(--surface);
  color: var(--ink);
  box-shadow: var(--shadow-sm);
}
.search-input:focus,
.date-filter input:focus,
.text-input:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: var(--ring);
  background: #fff;
}
.date-filter {
  display: flex;
  align-items: flex-end;
  gap: 14px;
  flex-wrap: wrap;
  margin: 0 0 18px;
  padding: 14px 16px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
}
.date-filter-field {
  display: flex;
  flex-direction: column;
  min-width: 170px;
}
.date-filter .field-label {
  margin: 0 0 6px;
}
.date-filter input {
  height: 38px;
  border: 1px solid var(--line);
  border-radius: 9px;
  padding: 0 10px;
  font-size: 13.5px;
  font-family: inherit;
  background: var(--surface-2);
  color: var(--ink);
}
.field-label {
  display: block;
  font-size: 12.5px;
  color: var(--ink-2);
  font-weight: 600;
  margin: 14px 0 6px;
}
.field-label:first-of-type {
  margin-top: 0;
}
.text-input {
  width: 100%;
  height: 42px;
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 0 12px;
  font-size: 14px;
  font-family: inherit;
  background: var(--surface-2);
  color: var(--ink);
}
.muted {
  color: var(--ink-2);
  font-size: 13.5px;
  margin: 0 0 16px;
}
.btn-stack {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}
.settings-actions {
  margin-top: 18px;
}

::-webkit-scrollbar {
  height: 8px;
  width: 8px;
}
::-webkit-scrollbar-thumb {
  background: #d9d4c8;
  border-radius: 8px;
}

.view {
  animation: fadeIn 0.22s var(--ease);
}
@keyframes fadeIn {
  from {
    opacity: 0;
    transform: translateY(4px);
  }
  to {
    opacity: 1;
    transform: none;
  }
}
a:focus-visible,
button:focus-visible,
.brand:focus-visible,
select:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

/* =====================================================
   LOGIN
   ===================================================== */
.login-screen {
  position: fixed;
  inset: 0;
  z-index: 9999;
  display: grid;
  grid-template-columns: minmax(0, 1.05fr) minmax(0, 1fr);
  background: var(--bg);
  overflow-y: auto;
}
.login-aside {
  position: relative;
  overflow: hidden;
  background:
    radial-gradient(80% 60% at 10% 10%, rgba(217, 164, 65, 0.22) 0%, transparent 60%),
    radial-gradient(70% 60% at 90% 100%, rgba(62, 122, 91, 0.35) 0%, transparent 60%),
    linear-gradient(160deg, var(--brand) 0%, var(--brand-2) 100%);
  color: #e8f1ec;
  padding: 48px 56px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
}
.login-aside::after {
  content: "";
  position: absolute;
  inset: 0;
  background-image:
    linear-gradient(rgba(255, 255, 255, 0.04) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255, 255, 255, 0.04) 1px, transparent 1px);
  background-size: 44px 44px;
  mask-image: linear-gradient(180deg, transparent 0%, #000 40%, transparent 100%);
  -webkit-mask-image: linear-gradient(180deg, transparent 0%, #000 40%, transparent 100%);
  pointer-events: none;
}
.login-aside > * {
  position: relative;
  z-index: 1;
}
.login-aside .brand-mark,
.login-logo .brand-mark {
  height: 40px;
}
.aside-brand {
  display: flex;
  align-items: center;
  gap: 12px;
  font-weight: 700;
  font-size: 18px;
  color: #fff;
}
.aside-copy h2 {
  font-size: clamp(28px, 3vw, 40px);
  line-height: 1.12;
  margin: 0 0 14px;
  color: #fff;
  max-width: 480px;
}
.aside-copy p {
  margin: 0;
  max-width: 440px;
  color: #a9c3b8;
  font-size: 15px;
}
.aside-features {
  display: grid;
  gap: 12px;
  margin-top: 32px;
  padding: 0;
  list-style: none;
}
.aside-features li {
  display: flex;
  align-items: center;
  gap: 12px;
  font-size: 14px;
  color: #d4e4dc;
}
.aside-features .i {
  width: 30px;
  height: 30px;
  padding: 6px;
  border-radius: 9px;
  background: rgba(255, 255, 255, 0.08);
  color: var(--accent);
}
.aside-foot {
  font-size: 12.5px;
  color: #6f9385;
}
.login-main {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 40px 24px;
}
.login-card {
  width: min(400px, 100%);
}
.login-logo {
  display: none;
  align-items: center;
  gap: 12px;
  margin-bottom: 28px;
}
.login-logo strong {
  display: block;
  font-size: 18px;
  color: var(--ink);
}
.login-logo span {
  display: block;
  font-size: 12.5px;
  color: var(--ink-3);
}
.login-card h2 {
  margin: 0 0 6px;
  font-size: 26px;
  color: var(--ink);
}
.login-card > p {
  margin: 0 0 28px;
  color: var(--ink-2);
  font-size: 14px;
}
.login-field {
  margin-bottom: 16px;
}
.login-field label {
  display: block;
  font-size: 13px;
  font-weight: 600;
  margin-bottom: 7px;
  color: var(--ink);
}
.input-wrap {
  position: relative;
}
.input-wrap > .i {
  position: absolute;
  left: 13px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--ink-3);
  width: 17px;
  height: 17px;
  pointer-events: none;
}
.login-field input {
  width: 100%;
  height: 46px;
  padding: 0 44px 0 40px;
  border: 1px solid var(--line);
  border-radius: 11px;
  font: inherit;
  font-size: 14.5px;
  background: var(--surface);
  color: var(--ink);
  outline: none;
  transition:
    border-color 0.15s ease,
    box-shadow 0.15s ease;
}
.login-field input:focus {
  border-color: var(--accent);
  box-shadow: var(--ring);
}
.pw-toggle {
  position: absolute;
  right: 6px;
  top: 50%;
  transform: translateY(-50%);
  width: 34px;
  height: 34px;
  border: 0;
  background: transparent;
  color: var(--ink-3);
  border-radius: 8px;
  display: grid;
  place-items: center;
  cursor: pointer;
}
.pw-toggle:hover {
  color: var(--ink);
  background: var(--line-2);
}
.login-btn {
  width: 100%;
  height: 46px;
  border: 0;
  border-radius: 11px;
  background: var(--brand);
  color: #fff;
  font-size: 14.5px;
  font-weight: 600;
  cursor: pointer;
  margin-top: 6px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  box-shadow: 0 6px 18px rgba(18, 56, 50, 0.25);
  transition:
    background 0.15s ease,
    transform 0.12s ease;
}
.login-btn:hover {
  background: var(--brand-3);
}
.login-btn:active {
  transform: translateY(1px);
}
.login-error {
  min-height: 20px;
  color: var(--red);
  font-size: 13px;
  font-weight: 500;
  margin: 12px 0 0;
}
.login-note {
  margin-top: 28px;
  font-size: 12.5px;
  color: var(--ink-3);
  text-align: center;
}
body.locked .sidebar,
body.locked .main {
  display: none;
}

/* =====================================================
   RESPONSIVE
   ===================================================== */
@media (max-width: 1200px) {
  .app-header {
    padding: 0 24px;
  }
  .content {
    padding: 24px 24px 56px;
  }
}

@media (max-width: 960px) {
  .sidebar {
    position: fixed;
    left: 0;
    top: 0;
    bottom: 0;
    width: min(290px, 86vw);
    transform: translateX(-100%);
    transition:
      transform 0.28s var(--ease),
      visibility 0.28s;
    visibility: hidden;
  }
  .sidebar.open {
    transform: translateX(0);
    visibility: visible;
    box-shadow: var(--shadow-lg);
  }
  .sidebar-close {
    display: grid;
  }
  .collapse-btn {
    display: none;
  }
  .menu-toggle {
    display: grid;
  }
  .panel-grid {
    grid-template-columns: 1fr;
  }
  .login-screen {
    grid-template-columns: 1fr;
  }
  .login-aside {
    display: none;
  }
  .login-logo {
    display: flex;
  }
}

@media (max-width: 720px) {
  .app-header {
    padding: 0 16px;
    gap: 8px;
  }
  .crumbs .crumb-root,
  .crumbs .sep {
    display: none;
  }
  .today-chip {
    padding: 0 10px;
    gap: 6px;
  }
  .today-chip .d-long {
    display: none;
  }
  .today-chip .d-short {
    display: inline;
  }
  .content {
    padding: 20px 16px 48px;
  }
  .topbar {
    align-items: stretch;
    flex-direction: column;
    margin-bottom: 18px;
  }
  .topbar h1 {
    font-size: 22px;
  }
  .topbar-actions,
  .topbar-actions .add-btn,
  .search-wrap,
  .search-input {
    width: 100%;
    min-width: 0;
  }
  .stats {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 10px;
  }
  .stat-card {
    padding: 12px;
    gap: 8px;
  }
  .stat-card .lab {
    font-size: 12px;
    margin-bottom: 4px;
  }
  .stat-ic {
    width: 30px;
    height: 30px;
    border-radius: 8px;
  }
  .stat-ic .i {
    width: 16px;
    height: 16px;
  }
  .stat-card .val {
    font-size: 20px;
  }
  .panel-card {
    padding: 18px;
  }
  .bar-row .bar-label {
    width: 96px;
  }
  .date-filter-field {
    flex: 1 1 140px;
    min-width: 0;
  }
  .date-filter input {
    width: 100%;
  }
  .btn-stack .add-btn {
    flex: 1 1 100%;
  }

  /* tables become cards */
  .table-scroll {
    overflow-x: visible;
  }
  table {
    min-width: 0;
  }
  thead {
    position: absolute;
    width: 1px;
    height: 1px;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    border: 0;
  }
  table,
  tbody,
  tr,
  td {
    display: block;
    width: 100%;
  }
  .table-card {
    background: transparent;
    border: 0;
    box-shadow: none;
    border-radius: 0;
    overflow: visible;
  }
  tbody tr,
  tbody tr:last-child {
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    box-shadow: var(--shadow-sm);
    margin-bottom: 12px;
    padding: 4px 2px;
  }
  tbody tr:hover {
    background: var(--surface);
  }
  tbody tr.empty-row {
    box-shadow: none;
    border-style: dashed;
  }
  tbody td,
  #custBody td {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 8px 12px;
    border-bottom: 1px solid var(--line-2);
    min-height: 46px;
  }
  tr td:last-child {
    border-bottom: 0;
  }
  td[data-label]:not([data-label=""])::before {
    content: attr(data-label);
    font-size: 12px;
    font-weight: 600;
    color: var(--ink-3);
    flex-shrink: 0;
    min-width: 92px;
  }
  td input,
  td select,
  td.name-cell input {
    width: auto;
    flex: 1;
    min-width: 0;
  }
  td.name-cell,
  td.phone-cell,
  td.bike-field,
  td.payment-cell,
  td.channel-cell {
    min-width: 0;
  }
  td.payment-cell,
  td.channel-cell {
    flex-wrap: wrap;
  }
  td.payment-cell select,
  td.channel-cell select {
    flex: 1;
    width: auto;
  }
  td.payment-cell .custom-payment,
  td.channel-cell .custom-channel {
    flex-basis: 100%;
    margin-left: 104px;
  }
  td.price-cell input {
    width: auto;
  }
  .row-actions {
    display: flex !important;
    justify-content: flex-end;
    width: 100%;
    min-height: 0 !important;
  }
  .empty-row td {
    display: block;
    text-align: center;
  }
  .empty-row td::before {
    content: none !important;
  }
}

@media (max-width: 420px) {
  .stat-card .val {
    font-size: 18px;
  }
  .save-chip span:last-child {
    display: none;
  }
  td.payment-cell .custom-payment,
  td.channel-cell .custom-channel {
    margin-left: 0;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation: none !important;
    transition: none !important;
  }
}
