/* =========================================================
   Контроль замовлень — тема «Скло»
   Темний фон з кольоровими плямами (кольори лого),
   напівпрозорі картки, жовто-зелений акцент для головних дій.
   ========================================================= */

/* ===== Токени ===== */
:root {
  color-scheme: dark;
  --bg: #0b1020;
  --glass: rgba(255, 255, 255, .055);
  --glass-hi: rgba(255, 255, 255, .09);
  --glass-line: rgba(255, 255, 255, .11);
  --glass-line-hi: rgba(255, 255, 255, .22);
  --solid: #141a2c;            /* непрозорі меню та діалоги */
  --text: #eef2ff;
  --muted: #95a1c0;
  --faint: #6c7896;
  --line: rgba(255, 255, 255, .08);

  --brand: #5b9bd5;            /* блакитний з лого */
  --lime: #d4df3f;             /* жовто-зелений з лого */
  --lime-2: #a6d86a;
  --on-lime: #0b1020;

  /* кольори етапів і категорій */
  --c-all: #8ec0f0;
  --c-pay: #facc15;
  --c-ship: #a78bfa;
  --c-partial: #fb923c;
  --c-done: #4ade80;
  --c-bad: #f87171;

  --ok: #4ade80;
  --warn: #f87171;
  --short: #fb923c;
  --danger: #ef4444;

  --shadow-pop: 0 24px 60px rgba(0, 0, 0, .55);
  --r-card: 18px;
  --r-ctl: 11px;
  --h-ctl: 40px;
  --blur: blur(18px) saturate(140%);
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
  color: var(--text);
  font: 14.5px/1.5 Manrope, -apple-system, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
}
/* кольорові плями на фоні: фіксовані, не заважають кліку */
body::before, body::after {
  content: ""; position: fixed; z-index: -1; border-radius: 50%; pointer-events: none;
  filter: blur(110px); opacity: .5;
}
body::before { width: 620px; height: 620px; background: #3f7fc0; top: -220px; left: -180px; }
body::after  { width: 560px; height: 560px; background: #8f9c25; bottom: -240px; right: -160px; opacity: .42; }

h1, h2 { margin: 0; font-weight: 800; letter-spacing: -.015em; }
h2 { font-size: 22px; }
p { margin: 0; }
.muted { color: var(--muted); }
.small { font-size: 12.5px; }
.req { color: var(--warn); font-weight: 700; }
.req-note { font-size: 12.5px; color: var(--muted); margin-top: 4px; }
.lbl-hint { font-weight: 500; color: var(--faint); font-size: 12px; }
.error { color: #fecaca; background: rgba(239, 68, 68, .14); border: 1px solid rgba(239, 68, 68, .35); border-radius: var(--r-ctl); padding: 9px 13px; margin-top: 12px; font-size: 14px; }
.notice { background: rgba(91, 155, 213, .14); border: 1px solid rgba(91, 155, 213, .35); color: var(--text); border-radius: var(--r-ctl); padding: 11px 15px; font-size: 14px; }

.card, .glass {
  background: var(--glass);
  border: 1px solid var(--glass-line);
  border-radius: var(--r-card);
  -webkit-backdrop-filter: var(--blur);
  backdrop-filter: var(--blur);
}

/* ===== Кнопки ===== */
.btn {
  font: inherit; font-weight: 600; font-size: 14px; line-height: 1;
  display: inline-flex; align-items: center; justify-content: center; gap: 7px;
  height: var(--h-ctl); padding: 0 16px;
  border-radius: var(--r-ctl);
  border: 1px solid var(--glass-line);
  background: var(--glass-hi); color: var(--text);
  cursor: pointer; white-space: nowrap;
  transition: background-color .15s, border-color .15s, filter .15s, transform .08s, box-shadow .15s;
}
.btn:hover { background: rgba(255, 255, 255, .14); border-color: var(--glass-line-hi); }
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: .45; cursor: not-allowed; transform: none; }
.btn.lg { height: 46px; font-size: 15px; }
.btn.sm, .row-edit, .parcel-add, .parcel-confirm, .parcel .btn { height: 30px; padding: 0 11px; font-size: 12.5px; border-radius: 9px; }

/* головна дія — фірмовий жовто-зелений */
.btn.primary {
  background: linear-gradient(135deg, var(--lime), var(--lime-2));
  border-color: transparent; color: var(--on-lime); font-weight: 800;
  box-shadow: 0 6px 20px rgba(212, 223, 63, .22);
}
.btn.primary:hover { filter: brightness(1.07); border-color: transparent; box-shadow: 0 8px 26px rgba(212, 223, 63, .32); }
.btn.danger { color: #fca5a5; border-color: rgba(239, 68, 68, .4); background: rgba(239, 68, 68, .08); }
.btn.danger:hover { background: rgba(239, 68, 68, .18); border-color: rgba(239, 68, 68, .7); }
.btn.danger-fill { background: var(--danger); border-color: var(--danger); color: #fff; }
.btn.btn-green { background: rgba(74, 222, 128, .16); border-color: rgba(74, 222, 128, .45); color: #86efac; }
.btn.btn-green:hover { background: rgba(74, 222, 128, .26); border-color: rgba(74, 222, 128, .7); }
.btn.has-filters { border-color: var(--brand); color: #b9d8f5; background: rgba(91, 155, 213, .16); }

.icon-btn {
  display: inline-grid; place-items: center; width: 36px; height: 36px; padding: 0;
  border-radius: 10px; border: 1px solid transparent; background: none; color: var(--muted); cursor: pointer;
  transition: background-color .15s, color .15s;
}
.icon-btn:hover { background: rgba(239, 68, 68, .16); color: #fca5a5; }

/* ===== Поля ===== */
input, select, textarea {
  font: inherit; font-size: 14.5px;
  width: 100%; height: var(--h-ctl); padding: 0 12px;
  border-radius: var(--r-ctl);
  border: 1px solid var(--glass-line);
  background: rgba(255, 255, 255, .05); color: var(--text);
  transition: border-color .15s, box-shadow .15s, background-color .15s;
}
select option { background: var(--solid); color: var(--text); }
textarea { height: auto; padding: 10px 12px; resize: vertical; line-height: 1.45; }
select { padding-right: 8px; }
input::placeholder, textarea::placeholder { color: var(--faint); }
input:hover, select:hover, textarea:hover { border-color: var(--glass-line-hi); }
input:focus-visible, select:focus-visible, textarea:focus-visible {
  outline: none; border-color: var(--brand); background: rgba(255, 255, 255, .08);
  box-shadow: 0 0 0 3px rgba(91, 155, 213, .28);
}
.btn:focus-visible, .step:focus-visible, .tab:focus-visible, .navbtn:focus-visible, .icon-btn:focus-visible, a:focus-visible {
  outline: 2px solid var(--lime); outline-offset: 2px;
}
input[type=checkbox], input[type=radio] { width: 18px; height: 18px; padding: 0; margin: 0; accent-color: var(--lime); cursor: pointer; flex: none; }

label { display: block; font-size: 13px; font-weight: 600; color: var(--text); }
label > input, label > select, label > textarea, label > .combo, label > .inline { margin-top: 6px; }
.check { display: flex; align-items: center; gap: 9px; white-space: nowrap; font-weight: 500; cursor: pointer; }
.check input { margin-top: 0; }
.field > label { margin-bottom: 0; }

/* ===== Вхід ===== */
.login { min-height: 100vh; display: grid; place-items: center; padding: 16px; }
.login-card { width: 100%; max-width: 400px; padding: 32px; display: grid; gap: 16px; box-shadow: var(--shadow-pop); }
.login-card .muted { margin-top: -6px; }
.demo-hint { font-size: 13px; color: var(--muted); }

/* ===== Бренд ===== */
.brand { display: flex; align-items: center; gap: 11px; }
.brand h1 { font-size: 16.5px; white-space: nowrap; }
.brand-lg h1 { font-size: 22px; }
.logo-img { width: 32px; height: 32px; flex: none; display: block; }
.brand-lg .logo-img { width: 48px; height: 48px; }

/* ===== Верхня панель ===== */
.topbar-wrap { position: sticky; top: 0; z-index: 20; padding: 14px 24px 0; }
.topbar {
  max-width: 1500px; margin: 0 auto; padding: 9px 10px 9px 16px;
  display: flex; align-items: center; gap: 16px;
  background: rgba(16, 22, 40, .72);
  box-shadow: 0 10px 30px rgba(0, 0, 0, .25);
}
.topnav { display: flex; align-items: center; gap: 4px; margin: 0 auto; }
.navbtn {
  font: inherit; font-size: 14px; font-weight: 700; color: var(--muted);
  display: inline-flex; align-items: center; gap: 8px;
  height: 38px; padding: 0 15px; border-radius: 12px; border: 0; background: none; cursor: pointer;
  transition: background-color .15s, color .15s;
}
.navbtn:hover { color: var(--text); background: rgba(255, 255, 255, .07); }
.navbtn.active { color: var(--text); background: rgba(255, 255, 255, .14); }
.user { display: flex; align-items: center; gap: 9px; }
.avatar {
  display: grid; place-items: center; width: 32px; height: 32px; border-radius: 50%;
  background: linear-gradient(135deg, var(--lime), var(--lime-2)); color: var(--on-lime);
  font-weight: 800; font-size: 14px;
}
.avatar:empty { display: none; }
.user-email { font-size: 13.5px; font-weight: 600; max-width: 160px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.banner { max-width: 1500px; margin: 12px auto 0; background: rgba(250, 204, 21, .12); border: 1px solid rgba(250, 204, 21, .35); color: #fde68a; padding: 8px 16px; border-radius: 12px; font-size: 13px; text-align: center; }

.count {
  display: inline-block; min-width: 22px; padding: 1px 7px; border-radius: 11px;
  background: rgba(255, 255, 255, .12); color: var(--text);
  font-size: 11.5px; font-weight: 800; text-align: center; line-height: 1.6;
}
.count:empty { display: none; }
.count.warn { background: rgba(248, 113, 113, .22); color: #fecaca; }
.navbtn.active .count { background: var(--lime); color: var(--on-lime); }

/* ===== Макет ===== */
.container { max-width: 1500px; margin: 0 auto; padding: 22px 24px 40px; display: grid; gap: 20px; }
.stack { display: grid; gap: 16px; align-content: start; }
.section-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; flex-wrap: wrap; }
.section-head .muted.small { margin-top: 4px; }
.section-tools { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.section-tools input[type=search] { width: 340px; max-width: 100%; }
.section-tools select { width: 180px; }

/* ===== Категорії-картки (вкладки) ===== */
.cats { display: grid; grid-template-columns: repeat(6, minmax(0, 1fr)); gap: 12px; }
.cat {
  --c: var(--c-all);
  position: relative; overflow: hidden; text-align: left;
  font: inherit; color: var(--text); cursor: pointer;
  display: grid; gap: 2px; align-content: start;
  padding: 15px 18px 17px;
  background: var(--glass); border: 1px solid var(--glass-line); border-radius: var(--r-card);
  -webkit-backdrop-filter: var(--blur); backdrop-filter: var(--blur);
  transition: background-color .15s, border-color .15s, transform .12s, box-shadow .15s;
}
.cat::after { /* смужка кольору категорії внизу */
  content: ""; position: absolute; left: 0; right: 0; bottom: 0; height: 3px;
  background: var(--c); opacity: .35; transition: opacity .15s, height .15s;
}
.cat:hover { background: var(--glass-hi); border-color: var(--glass-line-hi); transform: translateY(-1px); }
.cat[aria-selected="true"] {
  background: color-mix(in srgb, var(--c) 13%, rgba(255, 255, 255, .06));
  border-color: color-mix(in srgb, var(--c) 60%, transparent);
  box-shadow: 0 10px 30px color-mix(in srgb, var(--c) 18%, transparent);
}
.cat[aria-selected="true"]::after { opacity: 1; height: 4px; }
.cat-name { display: flex; align-items: center; gap: 8px; font-size: 13px; font-weight: 700; color: var(--muted); }
.cat[aria-selected="true"] .cat-name { color: var(--text); }
.cat .dot { width: 9px; height: 9px; border-radius: 50%; background: var(--c); box-shadow: 0 0 10px var(--c); flex: none; }
.cat-num { font-size: 30px; font-weight: 800; letter-spacing: -.02em; line-height: 1.15; margin-top: 4px; }
.cat-sum { font-size: 12.5px; color: var(--muted); font-variant-numeric: tabular-nums; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.c-pay { --c: var(--c-pay); }
.c-approved { --c: #60a5fa; }
.c-transit { --c: var(--c-ship); }
.c-partial { --c: var(--c-partial); }
.c-done { --c: var(--c-done); }

/* ===== Пошук і фільтри ===== */
.toolbar { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.search-box { position: relative; flex: 1 1 320px; min-width: 220px; }
.search-box svg { position: absolute; left: 13px; top: 50%; transform: translateY(-50%); color: var(--muted); z-index: 1; pointer-events: none; }
.search-box input { padding-left: 38px; background: var(--glass); -webkit-backdrop-filter: var(--blur); backdrop-filter: var(--blur); }
#btn-add { margin-left: 4px; }

.filters { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 14px 16px; padding: 16px 18px; align-items: end; }
.filters .combo { display: block; }
.filters .combo input { margin-top: 0; }
.filters-foot { grid-column: 1 / -1; display: flex; align-items: center; gap: 20px; flex-wrap: wrap; padding-top: 14px; border-top: 1px solid var(--line); }
.filters-foot .found { margin-left: auto; font-size: 13px; }
.filters.compact { --h-ctl: 36px; gap: 12px 14px; padding: 14px 16px; }
.filters.compact label { font-size: 12px; color: var(--muted); }
.filters.compact input, .filters.compact select { font-size: 13.5px; padding: 0 10px; }
.filters.compact .filters-foot { padding-top: 12px; gap: 18px; }
.filters.compact .filters-foot .check { color: var(--text); font-size: 13.5px; }
.hist-filters { grid-template-columns: minmax(0, 1.6fr) repeat(2, minmax(0, 1fr)) auto; }
.hist-filters .filters-foot { grid-column: auto; border-top: 0; padding-top: 0; gap: 12px; align-self: end; height: var(--h-ctl); }
.hist-filters .filters-foot .found { margin-left: 0; white-space: nowrap; }
.span2 { grid-column: span 2; }

/* ===== Смуги дій для категорії ===== */
.paybar {
  display: flex; align-items: center; justify-content: space-between; gap: 16px; flex-wrap: wrap;
  padding: 12px 14px 12px 18px; border-radius: 16px;
  background: var(--glass); border: 1px solid var(--glass-line);
  -webkit-backdrop-filter: var(--blur); backdrop-filter: var(--blur);
  box-shadow: inset 3px 0 0 var(--bar, var(--brand));
}
.paybar.pay { --bar: var(--c-pay); }
.paybar.transit { --bar: var(--c-ship); }
.paybar-text { display: grid; gap: 1px; }
.paybar-text strong { font-size: 14px; }
.paybar .muted { font-size: 13.5px; }

/* ===== Таблиці ===== */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
.orders-table { min-width: 1140px; }
.suppliers-table { min-width: 900px; }
.history-table { min-width: 680px; }
th, td { text-align: left; padding: 13px 14px; border-bottom: 1px solid var(--line); vertical-align: middle; }
th {
  font-size: 11.5px; text-transform: uppercase; letter-spacing: .06em;
  color: var(--faint); font-weight: 700; white-space: nowrap; padding-top: 14px; padding-bottom: 12px;
}
tbody tr:last-child td { border-bottom: 0; }
tbody tr:not(.group-row) { transition: background-color .12s; }
tbody tr:not(.group-row):hover { background: rgba(255, 255, 255, .035); }
.num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
td.num { font-weight: 700; }
.ev { white-space: nowrap; font-family: "JetBrains Mono", ui-monospace, Menlo, monospace; font-size: 13px; color: #a9cdf0; font-weight: 500; }
.col-sel { width: 42px; padding-right: 0; }
.col-sel input { display: block; }
.table-wrap:not(.pay) .col-sel { display: none; }
.col-act { white-space: nowrap; text-align: right; }
td.col-act .acts { display: flex; gap: 6px; justify-content: flex-end; flex-wrap: wrap; }
.empty { padding: 44px 24px; text-align: center; color: var(--muted); }
.group-row td {
  background: rgba(255, 255, 255, .04); font-weight: 800; font-size: 11.5px; color: var(--muted);
  padding: 9px 14px; text-transform: uppercase; letter-spacing: .07em;
}
.group-row.short td { background: rgba(251, 146, 60, .1); color: var(--short); }
tr.overdue td.due { color: var(--warn); font-weight: 700; }
tr.is-partial td:first-child, tr.is-partial td.ev { box-shadow: inset 3px 0 0 var(--c-partial); }
.table-wrap.pay tr.is-partial td.ev { box-shadow: none; }
.tag-overdue { display: inline-block; background: rgba(248, 113, 113, .16); color: #fca5a5; border-radius: 6px; padding: 1px 7px; font-size: 11.5px; margin-left: 6px; font-weight: 700; }
.chip { display: inline-flex; align-items: center; gap: 4px; padding: 2px 9px; border-radius: 999px; font-size: 12px; font-weight: 700; white-space: nowrap; }
.chip.returned { background: rgba(250, 204, 21, .16); color: var(--c-pay); }
.sup-name { cursor: pointer; }
.chip.short { background: rgba(251, 146, 60, .16); color: var(--short); }
.partial-note { font-size: 12.5px; color: #fdba74; }
.table-wrap td a, .suppliers-table a { color: #9cc4ec; text-decoration: none; }
.table-wrap td a:hover { text-decoration: underline; }

/* ===== Етапи: іконки (погодження, оплата, відвантаження, отримано) ===== */
.stepper { --c: #8a94a6; display: grid; grid-template-columns: auto auto; align-items: center; column-gap: 10px; justify-items: start; }
.stepper.st0 { --c: var(--c-pay); }
.stepper.st1 { --c: #60a5fa; }
.stepper.st2 { --c: var(--c-ship); }
.stepper.st3 { --c: var(--c-done); }
.stage-cell { display: grid; gap: 6px; justify-items: start; }
.stage-head { order: 2; display: flex; flex-direction: column; }
.stage-name { font-size: 13px; font-weight: 800; color: var(--c); white-space: nowrap; }
.stage-frac { font-size: 11.5px; font-weight: 700; color: var(--faint); font-variant-numeric: tabular-nums; }
.steps { display: flex; align-items: center; gap: 4px; }
.step { position: relative; padding: 0; border: 0; background: none; cursor: pointer; font: inherit; color: inherit; }
.step-dot, .step-lbl { display: none; }
.step-ic { display: grid; place-items: center; width: 28px; height: 28px; border-radius: 9px; transition: transform .12s, background-color .15s, box-shadow .15s; }
.step.todo .step-ic { color: var(--faint); background: rgba(255, 255, 255, .05); }
.step.done .step-ic { color: var(--c); background: color-mix(in srgb, var(--c) 16%, transparent); }
.step.cur .step-ic { color: #0b1020; background: var(--c); box-shadow: 0 0 14px color-mix(in srgb, var(--c) 50%, transparent); }
.step:hover .step-ic { transform: translateY(-2px); }
.step:not(.cur):hover .step-ic { background: rgba(255, 255, 255, .14); color: var(--text); }

/* ===== Посилка ===== */
.parcel { display: grid; gap: 4px; font-size: 13px; justify-items: start; }
.parcel-status { font-weight: 700; }
.parcel-status.done { color: var(--ok); }
.parcel-status.bad { color: var(--warn); }
.parcel-status.st::before { content: ""; display: inline-block; width: 7px; height: 7px; border-radius: 50%; background: currentColor; margin-right: 6px; vertical-align: 1px; }
.parcel-status.st-ready { color: #4ade80; }      /* у відділенні: можна забирати */
.parcel-status.st-done { color: #86efac; }       /* отримано */
.parcel-status.st-transit { color: #8ec0f0; }    /* у дорозі */
.parcel-status.st-new { color: #facc15; }        /* створено, ще не передано */
.parcel-status.st-bad { color: var(--warn); }    /* відмова, не знайдено */
.parcel-status.st-other { color: var(--text); }

/* ===== Охайні рядки: зверху головне, знизу дрібніше; уся інформація на місці ===== */
.parcel-refresh { display: inline-grid; place-items: center; }
.parcel-top { display: flex; align-items: center; gap: 8px; }
.parcel-sub { display: flex; align-items: baseline; gap: 8px; flex-wrap: wrap; }
@media (min-width: 1200px) {
  .orders-table { min-width: 0; }
  .orders-table th { padding: 10px 9px; }
  .orders-table td { padding: 8px 9px; }
  .orders-table .c-item { min-width: 150px; max-width: 280px; }
  .orders-table .c-sup { min-width: 150px; }
  .orders-table .ev, .orders-table .due { white-space: nowrap; }
  .orders-table .due .tag-overdue { display: block; width: max-content; margin: 2px 0 0; }
  .orders-table .c-item .muted, .orders-table .c-sup .small { margin-top: 1px; line-height: 1.3; }
  .orders-table .stage-cell { gap: 4px; }
  .orders-table .stepper { grid-template-columns: auto; row-gap: 3px; }
  .orders-table .stage-head { flex-direction: row; align-items: baseline; gap: 6px; }
  .orders-table .parcel-top { white-space: nowrap; }
  .orders-table .parcel-sub { flex-direction: column; align-items: flex-start; gap: 1px; max-width: 200px; }
  .orders-table .parcel { gap: 3px; }
  .orders-table .parcel .parcel-refresh { width: 26px; height: 26px; padding: 0; }
  .orders-table td.col-act .acts { flex-direction: column; align-items: flex-end; }
  /* запасний захід: якщо таблиця все ж ширша за екран, кнопки лишаються видимими */
  .orders-table td.col-act { position: sticky; right: 0; background: var(--solid); }
}

/* ===== Фільтри: охайно ===== */
#filters-panel.filters.compact { grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 14px 14px; padding: 16px 18px; }
#filters-panel.filters.compact > label:first-child { grid-column: span 2; }
.filters.compact label, .range-lbl {
  font-size: 11.5px; font-weight: 700; text-transform: uppercase; letter-spacing: .06em; color: var(--faint);
}
.filters.compact label > input, .filters.compact label > select, .filters.compact label > .combo { margin-top: 6px; }
.filters.compact input, .filters.compact select { text-transform: none; letter-spacing: 0; font-weight: 500; }
.range { display: block; }
.range-lbl { display: block; }
.range-row { display: grid; grid-template-columns: minmax(0, 1fr) auto minmax(0, 1fr); align-items: center; gap: 8px; margin-top: 6px; }
.range-dash { color: var(--faint); }
.filters.compact .filters-foot { gap: 10px; padding-top: 14px; }
.filters.compact .filters-foot .check {
  gap: 8px; padding: 6px 13px 6px 10px; border: 1px solid var(--line); border-radius: 999px;
  background: rgba(255, 255, 255, .04); font-size: 13px; color: var(--muted); transition: background-color .15s, border-color .15s, color .15s;
}
.filters.compact label.check { text-transform: none; letter-spacing: 0; font-weight: 500; }
.filters.compact .filters-foot .check:hover { background: rgba(255, 255, 255, .08); color: var(--text); }
.filters.compact .filters-foot .check:has(input:checked) { border-color: rgba(212, 223, 63, .55); background: rgba(212, 223, 63, .12); color: var(--text); }
.filters.compact .filters-foot .found { margin-left: auto; color: var(--faint); }
@media (max-width: 1100px) { #filters-panel.filters.compact { grid-template-columns: repeat(2, minmax(0, 1fr)); } #filters-panel.filters.compact > label:first-child { grid-column: 1 / -1; } }
@media (max-width: 640px) { #filters-panel.filters.compact { grid-template-columns: 1fr; } #filters-panel.filters.compact .span2 { grid-column: auto; } }

/* ===== Постачальник у рядку: видно, що можна відкрити ===== */
.sup-name { border-radius: 6px; transition: color .15s; }
.sup-name::after { content: "✎"; margin-left: 6px; font-size: 12px; color: var(--lime); opacity: 0; transition: opacity .15s; }
.sup-name:hover, .sup-name:focus-visible { color: var(--lime); }
.sup-name:hover::after, .sup-name:focus-visible::after { opacity: 1; }
.sup-name:focus-visible { outline: 2px solid var(--lime); outline-offset: 2px; }
@media (hover: none) { .sup-name::after { opacity: .55; } }

/* ===== Телефон ===== */
.phone-viber { color: #9cc4ec; text-decoration: none; }
.phone-viber:hover { text-decoration: underline; }

/* ===== Список-підказка (combobox) ===== */
.inline { display: flex; gap: 8px; align-items: center; }
.inline input { flex: 1; min-width: 0; }
.inline select { flex: 1; }
.cur-select { width: 112px !important; flex: 0 0 112px !important; }
.combo { position: relative; }
.combo-menu {
  position: absolute; top: 100%; left: 0; right: 0; z-index: 30;
  margin: 6px 0 0; padding: 5px; list-style: none;
  max-height: 270px; overflow: auto;
  background: var(--solid); border: 1px solid var(--glass-line-hi); border-radius: 13px;
  box-shadow: var(--shadow-pop);
}
.combo-menu li { display: grid; gap: 1px; padding: 8px 10px; border-radius: 8px; cursor: pointer; font-weight: 500; }
.combo-menu li.active, .combo-menu li:hover { background: rgba(91, 155, 213, .2); }
.combo-menu li.all-opt { font-weight: 700; }
.combo-menu li.empty-opt { cursor: default; }
.combo-menu li.empty-opt:hover { background: none; }
.inline.combo input { flex: 1; }

/* ===== Нотатки ===== */
.note { display: grid; grid-template-columns: auto 1fr auto; gap: 14px; align-items: start; padding: 15px 18px; border-bottom: 1px solid var(--line); }
.note:last-child { border-bottom: 0; }
#notes-list:empty { display: none; }
.note input[type=checkbox] { width: 20px; height: 20px; margin-top: 2px; }
.note-text { font-weight: 700; }
.note.is-done .note-text { text-decoration: line-through; color: var(--faint); font-weight: 500; }
.note-due { font-size: 13px; color: var(--muted); margin-top: 2px; }
.note-due.over { color: var(--warn); font-weight: 700; }
.note-due.today { color: var(--c-pay); font-weight: 700; }
.note-created { font-size: 12px; color: var(--faint); margin-top: 4px; font-variant-numeric: tabular-nums; }
.note-details { font-size: 13px; color: var(--muted); white-space: pre-line; margin-top: 3px; }

/* ===== Діалоги ===== */
dialog {
  border: 1px solid var(--glass-line-hi); border-radius: 20px;
  background: rgba(20, 26, 44, .94); color: var(--text);
  -webkit-backdrop-filter: blur(24px); backdrop-filter: blur(24px);
  padding: 26px; width: min(620px, calc(100vw - 24px)); max-height: calc(100vh - 24px); overflow: auto;
  box-shadow: var(--shadow-pop);
}
dialog::backdrop { background: rgba(5, 8, 18, .6); -webkit-backdrop-filter: blur(4px); backdrop-filter: blur(4px); }
dialog h2 { font-size: 20px; }
.grid { display: grid; grid-template-columns: 1fr 1fr; gap: 14px 16px; margin-top: 18px; }
.dlg-actions { display: flex; gap: 8px; margin-top: 24px; align-items: center; }
.spacer { flex: 1; }
.hint { font-size: 13px; margin-top: 12px; }
.confirm-dlg { width: min(470px, calc(100vw - 24px)); }
.confirm-dlg p { white-space: pre-line; }
.confirm-dlg form > label { margin-top: 12px; }
.confirm-dlg h2 + p { margin-top: 4px; }
.radios { display: flex; gap: 20px; margin: 14px 0 2px; }
.partial-box {
  display: grid; gap: 10px; padding: 12px 14px; border-radius: var(--r-ctl);
  border: 1px dashed rgba(251, 146, 60, .5); background: rgba(251, 146, 60, .07);
}
.partial-box .check { color: #fdba74; font-weight: 600; white-space: normal; }

/* ===== Документ на оплату ===== */
.doc-dlg { width: min(960px, calc(100vw - 24px)); }
.doc h2 { font-size: 22px; }
.doc-table { min-width: 0; margin-top: 14px; font-size: 13.5px; }
.doc-table th, .doc-table td { border: 1px solid var(--line); padding: 8px 10px; }
.doc-table tfoot td { border-top: 2px solid var(--text); }

/* ===== Копіювання ЄВ ===== */
.copy-btn {
  margin-left: 4px; width: 24px; height: 24px; padding: 0;
  border: 1px solid var(--glass-line); border-radius: 7px; background: rgba(255, 255, 255, .05);
  color: var(--faint); font-size: 13px; line-height: 1; cursor: pointer; vertical-align: middle;
  opacity: .55; transition: opacity .15s, color .15s, border-color .15s;
}
tr:hover .copy-btn, .copy-btn:focus-visible { opacity: 1; }
.copy-btn:hover { color: var(--lime); border-color: var(--lime); }
.copy-btn.copied { color: var(--ok); border-color: var(--ok); opacity: 1; }

/* ===== Друк: документ завжди білий ===== */
@media print {
  body { background: #fff; }
  body::before, body::after { display: none; }
  body:has(#ddlg[open]) > *:not(#ddlg) { display: none !important; }
  #ddlg[open] { position: static; display: block; width: 100%; max-height: none; border: 0; padding: 0; background: #fff; color: #000; overflow: visible; box-shadow: none; backdrop-filter: none; }
  #ddlg::backdrop { display: none; }
  .no-print { display: none !important; }
  .doc .muted, .doc .small { color: #444; }
  .doc-table th, .doc-table td { border-color: #888; background: none; color: #000; }
  .doc-table tfoot td { border-top-color: #000; }
}

/* ===== Адаптивність ===== */
@media (max-width: 1180px) {
  .topnav { margin: 0; }
  .user-email { display: none; }
}
@media (max-width: 1100px) {
  .cats { grid-template-columns: repeat(6, minmax(150px, 1fr)); overflow-x: auto; padding-bottom: 4px; scroll-snap-type: x mandatory; }
  .cat { scroll-snap-align: start; }
  .filters { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .hist-filters { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .hist-filters .filters-foot { grid-column: 1 / -1; height: auto; }
}
.nav-ic { opacity: .75; flex: none; }
.navbtn.active .nav-ic { opacity: 1; color: var(--lime); }
.cats { scrollbar-width: none; }
.cats::-webkit-scrollbar { display: none; }
.search-box input { text-align: left; }

/* Телефон і планшет: розділи — у нижній панелі під великий палець */
@media (max-width: 860px) {
  body { padding-bottom: calc(76px + env(safe-area-inset-bottom)); }
  .topbar-wrap { padding: 10px 12px 0; }
  /* без blur у шапці: інакше нижня панель «прилипає» до шапки, а не до екрана */
  .topbar { gap: 8px; padding: 8px 8px 8px 12px; -webkit-backdrop-filter: none; backdrop-filter: none; background: rgba(16, 22, 40, .94); }
  .brand h1 { font-size: 15px; }
  .user { margin-left: auto; }
  .topnav {
    position: fixed; z-index: 25; left: 10px; right: 10px; bottom: calc(10px + env(safe-area-inset-bottom));
    display: grid; grid-template-columns: repeat(4, 1fr); gap: 2px; margin: 0; padding: 6px;
    background: rgba(16, 22, 40, .86); border: 1px solid var(--glass-line); border-radius: 20px;
    -webkit-backdrop-filter: var(--blur); backdrop-filter: var(--blur);
    box-shadow: 0 -6px 30px rgba(0, 0, 0, .35);
  }
  .navbtn {
    position: relative; flex-direction: column; gap: 3px; height: 54px; padding: 0 2px;
    font-size: 10px; letter-spacing: -.01em; font-weight: 700; border-radius: 14px; min-width: 0;
  }
  .nav-lbl { max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .nav-ic { width: 21px; height: 21px; }
  .navbtn .count { position: absolute; top: 4px; left: calc(50% + 6px); min-width: 18px; padding: 0 5px; font-size: 10px; line-height: 1.55; }
  .container { padding: 14px 12px 24px; }
  .cats { grid-template-columns: repeat(6, minmax(138px, 1fr)); }
  .cat-num { font-size: 24px; }
}
@media (max-width: 640px) {
  .toolbar .btn { flex: 1 1 0; padding: 0 10px; font-size: 13px; }
  .search-box { flex-basis: 100%; }
  #btn-add { flex-basis: 100%; margin-left: 0; height: 46px; font-size: 15px; }

  .paybar .btn { width: 100%; height: 44px; }

  .hist-filters { grid-template-columns: 1fr 1fr; }
  .hist-filters label:first-child, .hist-filters .filters-foot { grid-column: 1 / -1; }
  .filters { grid-template-columns: 1fr; padding: 14px; }
  .span2 { grid-column: span 1; }
  .grid { grid-template-columns: 1fr; }
  .filters-foot { gap: 12px; }
  .filters-foot .found { margin-left: 0; }
  .section-tools { width: 100%; }
  .section-tools input[type=search], .section-tools select { flex: 1; width: auto; }
  dialog { padding: 18px; }
  .dlg-actions { flex-wrap: wrap; }
}

/* Замовлення: на вузьких екранах картки, щоб кнопки дій не ховались за краєм таблиці */
@media (max-width: 1199px) {
  /* замовлення — картками замість широкої таблиці */
  .orders-table { min-width: 0; }
  .orders-table thead { display: none; }
  .orders-table, .orders-table tbody { display: block; }
  #orders-wrap { background: none; border: 0; -webkit-backdrop-filter: none; backdrop-filter: none; overflow: visible; }
  .orders-table tbody { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(340px, 100%), 1fr)); gap: 10px; }
  .orders-table tr:not(.group-row) {
    display: grid; grid-template-columns: auto 1fr auto;
    grid-template-areas: "sel ev sum" "item item item" "sup sup sup" "stage stage due" "parcel parcel parcel" "act act act";
    padding: 12px 14px; border-radius: 16px;
    background: var(--glass); border: 1px solid var(--glass-line);
    -webkit-backdrop-filter: var(--blur); backdrop-filter: var(--blur);
  }
  .orders-table tr.is-partial { border-left: 3px solid var(--c-partial); }
  .orders-table tr.is-partial td { box-shadow: none !important; }
  .orders-table td { display: block; border: 0; padding: 4px 0; }
  .orders-table .col-sel { grid-area: sel; width: auto; padding-right: 10px; align-self: center; }
  .orders-table .c-ev { grid-area: ev; align-self: center; }
  .orders-table .c-sum { grid-area: sum; font-size: 16px; align-self: center; }
  .orders-table .c-item { grid-area: item; font-size: 15.5px; font-weight: 700; padding-top: 8px; }
  .orders-table .c-item .muted { font-weight: 500; }
  .orders-table .c-sup { grid-area: sup; color: var(--muted); font-size: 13.5px; }
  .orders-table .c-stage { grid-area: stage; padding-top: 10px; }
  .orders-table .due { grid-area: due; text-align: right; padding-top: 10px; font-size: 13px; }
  .orders-table .due::before { content: attr(data-label); display: block; font-size: 11px; color: var(--faint); font-weight: 600; }
  .orders-table .c-parcel { grid-area: parcel; margin-top: 8px; padding-top: 10px; border-top: 1px solid var(--line); }
  .orders-table .col-act { grid-area: act; padding-top: 10px; }
  .orders-table .col-act .acts { justify-content: stretch; }
  .orders-table .col-act .acts .btn { flex: 1; height: 38px; }
  .orders-table .group-row { display: block; grid-column: 1 / -1; }
  .orders-table .group-row td { display: block; background: none; padding: 8px 4px 0; }
  .orders-table .copy-btn { opacity: 1; }
  /* «Вибрати всі» лишається доступним і в картках */
  .table-wrap.pay .orders-table thead { display: block; }
  .table-wrap.pay .orders-table thead th { display: none; }
  .table-wrap.pay .orders-table thead th.col-sel { display: flex; align-items: center; gap: 10px; width: auto; min-height: 40px; padding: 0 14px; border: 0; }
  .table-wrap.pay .orders-table thead th.col-sel::after { content: "Вибрати всі"; text-transform: none; letter-spacing: 0; font-size: 13.5px; color: var(--muted); }
}

/* ===== Екран вибору розділу ===== */
.hub { min-height: 100vh; max-width: 880px; margin: 0 auto; padding: 22px 18px 48px; display: flex; flex-direction: column; }
.hub-top { display: flex; justify-content: flex-end; align-items: center; gap: 10px; }
.hub-user { display: inline-flex; align-items: center; gap: 8px; color: var(--muted); font-weight: 600; }
.hub-head { text-align: center; margin: 7vh 0 28px; }
.hub-head h1 { margin: 12px 0 4px; font-size: 30px; letter-spacing: -.02em; }
.hub-head p { margin: 0; }
.hub-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 16px; }
.hub-card {
  display: flex; flex-direction: column; gap: 8px; text-align: left; text-decoration: none; color: var(--text);
  padding: 26px 24px; border-radius: 22px; cursor: pointer; font: inherit;
  background: var(--glass); border: 1px solid var(--glass-line);
  -webkit-backdrop-filter: var(--blur); backdrop-filter: var(--blur);
  transition: transform .18s ease, border-color .18s ease, background .18s ease, box-shadow .18s ease;
}
.hub-card:hover { transform: translateY(-3px); background: var(--glass-hi); border-color: var(--glass-line-hi); box-shadow: var(--shadow-pop); }
.hub-card:focus-visible { outline: 2px solid var(--lime); outline-offset: 3px; }
.hub-ic { width: 54px; height: 54px; border-radius: 16px; display: grid; place-items: center; margin-bottom: 8px; }
.hub-orders .hub-ic { background: rgba(91, 155, 213, .18); color: var(--brand); }
.hub-logi .hub-ic { background: rgba(45, 212, 191, .16); color: #2dd4bf; }
.hub-title { font-size: 20px; font-weight: 800; letter-spacing: -.01em; }
.hub-desc { color: var(--muted); font-size: 14px; line-height: 1.45; }
.hub-go { margin-top: 10px; font-weight: 700; color: var(--lime); }
.hub-logi .hub-go { color: #2dd4bf; }
@media (max-width: 640px) {
  .hub-grid { grid-template-columns: 1fr; }
  .hub-head { margin: 4vh 0 20px; }
}
@media (prefers-reduced-motion: reduce) { .hub-card { transition: none; } .hub-card:hover { transform: none; } }

#btn-hub:hover { background: var(--glass-hi); color: var(--text); }
.hub-head .logo-img { display: block; margin: 0 auto; }
