@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700&family=Onest:wght@500;600;700&display=swap');

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  /* ─ Design tokens — mirrored from analytics.fasunok.support ─────────── */
  --ink:        #202331;
  --muted:      #737786;
  --subtle:     #a6aab5;
  --line:       #e7e8ed;
  --canvas:     #fbfbfc;
  --panel:      #ffffff;
  --nav:        #fdfdfe;

  --indigo:      #526eee;
  --indigo-ink:  #425bd6;
  --indigo-soft: #eef1ff;
  --orange:      #d97828;
  --orange-ink:  #a65c1c;
  --orange-soft: #fff4e9;
  --green:       #10956b;
  --green-ink:   #087d59;
  --green-soft:  #e8f6f0;
  --red:         #d84b55;
  --red-ink:     #b83f49;
  --red-soft:    #fff0f1;

  /* Neutrals that were literal hex in several rules – same values, now named. */
  --neutral-soft: #f0f1f5;   /* inactive / neutral badge and pill ground */
  --line-strong:  #cdd2df;   /* hover border, dashed upload zone */
  --red-line:     #f5cfd2;   /* border of an error alert / error card */

  /* Added for the light redesign (2026-11-10). Unused until step 2 – no visual change. */
  --line-soft:   #f1f2f5;    /* divider inside a panel (feed rows, kasa list) */
  --prev:        #d9dce4;    /* previous period on charts */

  --radius: 8px;
  --shadow: 0 2px 8px rgba(31,35,49,.043), 0 14px 30px rgba(31,35,49,.024);

  /* Spacing – 4px grid. New UI uses these, not 11/14/22. */
  --s-1: 4px;
  --s-2: 8px;
  --s-3: 12px;
  --s-4: 16px;
  --s-5: 24px;
  --s-6: 32px;

  /* Type – one ramp of six steps. */
  --f-ui:  Inter, -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  --f-num: ui-monospace, SFMono-Regular, Menlo, 'Courier New', monospace;
  --fs-xs: 11px;     /* eyebrow, axis, counters */
  --fs-sm: 12.5px;   /* secondary line, meta */
  --fs-md: 13.5px;   /* body, table cell, nav */
  --fs-lg: 15px;     /* panel title, small figure */
  --fs-xl: 19px;     /* section heading */
  --fs-2xl: 26px;    /* page title, KPI value */

  /* Display face for page titles and figures (redesign v3); Inter stays for UI text. */
  --f-display: Onest, Inter, -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;

  /* Motion – one easing; transform / opacity only. Off under prefers-reduced-motion. */
  --ease:   cubic-bezier(.22, .8, .24, 1);
  --t-fast: 140ms;
  --t:      220ms;
  --t-data: 420ms;
  --wash:   #f3f4f7;

  /* Light only, by owner's rule: no dark theme, no prefers-color-scheme: dark.
     Also keeps native controls and scrollbars light on a dark OS. */
  color-scheme: light;

  /* ─ Legacy aliases — keep every existing class reference working ─ */
  --bg:             var(--canvas);
  --surface:        var(--panel);
  --brand:          var(--indigo);
  --text:           var(--ink);
  --text-2:         var(--muted);
  --ok:             var(--green);
  --warn:           var(--orange);
  --err:            var(--red);
  --sidebar-bg:     var(--nav);
  --sidebar-text:   var(--muted);
  --sidebar-active: var(--indigo);
  --main-bg:        var(--canvas);
  --card-bg:        var(--panel);
  --accent:         var(--indigo);
  --success:        var(--green);
  --warning:        var(--orange);
  --danger:         var(--red);
  --text-primary:   var(--ink);
  --text-secondary: var(--muted);
  --border:         var(--line);
  --radius-card:    var(--radius);
  --radius-btn:     var(--radius);
}

body {
  font-family: var(--f-ui);
  font-size: 14px;
  line-height: 1.4;
  background: var(--canvas);
  color: var(--ink);
  display: flex;
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
}

/* ── Sidebar ─────────────────────────────── */
.sidebar {
  width: 272px;
  min-height: 100vh;
  background: var(--nav);
  border-right: 1px solid var(--line);
  position: fixed;
  left: 0; top: 0;
  display: flex;
  flex-direction: column;
  z-index: 100;
}

.sidebar-logo {
  display: flex;
  align-items: center;
  gap: 11px;
  height: 80px;
  padding: 0 28px;
  border-bottom: 1px solid var(--line);
  font-size: 16px;
  font-weight: 650;
  letter-spacing: -.025em;
  flex-shrink: 0;
}
.sidebar-logo-icon {
  width: 28px; height: 28px;
  border-radius: var(--radius);
  background: linear-gradient(145deg, #6a81f6, #465ee1);
  box-shadow: inset 0 1px rgba(255,255,255,.35);
  display: grid; place-items: center;
  font-size: 11px; font-weight: 700; color: #fff;
  flex-shrink: 0;
}
.sidebar-logo-name { color: var(--ink); }

.sidebar-nav {
  flex: 1;
  padding: 20px 16px;
  display: flex;
  flex-direction: column;
  gap: 3px;
  overflow-y: auto;
}

.nav-sect-label {
  font-size: 12px;
  font-weight: 400;
  color: var(--muted);
  margin: 22px 12px 8px;
}
.sidebar-nav > .nav-sect-label:first-child { margin-top: 0; }

.nav-item {
  display: flex;
  align-items: center;
  gap: 12px;
  height: 39px;
  padding: 0 10px;
  border-radius: var(--radius);
  font-size: 14px;
  font-weight: 400;
  color: #555a68;
  text-decoration: none;
  transition: background .15s, color .15s;
  cursor: pointer;
  border: none;
  background: none;
  width: 100%;
  text-align: left;
}
.nav-item svg { color: #777d8d; flex-shrink: 0; }
.nav-item:hover { background: #f3f4f6; }
.nav-item.active { background: #f0f2f4; color: #2c3550; font-weight: 600; }
.nav-item.active svg { color: var(--indigo); }
.nav-item.dim { color: var(--subtle); cursor: default; }
.nav-item.dim:hover { background: none; }

.nav-soon {
  font-size: 11px; font-weight: 500;
  background: #edf0f8;
  color: #6c7180;
  padding: 1px 5px; border-radius: 4px;
  margin-left: auto;
}

.sidebar-user {
  padding: 14px 16px;
  border-top: 1px solid var(--line);
  display: flex;
  align-items: center;
  gap: 10px;
  flex-shrink: 0;
}
.sidebar-avatar {
  width: 32px; height: 32px; border-radius: 50%;
  background: #dceaf0;
  display: grid; place-items: center;
  font-size: 11px; font-weight: 750; color: #47535a;
  flex-shrink: 0;
}
.sidebar-user-info { flex: 1; min-width: 0; }
.sidebar-user-name { font-size: 13px; font-weight: 600; color: var(--ink); }
.sidebar-user-email {
  font-size: 11px; color: var(--muted); display: block;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.sidebar-logout {
  width: 30px; height: 30px; flex-shrink: 0;
  color: var(--muted);
  border-radius: 50%;
  display: grid; place-items: center;
  text-decoration: none;
  transition: background .15s, color .15s;
}
.sidebar-logout:hover { background: #f2f3f6; color: var(--ink); }

/* ── Main content ────────────────────────── */
.main-content {
  margin-left: 272px;
  flex: 1;
  padding: 30px 38px 70px;
  min-width: 0;
  min-height: 100vh;
}

/* ── Page header ──────────────────────────── */
.page-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  margin-bottom: 25px;
}
.page-title { font: 600 var(--fs-2xl)/1.15 var(--f-display); color: var(--ink); letter-spacing: -.02em; }
.page-subtitle, .page-sub { font-size: 14px; color: var(--muted); margin-top: 5px; }

/* ── Cards ────────────────────────────────── */
.card, .stat-card, .project-card {
  background: var(--panel);
  border-radius: var(--radius);
  border: 1px solid var(--line);
  box-shadow: var(--shadow);
}
.card-body { padding: 22px; }
.card-header, .card-head {
  padding: 16px 22px;
  border-bottom: 1px solid var(--line);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}
.card-title { font-size: 16px; font-weight: 620; color: var(--ink); letter-spacing: -.02em; }
.card-subtitle { font-size: 13px; color: var(--muted); margin-top: 2px; }

/* ── Buttons ──────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  border: none;
  border-radius: var(--radius);
  font-family: inherit;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  height: 38px;
  padding: 0 16px;
  text-decoration: none;
  transition: filter .15s, opacity .15s, border-color .15s, background .15s;
  white-space: nowrap;
}
.btn:hover { filter: brightness(.95); }
.btn:disabled { opacity: .45; cursor: not-allowed; filter: none; }

.btn-primary   { background: var(--ink); color: #fff; }
.btn-primary:hover { background: #3a3f52; filter: none; }
.btn-secondary { background: var(--indigo-soft); color: var(--indigo-ink); }
.btn-outlined  { background: var(--panel); color: var(--ink); border: 1px solid var(--line); }
.btn-outlined:hover { border-color: var(--line-strong); filter: none; background: var(--canvas); }
.btn-danger    { background: var(--red); color: #fff; }
.btn-danger-outlined { background: var(--panel); color: var(--red-ink); border: 1px solid var(--line); }
.btn-danger-outlined:hover { border-color: var(--red); filter: none; }
.btn-ghost     { background: transparent; color: var(--muted); border: 1px solid var(--line); }

.btn-sm { height: 32px; padding: 0 12px; font-size: 13px; }
.btn-icon { width: 38px; padding: 0; }

/* ── Icon buttons ──────────────────────────── */
.icon-btn {
  background: none; border: none; cursor: pointer;
  width: 30px; height: 30px; border-radius: 50%;
  color: var(--muted);
  display: inline-grid; place-items: center;
  transition: background .12s, color .12s;
}
.icon-btn:hover { background: #f2f3f6; color: var(--ink); }

/* ── Inputs ───────────────────────────────── */
.form-group { margin-bottom: 16px; }
.form-group:last-child { margin-bottom: 0; }

label {
  font-size: 12px; font-weight: 500;
  color: #626777;
  display: block; margin-bottom: 6px;
}
input[type="text"], input[type="email"], input[type="password"],
input[type="tel"], input[type="url"], input[type="number"],
input[type="date"], input[type="time"], input[type="search"], textarea {
  width: 100%;
  height: 42px;
  padding: 0 11px;
  font-size: 14px;
  font-family: inherit;
  border: 1px solid #dfe2e8;
  border-radius: var(--radius);
  outline: none;
  background-color: var(--panel);
  color: var(--ink);
  transition: border-color .15s, box-shadow .15s;
  appearance: none;
}
textarea { height: auto; padding: 10px 11px; line-height: 1.5; }
select {
  width: 100%;
  height: 42px;
  padding: 0 30px 0 11px;
  font-size: 14px;
  font-family: inherit;
  border: 1px solid #dfe2e8;
  border-radius: var(--radius);
  outline: none;
  background-color: var(--panel);
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16' fill='none'%3E%3Cpath d='M4 6l4 4 4-4' stroke='%23737786' stroke-width='1.5' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 10px center;
  background-size: 16px 16px;
  color: var(--ink);
  transition: border-color .15s, box-shadow .15s;
  appearance: none;
  cursor: pointer;
}
input:focus, select:focus, textarea:focus {
  border-color: var(--indigo);
  box-shadow: 0 0 0 3px var(--indigo-soft);
}
input[readonly], textarea[readonly] { background-color: var(--canvas); cursor: default; }
.input-hint  { font-size: 12px; color: var(--muted); margin-top: 5px; }
.input-error { font-size: 12px; color: var(--red-ink); margin-top: 5px; }

.input-group { display: flex; align-items: stretch; }
.input-group input { border-radius: var(--radius) 0 0 var(--radius); }
.input-group .btn  { border-radius: 0 var(--radius) var(--radius) 0; flex-shrink: 0; }

/* ── Grid ─────────────────────────────────── */
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 22px; }
.grid-3 { display: grid; grid-template-columns: repeat(3, minmax(0,1fr)); gap: 22px; }
.grid-4 { display: grid; grid-template-columns: repeat(4, minmax(0,1fr)); gap: 14px; }

/* ── Tables ───────────────────────────────── */
table { width: 100%; border-collapse: collapse; font-size: 14px; }
thead th {
  padding: 0 14px;
  height: 37px;
  text-align: left;
  font-size: 12px;
  font-weight: 500;
  color: var(--muted);
  letter-spacing: 0;
  text-transform: none;
  border-bottom: 1px solid var(--line);
  background: transparent;
  white-space: nowrap;
}
tbody tr { border-bottom: 1px solid var(--line); transition: background .1s; }
tbody tr:last-child { border-bottom: none; }
tbody tr:hover { background: var(--canvas); }
tbody td { padding: 10px 14px; min-height: 54px; color: #4a4e5c; vertical-align: middle; }
td.amount, .num { font-variant-numeric: tabular-nums; color: var(--ink); font-weight: 550; }
.sub { color: var(--muted); margin-top: 2px; font-size: 12px; }
.muted { color: var(--muted); }

/* ── Status badges ─────────────────────────── */
.badge {
  display: inline-flex; align-items: center;
  height: 23px;
  padding: 0 8px;
  border-radius: var(--radius);
  font-size: 11px;
  font-weight: 650;
  white-space: nowrap;
}
.badge-active     { background: var(--green-soft);  color: var(--green-ink); }
.badge-inactive   { background: var(--neutral-soft);            color: var(--muted); }
.badge-confirm    { background: var(--orange-soft); color: var(--orange-ink); }
.badge-collecting { background: var(--indigo-soft); color: var(--indigo-ink); }
.badge-ready      { background: var(--indigo-soft); color: var(--indigo-ink); }
.badge-transit    { background: var(--indigo-soft); color: var(--indigo-ink); }
.badge-branch     { background: var(--orange-soft); color: var(--orange-ink); }
.badge-received   { background: var(--green-soft);  color: var(--green-ink); }
.badge-connected  { background: var(--green-soft);  color: var(--green-ink); }
.badge-error      { background: var(--red-soft);    color: var(--red-ink); }

/* Tone variants, for badges that carry no order status. */
.badge-indigo  { background: var(--indigo-soft); color: var(--indigo-ink); }
.badge-green   { background: var(--green-soft);  color: var(--green-ink); }
.badge-orange  { background: var(--orange-soft); color: var(--orange-ink); }
.badge-red     { background: var(--red-soft);    color: var(--red-ink); }
.badge-neutral { background: var(--neutral-soft);            color: var(--muted); }

/* A round chip, for counts and free-form labels that are not statuses. */
.pill {
  display: inline-flex; align-items: center;
  height: 22px; padding: 0 8px;
  border-radius: 999px;
  background: var(--neutral-soft); color: var(--muted);
  font-size: 11.5px; font-weight: 600;
}

/* ── Toggle ───────────────────────────────── */
.toggle {
  position: relative;
  width: 39px; height: 23px;
  flex-shrink: 0;
  cursor: pointer;
}
.toggle input { opacity: 0; width: 0; height: 0; position: absolute; }
.toggle-track {
  position: absolute; inset: 0;
  background: #d6d9e1;
  border-radius: 12px;
  transition: background .2s;
}
.toggle input:checked + .toggle-track { background: var(--ink); }
.toggle-thumb {
  position: absolute;
  width: 17px; height: 17px;
  background: #fff;
  border-radius: 50%;
  top: 3px; left: 3px;
  transition: left .2s;
  box-shadow: 0 1px 3px rgba(31,35,49,.2);
}
.toggle input:checked ~ .toggle-thumb { left: 19px; }

/* ── Stats card ───────────────────────────── */
.stat-card { padding: 16px 17px; }
.stat-label { font-size: 12px; font-weight: 400; color: var(--muted); margin-bottom: 5px; }
.stat-value {
  font-size: 21px; font-weight: 560; color: var(--ink);
  letter-spacing: -.035em; line-height: 1.2;
  font-variant-numeric: tabular-nums;
}
.stat-trend { font-size: 13px; font-weight: 600; margin-top: 6px; display: flex; align-items: center; gap: 3px; }
.stat-trend.up   { color: var(--green); }
.stat-trend.down { color: var(--red); }

/* ── Avatar ───────────────────────────────── */
.avatar {
  width: 32px; height: 32px;
  border-radius: 50%;
  display: grid; place-items: center;
  font-size: 11px; font-weight: 750;
  color: #47535a;
  background: #dceaf0;
  flex-shrink: 0;
}

/* ── Breadcrumb ───────────────────────────── */
.breadcrumb, .crumb { font-size: 13px; color: var(--muted); }
.breadcrumb a, .crumb a { color: var(--muted); text-decoration: none; }
.breadcrumb a:hover, .crumb a:hover { color: var(--indigo); }
.breadcrumb span { color: var(--ink); font-weight: 550; }

/* ── Sticky top bar ───────────────────────── */
.sticky-bar {
  position: sticky;
  top: 0;
  z-index: 10;
  background: rgba(253,253,254,.9);
  backdrop-filter: saturate(180%) blur(8px);
  border-bottom: 1px solid var(--line);
  margin: -30px -38px 25px;
  padding: 0 38px;
  min-height: 62px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
}

/* ── Section ──────────────────────────────── */
.section { margin-bottom: 22px; }
.section-title {
  font-size: 18px; font-weight: 600; color: var(--ink);
  letter-spacing: -.025em;
  margin-bottom: 16px;
}

/* ── Tabs ─────────────────────────────────── */
.tabs {
  display: flex; gap: 25px;
  border-bottom: 1px solid var(--line);
  margin-bottom: 26px;
}
.tab, .tab-btn {
  position: relative;
  height: 38px;
  padding: 0;
  font: inherit;
  font-size: 14px;
  color: var(--muted);
  background: none;
  border: none;
  cursor: pointer;
}
.tab.active, .tab-btn.active { color: var(--ink); font-weight: 550; }
.tab.active::after, .tab-btn.active::after {
  content: "";
  position: absolute; left: 0; right: 0; bottom: -1px;
  height: 2px; border-radius: 2px;
  background: var(--ink);
}

/* ── Accordion (status mapping) ──────────── */
.accordion { border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; background: var(--panel); }
.accordion-row { border-bottom: 1px solid var(--line); }
.accordion-row:last-child { border-bottom: none; }
.accordion-header {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 13px 16px;
  cursor: pointer;
  background: transparent;
  border: none;
  width: 100%;
  text-align: left;
  font-family: inherit;
  font-size: 14px;
  font-weight: 500;
  color: var(--ink);
  transition: background .15s;
}
.accordion-header:hover, .accordion-header.open { background: var(--canvas); }
.accordion-dot { width: 8px; height: 8px; border-radius: 50%; flex-shrink: 0; }
.accordion-label { flex: 1; }
.accordion-badge {
  font-size: 11px; font-weight: 650; padding: 0 8px; height: 23px;
  display: inline-flex; align-items: center;
  border-radius: 5px; background: var(--green-soft); color: var(--green-ink);
}
.accordion-arrow { color: var(--muted); transition: transform .2s; flex-shrink: 0; }
.accordion-header.open .accordion-arrow { transform: rotate(180deg); }

.accordion-body {
  display: none;
  background: var(--canvas);
  padding: 16px;
  border-top: 1px solid var(--line);
}
.accordion-body.open { display: block; }
.accordion-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 12px;
}

/* ── Logo upload zone ─────────────────────── */
.upload-zone {
  border: 1px dashed var(--line-strong);
  border-radius: var(--radius);
  padding: 24px;
  text-align: center;
  cursor: pointer;
  background: var(--canvas);
  transition: border-color .15s, background .15s;
}
.upload-zone:hover { border-color: var(--indigo); background: var(--indigo-soft); }
.upload-zone-text { font-size: 13px; color: var(--muted); margin-top: 8px; }
.logo-preview { width: 80px; height: 80px; border-radius: var(--radius); object-fit: cover; }

/* ── Color picker ─────────────────────────── */
.color-picker-row { display: flex; align-items: center; gap: 12px; }
.color-swatch {
  width: 34px; height: 34px;
  border-radius: var(--radius);
  border: 1px solid var(--line);
  flex-shrink: 0;
  cursor: pointer;
  overflow: hidden;
}
.color-swatch input[type="color"] {
  width: 100%; height: 100%;
  border: none; padding: 0; cursor: pointer;
  opacity: 0;
  position: absolute;
}
.color-swatch-wrap { position: relative; }
.color-hex { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 12px; color: var(--muted); }

/* ── API status dot ───────────────────────── */
.api-dot, .status-dot {
  width: 8px; height: 8px;
  border-radius: 999px;
  display: inline-block;
  flex-shrink: 0;
}
.api-dot.ok  { background: var(--green); }
.api-dot.err { background: var(--red); }
.api-dot.unk { background: #d6d9e1; }

/* ── Inline connection status ─────────────── */
.conn-status { display: inline-flex; align-items: center; gap: 6px; font-size: 13px; font-weight: 550; }
.conn-status.ok  { color: var(--green-ink); }
.conn-status.err { color: var(--red-ink); }

/* ── Activity feed ────────────────────────── */
.feed-row {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 13px 22px;
  border-bottom: 1px solid var(--line);
  font-size: 14px;
}
.feed-row:last-child { border-bottom: none; }
.feed-dot  { width: 7px; height: 7px; border-radius: 50%; flex-shrink: 0; }
.feed-text { flex: 1; }
.feed-shop { color: var(--muted); }
.feed-time { font-size: 12px; color: var(--muted); white-space: nowrap; }

/* ── Project card (grid) ──────────────────── */
.project-card { padding: 22px; }
.project-card-add {
  background: var(--panel);
  border: 1px dashed var(--line-strong);
  border-radius: var(--radius);
  padding: 22px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: 140px;
  cursor: pointer;
  text-decoration: none;
  color: var(--muted);
  font-size: 14px;
  font-weight: 550;
  gap: 8px;
  transition: border-color .15s, color .15s;
}
.project-card-add:hover { border-color: var(--indigo); color: var(--indigo); }

/* ── Empty state ──────────────────────────── */
.empty-state {
  display: flex; flex-direction: column;
  align-items: center; justify-content: center;
  padding: 60px 24px;
  text-align: center;
  gap: 10px;
}
.empty-icon {
  width: 44px; height: 44px;
  border-radius: 12px; background: var(--neutral-soft);
  display: grid; place-items: center;
  font-size: 21px;
}
.empty-title    { font-size: 16px; font-weight: 600; color: var(--ink); }
.empty-subtitle { font-size: 13px; color: var(--muted); }

/* ── Alerts ───────────────────────────────── */
.alert {
  padding: 14px 16px;
  border-radius: var(--radius);
  font-size: 13px;
  margin-bottom: 22px;
  display: flex;
  align-items: flex-start;
  gap: 12px;
}
.alert-success { background: var(--green-soft);  color: var(--green-ink);  border: 1px solid #c9e8dc; }
.alert-error   { background: var(--red-soft);    color: var(--red-ink);    border: 1px solid var(--red-line); }
.alert-warn    { background: var(--orange-soft); color: var(--orange-ink); border: 1px solid #f3ddc4; }

/* ── Pagination ───────────────────────────── */
.pagination {
  display: flex; align-items: center; gap: 6px;
  padding: 14px 22px;
  border-top: 1px solid var(--line);
  color: var(--muted);
  font-size: 13px;
}
.page-btn {
  height: 32px;
  display: inline-flex; align-items: center;
  padding: 0 12px;
  border-radius: var(--radius);
  font-size: 13px; font-weight: 500;
  border: 1px solid var(--line);
  background: var(--panel);
  color: var(--ink);
  cursor: pointer;
  text-decoration: none;
  transition: background .1s, border-color .1s;
}
.page-btn:hover { background: var(--canvas); border-color: var(--line-strong); }
.page-btn.active { background: var(--ink); color: #fff; border-color: var(--ink); }
.page-btn:disabled { opacity: .4; cursor: not-allowed; }

/* ── Filters row ──────────────────────────── */
.filters-row { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.filters-row input, .filters-row select { width: auto; flex: 1; min-width: 145px; height: 38px; }

/* ── Max width container ──────────────────── */
.content-narrow { max-width: 720px; }

/* ── Tag pill input ───────────────────────── */
.tag-pills {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  padding: 6px 0;
  min-height: 32px;
}
.tag-pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: var(--indigo-soft);
  color: var(--indigo-ink);
  border: 1px solid #d9e0ff;
  border-radius: 999px;
  padding: 3px 8px 3px 12px;
  font-size: 12.5px;
  font-weight: 600;
}
.tag-pill button {
  background: none; border: none; cursor: pointer;
  color: var(--subtle);
  font-size: 17px; line-height: 1;
  padding: 0 2px;
  display: flex; align-items: center;
  transition: color .1s;
}
.tag-pill button:hover { color: var(--indigo); }

/* ── Checkbox ─────────────────────────────── */
input[type="checkbox"] {
  appearance: none;
  -webkit-appearance: none;
  width: 16px;
  height: 16px;
  border: 1.5px solid #c8ccd6;
  border-radius: 4px;
  cursor: pointer;
  display: inline-grid;
  place-items: center;
  background: #fff;
  transition: background .12s, border-color .12s;
  flex-shrink: 0;
}
input[type="checkbox"]:checked {
  background: var(--ink);
  border-color: var(--ink);
}
input[type="checkbox"]:checked::after {
  content: "";
  width: 9px;
  height: 5px;
  border-left: 1.5px solid #fff;
  border-bottom: 1.5px solid #fff;
  transform: rotate(-45deg) translate(1px, -1px);
}
input[type="checkbox"]:focus-visible {
  outline: none;
  box-shadow: 0 0 0 3px var(--indigo-soft);
}

/* ── Eye toggle for password ──────────────── */
.pw-wrap { position: relative; }
.pw-wrap input { padding-right: 40px; }
.pw-eye {
  position: absolute; right: 10px; top: 50%; transform: translateY(-50%);
  background: none; border: none; cursor: pointer;
  color: var(--muted);
  display: flex; align-items: center;
}

/* ── Shared filter bar (admin/partials/filter-bar.php) ──────────────── */
.fbar {
  display: flex; gap: 8px; align-items: center; flex-wrap: wrap;
  background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 10px 12px; margin-bottom: 20px;
}
/* Selectors are scoped under .fbar on purpose: the global input[type=date] / input[type=text]
   rules carry an attribute selector and would otherwise win on specificity and stretch every
   field to width:100%, breaking the row into one field per line. */
.fbar .fbar-select, .fbar .fbar-input, .fbar .fbar-date {
  font-size: 13px; height: 38px; width: auto; padding: 0 11px;
  border: 1px solid var(--line); border-radius: var(--radius);
  background: #fff; color: var(--ink); flex: 0 0 auto; box-sizing: border-box;
}
.fbar .fbar-select {
  width: 160px; padding: 0 28px 0 11px; cursor: pointer; appearance: none; -webkit-appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16' fill='none'%3E%3Cpath d='M4 6l4 4 4-4' stroke='%23737786' stroke-width='1.5' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 9px center; background-size: 15px;
}
.fbar .fbar-input { width: 150px; }
.fbar .fbar-date  { width: 138px; padding: 0 9px; }
.fbar .fbar-select:disabled { background-color: #f4f5f7; color: var(--subtle); cursor: not-allowed; }
.fbar .fbar-select:focus, .fbar .fbar-input:focus, .fbar .fbar-date:focus {
  outline: none; border-color: var(--indigo); box-shadow: 0 0 0 3px var(--indigo-soft);
}
.fbar .fbar-input::placeholder { color: var(--subtle); }
.fbar-sep { width: 1px; height: 22px; background: var(--line); flex: 0 0 auto; }
/* A date range reads as one control, not two loose fields. */
.fbar-range { display: flex; align-items: center; gap: 0; flex: 0 0 auto; }
.fbar-range .fbar-date { border-radius: var(--radius) 0 0 var(--radius); }
.fbar-range .fbar-date + .fbar-date { border-radius: 0 var(--radius) var(--radius) 0; margin-left: -1px; }
.fbar-range .fbar-date:focus { position: relative; z-index: 1; }
.fbar-group { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.fbar-hint { font-size: 12px; color: var(--muted); flex: 0 0 auto; }
.fbar-reset {
  font-size: 13px; font-weight: 550; color: var(--muted); text-decoration: none;
  padding: 0 12px; height: 38px; border: 1px solid var(--line); border-radius: var(--radius);
  background: #fff; display: inline-flex; align-items: center; gap: 4px; flex: 0 0 auto;
}
.fbar-reset:hover { border-color: var(--red); color: var(--red-ink); }
.fbar-seg { display: flex; height: 38px; border: 1px solid var(--line); border-radius: var(--radius); background: #fff; padding: 3px; gap: 4px; flex: 0 0 auto; }
.fbar-seg button {
  padding: 0 14px; font: inherit; font-size: 13px; font-weight: 400; background: none;
  color: var(--muted); border: none; border-radius: 6px; cursor: pointer; white-space: nowrap;
}
.fbar-seg button.on { background: var(--ink); color: #fff; font-weight: 550; }
.fbar-apply {
  height: 38px; padding: 0 14px; font: inherit; font-size: 13px; font-weight: 550;
  background: #fff; color: var(--ink); border: 1px solid var(--line); border-radius: var(--radius); cursor: pointer; flex: 0 0 auto;
}
.fbar-apply:hover { border-color: var(--indigo); color: var(--indigo-ink); }

/* ── Responsive ───────────────────────────── */
@media (max-width: 920px) {
  .sidebar { width: 76px; }
  .sidebar-logo { justify-content: center; padding: 0; }
  .sidebar-logo-name, .nav-sect-label, .sidebar-user-info { display: none; }
  .sidebar-nav { padding: 20px 12px; }
  .nav-item { justify-content: center; padding: 0; }
  .nav-item span { display: none; }
  .sidebar-user { justify-content: center; }
  .main-content { margin-left: 76px; padding: 30px 24px 60px; }
  .sticky-bar { margin: -30px -24px 25px; padding: 0 24px; }
  .grid-2, .grid-3, .grid-4 { grid-template-columns: 1fr; }
}

/* ── Filter bar controls ────────────────────────────────────────────────
   Ported from the analytics design system. A native <select> paints its own menu
   from the OS — dark on macOS — so every filter dropdown is a button plus a panel. */
.fsel, .fdate-wrap, .fbar-more { position: relative; flex: 0 0 auto; }

.fsel-trigger, .fdate-trigger, .fbar-more-trigger {
  display: inline-flex; align-items: center; gap: 9px;
  height: 38px; padding: 0 12px;
  min-width: 0; max-width: 230px;
  border: 1px solid var(--line); border-radius: var(--radius);
  background: #fff; color: var(--ink);
  font: inherit; font-size: 13px; font-weight: 550;
  text-align: left; cursor: pointer;
  transition: border-color .12s, background .12s;
}
.fsel-trigger:hover, .fdate-trigger:hover, .fbar-more-trigger:hover { border-color: var(--line-strong); }
.fsel.open .fsel-trigger, .fdate-wrap.open .fdate-trigger, .fbar-more.open .fbar-more-trigger {
  background: #f6f7fa; border-color: var(--line-strong);
}
.fsel-trigger[disabled] { background: #f4f5f7; color: var(--subtle); cursor: not-allowed; }
.fsel-label { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.fsel-trigger.picked .fsel-label, .fdate-trigger.picked { color: var(--ink); font-weight: 600; }
.fsel-chev { width: 15px; height: 15px; color: var(--subtle); flex-shrink: 0; }

.fsel-panel {
  display: none; position: absolute; z-index: 40; top: calc(100% + 7px); left: 0;
  min-width: 100%; width: max-content; max-width: 320px; max-height: 340px; overflow-y: auto;
  padding: 5px; background: #fff;
  border: 1px solid #dfe2e9; border-radius: 10px;
  box-shadow: 0 16px 34px rgba(30,35,52,.13);
}
.fsel.open .fsel-panel { display: block; }
.fsel-panel button, .fsel-panel label {
  display: flex; align-items: center; gap: 8px;
  width: 100%; height: 35px; padding: 0 9px; margin: 0;
  border: 0; border-radius: 6px; background: none;
  font: inherit; font-size: 13px; font-weight: 400; color: var(--ink);
  text-align: left; cursor: pointer; white-space: nowrap;
}
.fsel-panel button:hover, .fsel-panel label:hover { background: var(--canvas); }
.fsel-panel button.active { background: var(--wash); color: var(--ink); font-weight: 600; }
.fsel-panel input[type="checkbox"] { flex: 0 0 auto; }
.fsel-group { display: block; padding: var(--s-2) 9px var(--s-1); font-size: var(--fs-xs); font-weight: 600; color: var(--muted); }
.fsel-group:not(:first-child) { margin-top: var(--s-1); padding-top: var(--s-2); border-top: 1px solid var(--line-soft); }
.fsel-panel:has(.fsel-group) { max-height: 480px; }
.fsel-opt { flex: 1; }
.fsel-panel:has(.fsel-meta) { max-width: 460px; }
.fsel-meta { margin-left: var(--s-3); font-size: var(--fs-sm); color: var(--muted); font-variant-numeric: tabular-nums; }
/* `.fsel-panel button` would make it a plain row (owner, 2026-11-12: "непомітна") – the panel prefix wins that back.
   Sticky: a long list keeps the button in sight; the white band under it hides the rows scrolling past. */
.fsel-panel .fsel-apply {
  position: sticky; bottom: -5px; z-index: 1;
  justify-content: center; width: 100%; height: 36px; margin: var(--s-2) 0 0;
  border: 0; border-radius: var(--radius);
  background: var(--ink); color: #fff;
  font: inherit; font-size: 13px; font-weight: 600; cursor: pointer;
  box-shadow: 0 6px 0 #fff, 0 -8px 12px #fff;
}
.fsel-panel .fsel-apply:hover { background: #3a3f52; }

/* ── Date range + calendar ─────────────────────────────────────────────── */
.fdate-trigger { min-width: 184px; }
.calendar-popover {
  display: none; position: absolute; z-index: 40; top: calc(100% + 8px); left: 0; /* opens to the right: the range sits on the left of the bar */
  max-width: calc(100vw - 40px);
  gap: 4px; padding: 10px;
  background: #fff; border: 1px solid var(--line); border-radius: 12px;
  box-shadow: 0 18px 40px rgba(30,35,52,.16);
}
.fdate-wrap.open .calendar-popover { display: flex; }
.calendar-presets {
  display: grid; grid-template-columns: repeat(2, minmax(0,1fr));
  align-content: start; gap: 2px;
  flex: 0 0 232px; padding-right: 8px; border-right: 1px solid var(--line);
}
.calendar-presets button {
  height: 34px; padding: 0 10px; margin: 0;
  border: 0; border-radius: 7px; background: none;
  font: inherit; font-size: 13px; color: var(--ink);
  text-align: left; white-space: nowrap; cursor: pointer;
}
.calendar-presets button:hover { background: var(--canvas); }
.calendar-presets button.active { background: var(--ink); color: #fff; font-weight: 550; }
.calendar-basis { grid-column: 1 / -1; display: flex; gap: 4px; margin-bottom: 6px; }
.calendar-basis button { flex: 1; text-align: center; height: 30px; font-size: 12.5px; background: var(--canvas); }
.calendar-basis button.active { background: var(--ink); color: #fff; }

.calendar-body { flex: 0 0 290px; padding: 2px 6px 0; }
.calendar-top {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 12px; font-size: 13px; font-weight: 650;
}
.calendar-top span { white-space: nowrap; font-variant-numeric: tabular-nums; }
.calendar-top button {
  width: 27px; height: 27px; display: grid; place-items: center;
  border: 0; border-radius: 6px; background: none; color: var(--muted); cursor: pointer;
}
.calendar-top button:hover { background: #f1f3f7; color: var(--ink); }
.calendar-grid { display: grid; grid-template-columns: repeat(7, 1fr); gap: 3px; text-align: center; }
.calendar-grid span {
  display: grid; place-items: center; height: 28px;
  font-size: 11px; font-weight: 650; color: var(--muted);
}
.calendar-grid button {
  height: 32px; border: 0; border-radius: 6px; background: none;
  font: inherit; font-size: 13px; color: var(--ink); cursor: pointer;
}
.calendar-grid button:hover { background: #f1f3f7; }
.calendar-grid button.outside { color: var(--subtle); }
.calendar-grid button:disabled { opacity: .45; cursor: not-allowed; background: none; }
.calendar-grid button.today { font-weight: 700; }
.calendar-grid button.in-range { background: #eceef3; border-radius: 0; }
.calendar-grid button.range-start,
.calendar-grid button.range-end { background: var(--ink); color: #fff; font-weight: 650; }
.calendar-grid button.range-start { border-radius: 6px 0 0 6px; }
.calendar-grid button.range-end   { border-radius: 0 6px 6px 0; }
.calendar-grid button.range-start.range-end { border-radius: 6px; }
.calendar-actions {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  margin-top: 12px; padding-top: 11px; border-top: 1px solid var(--line);
}
.calendar-draft { font-size: 12px; color: var(--muted); font-variant-numeric: tabular-nums; }
.calendar-actions button {
  border: 0; background: none; padding: 0;
  font: inherit; font-size: 12px; font-weight: 600; color: var(--muted); cursor: pointer;
}
.calendar-actions .calendar-apply {
  height: 30px; padding: 0 12px; border-radius: var(--radius);
  background: var(--ink); color: #fff;
}
.calendar-actions button[disabled] { opacity: .4; pointer-events: none; }

/* ── Overflow panel ───────────────────────────────────────────────────── */
.fbar-more-panel {
  display: none; position: absolute; z-index: 40; top: calc(100% + 7px); left: 0;
  width: max-content; padding: 14px;
  background: #fff; border: 1px solid var(--line); border-radius: 12px;
  box-shadow: 0 18px 40px rgba(30,35,52,.16);
}
.fbar-more.open .fbar-more-panel { display: grid; }
.fbar-more-panel { grid-template-columns: repeat(2, 220px); gap: 10px; }
.fbar-more-panel .fsel-trigger { width: 100%; max-width: none; }
.fbar-more-panel .fsel { width: 100%; }
.fbar-more-count {
  display: inline-grid; place-items: center; min-width: 20px; height: 18px; padding: 0 5px;
  border-radius: 999px; background: var(--ink); color: #fff;
  font-size: 11px; font-weight: 700;
}

/* ── Modal ────────────────────────────────────────────────────────────── */
.modal-overlay {
  display: none; position: fixed; inset: 0; z-index: 200;
  background: rgba(24,30,45,.35);
  align-items: flex-start; justify-content: center; padding: 10vh 20px 20px;
}
.modal-overlay.open { display: flex; }
.modal-card {
  width: min(620px, 100%); padding: 26px;
  background: #fff; border: 1px solid var(--line); border-radius: var(--radius);
  box-shadow: 0 24px 60px rgba(24,30,45,.2);
}
.modal-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; margin-bottom: 23px; }
.modal-head h2 { margin: 0; font-size: 22px; font-weight: 580; letter-spacing: -.035em; }
.modal-head p { margin: 5px 0 0; font-size: 13px; color: var(--muted); }
.modal-close {
  width: 34px; height: 34px; flex-shrink: 0;
  display: grid; place-items: center;
  border: 0; border-radius: var(--radius); background: #f4f5f7; color: var(--muted); cursor: pointer;
}
.modal-close:hover { color: var(--ink); }
.modal-grid { display: grid; grid-template-columns: repeat(2, minmax(0,1fr)); gap: 16px; }
.modal-actions { display: flex; justify-content: flex-end; gap: 9px; margin-top: 24px; }

/* The real control behind a .styled-select — kept for its value, never shown. */
.native-hidden { position: absolute; width: 1px; height: 1px; opacity: 0; pointer-events: none; }
.modal-card .fsel, .modal-card .fsel-trigger { width: 100%; max-width: none; height: 42px; }


/* ── Redesign step 2: page head, period presets, source icons ──────────────
   docs/DESIGN-SYSTEM.md "Redesign v3". Selection is ink; motion is transform / opacity. */
.phead {
  display: flex; justify-content: space-between; align-items: flex-end;
  gap: 16px 24px; flex-wrap: wrap; margin-bottom: 20px;
}
.phead-l { min-width: 0; }
.phead-date { font-size: 12.5px; color: var(--muted); }
.phead-title { font: 600 var(--fs-2xl)/1.15 var(--f-display); letter-spacing: -.02em; color: var(--ink); margin-top: 3px; }
.phead-ctx { display: flex; flex-wrap: wrap; gap: 6px; align-items: baseline; margin-top: 6px; font-size: var(--fs-sm); color: var(--muted); }
.phead-ctx b { color: var(--ink); font-weight: 600; }
.phead-r { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }

.pseg {
  display: inline-flex; flex-wrap: wrap; gap: 2px; padding: 3px;
  background: var(--panel); border: 1px solid var(--line); border-radius: 10px;
}
.pseg-i {
  position: relative; isolation: isolate; display: inline-flex; align-items: center;
  padding: 6px 11px; border-radius: 7px; white-space: nowrap;
  font-size: var(--fs-sm); font-weight: 500; color: var(--muted); text-decoration: none;
  transition: color var(--t) var(--ease);
}
.pseg-i:hover { color: var(--ink); }
.pseg-i.on { color: #fff; }
.pseg-i:focus-visible { outline: 2px solid var(--indigo); outline-offset: 2px; }
.pseg-l { display: inline-flex; gap: 6px; align-items: center; }
/* The plate is one named element per page, so the browser slides it between page loads. */
.pseg-plate { position: absolute; inset: 0; z-index: -1; background: var(--ink); border-radius: 7px; view-transition-name: seg-plate; }

.src { display: inline-flex; align-items: center; gap: 5px; white-space: nowrap; max-width: 100%; vertical-align: middle; }
.src-ic {
  width: 16px; height: 16px; border-radius: 4px; flex-shrink: 0; overflow: hidden;
  display: inline-grid; place-items: center; font: 700 9.5px/1 var(--f-display); font-style: normal;
  color: #fff; background: var(--subtle);
}
.src-ic.img { background: var(--neutral-soft); }
.src-ic img { width: 100%; height: 100%; object-fit: contain; }
.src-name { overflow: hidden; text-overflow: ellipsis; }

@media (prefers-reduced-motion: reduce) {
  .pseg-i { transition: none; }
}
/* A source icon inside a filter option or trigger sits before the label. */
.fsel-label .src { margin-right: 7px; }
.fsel-panel .src-ic, .fsel-label .src-ic { width: 16px; height: 16px; }

/* ── Redesign step 4: data lists (orders, receipts) ─────────────────────────
   One fact per column, secondary facts under the main one, sums right, sticky head,
   state = dot + words (no emoji), ink for selection. docs/DESIGN-SYSTEM.md "Redesign v3". */

/* State tabs with counts – the main question of a list, one click each */
.stabs { display: flex; gap: 2px; border-bottom: 1px solid var(--line); margin: 4px 0 14px; overflow-x: auto; scrollbar-width: none; }
.stabs::-webkit-scrollbar { display: none; }
.stab {
  position: relative; display: inline-flex; align-items: center; gap: 7px; white-space: nowrap;
  padding: 10px 12px 11px; font-size: 13px; font-weight: 500; color: var(--muted); text-decoration: none;
  transition: color var(--t) var(--ease);
}
.stab:hover { color: var(--ink); }
.stab.on { color: var(--ink); }
.stab-n {
  font-size: 11.5px; font-weight: 600; padding: 0 6px; border-radius: 99px; line-height: 18px;
  background: var(--wash); color: var(--subtle); font-variant-numeric: tabular-nums;
}
.stab.on .stab-n { background: var(--ink); color: #fff; }
.stab.err .stab-n { background: var(--red-soft); color: var(--red-ink); }
.stab-line { position: absolute; left: 0; right: 0; bottom: -1px; height: 2px; background: var(--ink); border-radius: 2px; view-transition-name: stab-line; }
.stab:focus-visible { outline: 2px solid var(--indigo); outline-offset: -2px; border-radius: 6px; }

/* The list */
.dlist { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); overflow: auto; max-height: calc(100vh - 150px); }
.dtable { width: 100%; border-collapse: separate; border-spacing: 0; font-size: 13px; }
.dtable thead th {
  position: sticky; top: 0; z-index: 2; background: var(--nav);
  text-align: left; font-size: 12px; font-weight: 500; color: var(--muted); white-space: nowrap;
  padding: 10px 14px; border-bottom: 1px solid var(--line); letter-spacing: 0; text-transform: none;
}
.dtable tbody tr { border: 0; transition: background var(--t-fast) var(--ease); }
.dtable tbody tr:hover { background: var(--canvas); }
.dtable tbody tr:has(.row-check:checked) { background: #f5f6fa; }
.dtable tbody td { padding: 11px 14px; border-bottom: 1px solid #f1f2f4; color: var(--ink); vertical-align: middle; white-space: nowrap; min-height: 0; }
.dtable tbody tr:last-child td { border-bottom: 0; }
.dtable .num { text-align: right; font-weight: 600; font-variant-numeric: tabular-nums; }
.dtable .chk { width: 34px; padding-right: 0; }
.dtable .dstate { white-space: normal; min-width: 220px; max-width: 340px; }
.dtable .dwhen { color: var(--muted); font-size: 12.5px; }
.dtable .acts { text-align: right; position: sticky; right: 0; background: inherit; }
.dtable thead th.acts { background: var(--nav); z-index: 3; }
.dtable tbody td.acts { background: var(--panel); box-shadow: -10px 0 10px -10px rgba(31,35,49,.12); }
.dtable tbody tr:hover td.acts { background: var(--canvas); }
.dtable .oid { font-weight: 600; color: var(--ink); text-decoration: none; font-variant-numeric: tabular-nums; }
.dtable .oid:hover { color: var(--indigo-ink); }
.dsub { font-size: 12px; color: var(--muted); margin-top: 2px; white-space: normal; }
.dsub.derr { color: var(--red-ink); }
.dnone { color: var(--subtle); }

/* State: coloured dot + words */
.state { display: inline-flex; align-items: center; gap: 6px; font-weight: 500; white-space: nowrap; }
.state::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; flex-shrink: 0; }
.s-ok { color: var(--green-ink); }
.s-wait { color: var(--orange-ink); }
.s-err { color: var(--red-ink); }
.s-mute { color: var(--muted); }
.s-ind { color: var(--indigo-ink); }

/* Row actions */
.dbtn {
  display: inline-flex; align-items: center; gap: 5px; height: 28px; padding: 0 10px; margin-left: 4px;
  border: 1px solid var(--line); border-radius: 7px; background: var(--panel); color: var(--ink);
  font: 500 12px var(--f-ui); text-decoration: none; cursor: pointer; white-space: nowrap;
  transition: border-color var(--t-fast) var(--ease), background var(--t-fast) var(--ease);
}
.dbtn:hover { border-color: var(--line-strong); }
.dbtn.pri { background: var(--ink); border-color: var(--ink); color: #fff; }
.dbtn.pri:hover { background: #3a3f52; }
.dbtn:disabled { opacity: .5; cursor: not-allowed; }
.dbtn:focus-visible { outline: 2px solid var(--indigo); outline-offset: 2px; }

/* Empty result: name the filter, offer the way out */
.dempty { display: flex; flex-direction: column; align-items: center; gap: 4px; padding: 56px 16px; text-align: center; color: var(--muted); font-size: 13px; }
.dempty b { color: var(--ink); font: 600 15px var(--f-display); }
.dempty .btn { margin-top: 12px; }

/* Pagination (shared look) */
.pagination { display: flex; gap: 4px; align-items: center; justify-content: center; margin-top: 18px; flex-wrap: wrap; }
.pagination a, .pagination span {
  display: inline-flex; align-items: center; justify-content: center; min-width: 32px; height: 32px; padding: 0 8px;
  border-radius: 8px; font-size: 13px; font-weight: 500; text-decoration: none;
  border: 1px solid var(--line); background: var(--panel); color: var(--muted); font-variant-numeric: tabular-nums;
}
.pagination a:hover { border-color: var(--line-strong); color: var(--ink); }
.pagination .pg-cur { background: var(--ink); color: #fff; border-color: var(--ink); }
.pagination .pg-dots { border: 0; background: none; }
.dbtn.dicon { width: 28px; padding: 0; justify-content: center; color: var(--muted); }
.dbtn.dicon:hover { color: var(--red-ink); border-color: var(--red-line); }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.dtable .num .dsub { white-space: nowrap; font-weight: 400; }

/* ── Redesign step 3: Огляд (dashboard) ────────────────────────────────────
   Metrics grouped by meaning, smooth sparklines (core/Charts.php), latest orders, hour bars,
   funnel, kasa health. Entrance motion is transform/opacity only and only with .ov-anim. */
:root { --ink-2: #3a3f52; }
.ov-alert {
  display: flex; gap: 10px; align-items: center; flex-wrap: wrap; margin-bottom: 14px;
  background: var(--red-soft); border: 1px solid var(--red-line); border-radius: var(--radius);
  padding: 10px 14px; font-size: 13px; color: var(--ink);
}
.ov-alert svg { color: var(--red-ink); flex-shrink: 0; }
.ov-alert b { color: var(--red-ink); font-weight: 600; }
.ov-alert a { margin-left: auto; color: var(--red-ink); font-weight: 600; font-size: 12.5px; text-decoration: none; }
.ov-alert a:hover { text-decoration: underline; }

.ov-groups { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; margin-bottom: 12px; }
.ov-group { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); min-width: 0; overflow: hidden; }
.ov-group-h { display: flex; justify-content: space-between; align-items: baseline; padding: 12px 16px 0; }
.ov-group-h b { font-size: 13px; font-weight: 600; color: var(--ink); }
.ov-group-h a { font-size: 12px; color: var(--indigo-ink); text-decoration: none; }
.ov-group-h a:hover { text-decoration: underline; }
.ov-pair { display: grid; grid-template-columns: 1fr 1fr; }
.ov-kpi {
  display: grid; grid-template-columns: 1fr auto; grid-template-rows: auto auto auto; column-gap: 10px;
  padding: 10px 16px 14px; color: inherit; text-decoration: none; min-width: 0;
  transition: background var(--t-fast) var(--ease);
}
.ov-kpi + .ov-kpi { border-left: 1px solid #f1f2f4; }
.ov-kpi:hover { background: var(--canvas); }
.ov-kl { grid-column: 1 / -1; font-size: 12.5px; color: var(--muted); }
.ov-kv { font: 600 28px/1.1 var(--f-display); letter-spacing: -.02em; margin-top: 6px; color: var(--ink); font-variant-numeric: tabular-nums; }
.ov-kpi.warn .ov-kv { color: var(--red-ink); }
.ov-kd { font-size: 12px; font-weight: 500; margin-top: 3px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.ov-kd.up { color: var(--green-ink); } .ov-kd.down { color: var(--red-ink); } .ov-kd.flat { color: var(--muted); }
.ov-spark { grid-row: 2 / 4; grid-column: 2; align-self: end; width: 96px; height: 38px; overflow: visible; }

.ov-cols { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 12px; margin-bottom: 12px; }
.ov-panel { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px 16px; min-width: 0; }
.ov-ph { display: flex; justify-content: space-between; align-items: baseline; gap: 8px; flex-wrap: wrap; margin-bottom: 8px; }
.ov-ph b { font: 600 15px var(--f-display); color: var(--ink); }
.ov-ph small { font-size: 12px; color: var(--muted); }
.ov-empty { padding: 28px 8px; text-align: center; color: var(--muted); font-size: 13px; }
.ov-dim { color: var(--muted); font-weight: 400; }

.ov-feed { list-style: none; margin: 0; padding: 0; }
.ov-feed li { display: grid; grid-template-columns: 32px 1fr auto; gap: 10px; align-items: center; padding: 9px 0; border-top: 1px solid #f1f2f4; }
.ov-feed li:first-child { border-top: 0; }
.ov-feed .src-ic { width: 32px; height: 32px; border-radius: 8px; font-size: 13px; }
.ov-ft { min-width: 0; }
.ov-ft b { font-size: 13px; font-weight: 600; color: var(--ink); }
.ov-oid { font-size: 12.5px; color: var(--ink-2); text-decoration: none; margin-left: 4px; font-variant-numeric: tabular-nums; }
.ov-oid:hover { color: var(--indigo-ink); }
.ov-line { display: flex; gap: 5px; align-items: center; font-size: 12px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; margin-top: 1px; }
.ov-fr { text-align: right; font-size: 12px; color: var(--muted); white-space: nowrap; }
.ov-fr b { display: block; font-size: 13px; font-weight: 600; color: var(--ink); font-variant-numeric: tabular-nums; }
.ov-more { display: block; text-align: center; font-size: 12.5px; font-weight: 500; padding-top: 10px; margin-top: 2px; border-top: 1px solid #f1f2f4; color: var(--indigo-ink); text-decoration: none; }

.ov-legend { display: flex; gap: 12px; font-size: 11.5px; color: var(--muted); }
.ov-legend i { display: inline-block; width: 8px; height: 8px; border-radius: 2px; margin-right: 5px; }
.ov-peak { font: 600 24px/1.1 var(--f-display); letter-spacing: -.02em; color: var(--ink); }
.ov-psub { font-size: 12px; color: var(--muted); margin: 3px 0 12px; }
.ov-bars { height: 168px; display: grid; grid-template-columns: repeat(24, 1fr); gap: 3px; align-items: end; border-bottom: 1px solid var(--line); }
.ov-bar { position: relative; height: 100%; }
.ov-bar .p, .ov-bar .c { position: absolute; left: 0; right: 0; bottom: 0; height: 100%; border-radius: 3px 3px 0 0; transform-origin: bottom; transform: scaleY(var(--s)); }
.ov-bar .p { background: var(--prev); }
.ov-bar .c { background: var(--ink-2); left: 2px; right: 2px; }
.ov-bar.peak .c { background: var(--ink); }
.ov-bar:hover .c { background: var(--indigo); }
.ov-bar .tip { position: absolute; bottom: calc(100% + 6px); left: 50%; transform: translate(-50%, 3px); background: var(--ink); color: #fff; font-size: 11px; padding: 3px 7px; border-radius: 6px; white-space: nowrap; z-index: 2; pointer-events: none; opacity: 0; transition: opacity var(--t-fast) var(--ease), transform var(--t-fast) var(--ease); }
.ov-bar:hover .tip { opacity: 1; transform: translate(-50%, 0); }
.ov-axis { display: grid; grid-template-columns: repeat(24, 1fr); gap: 3px; font-size: 10.5px; color: var(--subtle); margin-top: 5px; font-variant-numeric: tabular-nums; }
.ov-quarters { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; margin-top: 14px; padding-top: 12px; border-top: 1px solid #f1f2f4; }
.ov-quarters div { font-size: 11.5px; color: var(--muted); }
.ov-quarters b { display: block; font: 600 16px var(--f-display); color: var(--ink); margin: 2px 0; font-variant-numeric: tabular-nums; }

.ov-funnel { display: flex; flex-direction: column; gap: 9px; }
.ov-fstep { display: grid; grid-template-columns: 170px 1fr 56px; gap: 10px; align-items: center; font-size: 12.5px; color: var(--ink); }
.ov-track { height: 8px; background: #f1f2f4; border-radius: 99px; overflow: hidden; }
.ov-track i { display: block; height: 100%; width: 100%; border-radius: 99px; transform-origin: left; transform: scaleX(var(--s)); }
.ov-n { text-align: right; font-weight: 600; font-variant-numeric: tabular-nums; }

.ov-kasa { display: grid; grid-template-columns: 1fr auto; gap: 10px; align-items: center; padding: 9px 0; border-top: 1px solid #f1f2f4; font-size: 12.5px; }
.ov-kasa:first-child { border-top: 0; }
.ov-kasa b { font-weight: 600; color: var(--ink); }
.ov-kasa small { display: block; color: var(--muted); font-size: 11.5px; margin-top: 1px; }

/* Entrance (only when JS confirmed motion is allowed) */
.ov-anim .ov-spark-line { stroke-dasharray: 1; stroke-dashoffset: 1; }
.ov-anim .ov-bar .p, .ov-anim .ov-bar .c { transform: scaleY(0); }
.ov-anim .ov-track i { transform: scaleX(0); }
.ov-anim .ov-feed li { opacity: 0; transform: translateY(6px); }
.ov-in .ov-spark-line { stroke-dashoffset: 0; transition: stroke-dashoffset 700ms var(--ease); }
.ov-in .ov-bar .p, .ov-in .ov-bar .c { transform: scaleY(var(--s)); transition: transform var(--t-data) var(--ease); transition-delay: calc(var(--i) * 10ms); }
.ov-in .ov-track i { transform: scaleX(var(--s)); transition: transform var(--t-data) var(--ease); transition-delay: calc(var(--i) * 30ms); }
.ov-in .ov-feed li { opacity: 1; transform: none; transition: opacity 320ms var(--ease), transform 320ms var(--ease); transition-delay: calc(var(--i) * 30ms); }

@media (max-width: 1180px) { .ov-groups, .ov-cols { grid-template-columns: 1fr; } }
@media (max-width: 640px) {
  .ov-pair { grid-template-columns: 1fr; }
  .ov-kpi + .ov-kpi { border-left: 0; border-top: 1px solid #f1f2f4; }
  .ov-fstep { grid-template-columns: 120px 1fr 44px; }
  .ov-quarters { grid-template-columns: repeat(2, 1fr); }
}

/* Projects list */
.dtable .shop { display: inline-flex; align-items: center; gap: 10px; color: inherit; text-decoration: none; }
.dtable .shop b { display: block; font-weight: 600; color: var(--ink); }
.dtable .shop:hover b { color: var(--indigo-ink); }
.dtable tr.off .shop b, .dtable tr.off .shop-ava { opacity: .55; }
.phead-r .btn { display: inline-flex; align-items: center; gap: 6px; }

/* Аналітика (stats) – same blocks as Огляд */
.st-quad { margin-bottom: 12px; }
.st-four { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); }
.st-four .st-k { display: flex; flex-direction: column; }
.st-four .st-k + .st-k { border-left: 1px solid #f1f2f4; }
.st-funnel .ov-fstep { grid-template-columns: 210px 1fr 96px; }
.st-funnel .ov-n small, .st-share small { color: var(--muted); font-weight: 400; font-size: 11.5px; margin-left: 4px; }
.st-hint { display: block; font-size: 11.5px; color: var(--muted); }
.st-block { margin-top: 18px; }
.st-h { font: 600 15px var(--f-display); color: var(--ink); margin: 0 0 10px; }
.st-share { display: flex; align-items: center; gap: 10px; }
.st-share .ov-track { flex: 1; }
.st-inline { display: inline; margin: 0; }
@media (max-width: 1180px) { .st-four { grid-template-columns: repeat(2, minmax(0, 1fr)); } .st-four .st-k:nth-child(3) { border-left: 0; } }
/* State tabs that do not fit fade at the edge (admin.js toggles .is-scroll / .at-end). */
.stabs.is-scroll { -webkit-mask-image: linear-gradient(to right, #000 calc(100% - 48px), transparent); mask-image: linear-gradient(to right, #000 calc(100% - 48px), transparent); }
.stabs.is-scroll.at-end { -webkit-mask-image: none; mask-image: none; }

/* ── Round 2: rows, actions, order side panel ───────────────────────────────
   Rows read as clickable (hover tint, pointer), actions are quiet until the row is hovered,
   no sticky divider next to them. */
.dtable tbody tr[data-details] { cursor: pointer; }
.dtable tbody tr:hover { background: #f5f6f9; }
.dtable tbody tr.is-open { background: #eef0f5; }
.dtable .acts { position: static; background: none; box-shadow: none; white-space: nowrap; }
.dtable tbody td.acts { background: none; box-shadow: none; }
.dtable thead th.acts { background: var(--nav); }
.dtable tbody tr:hover td.acts { background: none; }
.dbtn { color: var(--ink-2); }
.dbtn:hover { border-color: var(--ink); color: var(--ink); background: #fff; }
.dbtn.pri:hover { background: #3a3f52; color: #fff; }
.dtable tbody tr:not(:hover):not(.is-open) .dbtn:not(.pri) { border-color: transparent; background: none; color: var(--muted); }

.drawer { position: fixed; inset: 0; z-index: 500; pointer-events: none; }
.drawer-backdrop { position: absolute; inset: 0; background: rgba(29,32,48,.18); opacity: 0; transition: opacity var(--t) var(--ease); }
.drawer-panel {
  position: absolute; top: 0; right: 0; bottom: 0; width: min(480px, 100vw);
  background: var(--panel); border-left: 1px solid var(--line);
  box-shadow: -24px 0 48px -24px rgba(29,32,48,.18);
  transform: translateX(16px); opacity: 0; overflow-y: auto;
  transition: transform var(--t) var(--ease), opacity var(--t) var(--ease);
}
.drawer.open { pointer-events: auto; }
.drawer.open .drawer-backdrop { opacity: 1; }
.drawer.open .drawer-panel { transform: none; opacity: 1; }
.drawer-body { padding: 20px 22px 40px; }
.dr-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; }
.dr-kicker { font-size: 12px; color: var(--muted); display: flex; gap: 6px; align-items: center; flex-wrap: wrap; }
.dr-title { font: 600 22px/1.2 var(--f-display); letter-spacing: -.02em; color: var(--ink); margin-top: 4px; }
.dr-sum { color: var(--muted); font-weight: 500; margin-left: 6px; }
.dr-sub { font-size: 12.5px; color: var(--muted); margin-top: 4px; display: flex; gap: 6px; align-items: center; flex-wrap: wrap; }
.dr-close { width: 32px; height: 32px; border-radius: 8px; border: 1px solid var(--line); background: #fff; color: var(--muted); display: grid; place-items: center; cursor: pointer; flex-shrink: 0; }
.dr-close:hover { color: var(--ink); border-color: var(--line-strong); }
.dr-actions { display: flex; gap: 6px; margin: 14px 0 4px; }
.dr-actions .dbtn { margin: 0; border-color: var(--line); }
.dr-sec { border-top: 1px solid #f1f2f4; margin-top: 16px; padding-top: 14px; }
.dr-sec h3 { font: 600 13px var(--f-ui); color: var(--ink); margin: 0 0 10px; }
.dr-sec h3 small { color: var(--muted); font-weight: 500; margin-left: 4px; }
.dr-dl { display: grid; grid-template-columns: 110px 1fr; gap: 6px 12px; margin: 0; font-size: 13px; }
.dr-dl dt { color: var(--muted); }
.dr-dl dd { margin: 0; color: var(--ink); overflow-wrap: anywhere; }
.dr-items { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 10px; }
.dr-items li { display: grid; grid-template-columns: 40px 1fr auto; gap: 10px; align-items: center; font-size: 13px; }
.dr-items img, .dr-noimg { width: 40px; height: 40px; border-radius: 8px; object-fit: cover; background: var(--wash); border: 1px solid var(--line); }
.dr-iname { min-width: 0; color: var(--ink); }
.dr-iname small { display: block; color: var(--muted); font-size: 12px; margin-top: 2px; }
.dr-items b { font-weight: 600; font-variant-numeric: tabular-nums; }
.dr-receipt { display: flex; flex-direction: column; gap: 3px; margin-bottom: 8px; font-size: 13px; }
.dr-receipt small { color: var(--muted); font-size: 12px; }
.dr-time { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 8px; font-size: 13px; }
.dr-time li { display: flex; justify-content: space-between; gap: 10px; }
.dr-time time { color: var(--muted); font-size: 12px; font-variant-numeric: tabular-nums; }
.dr-muted { color: var(--muted); font-size: 12.5px; margin: 0 0 6px; }
.dr-empty { padding: 40px 8px; text-align: center; color: var(--muted); }
.dr-loading { display: flex; flex-direction: column; gap: 12px; }
.dr-loading span { height: 14px; border-radius: 6px; background: linear-gradient(90deg, #f1f2f4, #e8e9ee, #f1f2f4); background-size: 200% 100%; animation: dr-sh 1.1s linear infinite; }
.dr-loading span:nth-child(1) { width: 60%; height: 22px; } .dr-loading span:nth-child(2) { width: 90%; } .dr-loading span:nth-child(3) { width: 75%; }
@keyframes dr-sh { to { background-position: -200% 0; } }
@media (prefers-reduced-motion: reduce) { .drawer-panel, .drawer-backdrop { transition: none; } .dr-loading span { animation: none; } }

/* ── Аналітика (round 2): dashboard ─────────────────────────────────────── */
.an-range { display: flex; }
.an-range .fbar { background: none; border: 0; padding: 0; box-shadow: none; margin: 0; }
.an-cards { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 12px; margin-bottom: 12px; }
.an-card {
  position: relative; display: grid; grid-template-columns: 1fr auto; grid-template-rows: auto auto auto; column-gap: 10px;
  background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px 16px; min-width: 0;
}
.an-l { grid-column: 1 / -1; font-size: 12.5px; color: var(--muted); }
.an-v { font: 600 28px/1.1 var(--f-display); letter-spacing: -.02em; color: var(--ink); margin-top: 8px; font-variant-numeric: tabular-nums; }
.an-d { font-size: 12px; font-weight: 500; margin-top: 4px; }
.an-d.up { color: var(--green-ink); } .an-d.down { color: var(--red-ink); } .an-d.flat { color: var(--muted); }
.an-card .ov-spark { grid-row: 2 / 4; grid-column: 2; align-self: end; }
.an-card-plain { grid-template-columns: 1fr; }
.an-card-plain .an-d { grid-column: 1; }
.an-solo { margin-bottom: 12px; }
.an-range .fdate-trigger { min-width: 0; }
.an-chart-panel { margin-bottom: 12px; }
.an-chart { width: 100%; display: grid; grid-template-columns: auto minmax(0, 1fr) auto; gap: 10px; }
.an-plot { position: relative; min-width: 0; }
.an-chart svg { width: 100%; height: 240px; display: block; overflow: visible; }
/* Axis labels are HTML, so they keep their shape however wide the chart stretches. */
.an-yl, .an-yr { display: flex; flex-direction: column; justify-content: space-between; height: 240px; font-size: 11px; color: var(--subtle); font-variant-numeric: tabular-nums; line-height: 1; }
.an-yl { text-align: right; } .an-yr { color: #5fae8c; }
.an-yl span, .an-yr span { transform: translateY(-50%); } .an-yl span:last-child, .an-yr span:last-child { transform: none; }
.an-yl span:first-child, .an-yr span:first-child { transform: none; }
.an-xl { position: relative; height: 22px; margin-top: 6px; }
.an-xl span { position: absolute; top: 0; transform: translateX(-50%); font-size: 11px; color: var(--muted); white-space: nowrap; font-variant-numeric: tabular-nums; }
.an-bar .an-hit:hover { fill: rgba(29,32,48,.04); }
.an-li { display: inline-block; width: 14px; height: 2px; background: var(--green); border-radius: 2px; vertical-align: middle; margin-right: 5px; }
.an-heat { display: grid; grid-template-columns: 26px repeat(24, minmax(0, 1fr)); gap: 3px; align-items: center; }
.an-hd { font-size: 11px; color: var(--muted); }
.an-hc { height: 18px; border-radius: 3px; background: rgba(29,32,48, calc(.04 + var(--a) * .86)); }
.an-hc:hover { outline: 2px solid var(--ink); outline-offset: 1px; }
.an-hx { font-size: 10px; color: var(--subtle); text-align: left; font-variant-numeric: tabular-nums; }
.an-heat-legend { display: flex; align-items: center; gap: 4px; justify-content: flex-end; margin-top: 10px; font-size: 11px; color: var(--muted); }
.an-heat-legend i { width: 14px; height: 10px; border-radius: 2px; background: rgba(29,32,48, calc(.04 + var(--a) * .86)); }
.an-tbl { padding-bottom: 6px; }
.an-tbl .dtable thead th { position: static; background: none; padding-left: 0; }
.an-tbl .dtable tbody td { padding-left: 0; }
@media (max-width: 1180px) { .an-cards { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
@media (max-width: 640px) { .an-cards { grid-template-columns: 1fr; } }

/* Settings-like pages (Сповіщення, Система): two columns of cards instead of one long strip. */
.content-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; align-items: start; max-width: 1240px; }
.content-grid > .card, .content-grid > .alert { margin: 0 !important; }
.content-grid > .alert { grid-column: 1 / -1; }
@media (max-width: 1100px) { .content-grid { grid-template-columns: 1fr; max-width: 760px; } }
