@charset "UTF-8";

/* ======================================================================
   Кольори та спільні змінні
   ====================================================================== */

:root {
    --bg: #f6f5f1;
    --surface: #fff;
    --ink: #24382f;
    --muted: #7b827b;
    --line: #e4e6de;
    --green: #365a4c;
    --green-soft: #e7eee4;
    --lime: #e7edcb;
    --radius: 16px;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
    color: var(--ink);
    font-synthesis: none;
    text-rendering: optimizeLegibility;
}

/* ======================================================================
   Базові елементи
   ====================================================================== */

* {
    box-sizing: border-box;
}

body {
    margin: 0;
    background: var(--bg);
    font-size: 14px;
    line-height: 1.5;
}

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

button,
input {
    font: inherit;
}

button,
a,
input {
    -webkit-tap-highlight-color: transparent;
}

button {
    color: inherit;
    cursor: pointer;
}

button:disabled {
    cursor: default;
}

button:focus-visible,
a:focus-visible,
input:focus-visible {
    outline: 3px solid #91a977;
    outline-offset: 4px;
}

button {
    border: 0;
}

h1,
h2,
h3,
p {
    margin: 0;
}

h1 {
    font-size: 34px;
    font-weight: 600;
    letter-spacing: -1.4px;
    line-height: 1.25;
}

h2 {
    font-size: 20px;
    letter-spacing: -.4px;
    font-weight: 600;
}

h3 {
    font-size: 21px;
    font-weight: 600;
    letter-spacing: -.6px;
}

/* ======================================================================
   Іконки й службові класи
   ====================================================================== */

.icon {
    width: 21px;
    height: 21px;
    fill: none;
    stroke: currentColor;
    stroke-width: 1.6;
    flex-shrink: 0;
}

.skip {
    position: fixed;
    top: -100px;
    left: 10px;
    z-index: 100;
    background: var(--green);
    color: white;
    padding: 12px;
}

.skip:focus {
    top: 8px;
}

[hidden] {
    display: none!important;
}

/* ======================================================================
   Бічна навігація
   ====================================================================== */

.sidebar {
    position: fixed;
    inset: 0 auto 0 0;
    width: 238px;
    background: #fbfbf8;
    border-right: 1px solid var(--line);
    padding: 32px 18px 0;
    display: flex;
    flex-direction: column;
    z-index: 30;
}

.brand {
    display: flex;
    gap: 11px;
    align-items: center;
    margin: 0 10px 49px;
}

.brand > span {
    font-size: 25px;
    font-weight: 650;
    line-height: 1.1;
    letter-spacing: -1px;
}

.brand-caption {
    display: block;
    font-size: 10px;
    letter-spacing: .2px;
    font-weight: 400;
    color: var(--muted);
    margin-top: 7px;
}

.sidebar-label {
    font-size: 10px;
    letter-spacing: 1.7px;
    color: #959c93;
    padding: 0 13px;
    margin-bottom: 11px;
}

.modules-label {
    margin-top: 30px;
}

.nav-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 13px;
    border-radius: 8px;
    font-size: 13px;
    color: #707a70;
    margin: 3px 0;
    min-height: 45px;
}

.nav-item:hover {
    background: #edf0e8;
}

.nav-item.active {
    background: var(--green-soft);
    color: #345443;
    font-weight: 600;
}

.nav-dot {
    margin-left: auto;
    width: 5px;
    height: 5px;
    border-radius: 50%;
    background: #6c8a52;
}

.sidebar-bottom {
    margin-top: auto;
}

.owner {
    border-top: 1px solid var(--line);
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 21px 0;
    margin-top: 20px;
}

.avatar {
    width: 33px;
    height: 33px;
    border-radius: 50%;
    display: grid;
    place-items: center;
    background: #e6e8df;
    color: #5c6c56;
    font-size: 12px;
}

.owner strong {
    display: block;
    font-size: 10px;
    font-weight: 600;
}

.owner small {
    display: block;
    font-size: 10px;
    color: var(--muted);
    margin-top: 2px;
}

.owner form {
    margin-left: auto;
}

.icon-button {
    background: transparent;
    display: inline-grid;
    place-items: center;
    min-width: 36px;
    min-height: 36px;
    border-radius: 8px;
}

.icon-button:hover {
    background: #e8ece2;
}

.icon-button .icon {
    width: 18px;
    height: 18px;
}

/* ======================================================================
   Робоча область і верхня панель
   ====================================================================== */

.workspace {
    margin-left: 238px;
}

.topbar {
    height: 80px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 46px;
    border-bottom: 1px solid var(--line);
    background: var(--bg);
}

.breadcrumbs {
    display: flex;
    align-items: center;
    gap: 13px;
    font-size: 12px;
    color: #8b9188;
}

.breadcrumbs .icon {
    width: 12px;
    height: 12px;
}

.breadcrumbs strong {
    font-weight: 500;
    color: #505d50;
}

.breadcrumbs a:hover {
    color: var(--ink);
    text-decoration: underline;
}

.connection {
    font-size: 11px;
    display: flex;
    gap: 7px;
    align-items: center;
    color: #7d8777;
}

.status-dot {
    display: inline-block;
    width: 6px;
    height: 6px;
    background: #7b985c;
    border-radius: 50%;
    flex-shrink: 0;
}

/* ======================================================================
   Заголовок сторінки та мітки стану
   ====================================================================== */

main#main {
    max-width: 1540px;
    margin: 0 auto;
    padding: 45px 46px 0;
    min-height: calc(100vh - 80px);
    display: flex;
    flex-direction: column;
    outline: none;
}

.page-heading {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 20px;
    margin-bottom: 32px;
}

.heading-actions {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: flex-end;
    gap: 10px;
}

.eyebrow {
    display: block;
    color: #87917e;
    font-size: 10px;
    letter-spacing: 1.8px;
    font-weight: 550;
    margin-bottom: 12px;
}

.subtitle {
    font-size: 13px;
    color: #81887d;
    margin-top: 11px;
}

.pill {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    border-radius: 6px;
    font-size: 10px;
    font-weight: 500;
    white-space: nowrap;
    padding: 5px 9px;
}

.pill.neutral {
    background: #eeeee7;
    color: #848976;
    border: 1px solid #e1e3d8;
}

.pill.demo {
    background: #f2eddd;
    color: #8c7d47;
}

.pill.demo .icon {
    width: 14px;
    height: 14px;
}

.pill.success {
    background: #e9efe3;
    color: #64824e;
}

.pill.pending {
    background: #f4eedf;
    color: #9b864e;
}

/* ======================================================================
   Головна: вітальний блок та ілюстрація
   ====================================================================== */

.welcome {
    background: var(--lime);
    border: 1px solid #dde4bf;
    border-radius: var(--radius);
    min-height: 301px;
    display: flex;
    position: relative;
    overflow: hidden;
}

.welcome-copy {
    padding: 35px 37px;
    z-index: 1;
}

.welcome .eyebrow {
    color: #7e8c63;
    font-size: 9px;
    margin-bottom: 12px;
}

.welcome h2 {
    font-size: 34px;
    line-height: 1.12;
    font-weight: 500;
    letter-spacing: -1px;
}

.welcome p {
    font-size: 12px;
    line-height: 1.8;
    color: #7d8968;
    margin: 15px 0 21px;
}

.button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 11px;
    padding: 11px 16px;
    border-radius: 7px;
    font-size: 12px;
    font-weight: 500;
    min-height: 42px;
    transition: background .15s;
}

.button .icon {
    width: 16px;
    height: 16px;
}

.button.primary {
    background: var(--green);
    color: #fff;
}

.button.primary:hover {
    background: #284638;
}

.button.secondary {
    background: #fff;
    border: 1px solid var(--line);
}

.button.secondary:hover {
    background: #f1f3ea;
}

.welcome-art {
    position: absolute;
    right: 5%;
    top: 0;
    width: 340px;
    height: 100%;
    pointer-events: none;
}

.art-grid {
    position: absolute;
    inset: 0;
    background-image: linear-gradient(#d9e0bb 1px, transparent 1px), linear-gradient(90deg, #d9e0bb 1px, transparent 1px);
    background-size: 33px 33px;
    mask-image: radial-gradient(ellipse, #000 10%, transparent 72%);
}

.art-receipt {
    position: absolute;
    background: #fffef7;
    top: 53px;
    left: 85px;
    width: 160px;
    height: 207px;
    transform: rotate(10deg);
    padding: 20px 17px;
    box-shadow: 0 15px 28px #62704818;
    clip-path: polygon(0 0, 100% 0, 100% 97%, 94% 100%, 88% 97%, 82% 100%, 76% 97%, 70% 100%, 64% 97%, 58% 100%, 52% 97%, 46% 100%, 40% 97%, 34% 100%, 28% 97%, 22% 100%, 16% 97%, 10% 100%, 4% 97%, 0 99%);
}

.art-head {
    font-size: 9px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 21px;
    color: #65705a;
}

.art-head span {
    font-size: 20px;
}

.art-line {
    height: 4px;
    width: 70%;
    background: #e9ecdf;
    border-radius: 2px;
    margin: 9px 0;
}

.art-line.long {
    width: 100%;
}

.art-line.medium {
    width: 85%;
}

.art-rule {
    height: 1px;
    border-top: 1px dashed #c9ceb9;
    margin: 18px 0 12px;
}

.art-total {
    display: flex;
    justify-content: space-between;
    font-size: 8px;
    color: #7a8568;
}

.art-barcode {
    height: 22px;
    width: 75px;
    margin: 17px auto 0;
    background: repeating-linear-gradient(90deg, #91a07a 0, #91a07a 1px, transparent 1px, transparent 3px, #91a07a 3px, #91a07a 5px, transparent 5px, transparent 7px);
}

.art-note {
    position: absolute;
    top: 49px;
    left: 10px;
    z-index: 2;
    border: 1px solid #edf0e0;
    background: #fcfdf7;
    box-shadow: 0 8px 20px #63754412;
    padding: 9px 12px;
    border-radius: 9px;
    display: flex;
    align-items: center;
    gap: 9px;
    font-size: 9px;
    transform: rotate(-7deg);
}

.art-note-icon {
    display: grid;
    place-items: center;
    background: #e0ead0;
    color: #537341;
    border-radius: 50%;
    width: 21px;
    height: 21px;
}

.art-spark {
    position: absolute;
    font-size: 42px;
    color: #82925e;
}

.art-spark.one {
    right: 13px;
    top: 57px;
}

.art-spark.two {
    left: 14px;
    bottom: 26px;
    font-size: 29px;
}

/* ======================================================================
   Головна: модулі
   ====================================================================== */

.modules-section {
    margin-top: 35px;
}

.section-heading {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 17px;
}

.section-heading h2 {
    font-size: 17px;
    display: flex;
    align-items: center;
    gap: 10px;
}

.section-heading > span {
    font-size: 11px;
    color: #969c8d;
}

.count {
    font-size: 10px;
    letter-spacing: 0;
    background: #eceee6;
    color: #7c8773;
    display: inline-grid;
    place-items: center;
    min-width: 22px;
    height: 21px;
    border-radius: 6px;
    font-weight: 400;
}

.module-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 18px;
}

.module-card {
    display: block;
    background: #fff;
    border: 1px solid var(--line);
    border-radius: 13px;
    padding: 24px 25px;
    transition: transform .15s, border-color .15s;
}

.module-card:hover {
    border-color: #a9b99b;
    transform: translateY(-2px);
}

.module-top {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 23px;
}

.module-icon {
    display: grid;
    place-items: center;
    width: 42px;
    height: 42px;
    border-radius: 11px;
    background: #edf1e6;
    color: #668055;
}

.module-icon .icon {
    width: 23px;
    height: 23px;
}

.module-card p {
    font-size: 12px;
    line-height: 1.7;
    color: #8c9286;
    margin-top: 7px;
    max-width: 300px;
}

.module-footer {
    border-top: 1px solid #eeefe8;
    margin-top: 22px;
    padding-top: 15px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    font-size: 11px;
    color: #577047;
}

.module-footer .icon {
    width: 16px;
    height: 16px;
}

.space-card {
    border: 1px dashed #d5daca;
    border-radius: 13px;
    padding: 27px;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    text-align: center;
    background: #f7f7f1;
}

.space-symbol {
    font-size: 32px;
    color: #b6bea6;
    margin-bottom: 14px;
}

.space-card h3 {
    font-size: 15px;
    letter-spacing: -.2px;
    color: #89947b;
    font-weight: 500;
}

.space-card p {
    font-size: 11px;
    color: #a0a694;
    max-width: 260px;
    margin-top: 8px;
    line-height: 1.8;
}

/* ======================================================================
   Примітка, підвал, мобільне меню
   ====================================================================== */

.preview-note {
    margin-top: 25px;
    background: #eeefe6;
    border: 1px solid #e4e7d9;
    border-radius: 9px;
    padding: 17px 19px;
    display: flex;
    gap: 12px;
    align-items: flex-start;
    color: #838f75;
}

.preview-note > .icon {
    width: 17px;
    height: 17px;
    margin-top: 2px;
}

.preview-note strong {
    font-size: 11px;
    font-weight: 550;
    color: #667758;
}

.preview-note p {
    font-size: 11px;
    line-height: 1.8;
    margin-top: 3px;
    max-width: 650px;
}

.preview-note > a {
    margin-left: auto;
    font-size: 10px;
    display: flex;
    gap: 8px;
    align-items: center;
    white-space: nowrap;
    padding-top: 3px;
}

.preview-note > a .icon {
    width: 13px;
    height: 13px;
}

footer {
    margin-top: auto;
    padding: 38px 0 22px;
    display: flex;
    justify-content: space-between;
    gap: 12px;
    font-size: 10px;
    color: #a1a697;
}

.mobile-menu {
    display: none;
}

.scrim {
    position: fixed;
    inset: 0;
    z-index: 25;
    background: #1f302e66;
}

/* ======================================================================
   Модуль «Чеки»: вкладки й поле пошуку
   ====================================================================== */

.tabs {
    display: flex;
    gap: 24px;
    border-bottom: 1px solid var(--line);
    margin: 25px 0 27px;
    overflow: auto;
}

.tab {
    padding: 13px 0;
    white-space: nowrap;
    font-size: 12px;
    color: #969b8c;
    border-bottom: 2px solid transparent;
    display: flex;
    gap: 7px;
    align-items: center;
}

.tab.selected {
    color: var(--green);
    border-color: var(--green);
    font-weight: 600;
}

.tab > span {
    font-size: 9px;
    border-radius: 4px;
    background: #ececde;
    padding: 0 5px;
}

.search-box {
    display: flex;
    align-items: center;
    gap: 8px;
    border: 1px solid var(--line);
    background: white;
    padding: 9px 12px;
    border-radius: 8px;
}

.search-box .icon {
    width: 16px;
    height: 16px;
    color: #949e88;
}

.search-box input {
    background: none;
    border: 0;
    width: 190px;
    outline: 0;
    font-size: 12px;
    color: var(--ink);
}

.search-box:focus-within {
    outline: 2px solid #91a977;
}

/* ======================================================================
   Порожні стани
   ====================================================================== */

.empty-state {
    margin-top: 5px;
    min-height: 310px;
    background: #fff;
    border: 1px solid var(--line);
    border-radius: 12px;
    text-align: center;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-direction: column;
    padding: 40px 25px;
}

.empty-state > .icon {
    width: 36px;
    height: 36px;
    color: #82966d;
    margin-bottom: 25px;
}

.empty-state p {
    color: #8c9780;
    font-size: 12px;
    max-width: 430px;
    line-height: 1.8;
    margin: 12px 0 24px;
}

.empty-state .eyebrow {
    font-size: 9px;
}

/* ======================================================================
   Налаштування
   ====================================================================== */

.settings-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 21px;
}

.panel {
    background: white;
    border: 1px solid var(--line);
    border-radius: 12px;
    padding: 26px;
}

.panel-icon {
    display: grid;
    place-items: center;
    width: 40px;
    height: 40px;
    border-radius: 9px;
    background: #edf2e6;
    color: #7a8e65;
    margin-bottom: 22px;
}

.panel h2 {
    font-size: 18px;
    margin-bottom: 13px;
}

.panel p {
    font-size: 12px;
    line-height: 1.8;
    color: #8d9682;
}

.panel small {
    display: block;
    color: #9aa38e;
    font-size: 10px;
    line-height: 1.8;
    margin-top: 18px;
}

.setting-row {
    padding: 17px 0;
    border-bottom: 1px solid #edf0e7;
    display: flex;
    justify-content: space-between;
    gap: 10px;
    font-size: 11px;
    color: #8d9881;
}

.setting-row strong {
    font-weight: 500;
    color: #5c6e50;
}

.setting-row code {
    font-size: 10px;
    color: #667d55;
    overflow-wrap: anywhere;
}

/* ======================================================================
   Стан системи
   ====================================================================== */

.system-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 17px;
}

.system-card > .icon {
    color: #7e926c;
    width: 27px;
    height: 27px;
    margin-bottom: 24px;
}

.system-card h2 {
    font-size: 15px;
}

.system-value {
    display: block;
    font-size: 13px;
    font-weight: 500;
    margin-bottom: 10px;
    color: #5f7850;
}

.system-card p {
    font-size: 11px;
}

.public-link {
    margin-top: 22px;
}

.public-link > div {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 20px;
    margin-top: 17px;
}

.public-link a {
    font-size: 12px;
    color: #5d7751;
    overflow-wrap: anywhere;
}

/* ======================================================================
   Сторінка входу
   ====================================================================== */

.login-body {
    min-height: 100svh;
    display: grid;
    place-items: center;
    background: radial-gradient(ellipse at 80% 15%, #e8eddb, transparent 50%), var(--bg);
}

.login-shell {
    max-width: 460px;
    width: 100%;
    padding: 35px 24px;
}

.login-shell .brand {
    justify-content: center;
    margin-bottom: 40px;
}

.login-card {
    background: #fff;
    border: 1px solid var(--line);
    border-radius: 18px;
    padding: 34px;
}

.login-card h1 {
    font-size: 35px;
    line-height: 1.2;
}

.login-card > p {
    margin: 14px 0 30px;
    color: #8d9685;
    font-size: 12px;
    line-height: 1.8;
}

.login-card label {
    display: block;
    font-size: 12px;
    color: #66765d;
    margin-bottom: 8px;
}

.password-field {
    position: relative;
}

.password-field input {
    width: 100%;
    border: 1px solid #dfe5d7;
    border-radius: 8px;
    background: #fbfcf8;
    padding: 13px 86px 13px 13px;
    font-size: 16px;
    color: var(--ink);
    min-height: 49px;
}

.password-field button {
    position: absolute;
    right: 7px;
    top: 3px;
    background: transparent;
    font-size: 10px;
    color: #7a8e66;
    min-height: 43px;
    padding: 0 7px;
}

.login-submit {
    width: 100%;
    margin-top: 17px;
    justify-content: space-between;
    min-height: 47px;
}

.login-security {
    margin-top: 25px;
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 7px;
    font-size: 10px;
    color: #96a088;
}

.login-foot {
    text-align: center;
    color: #a0a890;
    font-size: 10px;
    line-height: 1.8;
    margin-top: 24px;
}

.login-foot code {
    font-size: 9px;
}

.form-error {
    color: #a95440;
    background: #fbefeb;
    border-radius: 6px;
    padding: 10px 12px;
    font-size: 11px;
    margin-top: 12px;
}

/* ======================================================================
   Сповіщення
   ====================================================================== */

.toast {
    position: fixed;
    bottom: 28px;
    left: 50%;
    transform: translateX(-50%);
    background: var(--green);
    color: white;
    border-radius: 9px;
    padding: 12px 20px;
    font-size: 12px;
    z-index: 80;
    box-shadow: 0 8px 25px #0002;
}

/* ======================================================================
   Модуль «Чеки»: архів
   ====================================================================== */

.live-status {
    font-size: 11px;
    padding: 7px 11px;
    border-radius: 7px;
    background: #eef2e8;
    color: #4f6a3e;
    align-self: center;
}

.live-status.offline {
    background: #f8ece4;
    color: #9a5a35;
}

.live-status a {
    margin-left: 4px;
    font-weight: 600;
    text-decoration: underline;
}

.archive-counters {
    display: grid;
    grid-template-columns: repeat(5, minmax(0, 1fr));
    gap: 12px;
    margin-bottom: 22px;
}

.counter {
    display: flex;
    flex-direction: column;
    gap: 2px;
    padding: 14px 16px;
    background: #fff;
    border: 1px solid var(--line);
    border-radius: 12px;
}

.counter:hover {
    border-color: #cfd6c4;
}

.counter-value {
    font-size: 24px;
    font-weight: 600;
    letter-spacing: -.6px;
    font-variant-numeric: tabular-nums;
}

.counter-label {
    font-size: 11px;
    color: var(--muted);
}

.counter.attention {
    background: #fbf6e8;
    border-color: #eadfbe;
}

.counter.attention .counter-value {
    color: #9b864e;
}

/* ----- Пошук і фільтри ----- */

.archive-filters {
    margin-bottom: 22px;
}

.search-row {
    display: flex;
    gap: 10px;
}

.search-row .search-box {
    flex: 1;
    min-height: 44px;
    padding: 0 14px;
}

.search-row .search-box input {
    width: 100%;
    font-size: 14px;
}

.filter-panel {
    margin-top: 10px;
    background: #fff;
    border: 1px solid var(--line);
    border-radius: 12px;
}

.filter-panel summary {
    display: flex;
    align-items: center;
    gap: 9px;
    padding: 13px 16px;
    font-size: 12px;
    color: #5d6b58;
    cursor: pointer;
    list-style: none;
}

.filter-panel summary::-webkit-details-marker {
    display: none;
}

.filter-panel summary .icon {
    width: 16px;
    height: 16px;
}

.filter-panel summary .count {
    padding: 0 7px;
}

.filter-panel[open] summary {
    border-bottom: 1px solid var(--line);
}

.filter-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
    gap: 14px;
    padding: 16px;
}

.filter-grid label {
    display: flex;
    flex-direction: column;
    gap: 6px;
    font-size: 11px;
    color: var(--muted);
}

.filter-grid input,
.filter-grid select {
    width: 100%;
    min-height: 40px;
    padding: 9px 10px;
    font: inherit;
    font-size: 13px;
    color: var(--ink);
    background: #fbfbf8;
    border: 1px solid var(--line);
    border-radius: 8px;
}

.filter-actions {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 0 16px 16px;
}

.quick-periods {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.chip {
    padding: 7px 11px;
    font-size: 11px;
    color: #5d6b58;
    background: #fbfbf8;
    border: 1px solid var(--line);
    border-radius: 999px;
}

.chip:hover {
    background: #f1f3ea;
}

.chip.selected {
    color: var(--green);
    font-weight: 600;
    background: var(--green-soft);
    border-color: #cddcc6;
}

.filter-buttons {
    display: flex;
    gap: 10px;
}

/* ----- Список і картка поруч ----- */

.archive-results {
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(0, 1.05fr);
    gap: 22px;
    align-items: start;
}

.archive-list {
    min-width: 0;
}

.list-heading {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    margin-bottom: 12px;
}

.list-heading h2 {
    display: flex;
    align-items: center;
    gap: 9px;
    font-size: 17px;
}

.list-range {
    font-size: 11px;
    color: var(--muted);
}

.receipt-cards {
    margin: 0;
    padding: 0;
    list-style: none;
    overflow: hidden;
    background: #fff;
    border: 1px solid var(--line);
    border-radius: 12px;
}

.receipt-cards li {
    scroll-margin-top: 90px;
}

.receipt-cards li + li {
    border-top: 1px solid #edefe7;
}

.receipt-card {
    display: grid;
    grid-template-columns: 56px minmax(0, 1fr) auto;
    gap: 14px;
    align-items: center;
    padding: 12px 16px;
}

.receipt-card:hover {
    background: #f8faf4;
}

.receipt-card.current {
    background: var(--green-soft);
    box-shadow: inset 3px 0 0 var(--green);
}

.thumb {
    display: block;
    width: 56px;
    height: 74px;
    overflow: hidden;
    background: #eef0e8;
    border-radius: 7px;
}

.thumb img {
    display: block;
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.thumb.broken img,
.detail-photo.broken img {
    visibility: hidden;
}

.card-main {
    display: flex;
    flex-direction: column;
    gap: 3px;
    min-width: 0;
}

.card-main strong {
    overflow: hidden;
    font-size: 13px;
    font-weight: 600;
    white-space: nowrap;
    text-overflow: ellipsis;
}

.card-meta {
    font-size: 11px;
    color: var(--muted);
}

.card-note {
    display: -webkit-box;
    overflow: hidden;
    font-size: 12px;
    color: #4d5a4b;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
}

.missing {
    color: #a07e3c;
}

.card-side {
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    gap: 7px;
}

.card-amount {
    font-size: 14px;
    font-weight: 600;
    white-space: nowrap;
    font-variant-numeric: tabular-nums;
}

.card-amount small {
    font-size: 10px;
    font-weight: 400;
    color: var(--muted);
}

.pill.muted {
    background: #efefec;
    color: #8a8d84;
}

.pagination {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    margin-top: 14px;
}

.page-number {
    font-size: 11px;
    color: var(--muted);
}

.button.disabled,
.icon-button.disabled {
    opacity: .4;
    pointer-events: none;
}

.empty-state.compact {
    min-height: 0;
    padding: 36px 20px;
}

.empty-state h3 {
    font-size: 17px;
}

/* ----- Картка чека ----- */

.detail-placeholder {
    position: sticky;
    top: 20px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 14px;
    min-height: 360px;
    padding: 30px;
    font-size: 12px;
    color: var(--muted);
    text-align: center;
    border: 1px dashed #d6dacd;
    border-radius: 12px;
}

.detail-placeholder .icon {
    width: 30px;
    height: 30px;
    color: #9aa78c;
}

.receipt-detail {
    position: sticky;
    top: 20px;
    display: flex;
    flex-direction: column;
    gap: 16px;
    max-height: calc(100vh - 40px);
    overflow: auto;
    padding: 18px;
    background: #fff;
    border: 1px solid var(--line);
    border-radius: 12px;
}

.detail-nav {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
}

.detail-steps {
    display: flex;
    align-items: center;
    gap: 4px;
}

.detail-position {
    margin-right: 6px;
    font-size: 11px;
    color: var(--muted);
}

.detail-layout {
    display: grid;
    grid-template-columns: minmax(0, 220px) minmax(0, 1fr);
    gap: 18px;
    align-items: start;
}

.detail-photo {
    position: relative;
    display: block;
    min-height: 200px;
    overflow: hidden;
    background: #eef0e8;
    border-radius: 10px;
}

.detail-photo img {
    display: block;
    width: 100%;
    height: auto;
}

.zoom-hint {
    position: absolute;
    right: 8px;
    bottom: 8px;
    display: inline-flex;
    align-items: center;
    gap: 5px;
    padding: 5px 8px;
    font-size: 10px;
    background: #fffffff0;
    border-radius: 6px;
}

.zoom-hint .icon {
    width: 13px;
    height: 13px;
}

.detail-body {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    gap: 10px;
    min-width: 0;
}

.detail-body h2 {
    font-size: 21px;
    letter-spacing: -.5px;
    overflow-wrap: anywhere;
}

.detail-amount {
    font-size: 26px;
    font-weight: 600;
    letter-spacing: -.6px;
    font-variant-numeric: tabular-nums;
}

.detail-amount small {
    font-size: 13px;
    font-weight: 400;
    color: var(--muted);
}

.detail-fields {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px 16px;
    width: 100%;
    margin: 4px 0 0;
}

.detail-fields .wide {
    grid-column: 1 / -1;
}

.detail-fields dt {
    margin-bottom: 3px;
    font-size: 10px;
    letter-spacing: .4px;
    text-transform: uppercase;
    color: #959c93;
}

.detail-fields dd {
    margin: 0;
    font-size: 13px;
    overflow-wrap: anywhere;
}

.detail-note {
    white-space: pre-wrap;
}

.notice {
    display: flex;
    align-items: flex-start;
    gap: 9px;
    width: 100%;
    margin: 0;
    padding: 11px 13px;
    font-size: 12px;
    line-height: 1.55;
    color: #4f6145;
    background: #f2f5eb;
    border-radius: 9px;
}

.notice .icon {
    width: 16px;
    height: 16px;
    margin-top: 1px;
}

.notice.warning {
    color: #7d6530;
    background: #fbf4e4;
}

.notice a {
    text-decoration: underline;
}

.notice.success {
    color: #3f5f37;
    background: var(--green-soft);
}

.detail-actions {
    display: flex;
    flex-wrap: wrap;
    align-self: stretch;
    gap: 10px;
}

.button.danger {
    background: #fff;
    border: 1px solid #ecd3c6;
    color: #9a4a2c;
}

.button.danger:hover {
    background: #fbf0ea;
}

.button:disabled {
    opacity: .6;
}

.button.danger-solid {
    background: #a4492a;
    color: #fff;
}

.button.danger-solid:hover {
    background: #8a3a20;
}

.action-notice {
    margin: 14px 0;
}

/* ----- Редагування чека й сценарій «Без нотатки» ----- */

.notes-start {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: 12px 18px;
    margin: 14px 0;
    padding: 14px 16px;
    font-size: 12px;
    line-height: 1.55;
    background: var(--lime);
    border-radius: 10px;
}

.notes-start p {
    flex: 1 1 320px;
}

.edit-receipt {
    display: flex;
    flex-direction: column;
    gap: 16px;
    margin-top: 20px;
    padding: 20px;
    background: #fff;
    border: 1px solid var(--line);
    border-radius: 12px;
}

.edit-top {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
}

.edit-progress {
    font-size: 12px;
    color: var(--muted);
}

.edit-progress strong {
    color: var(--ink);
}

.edit-differences {
    margin: 6px 0 0;
    padding-left: 18px;
}

.edit-layout {
    display: grid;
    grid-template-columns: minmax(0, 340px) minmax(0, 1fr);
    gap: 22px;
    align-items: start;
}

.edit-photo {
    position: sticky;
    top: 20px;
}

.edit-form {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 14px;
    align-items: start;
}

.edit-heading {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 6px 12px;
    grid-column: 1 / -1;
}

.edit-heading h2 {
    font-size: 20px;
    letter-spacing: -.3px;
}

.edit-ocr {
    flex-basis: 100%;
    font-size: 11px;
    color: var(--muted);
}

.field {
    display: flex;
    flex-direction: column;
    gap: 6px;
    font-size: 12px;
    color: var(--muted);
}

.field.wide {
    grid-column: 1 / -1;
}

/* 16px у полях: менший шрифт змушує Safari на iPhone збільшувати сторінку. */
.field input,
.field select,
.field textarea {
    width: 100%;
    min-height: 44px;
    padding: 10px 12px;
    font: inherit;
    font-size: 16px;
    color: var(--ink);
    background: #fbfbf8;
    border: 1px solid var(--line);
    border-radius: 8px;
}

.field textarea {
    min-height: 90px;
    resize: vertical;
    line-height: 1.45;
}

.field input:focus,
.field select:focus,
.field textarea:focus {
    outline: 2px solid #91a977;
    outline-offset: 1px;
}

.field.invalid input,
.field.invalid select,
.field.invalid textarea {
    border-color: #d59a7d;
    background: #fdf7f3;
}

.field-error {
    font-size: 12px;
    color: #9a4a2c;
}

.edit-hint {
    display: flex;
    gap: 8px;
    grid-column: 1 / -1;
    font-size: 11px;
    line-height: 1.6;
    color: var(--muted);
}

.edit-hint .icon {
    flex: none;
    width: 15px;
    height: 15px;
}

.edit-buttons {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    grid-column: 1 / -1;
}

/* ----- Додавання фото з браузера ----- */

.upload-receipt {
    display: flex;
    flex-direction: column;
    gap: 14px;
    max-width: 640px;
    padding: 20px;
    background: #fff;
    border: 1px solid var(--line);
    border-radius: 12px;
}

.upload-receipt h2 {
    font-size: 20px;
    letter-spacing: -.3px;
}

.upload-lead {
    font-size: 13px;
    line-height: 1.6;
    color: #4e5a52;
}

.upload-form {
    display: flex;
    flex-direction: column;
    gap: 14px;
}

.upload-drop {
    position: relative;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 10px;
    padding: 22px 16px;
    text-align: center;
    background: #fbfbf8;
    border: 1.5px dashed #c9cfc0;
    border-radius: 10px;
    cursor: pointer;
}

.upload-drop:focus-within {
    outline: 2px solid #91a977;
    outline-offset: 2px;
}

/* Поле файлу прозоре поверх усієї області: дотик будь-де відкриває вибір фото. */
.upload-drop input {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    opacity: 0;
    cursor: pointer;
}

.upload-choose {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 14px;
}

.upload-choose .icon {
    width: 20px;
    height: 20px;
}

.upload-drop small {
    font-size: 11px;
    line-height: 1.5;
    color: var(--muted);
}

.upload-preview {
    max-width: 100%;
    max-height: 320px;
    border-radius: 8px;
}

/* ----- Звіти ----- */

.report-periods {
    display: flex;
    flex-direction: column;
    gap: 14px;
    margin: 18px 0;
    padding: 16px;
    background: #fff;
    border: 1px solid var(--line);
    border-radius: 12px;
}

.report-periods .chip {
    padding: 9px 13px;
    font-size: 12px;
}

.period-forms {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 14px;
}

.period-form {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.period-title {
    font-size: 11px;
    color: var(--muted);
}

.period-fields {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

/* 16px: менший шрифт змушує Safari на iPhone збільшувати сторінку. */
.period-fields select,
.period-fields input {
    flex: 1 1 120px;
    min-width: 0;
    min-height: 42px;
    padding: 8px 10px;
    font: inherit;
    font-size: 16px;
    color: var(--ink);
    background: #fbfbf8;
    border: 1px solid var(--line);
    border-radius: 8px;
}

.report-summary,
.report-export,
.report-list {
    display: flex;
    flex-direction: column;
    gap: 14px;
    margin-bottom: 18px;
    padding: 20px;
    background: #fff;
    border: 1px solid var(--line);
    border-radius: 12px;
}

.report-heading h2 {
    margin: 4px 0 6px;
    font-size: 24px;
    letter-spacing: -.5px;
}

.report-heading p {
    font-size: 12px;
    color: var(--muted);
}

.report-totals {
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
}

.report-total {
    display: flex;
    flex-direction: column;
    min-width: 130px;
    padding: 14px 16px;
    background: var(--green-soft);
    border-radius: 10px;
}

.report-value {
    font-size: 26px;
    font-weight: 600;
    letter-spacing: -.6px;
    font-variant-numeric: tabular-nums;
}

.report-label {
    font-size: 12px;
    color: #4f6145;
}

.report-notes {
    margin: 0;
    padding-left: 18px;
    font-size: 12px;
    line-height: 1.6;
    color: #4e5a52;
}

.report-notes a,
.report-export a:not(.button) {
    text-decoration: underline;
}

.report-categories {
    width: 100%;
    border-collapse: collapse;
    font-size: 13px;
}

.report-categories caption {
    margin-bottom: 6px;
    font-size: 12px;
    font-weight: 600;
    text-align: left;
}

.report-categories th,
.report-categories td {
    padding: 8px 6px;
    text-align: left;
    border-bottom: 1px solid var(--line);
}

.report-categories th {
    font-size: 11px;
    font-weight: 500;
    color: var(--muted);
}

.report-categories .money {
    text-align: right;
    white-space: nowrap;
    font-variant-numeric: tabular-nums;
}

.report-categories th:last-child {
    text-align: right;
}

.report-export h3,
.report-list h3 {
    font-size: 15px;
}

.report-export ul {
    margin: 0;
    padding-left: 18px;
    font-size: 12px;
    line-height: 1.6;
}

.export-buttons {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
}

.report-list .count {
    margin-left: 4px;
    color: var(--muted);
    font-weight: 400;
}

.report-rows {
    margin: 0;
    padding: 0;
    list-style: none;
}

.report-rows a {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 12px;
    padding: 10px 4px;
    border-bottom: 1px solid var(--line);
}

.report-rows a:hover {
    background: #fafbf6;
}

.report-row-main {
    display: flex;
    flex-direction: column;
    gap: 2px;
    min-width: 0;
}

.report-row-main strong {
    overflow-wrap: anywhere;
}

/* ----- Рідші дії в картці чека ----- */

.detail-more {
    display: flex;
    flex-wrap: wrap;
    align-self: stretch;
    gap: 10px;
}

/* ----- Сторінка помилки ----- */

.error-page {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    gap: 12px;
    max-width: 560px;
    margin: 30px 0;
    padding: 26px;
    background: #fff;
    border: 1px solid var(--line);
    border-radius: 12px;
}

.error-page > .icon {
    width: 28px;
    height: 28px;
    color: #9a5a35;
}

.error-page h1 {
    font-size: 26px;
    letter-spacing: -.5px;
}

.error-page p {
    font-size: 14px;
    line-height: 1.6;
    color: #4e5a52;
}

.error-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    margin-top: 6px;
}

/* ----- Повільний зв’язок: смужка завантаження та стан кнопок ----- */

/* Через тунель перехід може тривати секунду-дві: смужка вгорі показує, що натискання
   спрацювало і сторінка вантажиться. */
body.is-loading::before {
    content: '';
    position: fixed;
    top: 0;
    left: 0;
    z-index: 100;
    width: 100%;
    height: 3px;
    background: linear-gradient(90deg, transparent, var(--green), transparent);
    background-size: 50% 100%;
    background-repeat: no-repeat;
    animation: loading-bar 1.1s ease-in-out infinite;
}

@keyframes loading-bar {
    from {
        background-position: -50% 0;
    }

    to {
        background-position: 150% 0;
    }
}

.button[aria-busy='true'] {
    cursor: progress;
}

/* ----- Відновлений чернетковий текст ----- */

.draft-notice {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 8px 12px;
}

.edit-form > .draft-notice {
    grid-column: 1 / -1;
}

.draft-notice button {
    font-size: 12px;
    font-weight: 600;
    text-decoration: underline;
    background: none;
}

/* ----- Стан системи ----- */

.health-summary {
    margin-bottom: 18px;
}

.health-summary h2 {
    display: flex;
    align-items: center;
    gap: 10px;
}

.health-summary h2 .icon {
    width: 22px;
    height: 22px;
}

.health-summary.healthy h2 {
    color: var(--green);
}

.health-summary.attention h2 {
    color: #9a5a35;
}

.health-actions,
.health-queues {
    margin: 12px 0 0;
    padding-left: 20px;
    font-size: 13px;
    line-height: 1.6;
}

.health-actions li.problem {
    color: #9a4a2c;
    font-weight: 500;
}

.health-note {
    margin: 8px 0 14px;
    font-size: 12px;
    color: var(--muted);
}

.system-value.attention {
    color: #9a5a35;
}

/* ----- Підтвердження видалення ----- */

.delete-confirmation {
    display: flex;
    flex-direction: column;
    gap: 18px;
    max-width: 720px;
    margin-top: 20px;
    padding: 22px;
    background: #fff;
    border: 1px solid var(--line);
    border-radius: 12px;
}

.delete-confirmation h2 {
    font-size: 20px;
    letter-spacing: -.3px;
}

.delete-summary {
    display: flex;
    gap: 16px;
    align-items: flex-start;
}

.delete-summary img {
    flex: none;
    object-fit: cover;
    border-radius: 8px;
    background: var(--green-soft);
}

.delete-summary > div {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    gap: 4px;
    min-width: 0;
}

.delete-summary .detail-amount {
    font-size: 20px;
}

.delete-summary .detail-note {
    font-size: 12px;
    overflow-wrap: anywhere;
}

.delete-lists {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 18px;
}

.delete-lists h3 {
    margin: 0 0 6px;
    font-size: 13px;
}

.delete-lists ul {
    margin: 0;
    padding-left: 18px;
    font-size: 12px;
    line-height: 1.6;
    color: #4e5a52;
}

.delete-form {
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.delete-check {
    display: flex;
    align-items: flex-start;
    gap: 10px;
    padding: 12px 14px;
    font-size: 13px;
    border: 1px solid #ecd3c6;
    border-radius: 9px;
    background: #fdf7f3;
    cursor: pointer;
}

.delete-check input {
    flex: none;
    width: 20px;
    height: 20px;
    margin: 0;
    accent-color: #a4492a;
}

.delete-buttons {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
}

.detail-missing {
    display: flex;
    gap: 8px;
    font-size: 12px;
    color: #7d6530;
}

.detail-missing .icon {
    flex: none;
    width: 15px;
    height: 15px;
    margin-top: 2px;
}

.detail-history {
    align-self: stretch;
    border-top: 1px solid var(--line);
    padding-top: 12px;
    font-size: 12px;
}

.detail-history summary {
    cursor: pointer;
    font-weight: 600;
}

.detail-history .count {
    margin-left: 4px;
    color: var(--muted);
    font-weight: 400;
}

.detail-history ol {
    display: flex;
    flex-direction: column;
    gap: 10px;
    margin: 12px 0 0;
    padding: 0;
    list-style: none;
}

.detail-history li {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.history-meta {
    font-size: 11px;
    color: var(--muted);
}

.history-text {
    overflow-wrap: anywhere;
}

.detail-hint {
    display: flex;
    gap: 8px;
    font-size: 11px;
    line-height: 1.6;
    color: var(--muted);
}

.detail-hint .icon {
    width: 15px;
    height: 15px;
}

/* ----- Переглядач фото ----- */

.photo-viewer {
    width: 100vw;
    max-width: none;
    height: 100vh;
    height: 100dvh;
    max-height: none;
    margin: 0;
    padding: 0;
    color: #fff;
    background: #111a16f2;
    border: 0;
}

.photo-viewer[open] {
    display: flex;
    flex-direction: column;
}

.photo-viewer::backdrop {
    background: #0009;
}

.viewer-bar {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: max(12px, env(safe-area-inset-top)) 16px 12px;
}

.viewer-bar .button.secondary {
    color: #fff;
    background: #ffffff1a;
    border-color: #ffffff33;
}

.viewer-original {
    margin-right: auto;
    font-size: 12px;
    color: #d9e3d2;
    text-decoration: underline;
}

.viewer-bar .icon-button {
    color: #fff;
}

.viewer-bar .icon-button:hover {
    background: #ffffff22;
}

.viewer-canvas {
    display: flex;
    flex: 1;
    align-items: center;
    justify-content: center;
    min-height: 0;
    overflow: auto;
    padding: 8px 16px max(16px, env(safe-area-inset-bottom));
}

.viewer-canvas img {
    max-width: 100%;
    max-height: 100%;
    object-fit: contain;
}

.viewer-canvas.zoomed {
    display: block;
}

.viewer-canvas.zoomed img {
    max-width: none;
    max-height: none;
}

.viewer-canvas.broken::after {
    content: 'Фото не вдалося завантажити.';
    font-size: 13px;
}


/* ======================================================================
   Адаптивність: великі екрани
   ====================================================================== */

@media (min-width: 1500px) {
    main#main {
        padding-top: 55px;
    }

    .welcome {
        min-height: 330px;
    }

    .welcome-copy {
        padding: 40px 44px;
    }

    .welcome-art {
        right: 12%;
        transform: scale(1.1);
        transform-origin: center;
    }

    .page-heading {
        margin-bottom: 38px;
    }

    .module-card {
        padding: 29px;
    }

    .welcome h2 {
        font-size: 39px;
    }
}

/* ======================================================================
   Адаптивність: вужчі ноутбуки
   ====================================================================== */

@media (max-width: 1200px) {
    .sidebar {
        width: 215px;
        padding-left: 13px;
        padding-right: 13px;
    }

    .workspace {
        margin-left: 215px;
    }

    .topbar {
        padding: 0 30px;
    }

    main#main {
        padding: 32px 30px 0;
    }

    .welcome-art {
        right: 0;
        transform: scale(.85);
        transform-origin: right center;
    }

    .welcome h2 {
        font-size: 31px;
    }

    .welcome-copy {
        padding: 30px;
    }

    .preview-note > a {
        display: none;
    }

    /* Архів: картка чека відкривається окремим екраном замість панелі поруч. */
    .archive-results {
        grid-template-columns: minmax(0, 1fr);
    }

    .detail-placeholder {
        display: none;
    }

    .with-selection .page-heading:has(.live-status[hidden]),
    .with-selection .page-heading .heading-text,
    .with-selection .heading-actions .button,
    .with-selection #archive-tabs,
    .with-selection .archive-counters,
    .with-selection .archive-filters,
    .with-selection .archive-list {
        display: none;
    }

    .receipt-detail {
        position: static;
        max-height: none;
        overflow: visible;
    }

    .detail-layout {
        grid-template-columns: minmax(0, 320px) minmax(0, 1fr);
    }
}

/* ======================================================================
   Дотикові екрани: поля без збільшення сторінки, більші цілі для пальця
   ====================================================================== */

@media (pointer: coarse) {
    /* Safari на iPhone збільшує сторінку при фокусі поля зі шрифтом менше 16px. */
    input,
    select,
    textarea,
    .search-box input,
    .filter-grid input,
    .filter-grid select {
        font-size: 16px;
    }

    .icon-button {
        min-width: 44px;
        min-height: 44px;
    }

    .button {
        min-height: 44px;
    }

    .chip,
    .report-periods .chip {
        display: inline-flex;
        align-items: center;
        min-height: 40px;
        padding: 8px 14px;
        font-size: 13px;
    }

    .tab {
        min-height: 44px;
        font-size: 13px;
    }
}

/* ======================================================================
   Адаптивність: планшети
   ====================================================================== */

@media (max-width: 960px) {
    .welcome-art {
        opacity: .7;
        right: -50px;
    }

    .welcome-copy {
        max-width: 65%;
    }

    .welcome p {
        max-width: 250px;
    }

    .welcome .desktop-break {
        display: none;
    }

    .page-heading {
        align-items: flex-start;
        flex-direction: column;
        gap: 13px;
    }

    .system-grid {
        grid-template-columns: 1fr;
    }

    .settings-grid {
        grid-template-columns: 1fr;
    }

    .search-box {
        width: 100%;
    }

    .search-box input {
        width: 100%;
    }

    .section-heading > span {
        display: none;
    }
}

/* ======================================================================
   Адаптивність: телефони
   ====================================================================== */

/* Телефон: вертикально (до 760px) і боком (низький горизонтальний екран). */
@media (max-width: 760px), (max-height: 500px) and (orientation: landscape) {
    .focused-page .page-heading,
    .focused-page .tabs {
        display: none;
    }

    .focused-page .edit-receipt,
    .focused-page .upload-receipt,
    .focused-page .delete-confirmation {
        margin-top: 4px;
    }

    /* Головні дії лишаються під рукою, поки гортаєш довгий чек. */
    .detail-actions {
        position: sticky;
        bottom: 0;
        z-index: 5;
        display: grid;
        grid-template-columns: repeat(auto-fit, minmax(130px, 1fr));
        margin: 0 -14px;
        padding: 10px 14px max(10px, env(safe-area-inset-bottom));
        background: #fffffff2;
        border-top: 1px solid var(--line);
        box-shadow: 0 -6px 16px #24382f12;
    }

    .detail-more .button {
        flex: 1 1 100%;
    }

    .edit-buttons {
        position: sticky;
        bottom: 0;
        z-index: 5;
        display: grid;
        grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
        margin: 0 -14px;
        padding: 10px 14px max(10px, env(safe-area-inset-bottom));
        background: #fffffff2;
        border-top: 1px solid var(--line);
        box-shadow: 0 -6px 16px #24382f12;
    }

    .error-page {
        padding: 18px;
    }

    .period-forms {
        grid-template-columns: minmax(0, 1fr);
    }

    .report-summary,
    .report-export,
    .report-list {
        padding: 14px;
    }

    .report-total {
        flex: 1 1 40%;
        min-width: 0;
    }

    .export-buttons .button {
        flex: 1 1 100%;
    }

    .upload-receipt {
        padding: 14px;
    }

    .edit-receipt {
        padding: 14px;
    }

    .edit-layout {
        grid-template-columns: minmax(0, 1fr);
    }

    /* Не прилипає на телефоні, але лишається опорою для підпису «Збільшити». */
    .edit-photo {
        position: relative;
        top: auto;
    }

    .edit-photo img {
        max-height: 45vh;
        object-fit: contain;
    }

    .edit-form {
        grid-template-columns: minmax(0, 1fr);
    }

    .delete-confirmation {
        padding: 16px;
    }

    .delete-lists {
        grid-template-columns: 1fr;
    }

    .delete-buttons .button {
        flex: 1 1 100%;
    }

    .sidebar {
        width: 260px;
        transform: translateX(-100%);
        transition: transform .2s;
        padding-top: 25px;
    }

    .nav-open .sidebar {
        transform: none;
    }

    .nav-open {
        overflow: hidden;
    }

    .workspace {
        margin-left: 0;
    }

    .topbar {
        height: 65px;
        padding: 0 19px;
    }

    .mobile-menu {
        display: inline-grid;
        margin-left: -7px;
        min-width: 40px;
        min-height: 44px;
    }

    .mobile-menu .icon {
        width: 21px;
        height: 21px;
    }

    .breadcrumbs {
        gap: 9px;
        font-size: 11px;
    }

    .breadcrumbs .crumb-home {
        display: none;
    }

    .connection {
        font-size: 9px;
        gap: 5px;
    }

    main#main {
        padding: 28px 20px 0;
        min-height: calc(100svh - 65px);
    }

    h1 {
        font-size: 29px;
        letter-spacing: -1.1px;
    }

    .page-heading {
        margin-bottom: 24px;
    }

    .eyebrow {
        font-size: 9px;
        letter-spacing: 1.6px;
    }

    .subtitle {
        font-size: 12px;
        line-height: 1.7;
        max-width: 290px;
        margin-top: 9px;
    }

    .page-heading > .pill.neutral {
        display: none;
    }

    .welcome {
        min-height: 385px;
    }

    .welcome-copy {
        max-width: 100%;
        padding: 25px 23px;
    }

    .welcome h2 {
        font-size: 30px;
    }

    .welcome p {
        max-width: 240px;
        font-size: 11px;
        margin: 13px 0 19px;
    }

    .welcome-art {
        top: 110px;
        right: -57px;
        opacity: .8;
        transform: scale(.65);
        transform-origin: right center;
    }

    .welcome .button {
        position: relative;
        z-index: 3;
    }

    .welcome .eyebrow {
        font-size: 8px;
        max-width: 240px;
    }

    .module-grid {
        grid-template-columns: 1fr;
    }

    .modules-section {
        margin-top: 28px;
    }

    .module-card {
        padding: 22px;
    }

    .module-top {
        margin-bottom: 16px;
    }

    .module-card p {
        font-size: 12px;
        max-width: 265px;
    }

    .space-card {
        padding: 25px 22px;
    }

    .space-symbol {
        font-size: 25px;
        margin-bottom: 10px;
    }

    .space-card p {
        font-size: 11px;
        max-width: 250px;
    }

    .preview-note {
        padding: 15px;
        gap: 9px;
        margin-top: 20px;
    }

    .preview-note p {
        font-size: 10px;
        line-height: 1.8;
    }

    .preview-note strong {
        font-size: 11px;
    }

    footer {
        font-size: 9px;
        padding: 32px 0 20px;
        flex-direction: column;
        gap: 5px;
    }

    .tabs {
        gap: 22px;
        margin-top: 17px;
        margin-bottom: 22px;
    }

    .tab {
        font-size: 11px;
        min-height: 48px;
    }

    .search-box input {
        font-size: 16px;
        min-width: 0;
    }

    .search-box {
        min-height: 44px;
    }

    .settings-grid {
        gap: 16px;
    }

    .panel {
        padding: 22px;
    }

    .public-link > div {
        align-items: stretch;
        flex-direction: column;
        gap: 15px;
    }

    .public-link a {
        font-size: 11px;
    }

    .icon-button {
        min-width: 44px;
        min-height: 44px;
    }

    .login-shell {
        padding: 25px 20px;
    }

    .login-card {
        padding: 28px 24px;
    }

    .login-card h1 {
        font-size: 32px;
    }

    .login-card > p {
        font-size: 12px;
    }

    .login-shell .brand {
        margin-bottom: 30px;
    }

    .login-foot {
        font-size: 10px;
    }

    .empty-state {
        padding: 35px 20px;
        min-height: 320px;
    }

    .empty-state .eyebrow {
        font-size: 8px;
    }

    /* Архів на телефоні: компактні плитки й картки, фото на всю ширину. */
    .archive-counters {
        grid-template-columns: repeat(3, minmax(0, 1fr));
        gap: 8px;
        margin-bottom: 18px;
    }

    .counter {
        padding: 10px 12px;
    }

    .counter-value {
        font-size: 19px;
    }

    .counter-label {
        font-size: 10px;
    }

    .search-row .search-box input,
    .filter-grid input,
    .filter-grid select {
        font-size: 16px;
    }

    .filter-grid {
        grid-template-columns: repeat(2, minmax(0, 1fr));
        gap: 12px;
        padding: 14px;
    }

    .filter-actions {
        flex-direction: column;
        align-items: stretch;
        padding: 0 14px 14px;
    }

    .filter-buttons .button {
        flex: 1;
    }

    .receipt-card {
        grid-template-columns: 46px minmax(0, 1fr) auto;
        gap: 11px;
        padding: 11px 12px;
    }

    .thumb {
        width: 46px;
        height: 62px;
    }

    .card-side .pill {
        padding: 4px 7px;
        font-size: 9px;
    }

    .pagination .button {
        padding: 9px 11px;
    }

    .receipt-detail {
        padding: 14px;
        margin: 0 -4px;
    }

    .detail-layout {
        grid-template-columns: minmax(0, 1fr);
    }

    /* Фото — до половини екрана, щоб сума й нотатка були видні одразу.
       Повне фото відкривається дотиком. */
    .detail-photo img {
        max-height: 45vh;
        object-fit: contain;
        margin: 0 auto;
    }

    .viewer-bar .button {
        padding: 9px 11px;
    }
}

/* ======================================================================
   Менше анімацій за налаштуванням системи
   ====================================================================== */

@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        transition: none!important;
        scroll-behavior: auto!important;
    }

    /* Без руху: смужка завантаження просто з’являється. */
    body.is-loading::before {
        animation: none;
        background: var(--green);
        opacity: .5;
    }
}

/* ======================================================================
   Телефон боком: фото й дані поруч, бо висота екрана лише ~390px
   ====================================================================== */

@media (max-height: 500px) and (orientation: landscape) {
    .detail-layout,
    .edit-layout {
        grid-template-columns: minmax(0, 260px) minmax(0, 1fr);
    }

    .detail-photo img,
    .edit-photo img {
        max-height: 80vh;
        object-fit: contain;
    }

    .edit-form {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }
}
