/* ==========================================================================
   K S M Medicals — Wholesale Purchase & Payment Management
   Main stylesheet · medical teal/emerald theme
   ========================================================================== */

:root {
  --brand:        #0e9f6e;
  --brand-600:    #0b8a5f;
  --brand-700:    #067a52;
  --brand-800:    #065f46;
  --brand-900:    #05372a;
  --teal:         #0d9488;
  --cyan:         #0891b2;

  --ink:          #0f2027;
  --ink-2:        #2c3f4a;
  --slate:        #5b7280;
  --muted:        #7c8f9b;
  --line:         #dfe9e6;
  --line-soft:    #ecf4f1;
  --bg:           #f2f7f5;
  --card:         #ffffff;
  --card-2:       #f8fbfa;

  --danger:       #e11d48;
  --danger-soft:  #fff1f4;
  --warn:         #d97706;
  --warn-soft:    #fff8ed;
  --ok:           #059669;
  --ok-soft:      #ecfdf5;
  --info:         #0284c7;
  --info-soft:    #eff9ff;
  --violet:       #7c3aed;

  --r-xl: 20px;
  --r-lg: 16px;
  --r-md: 12px;
  --r-sm: 9px;

  --sh-1: 0 1px 2px rgba(15, 32, 39, .05), 0 1px 3px rgba(15, 32, 39, .04);
  --sh-2: 0 2px 4px rgba(15, 32, 39, .04), 0 8px 22px -12px rgba(15, 32, 39, .18);
  --sh-3: 0 14px 40px -14px rgba(15, 32, 39, .26), 0 4px 12px -6px rgba(15, 32, 39, .10);
  --sh-brand: 0 12px 26px -14px rgba(14, 159, 110, .75);

  --ff: 'Plus Jakarta Sans', ui-sans-serif, system-ui, -apple-system, 'Segoe UI', Roboto, Arial, sans-serif;
  --side-w: 264px;
}

* { box-sizing: border-box; }
*::selection { background: #b8f0dd; color: var(--brand-900); }

html, body { height: 100%; }

body {
  margin: 0;
  font-family: var(--ff);
  color: var(--ink);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  font-size: 15px;
  line-height: 1.5;
}

body::before {
  content: '';
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 0;
  background:
    radial-gradient(900px 460px at 88% -8%, rgba(13, 148, 136, .10), transparent 60%),
    radial-gradient(760px 420px at -6% 102%, rgba(14, 159, 110, .10), transparent 62%);
}

h1, h2, h3, h4 { margin: 0; font-weight: 700; letter-spacing: -.015em; color: var(--ink); }
p { margin: 0; }
a { color: var(--brand-700); }
code {
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  background: var(--line-soft);
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 1px 6px;
  font-size: .84em;
  color: var(--brand-800);
}

.muted { color: var(--muted); }
.nowrap { white-space: nowrap; }
.hidden { display: none !important; }
[hidden] { display: none !important; }

svg.ico {
  width: 18px; height: 18px;
  flex: 0 0 auto;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.75;
  stroke-linecap: round;
  stroke-linejoin: round;
}

/* ============================== BUTTONS ============================== */
.btn {
  --btn-bg: var(--card);
  --btn-fg: var(--ink-2);
  --btn-bd: var(--line);
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  font: inherit; font-weight: 650; font-size: .875rem;
  padding: 10px 16px;
  border-radius: var(--r-md);
  border: 1px solid var(--btn-bd);
  background: var(--btn-bg);
  color: var(--btn-fg);
  cursor: pointer;
  transition: transform .12s ease, box-shadow .18s ease, background .18s ease, border-color .18s ease, color .18s;
  white-space: nowrap;
  text-decoration: none;
  line-height: 1.2;
}
.btn:hover { transform: translateY(-1px); box-shadow: var(--sh-2); }
.btn:active { transform: translateY(0); }
.btn:disabled { opacity: .5; cursor: not-allowed; transform: none; box-shadow: none; }
.btn:focus-visible, .icon-btn:focus-visible, .input:focus-visible, .select:focus-visible,
.nav-item:focus-visible, a:focus-visible, .seg-btn:focus-visible, .chip:focus-visible {
  outline: 2px solid var(--brand); outline-offset: 2px;
}

.btn-primary { --btn-bd: transparent; --btn-fg: #fff; background-image: linear-gradient(135deg, var(--brand) 0%, var(--brand-700) 58%, var(--teal) 130%); box-shadow: var(--sh-brand); }
.btn-primary:hover { box-shadow: 0 16px 30px -14px rgba(14, 159, 110, .85); }
.btn-dark { --btn-bd: transparent; --btn-fg: #fff; background: linear-gradient(135deg, #17323c, #0f2027); }
.btn-outline { --btn-bd: var(--line); --btn-fg: var(--brand-800); background: #fff; }
.btn-outline:hover { border-color: #bfe6d8; background: #f6fdfa; }
.btn-ghost { --btn-bd: transparent; --btn-bg: transparent; --btn-fg: var(--slate); }
.btn-ghost:hover { --btn-bg: var(--line-soft); box-shadow: none; }
.btn-danger { --btn-bd: transparent; --btn-fg: #fff; background: linear-gradient(135deg, #f43f5e, #be123c); }
.btn-warn { --btn-bd: transparent; --btn-fg: #fff; background: linear-gradient(135deg, #f59e0b, #c2410c); }
.btn-sm { padding: 7px 12px; font-size: .8rem; border-radius: var(--r-sm); }
.btn-sm svg.ico { width: 15px; height: 15px; }
.btn-lg { padding: 13px 22px; font-size: .95rem; }
.btn-block { width: 100%; }

.icon-btn {
  display: inline-flex; align-items: center; justify-content: center;
  width: 34px; height: 34px;
  border-radius: 10px;
  border: 1px solid var(--line);
  background: #fff;
  color: var(--slate);
  cursor: pointer;
  transition: all .15s ease;
}
.icon-btn:hover { color: var(--brand-700); border-color: #bfe6d8; background: #f6fdfa; }
.icon-btn.danger:hover { color: var(--danger); border-color: #f8c6d1; background: var(--danger-soft); }
.icon-btn.flat { border-color: transparent; background: transparent; }

/* ============================== FORMS ============================== */
.field { display: flex; flex-direction: column; gap: 7px; }
.field > span:first-child, .field > label:first-child {
  font-size: .78rem; font-weight: 700; letter-spacing: .02em;
  text-transform: uppercase; color: var(--slate);
}
.field .hint { text-transform: none; letter-spacing: 0; font-weight: 600; color: var(--muted); font-size: .74rem; }

.input, .select, textarea.input {
  width: 100%;
  font: inherit; font-size: .9rem;
  color: var(--ink);
  padding: 10px 12px;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: var(--r-md);
  transition: border-color .16s, box-shadow .16s, background .16s;
  appearance: none;
}
.select {
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%237c8f9b' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 10px center;
  background-size: 15px;
  padding-right: 32px;
}
.input:focus, .select:focus, textarea.input:focus {
  outline: none;
  border-color: var(--brand);
  box-shadow: 0 0 0 4px rgba(14, 159, 110, .14);
}
textarea.input { min-height: 84px; resize: vertical; }
.input::placeholder { color: #a9b8c1; }

.input-wrap { position: relative; display: block; }
.input-wrap > svg.ico {
  position: absolute; left: 12px; top: 50%; transform: translateY(-50%);
  color: var(--muted); width: 17px; height: 17px;
}
.input-wrap .input { padding-left: 38px; }
.input-wrap .reveal {
  position: absolute; right: 6px; top: 50%; transform: translateY(-50%);
  border: 0; background: transparent; color: var(--muted); cursor: pointer;
  width: 32px; height: 32px; border-radius: 8px; display: grid; place-items: center;
}
.input-wrap .reveal:hover { color: var(--brand-700); background: var(--line-soft); }

.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; }
.form-grid .span-2 { grid-column: 1 / -1; }
.form-actions { display: flex; justify-content: flex-end; gap: 10px; flex-wrap: wrap; }

/* ============================== ALERTS / PILLS ============================== */
.alert {
  display: flex; align-items: flex-start; gap: 10px;
  padding: 12px 14px; border-radius: var(--r-md);
  font-size: .86rem; font-weight: 550;
  border: 1px solid var(--line);
  background: var(--card-2);
  color: var(--ink-2);
}
.alert svg.ico { margin-top: 1px; }
.alert-error { background: var(--danger-soft); border-color: #fbd0da; color: #9f1239; }
.alert-warn { background: var(--warn-soft); border-color: #fce4bd; color: #92400e; }
.alert-success { background: var(--ok-soft); border-color: #b6ead1; color: #065f46; }
.alert-info { background: var(--info-soft); border-color: #c5e6f8; color: #075985; }

.pill {
  display: inline-flex; align-items: center; gap: 5px;
  font-size: .74rem; font-weight: 700; letter-spacing: .01em;
  padding: 4px 10px; border-radius: 999px;
  background: var(--line-soft); color: var(--slate);
  border: 1px solid transparent; white-space: nowrap;
}
.pill svg.ico { width: 12px; height: 12px; stroke-width: 2.4; }
.pill-green { background: var(--ok-soft); color: #067a52; border-color: #bdead3; }
.pill-amber { background: var(--warn-soft); color: #b45309; border-color: #fbe2b6; }
.pill-red { background: var(--danger-soft); color: #be123c; border-color: #fbd0da; }
.pill-blue { background: var(--info-soft); color: #0369a1; border-color: #c5e6f8; }
.pill-violet { background: #f4f0ff; color: #6d28d9; border-color: #ded1fb; }
.pill-slate { background: #f1f5f6; color: #4b6470; border-color: #e0e9ea; }

.dot { width: 8px; height: 8px; border-radius: 50%; display: inline-block; }
.dot-green { background: var(--ok); }
.dot-amber { background: var(--warn); }
.dot-red { background: var(--danger); }
.dot-slate { background: #94a8b2; }

/* ============================== LOGIN SCREEN ============================== */
.login-screen {
  position: relative; z-index: 1;
  min-height: 100vh;
  display: grid;
  grid-template-columns: minmax(0, 1.06fr) minmax(0, .94fr);
}
.login-brand {
  position: relative;
  padding: clamp(28px, 4.4vw, 60px);
  color: #eafbf4;
  background:
    radial-gradient(760px 420px at 100% 0%, rgba(13, 148, 136, .55), transparent 62%),
    linear-gradient(158deg, #073c30 0%, #065f46 46%, #0b7a63 100%);
  display: flex; flex-direction: column; gap: 26px;
  overflow: hidden;
}
.login-brand::after {
  content: '';
  position: absolute; right: -140px; bottom: -160px;
  width: 460px; height: 460px; border-radius: 50%;
  border: 52px solid rgba(255, 255, 255, .05);
}
.brand-mark { display: flex; align-items: center; gap: 13px; position: relative; z-index: 1; }
.brand-logo svg { width: 46px; height: 46px; display: block; }
.brand-mark strong { display: block; font-size: 1.16rem; letter-spacing: -.02em; }
.brand-mark span { font-size: .8rem; color: rgba(234, 251, 244, .72); letter-spacing: .04em; text-transform: uppercase; }

.login-brand h1 {
  position: relative; z-index: 1;
  font-size: clamp(1.7rem, 3.1vw, 2.6rem);
  line-height: 1.16;
  color: #fff;
  font-weight: 800;
  max-width: 20ch;
}
.login-lead { position: relative; z-index: 1; color: rgba(234, 251, 244, .82); max-width: 52ch; font-size: .96rem; }

.login-points { position: relative; z-index: 1; list-style: none; margin: 0; padding: 0; display: grid; gap: 12px; }
.login-points li {
  display: flex; align-items: center; gap: 12px;
  font-size: .9rem; color: rgba(240, 255, 250, .95);
  background: rgba(255, 255, 255, .07);
  border: 1px solid rgba(255, 255, 255, .11);
  padding: 11px 14px; border-radius: 13px;
  backdrop-filter: blur(4px);
  max-width: 560px;
}
.lp-ic {
  width: 32px; height: 32px; flex: 0 0 auto; border-radius: 10px;
  display: grid; place-items: center;
  background: rgba(255, 255, 255, .14); color: #b9f6e0;
}
.lp-ic svg.ico { width: 17px; height: 17px; }

.login-foot { margin-top: auto; position: relative; z-index: 1; display: grid; gap: 8px; }
.login-foot .pulse { width: 100%; height: 34px; opacity: .9; }
.login-foot span { font-size: .77rem; color: rgba(234, 251, 244, .66); letter-spacing: .03em; }

.login-panel { display: grid; place-items: center; padding: clamp(22px, 4vw, 52px); }
.login-card {
  width: 100%; max-width: 428px;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: var(--r-xl);
  box-shadow: var(--sh-3);
  padding: clamp(24px, 3vw, 34px);
  display: grid; gap: 17px;
  position: relative; z-index: 1;
}
.login-card-head { display: grid; gap: 6px; }
.login-card-head h2 { font-size: 1.42rem; }
.login-card-head p { color: var(--muted); font-size: .86rem; }
.login-lock {
  width: 44px; height: 44px; border-radius: 14px; display: grid; place-items: center;
  background: linear-gradient(135deg, #eafaf3, #d6f5e8); color: var(--brand-700);
  border: 1px solid #cdeee0; margin-bottom: 4px;
}
.login-lock svg.ico { width: 22px; height: 22px; }
.login-hint {
  display: flex; gap: 10px; align-items: flex-start;
  background: var(--info-soft); border: 1px dashed #a9d8f2; color: #075985;
  padding: 11px 13px; border-radius: var(--r-md); font-size: .82rem;
}
.login-hint strong { display: block; font-size: .78rem; text-transform: uppercase; letter-spacing: .05em; }
.login-hint code { background: #fff; border-color: #bfe3f6; color: #0c4a6e; }
.login-note { font-size: .76rem; color: var(--muted); text-align: center; line-height: 1.55; }

/* ============================== APP SHELL ============================== */
.app-shell {
  position: relative; z-index: 1;
  display: grid;
  grid-template-columns: var(--side-w) minmax(0, 1fr);
  min-height: 100vh;
}
.scrim { position: fixed; inset: 0; background: rgba(6, 30, 24, .48); backdrop-filter: blur(2px); z-index: 40; border: 0; }

.sidebar {
  position: sticky; top: 0; height: 100vh;
  display: flex; flex-direction: column;
  padding: 18px 14px;
  gap: 16px;
  color: #dff6ee;
  background:
    radial-gradient(520px 300px at 110% -10%, rgba(13, 148, 136, .48), transparent 62%),
    linear-gradient(178deg, #07372c 0%, #05372a 52%, #062b22 100%);
  border-right: 1px solid rgba(255, 255, 255, .06);
  z-index: 45;
}
.side-brand { display: flex; align-items: center; gap: 11px; padding: 4px 6px 0; }
.side-logo svg { width: 40px; height: 40px; display: block; border-radius: 12px; box-shadow: 0 6px 16px -8px rgba(0, 0, 0, .6); }
.side-brand-text strong { display: block; font-size: 1.02rem; color: #fff; letter-spacing: -.02em; }
.side-brand-text span { font-size: .72rem; text-transform: uppercase; letter-spacing: .12em; color: rgba(223, 246, 238, .6); }

.side-nav { display: grid; gap: 4px; margin-top: 6px; overflow-y: auto; }
.side-nav .nav-label {
  font-size: .66rem; text-transform: uppercase; letter-spacing: .13em;
  color: rgba(223, 246, 238, .45); padding: 14px 10px 6px; font-weight: 700;
}
.nav-item {
  display: flex; align-items: center; gap: 11px;
  padding: 10px 11px; border-radius: 12px;
  color: rgba(230, 250, 243, .82);
  font-size: .885rem; font-weight: 600;
  text-decoration: none; cursor: pointer;
  border: 1px solid transparent;
  transition: background .16s, color .16s, transform .12s, border-color .16s;
}
.nav-item svg.ico { width: 18px; height: 18px; opacity: .9; }
.nav-item:hover { background: rgba(255, 255, 255, .08); color: #fff; }
.nav-item.active {
  background: linear-gradient(120deg, rgba(14, 159, 110, .95), rgba(13, 148, 136, .82));
  color: #fff;
  border-color: rgba(255, 255, 255, .16);
  box-shadow: 0 12px 24px -16px rgba(0, 0, 0, .9);
}
.nav-item .nav-badge {
  margin-left: auto; font-size: .7rem; font-weight: 700;
  background: rgba(255, 255, 255, .17); color: #fff;
  padding: 2px 8px; border-radius: 999px;
}
.nav-item.active .nav-badge { background: rgba(0, 0, 0, .22); }

.side-foot { margin-top: auto; display: grid; gap: 12px; }
.side-due {
  border: 1px solid rgba(255, 255, 255, .12);
  background: rgba(255, 255, 255, .07);
  border-radius: 14px; padding: 12px 13px;
  display: grid; gap: 2px;
}
.side-due .sd-label { font-size: .68rem; text-transform: uppercase; letter-spacing: .1em; color: rgba(223, 246, 238, .62); }
.side-due .sd-value { font-size: 1.22rem; font-weight: 800; color: #fff; letter-spacing: -.02em; }
.side-due .sd-sub { font-size: .72rem; color: rgba(223, 246, 238, .68); }
.side-user { display: flex; align-items: center; gap: 10px; border-top: 1px solid rgba(255, 255, 255, .1); padding-top: 12px; }
.side-user .ava { width: 34px; height: 34px; border-radius: 10px; display: grid; place-items: center; background: rgba(255, 255, 255, .13); color: #cff7e8; }
.side-user strong { display: block; font-size: .84rem; color: #fff; }
.side-user span { font-size: .72rem; color: rgba(223, 246, 238, .6); }
.side-user .icon-btn { margin-left: auto; background: transparent; border-color: rgba(255, 255, 255, .16); color: #dff6ee; }
.side-user .icon-btn:hover { background: rgba(255, 255, 255, .12); color: #fff; border-color: rgba(255, 255, 255, .3); }

.main { min-width: 0; display: flex; flex-direction: column; }
.topbar {
  position: sticky; top: 0; z-index: 30;
  display: flex; align-items: center; gap: 14px;
  padding: 15px clamp(16px, 2.4vw, 30px);
  background: rgba(255, 255, 255, .82);
  backdrop-filter: saturate(140%) blur(10px);
  border-bottom: 1px solid var(--line);
}
.topbar-title { min-width: 0; }
.topbar-title h1 { font-size: 1.28rem; letter-spacing: -.02em; }
.topbar-title p { font-size: .8rem; color: var(--muted); margin-top: 1px; }
.topbar-actions { margin-left: auto; display: flex; align-items: center; gap: 9px; flex-wrap: wrap; }
.nav-toggle { display: none; }

.view { padding: clamp(16px, 2.4vw, 28px); display: grid; gap: 20px; align-content: start; flex: 1; min-width: 0; }
.app-foot {
  display: flex; justify-content: space-between; gap: 12px; flex-wrap: wrap;
  padding: 14px clamp(16px, 2.4vw, 30px) 22px;
  font-size: .76rem; color: var(--muted);
}

/* ============================== PANELS / CARDS ============================== */
.panel {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--r-lg);
  box-shadow: var(--sh-1);
  padding: 18px;
  min-width: 0;
}
.panel-lg { padding: 22px; border-radius: var(--r-xl); }
.panel-head { display: flex; align-items: flex-start; gap: 12px; flex-wrap: wrap; margin-bottom: 15px; }
.panel-head h3 { font-size: 1.03rem; letter-spacing: -.02em; }
.panel-head p { font-size: .82rem; color: var(--muted); margin-top: 2px; }
.panel-head .panel-tools { margin-left: auto; display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }

.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)); }
.grid-wide { grid-template-columns: minmax(0, 1.55fr) minmax(0, 1fr); }
.grid-wide-l { grid-template-columns: minmax(0, 1fr) minmax(0, 1.55fr); }
.span-2 { grid-column: span 2; }
.stack { display: grid; gap: 16px; min-width: 0; }
.row { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; }
.row-tight { display: flex; gap: 6px; align-items: center; flex-wrap: wrap; }
.between { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; }

/* KPI cards */
.kpi {
  position: relative; overflow: hidden;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--r-lg);
  padding: 17px 18px;
  box-shadow: var(--sh-1);
  display: grid; gap: 12px;
  transition: transform .16s ease, box-shadow .2s ease, border-color .2s;
}
.kpi:hover { transform: translateY(-2px); box-shadow: var(--sh-2); border-color: #cfe8df; }
.kpi::after {
  content: ''; position: absolute; inset: 0 auto 0 0; width: 4px;
  background: linear-gradient(180deg, var(--brand), var(--teal));
}
.kpi.tone-green::after { background: linear-gradient(180deg, #059669, #34d399); }
.kpi.tone-amber::after { background: linear-gradient(180deg, #d97706, #fbbf24); }
.kpi.tone-red::after { background: linear-gradient(180deg, #e11d48, #fb7185); }
.kpi.tone-blue::after { background: linear-gradient(180deg, #0284c7, #38bdf8); }
.kpi.tone-slate::after { background: linear-gradient(180deg, #475569, #94a3b8); }
.kpi.tone-violet::after { background: linear-gradient(180deg, #7c3aed, #a78bfa); }
.kpi-top { display: flex; align-items: center; gap: 11px; }
.kpi-ic {
  width: 40px; height: 40px; border-radius: 12px; display: grid; place-items: center; flex: 0 0 auto;
  background: linear-gradient(135deg, #eafaf3, #d6f5e8); color: var(--brand-700);
  border: 1px solid #cdeee0;
}
.kpi-ic svg.ico { width: 20px; height: 20px; }
.kpi.tone-green .kpi-ic { background: linear-gradient(135deg, #e9fbf3, #d3f6e6); color: #047857; }
.kpi.tone-amber .kpi-ic { background: linear-gradient(135deg, #fff7e8, #fdeccd); color: #b45309; }
.kpi.tone-red .kpi-ic { background: linear-gradient(135deg, #fff1f4, #fddbe3); color: #be123c; }
.kpi.tone-blue .kpi-ic { background: linear-gradient(135deg, #eef8ff, #d5ecfb); color: #0369a1; }
.kpi.tone-slate .kpi-ic { background: linear-gradient(135deg, #f2f6f8, #e3ebef); color: #475569; }
.kpi.tone-violet .kpi-ic { background: linear-gradient(135deg, #f5f1ff, #e7dcfd); color: #6d28d9; }
.kpi-label { font-size: .76rem; font-weight: 700; text-transform: uppercase; letter-spacing: .07em; color: var(--muted); }
.kpi-value { font-size: 1.62rem; font-weight: 800; letter-spacing: -.03em; color: var(--ink); line-height: 1.1; }
.kpi-value.sm { font-size: 1.3rem; }
.kpi-sub { font-size: .78rem; color: var(--muted); display: flex; align-items: center; gap: 6px; }

/* hero / progress */
.hero {
  position: relative; overflow: hidden;
  color: #eafbf4;
  background:
    radial-gradient(620px 300px at 100% 0%, rgba(13, 148, 136, .5), transparent 60%),
    linear-gradient(120deg, #07382c 0%, #065f46 52%, #0c7d64 100%);
  border: 1px solid rgba(255, 255, 255, .09);
  border-radius: var(--r-xl);
  padding: clamp(18px, 2.4vw, 26px);
  box-shadow: var(--sh-3);
}
.hero h2 { color: #fff; font-size: 1.2rem; }
.hero .hero-sub { color: rgba(234, 251, 244, .78); font-size: .86rem; margin-top: 3px; }
.hero-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 14px; margin-top: 18px; }
.hero-stat { background: rgba(255, 255, 255, .09); border: 1px solid rgba(255, 255, 255, .13); border-radius: 14px; padding: 13px 15px; }
.hero-stat label { display: block; font-size: .7rem; text-transform: uppercase; letter-spacing: .1em; color: rgba(234, 251, 244, .68); }
.hero-stat strong { font-size: 1.32rem; font-weight: 800; letter-spacing: -.02em; color: #fff; }
.hero-top { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; flex-wrap: wrap; }
.hero-pct { text-align: right; }
.hero-pct strong { display: block; font-size: 2.3rem; font-weight: 800; line-height: 1; letter-spacing: -.04em; color: #fff; }
.hero-pct span { font-size: .74rem; text-transform: uppercase; letter-spacing: .1em; color: rgba(234, 251, 244, .7); }
.hero .pill { background: rgba(255, 255, 255, .15); color: #eafbf4; border-color: rgba(255, 255, 255, .2); }

.progress { height: 10px; border-radius: 999px; background: var(--line-soft); overflow: hidden; box-shadow: inset 0 1px 2px rgba(15, 32, 39, .06); }
.progress > i { display: block; height: 100%; border-radius: 999px; background: linear-gradient(90deg, var(--brand), var(--teal)); transition: width .5s cubic-bezier(.2, .7, .3, 1); }
.progress.lg { height: 13px; }
.hero .progress { background: rgba(0, 0, 0, .26); box-shadow: none; }
.hero .progress > i { background: linear-gradient(90deg, #34d399, #a7f3d0); }
.legend { display: flex; gap: 16px; flex-wrap: wrap; font-size: .8rem; color: var(--muted); margin-top: 10px; }
.legend span { display: inline-flex; align-items: center; gap: 7px; }
.hero .legend { color: rgba(234, 251, 244, .78); }

/* mini progress in table cells */
.cell-progress { display: grid; gap: 5px; min-width: 108px; }
.cell-progress .cp-num { font-weight: 700; color: var(--brand-700); font-size: .84rem; }
.cell-progress .progress { height: 6px; }

/* ============================== TABLES ============================== */
.table-wrap { overflow-x: auto; border: 1px solid var(--line); border-radius: var(--r-md); background: #fff; }
table.table { width: 100%; border-collapse: collapse; font-size: .87rem; min-width: 640px; }
table.table thead th {
  position: sticky; top: 0; z-index: 1;
  background: #f6faf9;
  color: var(--slate);
  font-size: .72rem; font-weight: 700; text-transform: uppercase; letter-spacing: .07em;
  text-align: left; padding: 11px 13px; border-bottom: 1px solid var(--line);
  white-space: nowrap;
}
table.table tbody td { padding: 11px 13px; border-bottom: 1px solid var(--line-soft); vertical-align: middle; }
table.table tbody tr:last-child td { border-bottom: 0; }
table.table tbody tr:hover { background: #f8fdfb; }
table.table tfoot td { padding: 11px 13px; background: #f6faf9; font-weight: 700; border-top: 1px solid var(--line); }
table.table .num { text-align: right; font-variant-numeric: tabular-nums; }
table.table .t-strong { font-weight: 700; color: var(--ink); }
table.table .t-sub { display: block; font-size: .76rem; color: var(--muted); font-weight: 500; }
table.table tr.row-link { cursor: pointer; }
table.table tr.is-overdue td { background: #fffafb; }
.cell-actions { display: flex; gap: 6px; justify-content: flex-end; }
.money { font-variant-numeric: tabular-nums; }
.money.danger { color: var(--danger); font-weight: 700; }
.money.ok { color: var(--brand-700); font-weight: 700; }

/* ============================== TOOLBAR / FILTERS ============================== */
.toolbar {
  display: flex; align-items: center; gap: 9px; flex-wrap: wrap;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--r-lg);
  padding: 12px 13px;
  box-shadow: var(--sh-1);
}
.toolbar .search { position: relative; flex: 1 1 220px; min-width: 190px; }
.toolbar .search svg.ico { position: absolute; left: 11px; top: 50%; transform: translateY(-50%); color: var(--muted); width: 17px; height: 17px; }
.toolbar .search .input { padding-left: 36px; }
.toolbar .select, .toolbar .input[type="date"], .toolbar .input[type="month"] { width: auto; min-width: 132px; }
.toolbar .spacer { flex: 1 1 auto; }

.seg { display: inline-flex; background: #eef5f3; border: 1px solid var(--line); border-radius: 11px; padding: 3px; gap: 2px; }
.seg-btn {
  border: 0; background: transparent; font: inherit; font-size: .82rem; font-weight: 650;
  color: var(--slate); padding: 7px 13px; border-radius: 8px; cursor: pointer; white-space: nowrap;
}
.seg-btn.active { background: #fff; color: var(--brand-800); box-shadow: var(--sh-1); }

.chips { display: flex; gap: 9px; flex-wrap: wrap; }
.chip {
  display: inline-flex; align-items: center; gap: 8px;
  background: #fff; border: 1px solid var(--line); border-radius: 999px;
  padding: 7px 13px; font: inherit; font-size: .8rem; font-weight: 650; color: var(--slate);
  cursor: pointer; transition: all .15s;
}
.chip:hover { border-color: #bfe6d8; }
.chip.active { border-color: var(--brand); box-shadow: 0 0 0 3px rgba(14, 159, 110, .13); color: var(--brand-800); }
.chip .count { font-weight: 800; color: var(--ink); }
.chip .amt { color: var(--muted); font-weight: 600; }

/* ============================== SUPPLIER CARDS ============================== */
.sup-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(304px, 1fr)); gap: 16px; }
.sup-card {
  background: var(--card); border: 1px solid var(--line); border-radius: var(--r-lg);
  padding: 16px; box-shadow: var(--sh-1); display: grid; gap: 13px;
  transition: transform .16s, box-shadow .2s, border-color .2s;
  position: relative; overflow: hidden;
}
.sup-card:hover { transform: translateY(-2px); box-shadow: var(--sh-2); border-color: #cfe8df; }
.sup-head { display: flex; gap: 12px; align-items: flex-start; }
.sup-ava {
  width: 44px; height: 44px; border-radius: 13px; flex: 0 0 auto;
  display: grid; place-items: center;
  background: linear-gradient(135deg, #eafaf3, #cff1e3);
  color: var(--brand-700); border: 1px solid #cdeee0;
  font-weight: 800; font-size: 1rem; letter-spacing: -.02em;
}
.sup-name { font-weight: 700; font-size: .98rem; color: var(--ink); letter-spacing: -.01em; line-height: 1.25; }
.sup-loc { font-size: .78rem; color: var(--muted); display: flex; align-items: center; gap: 5px; margin-top: 3px; }
.sup-loc svg.ico { width: 13px; height: 13px; }
.sup-head .pill { margin-left: auto; }
.sup-stats { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; }
.sup-stat { background: var(--card-2); border: 1px solid var(--line-soft); border-radius: 11px; padding: 9px 10px; }
.sup-stat label { display: block; font-size: .67rem; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); font-weight: 700; }
.sup-stat strong { font-size: .95rem; letter-spacing: -.02em; font-variant-numeric: tabular-nums; }
.sup-next {
  display: flex; align-items: center; gap: 9px;
  background: linear-gradient(120deg, #f4fbf8, #eefaf4);
  border: 1px dashed #bfe6d8; border-radius: 12px; padding: 10px 12px;
  font-size: .8rem; color: var(--brand-800);
}
.sup-next svg.ico { width: 16px; height: 16px; }
.sup-next strong { font-size: .95rem; }
.sup-actions { display: flex; gap: 7px; flex-wrap: wrap; }
.sup-actions .btn { flex: 1 1 auto; }

/* ============================== TIMELINE / LEDGER ============================== */
.timeline { display: grid; gap: 2px; }
.tl-row { display: flex; gap: 12px; align-items: flex-start; padding: 11px 4px; border-bottom: 1px dashed var(--line); }
.tl-row:last-child { border-bottom: 0; }
.tl-ic {
  width: 34px; height: 34px; border-radius: 11px; flex: 0 0 auto; display: grid; place-items: center;
  background: var(--ok-soft); color: var(--brand-700); border: 1px solid #bdead3;
}
.tl-ic.buy { background: var(--info-soft); color: #0369a1; border-color: #c5e6f8; }
.tl-ic.warn { background: var(--warn-soft); color: #b45309; border-color: #fbe2b6; }
.tl-main { min-width: 0; flex: 1; }
.tl-main strong { font-size: .89rem; }
.tl-main .tl-meta { font-size: .77rem; color: var(--muted); margin-top: 1px; }
.tl-amt { font-weight: 800; font-variant-numeric: tabular-nums; letter-spacing: -.02em; white-space: nowrap; }

.date-group { display: grid; gap: 0; border: 1px solid var(--line); border-radius: var(--r-md); overflow: hidden; background: #fff; }
.date-group-head {
  display: flex; align-items: center; gap: 10px; flex-wrap: wrap;
  padding: 9px 13px; background: #f4faf8; border-bottom: 1px solid var(--line);
  font-size: .8rem; font-weight: 700; color: var(--brand-800);
}
.date-group-head .dg-day { font-size: .74rem; color: var(--muted); font-weight: 600; }
.date-group-head .dg-sum { margin-left: auto; font-weight: 700; color: var(--ink); }
.date-group .pay-line {
  display: flex; align-items: center; gap: 12px; padding: 10px 13px; border-bottom: 1px dashed var(--line-soft);
}
.date-group .pay-line:last-child { border-bottom: 0; }
.pay-line-main { min-width: 0; flex: 1; }
.pay-line-main strong { font-size: .87rem; }
.pay-line-main .pl-meta { font-size: .76rem; color: var(--muted); }
.pay-line .amt { font-weight: 800; color: var(--brand-700); font-variant-numeric: tabular-nums; }

/* ============================== CHARTS ============================== */
.chart { width: 100%; overflow: visible; }
.chart text { font-family: var(--ff); font-size: 10.5px; fill: var(--muted); }
.chart .grid-line { stroke: var(--line-soft); stroke-width: 1; }
.chart .axis-line { stroke: var(--line); stroke-width: 1; }
.chart .bar-buy { fill: url(#gradBuy); }
.chart .bar-pay { fill: url(#gradPay); }
.chart .bar-hit { fill: transparent; }
.chart .bar-hit:hover + .bar-tip, .chart .bar-hit:focus + .bar-tip { opacity: 1; }
.chart .bar-tip { opacity: 0; transition: opacity .15s; pointer-events: none; }
.chart .bar-tip rect { fill: #0f2027; }
.chart .bar-tip text { fill: #fff; font-size: 10px; }
.chart-legend { display: flex; gap: 16px; flex-wrap: wrap; align-items: center; font-size: .78rem; color: var(--muted); margin-top: 10px; }
.chart-legend i { width: 11px; height: 11px; border-radius: 3px; display: inline-block; margin-right: 6px; vertical-align: -1px; }

.donut-wrap { display: flex; align-items: center; gap: 20px; flex-wrap: wrap; }
.donut { flex: 0 0 auto; }
.donut circle { fill: none; stroke-linecap: round; }
.donut .track { stroke: var(--line-soft); }
.donut text { font-family: var(--ff); }
.donut-center { font-weight: 800; fill: var(--ink); }
.donut-sub { fill: var(--muted); font-size: 10px; }
.donut-legend { display: grid; gap: 10px; min-width: 150px; flex: 1; }
.donut-legend .dl-row { display: flex; align-items: center; gap: 9px; font-size: .84rem; }
.donut-legend .dl-row i { width: 10px; height: 10px; border-radius: 3px; flex: 0 0 auto; }
.donut-legend .dl-row .dl-val { margin-left: auto; font-weight: 700; font-variant-numeric: tabular-nums; }

.bars { display: grid; gap: 12px; }
.bar-row { display: grid; gap: 6px; }
.bar-row-top { display: flex; align-items: baseline; gap: 10px; font-size: .82rem; }
.bar-row-top .br-name { font-weight: 650; color: var(--ink); min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.bar-row-top .br-val { margin-left: auto; font-weight: 700; font-variant-numeric: tabular-nums; white-space: nowrap; }
.bar-track { height: 9px; border-radius: 999px; background: var(--line-soft); overflow: hidden; }
.bar-track > i { display: block; height: 100%; border-radius: 999px; background: linear-gradient(90deg, #f59e0b, #e11d48); transition: width .5s ease; }
.bar-track.green > i { background: linear-gradient(90deg, var(--brand), var(--teal)); }

/* ============================== EMPTY / LOADER ============================== */
.empty { text-align: center; padding: 34px 20px; display: grid; gap: 8px; place-items: center; }
.empty .em-ic { width: 54px; height: 54px; border-radius: 16px; display: grid; place-items: center; background: var(--line-soft); color: var(--muted); }
.empty .em-ic svg.ico { width: 26px; height: 26px; }
.empty h4 { font-size: 1rem; }
.empty p { font-size: .84rem; color: var(--muted); max-width: 44ch; }

.loader { display: grid; gap: 10px; }
.skeleton { height: 14px; border-radius: 8px; background: linear-gradient(90deg, #eef4f2 25%, #e4ece9 37%, #eef4f2 63%); background-size: 400% 100%; animation: shimmer 1.3s ease infinite; }
@keyframes shimmer { 0% { background-position: 100% 0; } 100% { background-position: 0 0; } }

/* ============================== MODAL ============================== */
.modal-root { position: fixed; inset: 0; z-index: 80; display: grid; place-items: center; padding: 18px; }
.modal-root[hidden] { display: none; }
.modal-backdrop { position: absolute; inset: 0; background: rgba(7, 30, 24, .5); backdrop-filter: blur(3px); border: 0; }
.modal {
  position: relative; z-index: 1;
  width: 100%; max-width: 560px; max-height: calc(100vh - 40px);
  background: #fff; border: 1px solid var(--line); border-radius: var(--r-xl);
  box-shadow: var(--sh-3);
  display: flex; flex-direction: column;
  animation: pop .18s cubic-bezier(.2, .8, .3, 1);
}
.modal.wide { max-width: 900px; }
.modal.narrow { max-width: 430px; }
@keyframes pop { from { opacity: 0; transform: translateY(10px) scale(.985); } to { opacity: 1; transform: none; } }
.modal-head {
  display: flex; align-items: flex-start; gap: 12px;
  padding: 18px 20px 14px; border-bottom: 1px solid var(--line);
}
.modal-head h3 { font-size: 1.08rem; letter-spacing: -.02em; }
.modal-head p { font-size: .81rem; color: var(--muted); margin-top: 2px; }
.modal-head .icon-btn { margin-left: auto; }
.modal-body { padding: 18px 20px; overflow-y: auto; display: grid; gap: 16px; }
.modal-foot {
  display: flex; justify-content: flex-end; gap: 10px; flex-wrap: wrap;
  padding: 14px 20px; border-top: 1px solid var(--line); background: var(--card-2);
  border-radius: 0 0 var(--r-xl) var(--r-xl);
}

/* ============================== STATEMENT-ISH BLOCKS ============================== */
.stat-strip { display: grid; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); gap: 12px; }
.stat-box { background: var(--card-2); border: 1px solid var(--line-soft); border-radius: var(--r-md); padding: 12px 13px; }
.stat-box label { display: block; font-size: .68rem; text-transform: uppercase; letter-spacing: .07em; color: var(--muted); font-weight: 700; margin-bottom: 3px; }
.stat-box strong { font-size: 1.12rem; letter-spacing: -.02em; font-variant-numeric: tabular-nums; }
.stat-box.green { background: var(--ok-soft); border-color: #bdead3; }
.stat-box.green strong { color: #067a52; }
.stat-box.red { background: var(--danger-soft); border-color: #fbd0da; }
.stat-box.red strong { color: #be123c; }
.stat-box.amber { background: var(--warn-soft); border-color: #fbe2b6; }
.stat-box.amber strong { color: #b45309; }

.dl { display: grid; grid-template-columns: auto 1fr; gap: 8px 16px; font-size: .85rem; }
.dl dt { color: var(--muted); font-weight: 600; }
.dl dd { margin: 0; font-weight: 650; color: var(--ink); }

.aging { display: grid; grid-template-columns: repeat(auto-fit, minmax(126px, 1fr)); gap: 10px; }
.aging-cell { border: 1px solid var(--line); border-radius: var(--r-md); padding: 11px 12px; background: #fff; }
.aging-cell label { display: block; font-size: .68rem; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); font-weight: 700; }
.aging-cell strong { font-size: 1rem; font-variant-numeric: tabular-nums; }
.aging-cell small { display: block; font-size: .72rem; color: var(--muted); }
.aging-cell.a0 { border-top: 3px solid #38bdf8; }
.aging-cell.a1 { border-top: 3px solid #34d399; }
.aging-cell.a2 { border-top: 3px solid #fbbf24; }
.aging-cell.a3 { border-top: 3px solid #fb923c; }
.aging-cell.a4 { border-top: 3px solid #f43f5e; }

.badge-row { display: flex; gap: 7px; flex-wrap: wrap; }
.note { font-size: .8rem; color: var(--muted); }
.divider { height: 1px; background: var(--line); margin: 2px 0; }

/* ============================== TOASTS ============================== */
.toasts { position: fixed; right: 18px; bottom: 18px; z-index: 120; display: grid; gap: 10px; max-width: min(380px, calc(100vw - 36px)); }
.toast {
  display: flex; align-items: flex-start; gap: 10px;
  background: #fff; border: 1px solid var(--line); border-left: 4px solid var(--brand);
  border-radius: var(--r-md); box-shadow: var(--sh-3);
  padding: 12px 14px; font-size: .86rem;
  animation: slideIn .22s ease;
}
.toast.error { border-left-color: var(--danger); }
.toast.warn { border-left-color: var(--warn); }
.toast.info { border-left-color: var(--info); }
.toast svg.ico { margin-top: 1px; }
.toast.error svg.ico { color: var(--danger); }
.toast.warn svg.ico { color: var(--warn); }
.toast.info svg.ico { color: var(--info); }
.toast.out { animation: slideOut .2s ease forwards; }
@keyframes slideIn { from { opacity: 0; transform: translateX(20px); } to { opacity: 1; transform: none; } }
@keyframes slideOut { to { opacity: 0; transform: translateX(20px); } }

/* ============================== MISC ============================== */
.noscript { padding: 20px; background: var(--danger-soft); color: #be123c; font-weight: 600; }
.tag {
  display: inline-flex; align-items: center; gap: 5px; font-size: .72rem; font-weight: 700;
  background: var(--line-soft); color: var(--slate); padding: 3px 8px; border-radius: 7px;
}
.tag.mono { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; letter-spacing: -.01em; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

.report-tabs { display: flex; gap: 8px; flex-wrap: wrap; }

/* ============================== RESPONSIVE ============================== */
@media (max-width: 1180px) {
  .grid-4 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .grid-wide, .grid-wide-l { grid-template-columns: minmax(0, 1fr); }
}
@media (max-width: 1000px) {
  .grid-3 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .login-screen { grid-template-columns: minmax(0, 1fr); }
  .login-brand { order: 2; }
  .login-panel { order: 1; }
}
@media (max-width: 860px) {
  .app-shell { grid-template-columns: minmax(0, 1fr); }
  .sidebar {
    position: fixed; top: 0; left: 0; bottom: 0; width: min(296px, 86vw);
    transform: translateX(-104%); transition: transform .26s cubic-bezier(.2, .8, .3, 1);
    z-index: 50; height: 100vh;
  }
  body.nav-open .sidebar { transform: none; }
  .nav-toggle { display: inline-flex; }
  .hero-grid { grid-template-columns: minmax(0, 1fr); }
  .grid-2, .grid-3, .grid-4 { grid-template-columns: minmax(0, 1fr); }
  .span-2 { grid-column: auto; }
  .form-grid { grid-template-columns: minmax(0, 1fr); }
  .aging { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 560px) {
  body { font-size: 14.5px; }
  .view { padding: 14px; gap: 15px; }
  .topbar { padding: 12px 14px; }
  .topbar-title h1 { font-size: 1.1rem; }
  .kpi-value { font-size: 1.42rem; }
  .sup-stats { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .toasts { left: 14px; right: 14px; max-width: none; }
}
