/* ფერები და ზომები — ერთ ადგილას. მუქი თემა ავტომატურად სისტემის მიხედვით. */
/* „სახელოსნო“: ღია ფონი, მუქი გვერდითა მენიუ, ერთი ზღვისფერი აქცენტი.
   სტატუსის ფერები განსხვავდება სიღიაჟითაც (არა მხოლოდ ფერით). */
:root {
  --bg: #f3f4f1;
  --surface: #ffffff;
  --surface-2: #eef0ec;
  --surface-3: #fafbf9;
  --border: #e2e5e0;
  --border-strong: #dde1dc;
  --text: #17201d;
  --muted: #5b6661;
  --neutral-ink: #3f4a45;
  --primary: #0e6e66;
  --primary-ink: #ffffff;
  --primary-soft: #e1f0ee;
  --danger: #a1221b;
  --danger-soft: #fbe5e3;
  --warn: #7a4a00;
  --warn-soft: #fbefd9;
  --ok: #1e6b3a;
  --ok-soft: #e3f2e7;
  --info: #1f4fa8;
  --info-soft: #e5ecfb;
  --side: #17201d;
  --side-hover: #25302c;
  --side-active: #2a3732;
  --side-text: #c9d1cd;
  --side-muted: #9aa7a1;
  --radius: 14px;
  --radius-sm: 10px;
  --shadow: none;
  --font: "Noto Sans Georgian", "BPG Arial", system-ui, -apple-system, "Segoe UI", sans-serif;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #111614;
    --surface: #1a201e;
    --surface-2: #232b28;
    --surface-3: #1e2522;
    --border: #2c3532;
    --border-strong: #36413d;
    --text: #e6ebe8;
    --muted: #9aa7a1;
    --neutral-ink: #c9d1cd;
    --primary: #4fbdb2;
    --primary-ink: #0b1513;
    --primary-soft: #183330;
    --danger: #f08a83;
    --danger-soft: #3a1f1e;
    --warn: #f0b860;
    --warn-soft: #382c17;
    --ok: #6fd08f;
    --ok-soft: #173223;
    --info: #8fb0f5;
    --info-soft: #1c2740;
    --side: #0c100f;
    --side-hover: #19201d;
    --side-active: #222b27;
  }
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--bg); color: var(--text); font: 15px/1.5 var(--font); -webkit-font-smoothing: antialiased; }
a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }
h1 { font-size: 1.85rem; font-weight: 700; letter-spacing: -.01em; line-height: 1.25; margin: 0; display: flex; align-items: center; gap: .5rem; flex-wrap: wrap; }
h2 { font-size: 1.12rem; font-weight: 600; margin: 0; }
h3 { font-size: .95rem; margin: .5rem 0 0; }
.muted { color: var(--muted); }
.nowrap { white-space: nowrap; }
.num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.neg { color: var(--danger); font-weight: 600; }
.warn { color: var(--warn); font-weight: 600; }
.pos { color: var(--ok); }

/* ---------- განლაგება ---------- */
.shell { display: grid; grid-template-columns: 232px minmax(0, 1fr); min-height: 100vh; }
.sidebar {
  background: var(--side); color: var(--side-text);
  display: flex; flex-direction: column; padding: 1.25rem .85rem; gap: 1.5rem;
  position: sticky; top: 0; height: 100vh; overflow-y: auto;
}
.brand { display: flex; align-items: center; gap: .75rem; padding: 0 .5rem; }
.brand-mark {
  width: 36px; height: 36px; border-radius: 9px; background: var(--primary); color: var(--primary-ink);
  display: grid; place-items: center; font-weight: 700; font-size: 1.1rem; flex: none;
}
.brand-text { display: flex; flex-direction: column; line-height: 1.25; min-width: 0; }
.brand-name { font-weight: 600; color: #fff; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.brand-sub { font-size: .78rem; color: var(--side-muted); }
.nav { display: flex; flex-direction: column; gap: 2px; }
.nav a { display: flex; align-items: center; gap: .75rem; padding: .6rem .75rem; border-radius: 8px; color: var(--side-text); }
.nav a svg { flex: none; }
.nav a:hover { background: var(--side-hover); color: #fff; text-decoration: none; }
.nav a.active { background: var(--side-active); color: #fff; font-weight: 600; }
.nav a.active svg { color: var(--primary); }
.sidebar-foot { margin-top: auto; display: flex; align-items: center; gap: .6rem; padding: .85rem .5rem 0; border-top: 1px solid #2e3a35; }
.avatar-me { width: 32px; height: 32px; border-radius: 50%; background: #34433d; color: #fff; display: grid; place-items: center; font-size: .85rem; font-weight: 600; flex: none; }
.me { display: flex; flex-direction: column; font-size: .88rem; line-height: 1.3; min-width: 0; flex: 1; }
.me strong { font-weight: 500; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.me span { color: var(--side-muted); font-size: .78rem; }
.sidebar .btn-ghost { color: var(--side-text); }
.sidebar .btn-ghost:hover { background: var(--side-hover); color: #fff; }
.main { padding: 1.75rem 2.25rem 3rem; max-width: 1320px; width: 100%; }

.page-head { display: flex; align-items: center; justify-content: space-between; gap: 1rem; margin-bottom: 1.5rem; flex-wrap: wrap; }
.head-actions { display: flex; gap: .5rem; flex-wrap: wrap; }

/* ---------- ბარათები ---------- */
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 1.25rem 1.4rem; box-shadow: var(--shadow); margin-bottom: 1.25rem; }
.card-flush { padding: 0; overflow-x: auto; overflow-y: hidden; }
/* ვიწრო ბარათში ცხრილი გვერდს არ ასცდება — ბარათის შიგნით გადაიხვევა. */
.card:has(> .table) { overflow-x: auto; }
.card-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: .75rem; gap: .5rem; }
.grid-2 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 1.25rem; align-items: start; }
.grid-2 > .card { margin-bottom: 0; }
.grid-2.grid-main { grid-template-columns: minmax(0, 3fr) minmax(0, 2fr); }
.empty { color: var(--muted); padding: 1.25rem; text-align: center; }

.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(210px, 1fr)); gap: 1rem; margin-bottom: 1.25rem; }
.stat { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 1.1rem 1.25rem; display: flex; flex-direction: column; gap: .15rem; color: var(--text); box-shadow: var(--shadow); }
.stat-link:hover { border-color: var(--primary); text-decoration: none; }
.stat-label { color: var(--muted); font-size: .9rem; }
.stat-value { font-size: 1.85rem; font-weight: 700; line-height: 1.25; font-variant-numeric: tabular-nums; }
.stat-value-sm { font-size: 1.05rem; }
.stat-sub { color: var(--muted); font-size: .83rem; }

/* ---------- ცხრილები ---------- */
.table { width: 100%; border-collapse: collapse; }
.table th, .table td { padding: .8rem 1rem; border-bottom: 1px solid var(--surface-2); text-align: left; vertical-align: middle; }
.table th { font-size: .82rem; font-weight: 500; color: var(--muted); background: var(--surface-3); border-bottom-color: var(--border); white-space: nowrap; }
.table th.num, .table td.num { text-align: right; }
.table tbody tr:last-child td { border-bottom: 0; }
.card:not(.card-flush) .table th, .card:not(.card-flush) .table td { padding-left: 0; padding-right: .5rem; }
.card:not(.card-flush) .table th { background: none; }
.table tfoot td { border-bottom: 0; padding-top: .35rem; padding-bottom: .35rem; }
.table tfoot tr.total td { font-weight: 700; font-size: 1.05rem; border-top: 1px solid var(--border); padding-top: .6rem; }
tr.inactive td { opacity: .55; }
tr.row-warn td { background: var(--warn-soft); }
.table tbody tr:hover td { background: var(--surface-3); }
.table tbody tr.row-warn:hover td { background: var(--warn-soft); }

/* ---------- ფორმები ---------- */
label { display: flex; flex-direction: column; gap: .3rem; font-size: .85rem; font-weight: 500; }
input, select, textarea {
  font: inherit; color: var(--text); background: var(--surface); border: 1px solid var(--border);
  border: 1px solid var(--border-strong); border-radius: var(--radius-sm); padding: .55rem .75rem; min-height: 42px; width: 100%; min-width: 0;
}
textarea { min-height: 0; }
input:focus, select:focus, textarea:focus { outline: 3px solid var(--primary-soft); border-color: var(--primary); }
input[type=checkbox], input[type=radio] { width: auto; min-height: 0; accent-color: var(--primary); }
input[type=checkbox] { width: 18px; height: 18px; }
label.checkbox { flex-direction: row; align-items: center; gap: .5rem; font-weight: 400; }
.stack { display: flex; flex-direction: column; gap: .9rem; }
.stack-lg { display: flex; flex-direction: column; gap: 0; }
.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: .9rem 1rem; }
.form-grid h2, .form-grid h3 { margin: 0; }
.span-2 { grid-column: span 2; }
.form-actions { display: flex; align-items: center; gap: .75rem; flex-wrap: wrap; }
.toolbar { display: flex; gap: .75rem; align-items: center; margin-bottom: 1rem; flex-wrap: wrap; }
.toolbar input[type=search] { flex: 1 1 240px; max-width: 360px; width: auto; }
.toolbar select { width: auto; flex: 0 1 auto; }
.toolbar-right { margin-left: auto; }
.inline-form { display: flex; gap: .5rem; margin-top: 1rem; }
.list { list-style: none; margin: 0; padding: 0; }
.list li { padding: .5rem 0; border-bottom: 1px solid var(--border); }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: .35rem;
  font: inherit; font-weight: 500; padding: .5rem 1rem; min-height: 42px; border-radius: var(--radius-sm); cursor: pointer;
  border: 1px solid var(--border-strong); background: var(--surface); color: var(--text); white-space: nowrap;
}
.btn:hover { background: var(--surface-2); text-decoration: none; }
.btn-primary { background: var(--primary); border-color: var(--primary); color: var(--primary-ink); font-weight: 600; }
.btn-primary:hover { background: var(--primary); filter: brightness(1.08); }
.btn-danger { color: var(--danger); border-color: var(--border-strong); }
.btn-danger:hover { background: var(--danger-soft); }
.btn-ghost { border-color: transparent; background: transparent; }
.btn-sm { padding: .3rem .7rem; min-height: 34px; font-size: .87rem; border-radius: 8px; }

.alert { padding: .8rem 1rem; border-radius: var(--radius-sm); margin-bottom: 1rem; }
.alert-error { background: var(--danger-soft); color: var(--danger); }
.alert-warn { background: var(--warn-soft); color: var(--warn); }

/* ---------- სტატუსები ---------- */
.badge { display: inline-block; padding: .15rem .65rem; border-radius: 999px; font-size: .8rem; font-weight: 500; line-height: 1.5; background: var(--surface-2); color: var(--neutral-ink); vertical-align: middle; white-space: nowrap; }
.badge-new { background: var(--surface-2); color: var(--neutral-ink); }
.badge-confirmed, .badge-in_progress { background: var(--info-soft); color: var(--info); }
.badge-shipped { background: var(--info-soft); color: var(--info); }
.badge-delivered { background: var(--ok-soft); color: var(--ok); }
.badge-cancelled { background: var(--danger-soft); color: var(--danger); }
.status-actions { display: flex; gap: .5rem; flex-wrap: wrap; margin-bottom: 1rem; }
.badge-ready { background: var(--primary-soft); color: var(--primary); }
.badge-completed { background: var(--ok-soft); color: var(--ok); }
/* გადახდა */
.badge-pay-unpaid { background: var(--warn-soft); color: var(--warn); }
.badge-pay-partial { background: var(--info-soft); color: var(--info); }
.badge-pay-paid { background: var(--ok-soft); color: var(--ok); }
.badge-pay-overpaid, .badge-pay-refundable { background: var(--warn-soft); color: var(--warn); }
.badge-pay-na { display: none; }
/* მიწოდება */
.badge-dlv-pending { background: var(--surface-2); color: var(--muted); }
.badge-dlv-handed_over, .badge-dlv-in_transit { background: var(--info-soft); color: var(--info); }
.badge-dlv-delivered { background: var(--ok-soft); color: var(--ok); }
.badge-dlv-failed, .badge-dlv-returned { background: var(--danger-soft); color: var(--danger); }

.status-strip { display: flex; gap: 1.25rem; flex-wrap: wrap; margin-bottom: 1rem; }
.status-strip > div { display: flex; flex-direction: column; gap: .2rem; }
.money-row { display: grid; grid-template-columns: repeat(auto-fit, minmax(120px, 1fr)); gap: .75rem; margin-bottom: .75rem; }
.money-row > div { display: flex; flex-direction: column; min-width: 0; background: var(--surface-3); border: 1px solid var(--surface-2); border-radius: var(--radius-sm); padding: .6rem .8rem; }
.money-row strong { font-size: 1.05rem; font-variant-numeric: tabular-nums; white-space: nowrap; }
.pay-form { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: .5rem; margin-top: .75rem; }
details.refund { margin-top: .75rem; }
details.refund summary { cursor: pointer; color: var(--muted); font-size: .85rem; }
.breakdown td { padding-top: .3rem !important; padding-bottom: .3rem !important; }
.delivery-actions { display: flex; flex-direction: column; gap: .5rem; margin-bottom: 1rem; }
.delivery-step { display: flex; gap: .5rem; align-items: center; flex-wrap: wrap; }
.delivery-step input[name=note] { flex: 1; min-width: 160px; }
.timeline.compact li { padding: .35rem 0; }
.ship-head { padding: .75rem 1rem 0; }
.handover-bar { display: flex; gap: .75rem; align-items: center; flex-wrap: wrap; position: sticky; bottom: .5rem; }
.handover-bar select { max-width: 260px; }
.courier-row { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 2fr) auto auto; gap: .5rem; align-items: center; padding: .4rem 0; border-bottom: 1px solid var(--border); }
.courier-new { border-bottom: 0; }

/* ---------- წარმოება ---------- */
.qty-unit { display: flex; gap: .35rem; }
.qty-unit input { flex: 1; min-width: 0; }
.qty-unit select { width: auto; flex: 0 0 auto; }
.line-form { display: flex; flex-wrap: wrap; gap: .5rem; align-items: center; margin-top: .75rem; }
.line-form > input, .line-form > select { flex: 1 1 140px; width: auto; }
.line-form .qty-unit { flex: 1 1 160px; }
.recipe-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 1rem; flex-wrap: wrap; }
.recipe-head h2 { display: flex; gap: .4rem; align-items: center; flex-wrap: wrap; }
.recipe-head form { margin: 0; }
.choice-cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); gap: 1rem; margin-top: 1rem; }
.choice { display: flex; flex-direction: column; gap: .4rem; border: 1px solid var(--border); border-radius: var(--radius); padding: 1rem; color: var(--text); background: var(--surface-2); }
a.choice:hover { border-color: var(--primary); text-decoration: none; }
.calc-qty { margin: 0; align-items: center; }
.calc-qty input { width: 90px; }
.calc-table tr.unit-cost td { font-size: 1.1rem; color: var(--primary); }
.recommend { display: flex; gap: .75rem; align-items: center; flex-wrap: wrap; margin: .5rem 0; padding: .5rem .75rem; background: var(--primary-soft); border-radius: 8px; }
.machine-rate { font-weight: 700; font-variant-numeric: tabular-nums; }
.mode-choice { border: 1px solid var(--border); border-radius: 8px; padding: .5rem .75rem; display: flex; flex-direction: column; gap: .3rem; }
.mode-choice legend { font-size: .85rem; font-weight: 600; padding: 0 .25rem; }
.machine-fields { margin-bottom: .75rem; }
.lead { margin: 0 0 1rem; }
.tabs-sub { border-bottom: 0; margin-top: -.5rem; }
.tabs-sub a { font-size: .85rem; }
.badge-batch-draft { background: var(--surface-2); color: var(--muted); }
.badge-batch-planned { background: var(--info-soft); color: var(--info); }
.badge-batch-in_progress { background: var(--info-soft); color: var(--info); }
.badge-batch-completed { background: var(--ok-soft); color: var(--ok); }
.badge-batch-cancelled { background: var(--danger-soft); color: var(--danger); }
.complete-form { border-color: var(--primary); }
.ops-table .num { white-space: normal; }
.ops-table td { font-size: .9rem; }

@media print {
  .sidebar, .no-print, .btn { display: none !important; }
  .shell { display: block; }
  .main { padding: 0; max-width: none; }
  .card { box-shadow: none; break-inside: avoid; }
  body { background: #fff; }
}

.tabs { display: flex; gap: .25rem; border-bottom: 1px solid var(--border); margin-bottom: 1rem; overflow-x: auto; }
.tabs a { padding: .55rem .85rem; color: var(--muted); border-bottom: 2px solid transparent; white-space: nowrap; }
.tabs a:hover { color: var(--text); text-decoration: none; }
.tabs a.active { color: var(--text); border-bottom-color: var(--primary); font-weight: 600; }
.tabs .count { background: var(--surface-2); border-radius: 999px; padding: 0 .45rem; font-size: .75rem; }

.details { display: grid; grid-template-columns: auto 1fr; gap: .4rem 1rem; margin: 0 0 1.25rem; }
.details dt { color: var(--muted); }
.details dd { margin: 0; }

/* ---------- შეკვეთის პროდუქტები ---------- */
.items { display: flex; flex-direction: column; gap: .5rem; margin-bottom: .75rem; }
.item-row { display: grid; grid-template-columns: minmax(0, 1fr) 90px 140px auto; gap: .5rem; align-items: center; }

/* ---------- ვარიანტები ---------- */
.variant-grid { overflow-x: auto; }
.variant-row {
  display: grid; grid-template-columns: minmax(140px, 1.6fr) minmax(90px, 1fr) 100px 100px 80px 90px 60px 40px auto;
  gap: .5rem; align-items: center; padding: .4rem 0; border-bottom: 1px solid var(--border); min-width: 860px;
}
.variant-head { font-size: .8rem; font-weight: 600; color: var(--muted); }
.variant-new { border-bottom: 0; }

/* ---------- მენიუს ნიშნაკი ---------- */
.nav-badge { margin-left: auto; background: #b3261e; color: #fff; border-radius: 999px; font-size: .72rem; font-weight: 700; padding: 0 .45rem; line-height: 1.4rem; min-width: 1.4rem; text-align: center; }
a.me { color: #fff; }
a.me:hover { text-decoration: none; }
.small { font-size: .82rem; }
.alert-ok { background: var(--ok-soft); color: var(--ok); display: flex; align-items: center; gap: .75rem; flex-wrap: wrap; }
.stat-inline { display: flex; align-items: baseline; gap: .75rem; margin-bottom: .75rem; }
.tabs-inline { border-bottom: 0; margin-bottom: 0; }
details.card summary { cursor: pointer; font-weight: 600; }

/* ---------- ლიდების დაფა ---------- */
.board { display: flex; gap: .75rem; overflow-x: auto; padding-bottom: .75rem; align-items: flex-start; }
.kanban-col { flex: 0 0 272px; background: var(--surface-2); border-radius: var(--radius); padding: .75rem; display: flex; flex-direction: column; gap: .5rem; max-height: calc(100vh - 200px); }
.kanban-head { display: flex; align-items: center; gap: .45rem; padding: .15rem .25rem .3rem; font-size: .95rem; }
.kanban-title { font-weight: 700; }
.kanban-count { background: var(--surface); border-radius: 999px; padding: 0 .45rem; font-size: .75rem; color: var(--muted); }
.kanban-total { margin-left: auto; color: var(--muted); font-size: .78rem; font-variant-numeric: tabular-nums; }
.kanban-won .kanban-title { color: var(--ok); }
.kanban-lost .kanban-title { color: var(--danger); }
.kanban-cards { display: flex; flex-direction: column; gap: .5rem; min-height: 60px; overflow-y: auto; }
.lead-card { display: flex; flex-direction: column; gap: .35rem; background: var(--surface); border: 1px solid var(--border); border-radius: 12px; padding: .8rem .9rem; color: var(--text); box-shadow: var(--shadow); cursor: grab; }
.lead-card:hover { border-color: #b9c1bc; text-decoration: none; }
.lead-title { font-weight: 600; }
.lead-contact { color: var(--muted); font-size: .85rem; }
.lead-foot { display: flex; align-items: center; gap: .5rem; font-size: .8rem; }
.lead-value { font-weight: 600; font-variant-numeric: tabular-nums; }
.lead-tasks { color: var(--muted); }
.avatar { margin-left: auto; width: 22px; height: 22px; border-radius: 50%; background: var(--primary-soft); color: var(--primary); display: grid; place-items: center; font-size: .72rem; font-weight: 700; }
.lead-ghost { opacity: .4; }
.kanban-add { color: var(--muted); font-size: .85rem; padding: .25rem; }

.stage-bar { display: flex; flex-wrap: wrap; gap: 0; margin-bottom: 1rem; }
.stage-step { font: inherit; font-size: .85rem; border: 1px solid var(--border); background: var(--surface); color: var(--muted); padding: .45rem .8rem; cursor: pointer; margin-left: -1px; }
.stage-step:first-child { border-radius: 8px 0 0 8px; margin-left: 0; }
.stage-step:last-child { border-radius: 0 8px 8px 0; }
.stage-step:hover { background: var(--surface-2); color: var(--text); }
.stage-step.current { background: var(--primary); border-color: var(--primary); color: var(--primary-ink); font-weight: 600; position: relative; z-index: 1; }
.stage-step.stage-won.current { background: var(--ok); border-color: var(--ok); }
.stage-step.stage-lost.current { background: var(--danger); border-color: var(--danger); }
.badge-stage-open { background: var(--primary-soft); color: var(--primary); }
.badge-stage-won { background: var(--ok-soft); color: var(--ok); }
.badge-stage-lost { background: var(--danger-soft); color: var(--danger); }

.stage-list { list-style: none; margin: 0 0 1rem; padding: 0; }
.stage-list li { display: flex; align-items: center; gap: .5rem; padding: .4rem 0; border-bottom: 1px solid var(--border); flex-wrap: wrap; }
.stage-move { display: flex; }
.stage-rename { margin: 0; flex: 1; min-width: 200px; }

/* ---------- დავალებები ---------- */
.tasks { list-style: none; margin: 0; padding: 0; }
.task { display: flex; gap: .65rem; align-items: flex-start; padding: .55rem 0; border-bottom: 1px solid var(--border); }
.task:last-child { border-bottom: 0; }
.task form { margin: 0; }
.task-check { width: 20px; height: 20px; border-radius: 6px; border: 2px solid var(--border); background: var(--surface); cursor: pointer; display: grid; place-items: center; font-size: .75rem; color: var(--ok); padding: 0; margin-top: 2px; }
.task-check:hover { border-color: var(--ok); }
.task-body { display: flex; flex-direction: column; gap: .1rem; min-width: 0; }
.task-meta { display: flex; flex-wrap: wrap; gap: .2rem .6rem; font-size: .8rem; color: var(--muted); }
.task-due { font-weight: 600; }
.task-overdue .task-due { color: var(--danger); }
.task-done .task-title { text-decoration: line-through; color: var(--muted); }
.task-done .task-check { border-color: var(--ok); background: var(--ok-soft); }
.task-group-overdue h2 { color: var(--danger); }
.task-form { display: grid; grid-template-columns: minmax(0, 1.1fr) minmax(0, .8fr) minmax(0, 1fr) auto; gap: .5rem; align-items: center; margin-bottom: .5rem; }
.task-form input[name=title] { grid-column: 1 / -1; }
.task-form-wide input[name=title] { grid-column: auto; }
.task-form-wide { grid-template-columns: minmax(0, 2fr) 140px 100px 150px minmax(0, 1fr) auto; }

/* ---------- ისტორია ---------- */
.activity-form { display: flex; flex-direction: column; gap: .5rem; margin-bottom: 1rem; }
.activity-form-row { display: flex; gap: .5rem; justify-content: space-between; }
.activity-form-row select { max-width: 200px; }
.timeline { list-style: none; margin: 0; padding: 0; }
.timeline li { display: flex; gap: .65rem; padding: .55rem 0; border-bottom: 1px solid var(--border); }
.timeline li:last-child { border-bottom: 0; }
.tl-icon { width: 24px; flex: 0 0 24px; text-align: center; }
.tl-system .tl-icon { color: var(--muted); }
.tl-system .tl-text { color: var(--muted); font-size: .9rem; }
.tl-text { white-space: pre-wrap; overflow-wrap: anywhere; }
.tl-meta { font-size: .78rem; color: var(--muted); }

/* ---------- შესვლა ---------- */
.auth-body { display: grid; place-items: center; min-height: 100vh; padding: 1rem; }
.auth-card { background: var(--surface); border: 1px solid var(--border); border-radius: 14px; padding: 2rem; width: 100%; max-width: 420px; box-shadow: var(--shadow); }
.auth-card h1 { margin-bottom: .5rem; }
.error-page { max-width: 480px; margin: 15vh auto; text-align: center; padding: 1rem; }

/* ---------- მორგებადი პროდუქტები / აწყობა ---------- */
.badge-asm-pending { background: var(--surface-2); color: var(--muted); }
.badge-asm-in_progress { background: var(--info-soft); color: var(--info); }
.badge-asm-completed { background: var(--ok-soft); color: var(--ok); }
.badge-asm-cancelled { background: var(--danger-soft); color: var(--danger); }
a.badge:hover { text-decoration: none; filter: brightness(.95); }
.card-foot { display: flex; flex-wrap: wrap; gap: .5rem; margin-top: .75rem; }
.inline-actions { display: flex; flex-wrap: wrap; gap: .5rem; align-items: center; margin-top: .5rem; }
.inline-actions form { margin: 0; }
.inline-form.compact { margin-top: 0; align-items: center; }
ul.plain { list-style: none; padding: 0; margin: 0 0 .5rem; }
ul.plain li { padding: .2rem 0; }
.swatch { display: inline-block; width: .95rem; height: .95rem; border-radius: 4px; border: 1px solid rgba(0, 0, 0, .2); vertical-align: -2px; margin-right: .35rem; }
.color-list { list-style: none; padding: 0; margin: 0 0 .75rem; display: flex; flex-wrap: wrap; gap: .35rem 1rem; }
.color-input { width: 3rem; min-width: 3rem; padding: 0 .2rem; height: 2.3rem; }
.w-num { width: 6.5rem; }
.rule-rows { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr) minmax(0, 2fr); gap: .4rem .5rem; align-items: center; }
.rule-rows.two { grid-template-columns: minmax(0, 2fr) minmax(0, 1fr); }
.rule-rows.four { grid-template-columns: minmax(0, 2fr) minmax(0, 1fr) minmax(0, 1fr) minmax(0, 1fr); }
.letter-grid { display: grid; grid-template-columns: 3rem repeat(3, minmax(0, 8rem)); gap: .3rem .5rem; align-items: center; margin-bottom: 1rem; }
.letter-grid strong { font-size: 1.15rem; text-align: center; }
.name-input { font-size: 1.4rem; font-weight: 600; letter-spacing: .05em; }
.letter-colors { display: flex; flex-wrap: wrap; gap: .5rem; align-items: flex-end; margin: .5rem 0 1rem; }
.letter-colors > .muted { flex-basis: 100%; }
.letter-color { display: flex; flex-direction: column; align-items: center; gap: .2rem; font-weight: 400; }
.letter-color strong { font-size: 1.2rem; }
.letter-color select { min-width: 6.5rem; }
.clicker-preview { margin-bottom: 1rem; }
.clicker-insert { display: inline-flex; flex-wrap: wrap; gap: .35rem; padding: .6rem; border-radius: 12px; background: var(--surface-2); border: 2px solid var(--border); max-width: 100%; }
.clicker-key { display: flex; flex-direction: column; align-items: center; justify-content: center; min-width: 3.2rem; height: 3.6rem; padding: 0 .3rem; border-radius: 8px; border: 1px solid rgba(0, 0, 0, .25); box-shadow: inset 0 -3px 0 rgba(0, 0, 0, .15); color: #111; }
.clicker-key b { font-size: 1.35rem; line-height: 1.1; text-shadow: 0 0 3px rgba(255, 255, 255, .8); }
.clicker-key small { font-size: .62rem; background: rgba(255, 255, 255, .8); border-radius: 4px; padding: 0 .2rem; margin-top: .15rem; }
.clicker-sep { display: flex; align-items: center; justify-content: center; min-width: .8rem; font-weight: 700; color: var(--muted); }
.clicker-sep.slot { min-width: 3.2rem; border: 1px dashed var(--border); border-radius: 8px; }
.word-sequence { list-style: none; padding: 0; margin: 0 0 1rem; display: flex; flex-wrap: wrap; gap: .4rem; counter-reset: pos; }
.word-sequence li { display: flex; flex-direction: column; align-items: center; gap: .2rem; min-width: 3.4rem; counter-increment: pos; }
.word-sequence li::before { content: counter(pos); font-size: .7rem; color: var(--muted); }
.seq-ch { display: flex; align-items: center; justify-content: center; width: 2.6rem; height: 2.6rem; border-radius: 8px; border: 1px solid rgba(0, 0, 0, .25); font-size: 1.3rem; font-weight: 700; color: #111; background: var(--surface-2); text-shadow: 0 0 3px rgba(255, 255, 255, .8); }
.word-sequence li.sep .seq-ch { background: transparent; border-style: dashed; color: var(--muted); }
.seq-color { font-size: .75rem; text-align: center; }
.diff-card { border-color: var(--warn); }
.custom-item { border-left: 3px solid var(--primary); }
.print-page { background: #fff; color: #111; }
.print-page main { max-width: 800px; margin: 0 auto; padding: 1.5rem; }
.print-head { display: flex; justify-content: space-between; align-items: center; }
@media print { .print-page main { padding: 0; } .seq-ch, .clicker-key, .swatch { -webkit-print-color-adjust: exact; print-color-adjust: exact; } }

/* ---------- მთავარი: აწყობის რიგი, ლიდები ეტაპებით ---------- */
.queue { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: .6rem; }
.queue-item { display: flex; flex-direction: column; gap: .4rem; padding: .75rem .85rem; border: 1px solid var(--surface-2); border-radius: 12px; color: var(--text); }
.queue-item:hover { border-color: var(--border-strong); text-decoration: none; }
.queue-head { display: flex; align-items: center; gap: .5rem; flex-wrap: wrap; }
.queue-head .badge { margin-left: auto; }
.word-mini { display: flex; flex-wrap: wrap; gap: 4px; }
.word-mini span { width: 26px; height: 30px; border-radius: 6px; border: 1px solid rgba(0, 0, 0, .22); display: inline-flex; align-items: center; justify-content: center; font-weight: 700; font-size: .85rem; color: #111; background: var(--surface-2); }
.word-mini i { width: 8px; }
.stage-bars { list-style: none; margin: 0 0 1rem; padding: 0; display: flex; flex-direction: column; gap: .55rem; font-size: .92rem; }
.stage-bars li { display: grid; grid-template-columns: minmax(0, 12rem) minmax(3rem, 1fr) 2rem; align-items: center; gap: .6rem; }
.stage-bars-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.stage-bars-track { height: 10px; border-radius: 5px; background: var(--surface-2); }
.stage-bars-track span { display: block; height: 10px; border-radius: 5px; background: var(--primary); }

/* ---------- წესები: ნაწილები, ტიპები ---------- */
.part-rows { display: flex; flex-direction: column; gap: .75rem; }
.part-row { display: grid; grid-template-columns: minmax(0, 2fr) minmax(0, 1.5fr) minmax(0, .7fr) minmax(0, .7fr); gap: .5rem .75rem; align-items: end; padding: .85rem 1rem; border: 1px solid var(--border); border-radius: var(--radius-sm); background: var(--surface-3); }
.part-row.part-new { border-style: dashed; background: transparent; }
.part-qty { grid-column: span 2; align-self: center; }
.part-rule { grid-column: 1 / -1; margin: 0; }
.part-options { grid-column: 1 / -1; display: flex; flex-wrap: wrap; gap: .35rem 1rem; align-items: center; }
.part-options > .muted { flex-basis: 100%; }
.part-option { display: inline-flex; align-items: center; gap: .4rem; }
.part-option .w-num { width: 5.5rem; min-height: 34px; padding: .25rem .5rem; }
details.type-edit { border-bottom: 1px solid var(--surface-2); padding: .5rem 0; }
details.type-edit summary { cursor: pointer; font-weight: 500; }
details.type-edit form { margin-top: .75rem; }

/* ---------- Inbox ---------- */
.inbox { display: grid; grid-template-columns: minmax(260px, 340px) minmax(0, 1fr) minmax(240px, 300px); gap: 1rem; align-items: start; }
.inbox:not(.has-conv) { grid-template-columns: minmax(260px, 340px) minmax(0, 1fr); }
.inbox-list { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; }
.inbox-list .tabs { padding: 0 .5rem; margin-bottom: 0; }
.conv-list { list-style: none; margin: 0; padding: .35rem; max-height: calc(100vh - 220px); overflow-y: auto; }
.conv-item { display: flex; gap: .7rem; padding: .65rem .6rem; border-radius: 10px; color: var(--text); }
.conv-item:hover { background: var(--surface-3); text-decoration: none; }
.conv-item.active { background: var(--primary-soft); }
.conv-item.unread .conv-top strong, .conv-item.unread .conv-text { font-weight: 700; color: var(--text); }
.conv-avatar { width: 40px; height: 40px; border-radius: 50%; flex: none; display: grid; place-items: center; font-weight: 700; color: #fff; background: #4c6ef5; overflow: hidden; }
.conv-avatar.conv-instagram { background: #c13584; }
.conv-avatar.conv-facebook { background: #1877f2; }
.conv-avatar img { width: 100%; height: 100%; object-fit: cover; }
.conv-body { display: flex; flex-direction: column; gap: .15rem; min-width: 0; flex: 1; }
.conv-top { display: flex; justify-content: space-between; gap: .5rem; }
.conv-top strong { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.conv-text { color: var(--muted); font-size: .9rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.conv-meta { display: flex; align-items: center; gap: .4rem; flex-wrap: wrap; }
.conv-meta .nav-badge { margin-left: auto; }
.platform-tag { font-size: .75rem; font-weight: 600; padding: .05rem .5rem; border-radius: 999px; }
.platform-facebook { background: #e7f0fe; color: #1458c8; }
.platform-instagram { background: #fbe7f2; color: #a0236a; }
.inbox-thread { display: flex; flex-direction: column; gap: .75rem; margin-bottom: 0; min-height: 60vh; }
.inbox-placeholder { align-items: center; justify-content: center; }
.thread-head { display: flex; flex-wrap: wrap; align-items: center; gap: .75rem; padding-bottom: .75rem; border-bottom: 1px solid var(--surface-2); }
.thread-head form { margin-left: auto; }
.thread-title { display: flex; flex-direction: column; min-width: 0; flex: 1 1 160px; }
.thread-back { display: none; }
.thread-ad { margin: 0; }
.messages { list-style: none; margin: 0; padding: .25rem; display: flex; flex-direction: column; gap: .5rem; flex: 1; max-height: calc(100vh - 360px); min-height: 240px; overflow-y: auto; }
.msg { max-width: 75%; padding: .55rem .8rem; border-radius: 14px; background: var(--surface-2); align-self: flex-start; }
.msg-out { align-self: flex-end; background: var(--primary-soft); }
.msg-failed { background: var(--danger-soft); }
.msg-text { white-space: pre-wrap; overflow-wrap: anywhere; }
.msg-meta { font-size: .75rem; color: var(--muted); margin-top: .2rem; }
.msg-image { max-width: 240px; max-height: 240px; border-radius: 10px; display: block; }
.reply-form { display: flex; gap: .5rem; align-items: flex-end; }
.reply-form textarea { flex: 1; resize: vertical; }
.reply-hint { margin: -.4rem 0 0; }
.inbox-side .card { margin-bottom: 1rem; }
.order-from-chat { margin-top: .6rem; }
.empty-state { text-align: center; padding: 2.5rem 1.5rem; }
.empty-state p { max-width: 520px; margin: .5rem auto 1.25rem; }
@media (max-width: 1100px) {
  .inbox { grid-template-columns: minmax(240px, 300px) minmax(0, 1fr); }
  .inbox-side { grid-column: 2; }
}

/* ---------- საჯარო გვერდები ---------- */
.public-page { max-width: 760px; margin: 0 auto; padding: 2.5rem 1.25rem 4rem; line-height: 1.65; }
.public-page h1 { margin-bottom: 1rem; }
.public-page h2 { margin-top: 2rem; }

/* ---------- ტელეფონი ---------- */
@media (max-width: 860px) {
  .shell { grid-template-columns: minmax(0, 1fr); grid-template-rows: auto 1fr; }
  .sidebar { position: sticky; top: 0; z-index: 10; height: auto; flex-direction: row; align-items: center; padding: .5rem 1rem; gap: .5rem; border-right: 0; border-bottom: 0; }
  .brand-text, .me, .avatar-me { display: none; }
  .brand-mark { width: 32px; height: 32px; }
  .nav { flex-direction: row; overflow-x: auto; flex: 1; scrollbar-width: none; }
  .nav a { white-space: nowrap; padding: .5rem .65rem; }
  .nav a svg { display: none; }
  .sidebar-foot { margin: 0; padding: 0; border-top: 0; }
  h1 { font-size: 1.5rem; }
  .stats { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: .6rem; }
  .stat { padding: .85rem .9rem; }
  .stat-value { font-size: 1.35rem; }
  .main { padding: 1rem 1rem 3rem; }
  .grid-2, .grid-2.grid-main, .form-grid { grid-template-columns: minmax(0, 1fr); }
  .card { overflow-x: auto; padding: 1rem; }
  .span-2 { grid-column: auto; }
  .item-row { grid-template-columns: 1fr 70px 100px auto; }
  .task-form, .task-form-wide { grid-template-columns: 1fr 1fr; }
  .money-row { grid-template-columns: 1fr 1fr; }
  .pay-form { grid-template-columns: 1fr 1fr; }
  .courier-row { grid-template-columns: 1fr 1fr; }
  .task-form input[name=title] { grid-column: span 2; }
  .kanban-col { flex-basis: 240px; max-height: none; }
  .toolbar-right { margin-left: 0; }
  .rule-rows, .rule-rows.four { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); }
  .rule-rows > .muted { display: none; }
  .letter-grid { grid-template-columns: 2rem repeat(3, minmax(0, 1fr)); }
  .part-row { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); }
  .inbox, .inbox:not(.has-conv) { grid-template-columns: minmax(0, 1fr); }
  .inbox.has-conv .inbox-list { display: none; }
  .inbox-side { grid-column: auto; }
  .thread-back { display: inline-flex; }
  .msg { max-width: 88%; }
  .messages { max-height: none; }
  .part-row > label:first-of-type, .part-row > label:nth-of-type(2) { grid-column: 1 / -1; }
}
