:root {
    --brand: #c8102e;
    --brand-dark: #a00d25;
    --ink: #1c2530;
    --ink-soft: #55616f;
    --muted: #8a94a0;
    --bg: #f3f4f6;
    --surface: #ffffff;
    --line: #e2e5e9;
    --hover: #faf6f0;
    --open: #c8102e;
    --open-bg: #fdecef;
    --closed: #1d4ed8;
    --closed-bg: #e8eefc;
    --radius: 10px;
    --shadow: 0 1px 2px rgba(16, 24, 40, .06), 0 1px 3px rgba(16, 24, 40, .08);
    --cols: minmax(110px, 1.3fr) minmax(70px, .8fr) 70px minmax(200px, 3.2fr) minmax(80px, 1fr) minmax(90px, 1.2fr) 120px;
}

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

html { -webkit-text-size-adjust: 100%; }

body {
    margin: 0;
    background: var(--bg);
    color: var(--ink);
    font-family: "Segoe UI", Calibri, Arial, "Noto Sans Hebrew", sans-serif;
    font-size: 15px;
    line-height: 1.45;
}

a { color: inherit; text-decoration: none; }

small { font-size: .82em; color: var(--muted); }

/* ---------- ზედა ზოლი ---------- */
.topbar {
    position: sticky;
    top: 0;
    z-index: 20;
    background: var(--surface);
    box-shadow: var(--shadow);
}

.topbar__inner {
    display: flex;
    align-items: center;
    gap: 16px;
    max-width: 1500px;
    margin: 0 auto;
    padding: 10px 20px;
}

.brand { display: flex; flex-shrink: 0; }
.brand img { display: block; height: 40px; width: auto; }

.search {
    display: flex;
    flex: 1;
    max-width: 420px;
    margin-inline-start: auto;
    border: 1px solid var(--line);
    border-radius: 999px;
    background: var(--bg);
    overflow: hidden;
}
.search:focus-within { border-color: var(--brand); background: var(--surface); }
.search input {
    flex: 1;
    min-width: 0;
    border: 0;
    background: transparent;
    padding: 9px 16px;
    font: inherit;
    color: inherit;
    outline: none;
}
.search button {
    display: grid;
    place-items: center;
    width: 44px;
    border: 0;
    background: transparent;
    color: var(--ink-soft);
    cursor: pointer;
}
.search button:hover { color: var(--brand); }

svg { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; }

.user { display: flex; align-items: center; gap: 12px; flex-shrink: 0; }
.user__name { color: var(--ink-soft); font-weight: 600; }

.menu-toggle {
    display: none;
    place-items: center;
    width: 44px;
    height: 44px;
    border: 1px solid var(--line);
    border-radius: var(--radius);
    background: var(--surface);
    color: var(--ink);
    cursor: pointer;
}

/* ---------- მენიუ ---------- */
.nav { background: var(--ink); }
.nav__inner {
    display: flex;
    flex-wrap: wrap;
    max-width: 1500px;
    margin: 0 auto;
    padding: 0 12px;
}
.nav a {
    padding: 11px 13px;
    color: #d5dae0;
    font-weight: 600;
    white-space: nowrap;
    border-bottom: 3px solid transparent;
}
.nav a:hover { color: #fff; background: rgba(255, 255, 255, .07); }
.nav a.is-active { color: #fff; border-bottom-color: var(--brand); }
.nav .nav__logout { display: none; }

/* ---------- ღილაკები, ნიშნულები ---------- */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 40px;
    padding: 8px 16px;
    border: 1px solid transparent;
    border-radius: 8px;
    font: inherit;
    font-weight: 600;
    cursor: pointer;
    white-space: nowrap;
}
.btn--primary { background: var(--brand); color: #fff; }
.btn--primary:hover { background: var(--brand-dark); }
.btn--ghost { border-color: var(--line); color: var(--ink-soft); background: var(--surface); }
.btn--ghost:hover { border-color: var(--brand); color: var(--brand); }

.count {
    display: inline-block;
    min-width: 26px;
    padding: 1px 9px;
    border-radius: 999px;
    background: var(--ink);
    color: #fff;
    font-size: 13px;
    font-weight: 600;
    text-align: center;
    vertical-align: middle;
}

.chip {
    display: inline-block;
    padding: 1px 8px;
    border-radius: 6px;
    background: var(--bg);
    border: 1px solid var(--line);
    font-size: 13px;
    font-weight: 600;
    white-space: nowrap;
}

.badge {
    display: inline-block;
    padding: 2px 10px;
    border-radius: 999px;
    font-size: 13px;
    font-weight: 600;
    white-space: nowrap;
}
.badge--open { background: var(--open-bg); color: var(--open); }
.badge--closed { background: var(--closed-bg); color: var(--closed); }

.alert {
    max-width: 1460px;
    margin: 16px auto 0;
    padding: 10px 16px;
    border: 1px solid #f3b8c1;
    border-radius: var(--radius);
    background: var(--open-bg);
    color: var(--open);
    font-weight: 600;
}

/* ---------- განლაგება ---------- */
.layout {
    display: grid;
    grid-template-columns: minmax(0, 1fr) 280px;
    gap: 20px;
    align-items: start;
    max-width: 1500px;
    margin: 0 auto;
    padding: 20px;
}

.page-head {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 12px;
    margin-bottom: 14px;
}
.page-head h1 { margin: 0; font-size: 22px; }
.page-head .btn { margin-inline-start: auto; }

.filter-chip {
    padding: 3px 12px;
    border-radius: 999px;
    background: var(--closed-bg);
    color: var(--closed);
    font-weight: 600;
}

.empty {
    padding: 40px 20px;
    border-radius: var(--radius);
    background: var(--surface);
    box-shadow: var(--shadow);
    color: var(--ink-soft);
    text-align: center;
}

/* ---------- შემთხვევების სია (დესკტოპი: ცხრილი) ---------- */
.cases {
    border-radius: var(--radius);
    background: var(--surface);
    box-shadow: var(--shadow);
    overflow: hidden;
}

.cases__head,
.case {
    display: grid;
    grid-template-columns: var(--cols);
    gap: 12px;
    padding: 10px 16px;
}

.cases__head {
    background: #f8f9fa;
    border-bottom: 1px solid var(--line);
    color: var(--ink-soft);
    font-size: 13px;
    font-weight: 700;
}
.cases__head a:hover,
.cases__head a.is-sorted { color: var(--brand); }

.case { border-bottom: 1px solid var(--line); align-items: start; }
.case:last-child { border-bottom: 0; }
.case:hover { background: var(--hover); }

.case > span { min-width: 0; overflow-wrap: anywhere; }
.case__hospital strong { display: block; color: var(--closed); }
.case__prob strong,
.case__prob small { display: block; text-align: right; }
.case__prob strong { font-weight: 600; }
.case__freelancer { color: #15803d; }
.case__freelancer b { color: #c2590a; }
.case__worker small { display: block; }
.case__changes { text-align: right; }
.case__date > span { display: block; white-space: nowrap; }
.case__fixed { color: var(--muted); }

/* ---------- გვერდების ნუმერაცია ---------- */
.pagination {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 6px;
    margin-top: 18px;
}
.pagination a,
.pagination span {
    min-width: 40px;
    padding: 8px 12px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: var(--surface);
    font-weight: 600;
    text-align: center;
}
.pagination a:hover { border-color: var(--brand); color: var(--brand); }
.pagination .is-current { background: var(--ink); border-color: var(--ink); color: #fff; }

/* ---------- გვერდითი პანელი ---------- */
.panel {
    border-radius: var(--radius);
    background: var(--surface);
    box-shadow: var(--shadow);
    overflow: hidden;
}
.panel__title {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 16px;
    font-weight: 700;
    cursor: pointer;
    list-style: none;
}
.panel__title::-webkit-details-marker { display: none; }
.panel__title .count { background: var(--brand); }
.panel__empty { margin: 0; padding: 0 16px 16px; color: var(--ink-soft); }

.repeat-list { margin: 0; padding: 0; list-style: none; max-height: 70vh; overflow-y: auto; }
.repeat-list a {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 9px 16px;
    border-top: 1px solid var(--line);
}
.repeat-list a:hover { background: var(--hover); }
.repeat-list__hospital { flex: 1; min-width: 0; font-weight: 600; overflow-wrap: anywhere; }
.repeat-list__count { color: var(--open); font-weight: 700; }

/* ---------- განმეორებადი გაუმართაობების გვერდი ---------- */
.layout--single { grid-template-columns: minmax(0, 1fr); }

.repeat-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
    gap: 12px;
}
.repeat-card {
    display: flex;
    align-items: center;
    gap: 14px;
    padding: 14px 16px;
    border-inline-start: 4px solid var(--open);
    border-radius: var(--radius);
    background: var(--surface);
    box-shadow: var(--shadow);
}
.repeat-card:hover { background: var(--hover); }
.repeat-card__count {
    display: grid;
    place-items: center;
    flex-shrink: 0;
    width: 44px;
    height: 44px;
    border-radius: 50%;
    background: var(--open-bg);
    color: var(--open);
    font-size: 18px;
    font-weight: 700;
}
.repeat-card__body { display: flex; flex-direction: column; gap: 3px; min-width: 0; }
.repeat-card__body strong { color: var(--closed); font-size: 16px; overflow-wrap: anywhere; }

/* ---------- ფორმები (ახალი შემთხვევა / რედაქტირება) ---------- */
.layout--form { grid-template-columns: minmax(0, 860px); justify-content: center; }

.card {
    margin-bottom: 14px;
    padding: 18px 20px 6px;
    border-radius: var(--radius);
    background: var(--surface);
    box-shadow: var(--shadow);
}
.card h2 { margin: 0 0 14px; font-size: 16px; color: var(--ink-soft); }

.field { margin-bottom: 14px; min-width: 0; }
.field-row { display: grid; grid-template-columns: 1fr 1fr; gap: 0 16px; }
.field label, .field__label { display: block; margin-bottom: 5px; font-weight: 600; }

.field select,
.field textarea,
.field input[type="date"],
.field input[type="number"],
.field input[type="file"],
.picker__filter {
    width: 100%;
    min-height: 44px;
    padding: 9px 12px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: var(--surface);
    color: var(--ink);
    font: inherit;
    font-size: 16px;
}
.field textarea { resize: vertical; text-align: right; }
.field input[type="file"] { padding: 8px; }
.field select:focus,
.field textarea:focus,
.field input:focus,
.picker__filter:focus { border-color: var(--brand); outline: 2px solid var(--open-bg); }

.prefixed { display: flex; }
.prefixed span {
    display: grid;
    place-items: center;
    min-width: 48px;
    padding: 0 10px;
    border: 1px solid var(--line);
    border-right: 0;
    border-radius: 8px 0 0 8px;
    background: var(--bg);
    font-weight: 700;
}
.prefixed input { border-radius: 0 8px 8px 0 !important; }
.prefixed input:disabled { background: var(--bg); }

/* რადიო ღილაკები სეგმენტებად */
.segmented { display: flex; border: 1px solid var(--line); border-radius: 8px; overflow: hidden; }
.segmented label { flex: 1; margin: 0; cursor: pointer; }
.segmented input { position: absolute; opacity: 0; pointer-events: none; }
.segmented span {
    display: grid;
    place-items: center;
    min-height: 44px;
    padding: 6px 12px;
    border-inline-start: 1px solid var(--line);
    font-weight: 600;
    text-align: center;
}
.segmented label:first-child span { border-inline-start: 0; }
.segmented input:checked + span { background: var(--ink); color: #fff; }
.segmented input:focus-visible + span { outline: 2px solid var(--brand); outline-offset: -2px; }
.segmented--wrap { flex-wrap: wrap; border: 0; gap: 6px; overflow: visible; }
.segmented--wrap label { flex: 1 0 auto; }
.segmented--wrap span { border: 1px solid var(--line) !important; border-radius: 8px; }

/* ჩამოსაშლელი სია checkbox-ებით */
.picker { margin-bottom: 14px; border: 1px solid var(--line); border-radius: 8px; }
.picker summary {
    display: flex;
    align-items: center;
    justify-content: space-between;
    min-height: 44px;
    padding: 8px 12px;
    font-weight: 600;
    cursor: pointer;
    list-style: none;
}
.picker summary::-webkit-details-marker { display: none; }
.picker summary > span:first-child::after { content: " ▾"; color: var(--muted); }
.picker[open] summary { border-bottom: 1px solid var(--line); }
.picker [data-picker-count="0"], .picker .count:empty { background: var(--muted); }
.picker__filter { display: block; width: calc(100% - 20px); margin: 10px; }
.picker__list {
    display: grid;
    grid-template-columns: 1fr 1fr;
    max-height: 340px;
    margin: 0 10px 10px;
    border: 1px solid var(--line);
    border-radius: 8px;
    overflow-y: auto;
}
.picker__item {
    display: flex;
    align-items: center;
    gap: 10px;
    min-height: 42px;
    margin: 0 !important;
    padding: 6px 12px;
    background: var(--surface);
    font-weight: 400 !important;
    cursor: pointer;
}
/* ზებრა: რიგები მორიგეობით თეთრი და ღია ნაცრისფერი (კლასს js/app.js ანიჭებს ხილული რიგების მიხედვით) */
.picker__item.is-alt { background: #eef0f3; }
.picker__item:hover { background: var(--hover); }
.picker__item.is-checked { background: var(--open-bg); box-shadow: inset 3px 0 0 var(--brand); }
.picker__item input { flex-shrink: 0; width: 20px; height: 20px; accent-color: var(--brand); }
.picker__item span { flex: 1; text-align: right; overflow-wrap: anywhere; }
.picker__item input:checked + span { font-weight: 600; }
.picker__item[hidden] { display: none; }

.form-actions { display: flex; gap: 10px; margin: 6px 0 14px; }
.btn--large { min-height: 48px; padding: 10px 28px; font-size: 16px; }
.form-actions .btn--primary { flex: 1; max-width: 320px; }

.form-errors {
    margin-bottom: 14px;
    padding: 12px 16px;
    border: 1px solid #f3b8c1;
    border-radius: var(--radius);
    background: var(--open-bg);
    color: var(--open);
    font-weight: 600;
}

.summary {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
    gap: 12px 16px;
    margin: 0 0 14px;
    padding: 16px 20px;
    border-inline-start: 4px solid var(--brand);
    border-radius: var(--radius);
    background: var(--surface);
    box-shadow: var(--shadow);
}
.summary dt { color: var(--muted); font-size: 13px; }
.summary dd { margin: 0; font-weight: 600; overflow-wrap: anywhere; text-align: right; }
.summary__wide { grid-column: 1 / -1; }

.thumbs { display: flex; flex-wrap: wrap; gap: 8px; }
.thumbs img { display: block; width: 96px; height: 96px; border: 1px solid var(--line); border-radius: 8px; object-fit: cover; }

/* ---------- შემთხვევის ნახვა ---------- */
.pager { display: flex; gap: 8px; margin-inline-start: auto; }
.page-head .pager .btn { margin: 0; }

.case-view { padding-bottom: 18px; border-inline-start: 4px solid var(--open); }
.case-view--closed { border-inline-start-color: var(--closed); }
.case-view__head { display: flex; align-items: center; flex-wrap: wrap; gap: 10px; margin-bottom: 14px; }
.case-view__hospital { color: var(--closed); font-size: 22px; font-weight: 700; }
.case-view__hospital:hover, .link:hover { text-decoration: underline; }
.chip--large { padding: 4px 12px; font-size: 16px; }
a.chip:hover { border-color: var(--brand); color: var(--brand); }
.case-view__prob { margin: 0 0 8px; font-size: 17px; font-weight: 600; text-align: right; }
.case-view__comments { margin: 0 0 14px; color: var(--open); text-align: right; overflow-wrap: anywhere; }
.link { color: #c2590a; font-weight: 600; }

.details {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
    gap: 12px 16px;
    margin: 16px 0;
    padding: 14px 0;
    border-top: 1px solid var(--line);
    border-bottom: 1px solid var(--line);
}
.details dt { color: var(--muted); font-size: 13px; }
.details dd { margin: 0; font-weight: 600; overflow-wrap: anywhere; text-align: right; }
.details__wide { grid-column: 1 / -1; }

.thumbs--large img { width: 150px; height: 150px; }

.case-view__actions { display: flex; align-items: center; flex-wrap: wrap; gap: 10px; }
.case-view__delete { margin-inline-start: auto; }
.btn--danger { border-color: #f3b8c1; background: var(--surface); color: var(--open); }
.btn--danger:hover { background: var(--open); border-color: var(--open); color: #fff; }

.case-view__qr {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-top: 16px;
    padding-top: 14px;
    border-top: 1px solid var(--line);
}
.case-view__qr img { display: block; width: 120px; height: 120px; image-rendering: pixelated; }

/* ---------- თარიღების შუალედის ფილტრი ---------- */
.range-filter { display: flex; align-items: center; flex-wrap: wrap; gap: 10px; margin-bottom: 14px; }
.range-filter label { display: flex; align-items: center; gap: 6px; font-weight: 600; }
.range-filter input {
    min-height: 40px;
    padding: 6px 10px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: var(--surface);
    font: inherit;
}

/* ---------- სურათების დამთვალიერებელი ---------- */
.thumbs a { cursor: zoom-in; }
.lightbox {
    position: fixed;
    inset: 0;
    z-index: 100;
    display: grid;
    place-items: center;
    background: rgba(10, 14, 20, .92);
    touch-action: pan-y;
}
.lightbox[hidden] { display: none; }
.lightbox__image { max-width: 100vw; max-height: 100vh; object-fit: contain; user-select: none; }
.lightbox button {
    position: absolute;
    display: grid;
    place-items: center;
    width: 48px;
    height: 48px;
    border: 0;
    border-radius: 50%;
    background: rgba(255, 255, 255, .16);
    color: #fff;
    font-size: 26px;
    line-height: 1;
    cursor: pointer;
}
.lightbox button:hover { background: rgba(255, 255, 255, .32); }
.lightbox__close { top: 14px; left: 14px; }
.lightbox__prev { top: 50%; right: 14px; transform: translateY(-50%); }
.lightbox__next { top: 50%; left: 14px; transform: translateY(-50%); }
.lightbox__counter {
    position: absolute;
    bottom: 16px;
    left: 50%;
    transform: translateX(-50%);
    padding: 4px 14px;
    border-radius: 999px;
    background: rgba(0, 0, 0, .55);
    color: #fff;
    font-weight: 600;
}
.lightbox--single .lightbox__prev,
.lightbox--single .lightbox__next,
.lightbox--single .lightbox__counter { display: none; }

/* ---------- მომსახურების ფურცელი (PDF / ბეჭდვა) ---------- */
.sheet { padding: 24px; border-radius: var(--radius); background: var(--surface); box-shadow: var(--shadow); }
.sheet__head { display: flex; align-items: center; justify-content: space-between; gap: 16px; margin-bottom: 16px; }
.sheet__head h2 { margin: 0; font-size: 18px; }
.sheet__head p { margin: 2px 0 0; color: var(--ink-soft); }
.sheet table { width: 100%; border-collapse: collapse; margin-bottom: 14px; }
.sheet th, .sheet td { padding: 5px 8px; border: 1px solid #444; text-align: right; vertical-align: top; }
.sheet th { background: #f3f3f3; white-space: nowrap; }
.sheet__info td { color: var(--open); font-weight: 600; }
.sheet__list td:first-child { width: 52px; text-align: center; }
.sheet__list td:last-child { width: 32%; }
.sheet__section td { background: #f3f3f3; font-weight: 700; }
.sheet__list--report td:first-child { width: 34px; }
.sheet__list--report td:last-child { width: 86px; white-space: nowrap; }
.sheet__list--report td { font-size: .92em; overflow-wrap: anywhere; }

@media print {
    @page { size: A4; margin: 12mm; }
    body { background: #fff; font-size: 11pt; }
    .topbar, .no-print, .alert { display: none !important; }
    .layout { display: block; max-width: none; padding: 0; }
    .sheet { padding: 0; border-radius: 0; box-shadow: none; }
    .sheet th, .sheet td { padding: 3px 6px; }
    .sheet tr { break-inside: avoid; }
    .sheet__section td, .sheet th { -webkit-print-color-adjust: exact; print-color-adjust: exact; }
}

/* ---------- შეტყობინება ---------- */
.notice {
    margin-bottom: 14px;
    padding: 12px 16px;
    border: 1px solid #b7e0c2;
    border-radius: var(--radius);
    background: #eaf7ee;
    color: #15803d;
    font-weight: 600;
}

/* ---------- ფილების ბადე (კლიენტები, მართვის პანელი) ---------- */
.tile-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 12px; }
.tile {
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 6px 10px;
    min-height: 64px;
    padding: 14px 16px;
    border-inline-start: 4px solid var(--brand);
    border-radius: var(--radius);
    background: var(--surface);
    box-shadow: var(--shadow);
}
.tile:hover { background: var(--hover); }
.tile strong { font-size: 16px; overflow-wrap: anywhere; }
.tile small { flex-basis: 100%; }

/* ---------- სტრიქონების სია ფორმებით (ფაილები, მარაგი) ---------- */
.rows { margin-bottom: 14px; border-radius: var(--radius); background: var(--surface); box-shadow: var(--shadow); }
.rows__head, .rows__row { display: grid; align-items: center; gap: 12px; padding: 8px 16px; }
.rows__head {
    border-bottom: 1px solid var(--line);
    border-radius: var(--radius) var(--radius) 0 0;
    background: #f8f9fa;
    color: var(--ink-soft);
    font-size: 13px;
    font-weight: 700;
}
.rows__head a:hover { color: var(--brand); }
.rows__row { border-bottom: 1px solid var(--line); }
.rows__row:hover { background: var(--hover); }
.rows__head--stock, .rows__row--stock { grid-template-columns: minmax(0, 1fr) 150px; }
.rows__head--files, .rows__row--files { grid-template-columns: 56px minmax(0, 1fr) 130px auto; }
.rows__name { min-width: 0; font-weight: 600; overflow-wrap: anywhere; }
.rows__row.is-zero .rows__name, .rows__row.is-zero .inline-edit { color: var(--open); }
.rows__actions { display: flex; gap: 6px; justify-content: flex-end; }
.rows__footer { display: flex; padding: 12px 16px; position: sticky; bottom: 0; background: var(--surface); border-radius: 0 0 var(--radius) var(--radius); box-shadow: 0 -1px 0 var(--line); }
.rows__footer .btn { flex: 1; max-width: 320px; }

.rows input[type="text"], .rows select, .add-row input, .tool input, .tool select {
    width: 100%;
    min-height: 40px;
    padding: 6px 10px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: var(--surface);
    color: inherit;
    font: inherit;
    font-size: 16px;
}
.rows .inline-edit { border-color: transparent; background: transparent; font-weight: 600; }
.rows .inline-edit:hover { border-color: var(--line); }
.rows input:focus, .rows select:focus, .add-row input:focus, .tool input:focus { border-color: var(--brand); background: var(--surface); outline: 2px solid var(--open-bg); }

.stepper { display: flex; direction: ltr; }
.stepper button {
    width: 40px;
    min-height: 40px;
    border: 1px solid var(--line);
    background: var(--bg);
    color: var(--ink);
    font-size: 20px;
    line-height: 1;
    cursor: pointer;
}
.stepper button:first-of-type { border-radius: 8px 0 0 8px; }
.stepper button:last-of-type { border-radius: 0 8px 8px 0; }
.stepper button:hover { background: var(--line); }
.stepper input[type="number"] {
    width: 100%;
    min-width: 0;
    min-height: 40px;
    border: 1px solid var(--line);
    border-inline: 0;
    background: var(--surface);
    font: inherit;
    font-size: 16px;
    font-weight: 700;
    text-align: center;
    -moz-appearance: textfield;
}
.stepper input::-webkit-outer-spin-button, .stepper input::-webkit-inner-spin-button { -webkit-appearance: none; margin: 0; }
.stepper input.is-changed { background: #fff8e1; }

.add-row { display: flex; gap: 10px; padding: 14px 16px; }
.add-row input { flex: 1; min-width: 0; }

.tool-row { display: grid; grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); gap: 14px; align-items: start; margin-bottom: 14px; }
.tool { margin: 0; padding: 0; }
.tool summary { padding: 14px 16px; font-weight: 700; cursor: pointer; }
.tool[open] summary { border-bottom: 1px solid var(--line); }
.tool > form, .tool > .field, .tool > .details { margin: 14px 16px; }
.tool > .details { border: 0; padding: 0; }

.file-thumb { display: grid; place-items: center; width: 56px; height: 56px; border: 1px solid var(--line); border-radius: 8px; overflow: hidden; background: var(--bg); }
.file-thumb img { width: 100%; height: 100%; object-fit: cover; }
.file-thumb__pdf { color: var(--open); font-size: 13px; font-weight: 800; }

/* ---------- ადმინის ჩანართები და ფილტრის ღილაკები ---------- */
.tabs { display: flex; gap: 4px; margin-bottom: 14px; overflow-x: auto; border-bottom: 2px solid var(--line); scrollbar-width: none; }
.tabs::-webkit-scrollbar { display: none; }
.tabs a { flex-shrink: 0; padding: 9px 14px; margin-bottom: -2px; border-bottom: 2px solid transparent; color: var(--ink-soft); font-weight: 600; white-space: nowrap; }
.tabs a:hover { color: var(--ink); }
.tabs a.is-active { border-bottom-color: var(--brand); color: var(--brand); }

.chips { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 14px; }
.chips a { padding: 5px 14px; border: 1px solid var(--line); border-radius: 999px; background: var(--surface); font-weight: 600; white-space: nowrap; }
.chips a:hover { border-color: var(--brand); }
.chips a.is-active { background: var(--ink); border-color: var(--ink); color: #fff; }

.badge--ok { background: #eaf7ee; color: #15803d; }
.check { display: flex; align-items: center; gap: 6px; font-weight: 600; white-space: nowrap; }
.check input { width: 20px; height: 20px; accent-color: var(--brand); }
.add-row--wrap { flex-wrap: wrap; align-items: center; }
.add-row--wrap input[type="text"] { flex: 1 1 200px; }
.muted { color: var(--ink-soft); }

.rows__head--changes, .rows__row--changes { grid-template-columns: minmax(0, 1fr) 90px 110px auto; }
.rows__head--problems, .rows__row--problems { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr) auto; }
.rows__head--simple, .rows__row--simple { grid-template-columns: minmax(0, 1fr) 90px auto; }
.rows__head--users, .rows__row--users { grid-template-columns: minmax(0, 1.2fr) minmax(0, 1fr) 110px 80px auto; }
.rows__row.is-inactive .rows__name, .rows__row.is-inactive .rows__mono { color: var(--muted); }
.rows__mono { font-family: Consolas, monospace; overflow-wrap: anywhere; }
a.rows__name:hover { color: var(--brand); }
.user-form .form-actions { margin-bottom: 0; }
.user-form input[type="text"], .user-form input[type="password"] { width: 100%; min-height: 44px; padding: 9px 12px; border: 1px solid var(--line); border-radius: 8px; font: inherit; font-size: 16px; }

/* ---------- სტატისტიკა ---------- */
.stats__filters { display: flex; align-items: center; flex-wrap: wrap; gap: 10px 14px; padding: 14px 16px; }
.stats__filters .chips { margin: 0; }
.stats__filters label { display: flex; align-items: center; gap: 6px; font-weight: 600; }
.stats__filters input, .stats__filters select { min-height: 40px; padding: 6px 10px; border: 1px solid var(--line); border-radius: 8px; background: var(--surface); font: inherit; max-width: 100%; }

.kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); gap: 12px; margin-bottom: 14px; }
.kpi { display: flex; flex-direction: column; gap: 2px; padding: 14px 16px; border-radius: var(--radius); background: var(--surface); box-shadow: var(--shadow); }
a.kpi:hover { background: var(--hover); }
.kpi__label { color: var(--ink-soft); font-weight: 600; }
.kpi strong { font-size: 30px; line-height: 1.2; }
.kpi small { font-size: 12.5px; }
.kpi .is-up { color: var(--open); font-weight: 700; font-size: 14px; }
.kpi .is-down { color: #15803d; font-weight: 700; font-size: 14px; }
.stats .is-warn { color: var(--open); }

.stats__card { padding-bottom: 16px; }
.stats__card h2 { display: flex; align-items: center; flex-wrap: wrap; gap: 8px; color: var(--ink); }
.stats__card h2 .btn { margin-inline-start: auto; }
.stats__grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(330px, 1fr)); gap: 0 14px; align-items: start; }

.legend { display: flex; flex-wrap: wrap; gap: 6px 16px; margin-bottom: 10px; color: var(--ink-soft); font-size: 13px; }
.legend i { display: inline-block; width: 12px; height: 12px; margin-inline-end: 5px; border-radius: 3px; vertical-align: -1px; }
.src0 { background: #1c2530; }
.src1 { background: #1d4ed8; }
.src2 { background: #c8102e; }

.trend { display: flex; align-items: stretch; gap: 3px; height: 220px; }
.trend__col { flex: 1; min-width: 0; display: flex; flex-direction: column; justify-content: flex-end; align-items: center; }
.trend__value { font-size: 11px; color: var(--ink-soft); line-height: 1.3; white-space: nowrap; }
.trend__bar { display: flex; flex-direction: column; width: 100%; max-width: 46px; min-height: 0; border-radius: 4px 4px 0 0; overflow: hidden; }
.trend__bar i { display: block; width: 100%; min-height: 1px; }
.trend__col:hover .trend__bar { opacity: .75; }
.trend__label { height: 18px; margin-top: 4px; font-size: 11px; color: var(--muted); white-space: nowrap; }

.bar-row { display: grid; grid-template-columns: minmax(0, 1.3fr) minmax(60px, 1fr) auto; align-items: center; gap: 10px; padding: 5px 0; border-radius: 6px; }
a.bar-row:hover { background: var(--hover); }
.bar-row__label { min-width: 0; overflow-wrap: anywhere; text-align: right; }
.bar-row__track { display: flex; flex-direction: column; gap: 2px; height: 14px; border-radius: 4px; background: var(--bg); overflow: hidden; }
.bar-row__track i { display: block; flex: 1; border-radius: 4px; background: var(--ink); }
.bar-row__track i.is-warn { background: var(--open); }
.bar-row__track i.is-closed { background: #15803d; }
.bar-row--double .bar-row__track { height: 18px; background: transparent; }
.bar-row__value { min-width: 34px; font-weight: 700; text-align: left; white-space: nowrap; }
.bar-row__value a:hover { color: var(--brand); text-decoration: underline; }

.table-scroll { overflow-x: auto; }
.stats-table { width: 100%; border-collapse: collapse; }
.stats-table th, .stats-table td { padding: 8px 10px; border-bottom: 1px solid var(--line); text-align: right; white-space: nowrap; }
.stats-table thead th { background: #f8f9fa; color: var(--ink-soft); font-size: 13px; }
.stats-table tfoot th { border-bottom: 0; background: #f8f9fa; }
.stats-table td:first-child { min-width: 170px; white-space: normal; }
.stats-table a:hover { color: var(--brand); text-decoration: underline; }
.stats-table__name { font-weight: 600; }
.stats-table__bar { display: block; height: 4px; margin-top: 4px; border-radius: 2px; background: var(--bg); }
.stats-table__bar i { display: block; height: 100%; border-radius: 2px; background: var(--brand); }

/* ---------- მომხმარებლების ადგილმდებარეობა ---------- */
.rows__row--place { grid-template-columns: auto minmax(0, 1fr) auto; scroll-margin-top: 130px; }
.rows__row--place:target { background: #fff8e1; }
.place-files { grid-column: 1 / -1; display: flex; align-items: center; flex-wrap: wrap; gap: 8px; }
.place-files input[type="file"] { flex: 1; min-width: 180px; max-width: 100%; font: inherit; font-size: 13px; color: var(--ink-soft); }
.thumbs--small { gap: 6px; }
.thumbs--small img, .thumbs__video { width: 56px; height: 56px; }
.thumbs__video { display: grid; place-items: center; border: 1px solid var(--line); border-radius: 8px; background: var(--ink); color: #fff; font-size: 20px; cursor: pointer !important; }
.add-row .prefixed { flex: 1; min-width: 0; max-width: 220px; }
.add-row .prefixed input { border-radius: 0 8px 8px 0; }

/* ---------- მომსახურების ანგარიში (דוחות) ---------- */
.report-filters { display: flex; align-items: center; flex-wrap: wrap; gap: 10px 14px; padding: 14px 16px; }
.report-filters label { display: flex; align-items: center; gap: 6px; font-weight: 600; }
.report-filters input, .report-filters select { min-height: 40px; padding: 6px 10px; border: 1px solid var(--line); border-radius: 8px; background: var(--surface); font: inherit; max-width: 100%; }
.report-filters .spacer { flex: 1; }
.rows__head--report, .rows__row--report { grid-template-columns: 34px 70px minmax(120px, 1.1fr) 86px minmax(120px, 1.2fr) minmax(120px, 1.2fr) 150px auto; align-items: start; }
.rows__head--history, .rows__row--history { grid-template-columns: 34px 70px minmax(120px, 1fr) 86px minmax(140px, 1.5fr) minmax(140px, 1.5fr) 100px; align-items: start; }
.rows__row--report input[type="date"] { width: 100%; min-height: 40px; padding: 6px 8px; border: 1px solid var(--line); border-radius: 8px; font: inherit; }
.rows__row--report small, .rows__row--history small { display: block; margin-top: 3px; overflow-wrap: anywhere; }
.rows__num { color: var(--muted); padding-top: 9px; }
.rows__row--report .chip, .rows__row--history .chip { margin-top: 6px; }
.rows__row--history > span { padding-top: 6px; overflow-wrap: anywhere; }
a.chip { cursor: pointer; }
.treated { display: flex; align-items: center; gap: 6px; padding-top: 8px; font-weight: 600; white-space: nowrap; }
.treated input { width: 20px; height: 20px; accent-color: #15803d; }

/* ---------- კლიენტის პანელი ---------- */
.user--client { margin-inline-start: auto; }
.layout--client { grid-template-columns: minmax(0, 560px); }
.layout--client .case-form { padding: 20px 20px 8px; }
.layout--client .field input[type="text"], .layout--client .field input[type="tel"] {
    width: 100%; min-height: 44px; padding: 9px 12px; border: 1px solid var(--line); border-radius: 8px;
    background: var(--surface); color: var(--ink); font: inherit; font-size: 16px;
}
.layout--client .form-actions .btn--primary { max-width: none; }
.btn:disabled { opacity: .6; cursor: default; }
.sent { padding: 32px 24px; text-align: center; }
.sent h1 { margin: 12px 0 6px; font-size: 24px; }
.sent p { margin: 0 0 20px; color: var(--ink-soft); }
.sent__icon { display: grid; place-items: center; width: 64px; height: 64px; margin: 0 auto; border-radius: 50%; background: #eaf7ee; color: #15803d; font-size: 34px; font-weight: 700; }

/* მომსახურების ანგარიში: ერთიანი განახლება */
.rows__row--report.is-marked { background: #eaf7ee; }
.bulk-bar {
    position: sticky;
    bottom: 0;
    z-index: 5;
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 10px 16px;
    padding: 12px 16px;
    border-top: 2px solid var(--line);
    border-radius: 0 0 var(--radius) var(--radius);
    background: var(--surface);
    box-shadow: 0 -4px 12px rgba(16, 24, 40, .08);
}
.bulk-bar__date { display: flex; align-items: center; gap: 6px; font-weight: 600; }
.bulk-bar__date input { min-height: 40px; padding: 6px 8px; border: 1px solid var(--line); border-radius: 8px; font: inherit; }
.bulk-bar .btn--primary { margin-inline-start: auto; gap: 8px; }
.bulk-bar .btn--primary .count { background: #fff; color: var(--brand); }

/* ---------- შესვლის გვერდი ---------- */
.login-page { display: grid; place-items: center; min-height: 100vh; padding: 16px; }
.login {
    display: flex;
    flex-direction: column;
    gap: 8px;
    width: 100%;
    max-width: 380px;
    padding: 28px 24px;
    border-radius: 14px;
    background: var(--surface);
    box-shadow: var(--shadow);
}
.login img { align-self: center; height: 60px; width: auto; }
.login h1 { margin: 8px 0; font-size: 22px; text-align: center; }
.login label { margin-top: 6px; color: var(--ink-soft); font-weight: 600; }
.login input {
    padding: 11px 12px;
    border: 1px solid var(--line);
    border-radius: 8px;
    font: inherit;
    font-size: 16px;
}
.login input:focus { border-color: var(--brand); outline: 2px solid var(--open-bg); }
.login .btn { margin-top: 14px; min-height: 46px; }
.login__error {
    padding: 10px 12px;
    border-radius: 8px;
    background: var(--open-bg);
    color: var(--open);
    font-weight: 600;
    text-align: center;
}

/* ---------- პლანშეტი: გვერდითი პანელი ქვემოთ ---------- */
@media (max-width: 1200px) {
    .layout { grid-template-columns: minmax(0, 1fr); }
    .repeat-list { max-height: none; display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); }
}

/* ---------- მობილური ---------- */
@media (max-width: 860px) {
    .topbar__inner { flex-wrap: wrap; gap: 10px; padding: 10px 12px; }
    .brand img { height: 34px; }
    .user { display: none; }
    .user.user--client { display: flex; }
    .menu-toggle { display: grid; margin-inline-start: auto; }
    .search { order: 3; flex-basis: 100%; max-width: none; margin: 0; }
    .search input { font-size: 16px; }

    .nav { display: none; }
    .nav.is-open { display: block; }
    .nav__inner { flex-direction: column; padding: 4px 0; }
    .nav a { padding: 13px 18px; border-bottom: 0; border-inline-start: 4px solid transparent; }
    .nav a.is-active { border-inline-start-color: var(--brand); background: rgba(255, 255, 255, .07); }
    .nav .nav__logout { display: block; border-top: 1px solid rgba(255, 255, 255, .15); color: #ffb3bf; }

    .layout { padding: 12px; gap: 14px; }
    .page-head h1 { font-size: 19px; }
    .alert { margin: 12px 12px 0; }

    /* ცხრილი → ბარათები */
    .cases { background: transparent; box-shadow: none; overflow: visible; }
    .cases__head {
        display: flex;
        gap: 6px;
        overflow-x: auto;
        margin-bottom: 10px;
        padding: 0 0 4px;
        background: transparent;
        border: 0;
        scrollbar-width: none;
    }
    .cases__head::-webkit-scrollbar { display: none; }
    .cases__head a {
        flex-shrink: 0;
        padding: 5px 12px;
        border: 1px solid var(--line);
        border-radius: 999px;
        background: var(--surface);
    }
    .cases__head a.is-sorted { border-color: var(--brand); }

    .case {
        grid-template-columns: auto minmax(0, 1fr) auto;
        grid-template-areas:
            "hospital numpart status"
            "prob prob prob"
            "changes changes changes"
            "worker worker date";
        gap: 6px 10px;
        margin-bottom: 10px;
        padding: 12px 14px;
        border: 0;
        border-inline-start: 4px solid var(--open);
        border-radius: var(--radius);
        background: var(--surface);
        box-shadow: var(--shadow);
    }
    .case:last-child { border-inline-start: 4px solid var(--open); }
    .case.case--closed { border-inline-start-color: var(--closed); }
    .case__hospital { grid-area: hospital; display: flex; align-items: baseline; flex-wrap: wrap; gap: 6px; }
    .case__hospital strong { font-size: 16px; }
    .case__numpart { grid-area: numpart; }
    .case__status { grid-area: status; }
    .case__prob { grid-area: prob; }
    .case__changes { grid-area: changes; }
    .case__worker { grid-area: worker; }
    .case__date { grid-area: date; text-align: left; color: var(--ink-soft); font-size: 13px; }
    .case__worker, .case__changes { color: var(--ink-soft); font-size: 13px; }
    .case__worker::before, .case__changes::before { content: attr(data-label) ": "; color: var(--muted); }
    .case__changes:empty { display: none; }
    .case__worker small { display: inline; }

    .repeat-list { grid-template-columns: 1fr; }
    .pagination a, .pagination span { padding: 10px 12px; }

    .card { padding: 14px 14px 2px; }
    .field-row { grid-template-columns: 1fr; }
    .form-actions .btn--primary { max-width: none; }
    .summary { padding: 14px; grid-template-columns: 1fr 1fr; }
    .details { grid-template-columns: 1fr 1fr; }
    .case-view__actions .btn--large { flex: 1 0 100%; }
    .thumbs--large img { width: 104px; height: 104px; }
    .tile-grid { grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); }
    .bulk-bar .btn--primary { flex: 1 0 100%; }
    .bulk-bar__date { flex: 1; justify-content: space-between; }
    .picker__list { grid-template-columns: 1fr; }
    .report-filters label { flex: 1 0 100%; justify-content: space-between; }
    .report-filters input, .report-filters select { flex: 1; max-width: 230px; }
    .report-filters .spacer { display: none; }
    .rows__head--report, .rows__head--history { display: none; }
    .rows__row--report, .rows__row--history { grid-template-columns: auto minmax(0, 1fr) auto; }
    .rows__row--report .rows__num, .rows__row--history .rows__num { display: none; }
    .rows__row--report > .cell-wide, .rows__row--history > .cell-wide { grid-column: 1 / -1; }
    .rows__row--report .rows__actions .btn { flex: 1; }
    .rows__row--history > span[data-label]:not(:empty)::before { content: attr(data-label) ": "; color: var(--muted); }
    .rows__row--history > span:empty { display: none; }
    .rows__row--place { grid-template-columns: auto minmax(0, 1fr); }
    .rows__row--place .rows__actions { grid-column: 1 / -1; }
    .rows__row--place .rows__actions .btn { flex: 1; }
    .add-row { flex-wrap: wrap; }
    .rows__head--changes, .rows__head--problems, .rows__head--users { display: none; }
    .rows__row--changes { grid-template-columns: minmax(0, 1fr) 90px; }
    .rows__row--changes input[name="name"], .rows__row--changes .rows__actions { grid-column: 1 / -1; }
    .rows__row--problems { grid-template-columns: minmax(0, 1fr); }
    .rows__row--users { grid-template-columns: minmax(0, 1fr) auto; }
    .rows__row--users .rows__actions { grid-column: 1 / -1; }
    .rows__row--changes .rows__actions .btn, .rows__row--problems .rows__actions .btn, .rows__row--users .rows__actions .btn { flex: 1; }
    .stats__filters label { flex: 1 0 100%; justify-content: space-between; }
    .stats__filters input, .stats__filters select { flex: 1; max-width: 220px; }
    .stats__filters .btn { flex: 1; }
    .kpis { grid-template-columns: 1fr 1fr; }
    .kpi strong { font-size: 24px; }
    .stats__grid { grid-template-columns: minmax(0, 1fr); }
    .trend { height: 170px; gap: 1px; }
    .trend__value { display: none; }
    .rows__head, .rows__row { padding: 8px 12px; gap: 8px; }
    .rows__head--stock, .rows__row--stock { grid-template-columns: minmax(0, 1fr) 132px; }
    .rows__head--files { display: none; }
    .rows__row--files { grid-template-columns: 56px minmax(0, 1fr); }
    .rows__row--files select { grid-column: 2; }
    .rows__row--files .rows__actions { grid-column: 1 / -1; }
    .rows__row--files .rows__actions .btn { flex: 1; }
    .rows__footer .btn { max-width: none; }
    .sheet { padding: 14px; overflow-x: auto; }
    .sheet__head { flex-direction: column; align-items: flex-start; }
    .page-head .pager { margin-inline-start: 0; flex-wrap: wrap; }
    .range-filter label { flex: 1 0 100%; justify-content: space-between; }
    .range-filter input { flex: 1; max-width: 220px; }
}
