:root {
    --bg: #f6f7f2;
    --panel: #ffffff;
    --text: #1c2320;
    --muted: #64706a;
    --line: #dfe5dd;
    --primary: #16745f;
    --primary-dark: #0d5c4b;
    --accent: #c44834;
    --warning: #b7791f;
    --danger: #b42318;
    --shadow: 0 18px 45px rgba(32, 44, 38, .10);
}

* { box-sizing: border-box; }
html { color-scheme: light; }
body {
    margin: 0;
    background: var(--bg);
    color: var(--text);
    font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
    line-height: 1.45;
}
a { color: inherit; text-decoration: none; }
button, input, textarea, select { font: inherit; }
svg { width: 20px; height: 20px; flex: 0 0 auto; }

.auth-page {
    min-height: 100vh;
    background:
        linear-gradient(135deg, rgba(22, 116, 95, .92), rgba(196, 72, 52, .82)),
        url("../img/store-pattern.svg") center/420px;
}
.auth-shell {
    min-height: 100vh;
    display: grid;
    place-items: center;
    padding: 24px;
}
.auth-panel {
    width: min(440px, 100%);
    background: rgba(255,255,255,.96);
    border: 1px solid rgba(255,255,255,.65);
    border-radius: 8px;
    padding: 28px;
    box-shadow: var(--shadow);
}
.brand-mark {
    width: 52px;
    height: 52px;
    display: grid;
    place-items: center;
    border-radius: 8px;
    color: #fff;
    background: var(--primary);
    margin-bottom: 18px;
}
.auth-panel h1 { margin: 0 0 8px; font-size: 1.8rem; }
.auth-panel p { margin: 0 0 22px; color: var(--muted); }
.app-footer {
    margin-top: 26px;
    padding: 16px 0 0;
    color: var(--muted);
    font-size: .86rem;
    text-align: center;
}
.auth-footer {
    border-top: 1px solid var(--line);
}

.app-shell { min-height: 100vh; }
.sidebar {
    display: none;
    position: fixed;
    inset: 0 auto 0 0;
    width: 260px;
    padding: 22px;
    background: #fcfdf9;
    border-right: 1px solid var(--line);
}
.brand {
    display: flex;
    align-items: center;
    gap: 10px;
    font-weight: 800;
    font-size: 1.1rem;
    margin-bottom: 28px;
}
.brand svg { color: var(--primary); }
.sidebar nav { display: grid; gap: 8px; }
.sidebar nav a {
    display: flex;
    align-items: center;
    gap: 10px;
    min-height: 44px;
    padding: 10px 12px;
    border-radius: 8px;
    color: #34423b;
}
.sidebar nav a:hover { background: #eef4ee; color: var(--primary-dark); }
.content {
    width: min(1180px, 100%);
    margin: 0 auto;
    padding: 18px 14px 110px;
}
.topbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    margin-bottom: 16px;
}
.topbar h1 { margin: 2px 0 0; font-size: clamp(1.35rem, 2.8vw, 2.2rem); }
.eyebrow {
    display: inline-block;
    color: var(--primary-dark);
    font-weight: 800;
    font-size: .76rem;
    text-transform: uppercase;
    letter-spacing: 0;
}
.hero {
    display: grid;
    gap: 18px;
    background: linear-gradient(135deg, #0f6b59, #2b8a67 52%, #c44834);
    color: #fff;
    border-radius: 8px;
    padding: clamp(22px, 5vw, 38px);
    box-shadow: var(--shadow);
    margin-bottom: 18px;
}
.hero .eyebrow { color: rgba(255,255,255,.82); }
.hero h2 { margin: 4px 0 8px; font-size: clamp(1.8rem, 5vw, 3.2rem); }
.hero p { max-width: 620px; margin: 0; color: rgba(255,255,255,.9); }
.hero-actions, .action-row, .form-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    align-items: center;
}
.panel, .metric {
    background: var(--panel);
    border: 1px solid var(--line);
    border-radius: 8px;
    box-shadow: 0 10px 28px rgba(25, 34, 30, .06);
}
.panel { padding: 16px; margin-bottom: 16px; }
.narrow { max-width: 760px; }
.metric-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(170px, 1fr));
    gap: 12px;
    margin-bottom: 16px;
}
.metric {
    padding: 16px;
    display: grid;
    gap: 8px;
    min-height: 128px;
}
.metric svg { color: var(--primary); }
.metric span { color: var(--muted); font-size: .92rem; }
.metric strong { font-size: clamp(1.35rem, 3vw, 1.9rem); }
.metric.danger svg, .metric.danger strong { color: var(--danger); }
.metric.warning svg, .metric.warning strong { color: var(--warning); }
.compact .metric { min-height: 96px; }
.two-columns { display: grid; gap: 16px; }
.section-title {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    margin-bottom: 14px;
}
.section-title h2 { margin: 0; font-size: 1.1rem; }
.section-title a, .section-title span { color: var(--muted); font-size: .92rem; }

.button, .icon-button {
    border: 1px solid var(--line);
    background: #fff;
    color: var(--text);
    border-radius: 8px;
    min-height: 44px;
    padding: 10px 14px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    cursor: pointer;
    font-weight: 750;
}
.button.primary { background: var(--primary); border-color: var(--primary); color: #fff; }
.button.primary:hover { background: var(--primary-dark); }
.button.light { background: rgba(255,255,255,.16); border-color: rgba(255,255,255,.42); color: #fff; }
.button.danger { color: var(--danger); border-color: #f0c8c4; }
.button.small { min-height: 36px; padding: 7px 10px; font-size: .9rem; }
.icon-button { width: 44px; padding: 0; }
.link { color: var(--primary-dark); font-weight: 750; }

.form-stack, .form-grid, .filter-bar { display: grid; gap: 14px; }
.form-grid { grid-template-columns: 1fr; }
.filter-bar {
    grid-template-columns: repeat(auto-fit, minmax(170px, 1fr));
    align-items: end;
    margin-bottom: 14px;
}
.inline-form {
    display: grid;
    grid-template-columns: 1fr auto;
    gap: 12px;
    align-items: end;
    margin-bottom: 16px;
}
label { display: grid; gap: 6px; color: #3c4943; font-weight: 720; }
input, textarea, select {
    width: 100%;
    min-height: 44px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: #fff;
    color: var(--text);
    padding: 10px 12px;
}
textarea { resize: vertical; }
input:focus, textarea:focus, select:focus {
    outline: 3px solid rgba(22, 116, 95, .18);
    border-color: var(--primary);
}
.password-field {
    position: relative;
    display: block;
}
.password-field input {
    padding-right: 52px;
}
.password-toggle {
    position: absolute;
    top: 50%;
    right: 6px;
    transform: translateY(-50%);
    width: 38px;
    height: 38px;
    display: grid;
    place-items: center;
    border: 0;
    border-radius: 8px;
    background: transparent;
    color: var(--muted);
    cursor: pointer;
}
.password-toggle:hover,
.password-toggle:focus-visible {
    background: #eef4ee;
    color: var(--primary-dark);
}
.password-toggle:focus-visible {
    outline: 3px solid rgba(22, 116, 95, .18);
}
.check-row { display: flex; align-items: center; gap: 10px; }
.check-row input { width: 18px; min-height: 18px; }
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; min-width: 680px; }
th, td { padding: 12px 10px; border-bottom: 1px solid var(--line); text-align: left; vertical-align: middle; }
th { color: var(--muted); font-size: .82rem; text-transform: uppercase; letter-spacing: 0; }
td small { display: block; color: var(--muted); margin-top: 2px; }
.actions { text-align: right; white-space: nowrap; }
.category-actions {
    display: flex;
    justify-content: flex-end;
    gap: 8px;
}
.list { display: grid; gap: 8px; }
.list-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 13px;
    border: 1px solid var(--line);
    border-radius: 8px;
}
.list-row:hover { border-color: var(--primary); }
.client-head {
    display: grid;
    gap: 16px;
    align-items: start;
}
.client-head h2 { margin: 0 0 4px; font-size: 1.7rem; }
.client-head p { margin: 2px 0; color: var(--muted); }
.toast-region {
    position: fixed;
    top: 16px;
    right: 16px;
    z-index: 80;
    display: grid;
    gap: 10px;
    width: min(420px, calc(100vw - 28px));
    pointer-events: none;
}
.toast {
    display: grid;
    grid-template-columns: 38px minmax(0, 1fr) 34px;
    gap: 12px;
    align-items: start;
    padding: 14px;
    border: 1px solid var(--line);
    border-left: 4px solid var(--primary);
    border-radius: 8px;
    background: rgba(255,255,255,.98);
    color: var(--text);
    box-shadow: var(--shadow);
    pointer-events: auto;
    animation: toast-in .2s ease-out;
}
.toast.is-leaving {
    animation: toast-out .18s ease-in forwards;
}
.toast-icon {
    width: 38px;
    height: 38px;
    display: grid;
    place-items: center;
    border-radius: 8px;
    background: #eef4ee;
    color: var(--primary-dark);
}
.toast-content {
    display: grid;
    gap: 4px;
    min-width: 0;
}
.toast-content strong {
    font-size: .96rem;
}
.toast-content p {
    margin: 0;
    color: var(--muted);
    font-size: .92rem;
}
.toast-close {
    width: 34px;
    height: 34px;
    display: grid;
    place-items: center;
    border: 0;
    border-radius: 8px;
    background: transparent;
    color: var(--muted);
    cursor: pointer;
}
.toast-close:hover,
.toast-close:focus-visible {
    background: #f1f4f0;
    color: var(--text);
}
.toast-success { border-left-color: var(--primary); }
.toast-error { border-left-color: var(--danger); }
.toast-error .toast-icon { background: #fff1ef; color: var(--danger); }
.toast-warning,
.toast-confirm { border-left-color: var(--warning); }
.toast-warning .toast-icon,
.toast-confirm .toast-icon { background: #fff7e6; color: var(--warning); }
.toast-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-top: 8px;
}
.toast-action {
    min-height: 36px;
    padding: 7px 12px;
    border-radius: 8px;
    border: 1px solid var(--line);
    background: #fff;
    color: var(--text);
    cursor: pointer;
    font-weight: 750;
}
.toast-action.danger {
    background: var(--danger);
    border-color: var(--danger);
    color: #fff;
}
@keyframes toast-in {
    from { opacity: 0; transform: translateY(-8px) scale(.98); }
    to { opacity: 1; transform: translateY(0) scale(1); }
}
@keyframes toast-out {
    to { opacity: 0; transform: translateY(-6px) scale(.98); }
}
.empty-state, .empty-inline {
    display: grid;
    place-items: center;
    text-align: center;
    gap: 8px;
    padding: 28px 16px;
    color: var(--muted);
}
.empty-state svg { width: 42px; height: 42px; color: var(--primary); }
.empty-state h2 { color: var(--text); margin: 0; }
.empty-state p { margin: 0; }

.bottom-bar {
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 20;
    display: grid;
    grid-template-columns: repeat(6, 1fr);
    gap: 2px;
    padding: 8px max(8px, env(safe-area-inset-left)) calc(8px + env(safe-area-inset-bottom));
    background: rgba(252,253,249,.96);
    border-top: 1px solid var(--line);
    box-shadow: 0 -14px 30px rgba(25, 34, 30, .08);
}
.bottom-bar a {
    min-height: 58px;
    display: grid;
    place-items: center;
    gap: 3px;
    border-radius: 8px;
    color: #3f4d46;
    font-size: .72rem;
    font-weight: 760;
}
.bottom-bar a:hover { background: #eef4ee; color: var(--primary-dark); }

@media (min-width: 760px) {
    .content { padding: 24px 24px 110px; }
    .hero { grid-template-columns: 1fr auto; align-items: end; }
    .two-columns { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); }
    .client-head { grid-template-columns: 1fr auto; }
}

@media (min-width: 1120px) {
    .sidebar { display: block; }
    .content { margin-left: 260px; width: calc(100% - 260px); max-width: 1240px; padding: 28px 32px 40px; }
    .bottom-bar { display: none; }
}

@media print {
    .sidebar, .bottom-bar, .topbar, .button, .filter-bar { display: none !important; }
    .content { margin: 0; width: 100%; padding: 0; }
    .panel { box-shadow: none; break-inside: avoid; }
}
