:root {
    --green: #0f5132;
    --green-dark: #0a3d26;
    --green-light: #157347;
    --gold: #d4af37;
    --gold-soft: #f3e7c1;
    --cream: #f7f4ec;
    --ink: #1f2421;
    --muted: #6b7280;
    --line: #e3e0d6;
    --danger: #b02a37;
    --radius: 14px;
    --shadow: 0 10px 30px rgba(15, 81, 50, 0.12);
}

* {
    box-sizing: border-box;
}

html,
body {
    margin: 0;
    padding: 0;
}

body {
    font-family: "Segoe UI", system-ui, -apple-system, Roboto, Helvetica, Arial, sans-serif;
    color: var(--ink);
    background: var(--cream);
    line-height: 1.5;
}

a {
    color: var(--green-light);
    text-decoration: none;
}

a:hover {
    text-decoration: underline;
}

/* ---------- Location switcher (sidebar, SaaS-style) ---------- */
.visually-hidden {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

.sidebar-location {
    padding: 0 1rem 0.75rem;
    border-bottom: 1px solid rgba(255, 255, 255, 0.08);
}

.loc-switcher {
    background: rgba(255, 255, 255, 0.06);
    border: 1px solid rgba(255, 255, 255, 0.12);
    border-radius: 12px;
    padding: 0.75rem 0.875rem;
    transition: border-color 0.15s ease, background 0.15s ease;
}

.loc-switcher:focus-within {
    border-color: rgba(212, 175, 55, 0.55);
    background: rgba(255, 255, 255, 0.08);
    box-shadow: 0 0 0 3px rgba(212, 175, 55, 0.15);
}

.loc-switcher__header {
    display: flex;
    align-items: center;
    gap: 0.45rem;
    margin-bottom: 0.55rem;
}

.loc-switcher__icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    color: var(--gold);
    flex-shrink: 0;
}

.loc-switcher__title {
    font-size: 0.6875rem;
    font-weight: 600;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    color: rgba(255, 255, 255, 0.55);
}

.loc-switcher__form {
    margin: 0;
}

.loc-switcher__control {
    position: relative;
}

.loc-switcher__select {
    width: 100%;
    appearance: none;
    -webkit-appearance: none;
    background: rgba(0, 0, 0, 0.22);
    border: 1px solid rgba(255, 255, 255, 0.14);
    border-radius: 8px;
    color: #fff;
    font-family: inherit;
    font-size: 0.875rem;
    font-weight: 600;
    line-height: 1.35;
    padding: 0.625rem 2.25rem 0.625rem 0.75rem;
    cursor: pointer;
    transition: border-color 0.15s ease, background 0.15s ease;
}

.loc-switcher__select:hover {
    border-color: rgba(255, 255, 255, 0.22);
    background: rgba(0, 0, 0, 0.28);
}

.loc-switcher__select:focus {
    outline: none;
    border-color: var(--gold);
}

.loc-switcher__select option {
    color: var(--ink);
    background: #fff;
}

.loc-switcher__chevron {
    position: absolute;
    right: 0.65rem;
    top: 50%;
    transform: translateY(-50%);
    pointer-events: none;
    color: rgba(255, 255, 255, 0.55);
    display: inline-flex;
    align-items: center;
}

.loc-switcher__empty {
    margin: 0;
    font-size: 0.8125rem;
    color: rgba(255, 255, 255, 0.45);
    line-height: 1.4;
}

/* ---------- Buttons ---------- */
.btn {
    display: inline-block;
    border: none;
    border-radius: 999px;
    padding: 0.75rem 1.5rem;
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    transition: transform 0.05s ease, background 0.2s ease;
    text-align: center;
}

.btn:active {
    transform: translateY(1px);
}

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

.btn-primary:hover {
    background: var(--green-light);
    text-decoration: none;
}

.btn-block {
    display: block;
    width: 100%;
}

.btn-danger {
    background: var(--danger);
    color: #fff;
}

.btn-ghost {
    background: transparent;
    color: var(--green);
    border: 1px solid var(--line);
}

/* ---------- Guest (auth) layout ---------- */
.auth-wrap {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 2rem 1rem;
    background:
        radial-gradient(1200px 600px at 50% -10%, rgba(212, 175, 55, 0.18), transparent),
        linear-gradient(160deg, var(--green-dark), var(--green));
}

.auth-card {
    width: 100%;
    max-width: 440px;
    background: #fff;
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    padding: 2.25rem;
}

.brand {
    text-align: center;
    margin-bottom: 1.5rem;
}

.brand .crest {
    width: 64px;
    height: 64px;
    border-radius: 50%;
    background: var(--green);
    color: var(--gold);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 1.6rem;
    font-weight: 800;
    border: 3px solid var(--gold);
}

.brand h1 {
    font-size: 1.35rem;
    margin: 0.75rem 0 0.15rem;
    color: var(--green-dark);
}

.brand p {
    margin: 0;
    color: var(--muted);
    font-size: 0.9rem;
}

/* ---------- Forms ---------- */
.field {
    margin-bottom: 1.1rem;
}

.field label {
    display: block;
    font-weight: 600;
    font-size: 0.9rem;
    margin-bottom: 0.35rem;
    color: var(--ink);
}

.field .hint {
    color: var(--muted);
    font-weight: 400;
    font-size: 0.8rem;
}

.input,
select.input {
    width: 100%;
    padding: 0.7rem 0.9rem;
    border: 1px solid var(--line);
    border-radius: 10px;
    font-size: 1rem;
    background: #fff;
    color: var(--ink);
}

.input:focus,
select.input:focus {
    outline: none;
    border-color: var(--green-light);
    box-shadow: 0 0 0 3px rgba(21, 115, 71, 0.15);
}

.input.code-input {
    text-align: center;
    letter-spacing: 0.6rem;
    font-size: 1.6rem;
    font-weight: 700;
}

.checkbox-row {
    display: flex;
    align-items: flex-start;
    gap: 0.6rem;
}

.checkbox-row input {
    margin-top: 0.25rem;
}

.error {
    color: var(--danger);
    font-size: 0.82rem;
    margin-top: 0.3rem;
}

.form-row {
    display: flex;
    gap: 1rem;
}

.form-row > .field {
    flex: 1;
}

.muted {
    color: var(--muted);
}

.center {
    text-align: center;
}

.mt {
    margin-top: 1rem;
}

.small {
    font-size: 0.85rem;
}

/* ---------- Alerts ---------- */
.alert {
    border-radius: 10px;
    padding: 0.8rem 1rem;
    margin-bottom: 1.2rem;
    font-size: 0.9rem;
}

.alert-success {
    background: #e7f3ec;
    border: 1px solid #b8dcc6;
    color: var(--green-dark);
}

.alert-error {
    background: #fbe9eb;
    border: 1px solid #f0c2c7;
    color: var(--danger);
}

/* ---------- App shell ---------- */
.app {
    display: flex;
    min-height: 100vh;
}

.sidebar {
    width: 260px;
    background: var(--green-dark);
    color: #fff;
    display: flex;
    flex-direction: column;
    flex-shrink: 0;
}

.sidebar-brand,
.sidebar .logo {
    padding: 1.35rem 1.25rem 1.15rem;
    display: flex;
    align-items: center;
    gap: 0.7rem;
    border-bottom: 1px solid rgba(255, 255, 255, 0.08);
}

.sidebar-brand .crest,
.sidebar .logo .crest {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: var(--green);
    color: var(--gold);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-weight: 800;
    border: 2px solid var(--gold);
}

.sidebar-brand strong,
.sidebar .logo strong {
    font-size: 0.95rem;
    line-height: 1.2;
}

.sidebar-nav {
    flex: 1;
    overflow-y: auto;
}

.nav {
    list-style: none;
    padding: 0.5rem 0 0.75rem;
    margin: 0;
}

.nav a {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.8rem 1.25rem;
    color: rgba(255, 255, 255, 0.82);
    font-weight: 500;
    border-left: 3px solid transparent;
}

.nav a:hover {
    background: rgba(255, 255, 255, 0.06);
    color: #fff;
    text-decoration: none;
}

.nav a.active {
    background: rgba(212, 175, 55, 0.12);
    color: #fff;
    border-left-color: var(--gold);
}

.nav .danger-link {
    color: #f7b5bb;
}

.sidebar .signout {
    padding: 1rem 1.25rem;
    border-top: 1px solid rgba(255, 255, 255, 0.08);
}

.sidebar .signout button {
    background: transparent;
    border: 1px solid rgba(255, 255, 255, 0.25);
    color: #fff;
    border-radius: 999px;
    padding: 0.5rem 1rem;
    width: 100%;
    cursor: pointer;
    font-size: 0.9rem;
}

.sidebar .signout button:hover {
    background: rgba(255, 255, 255, 0.08);
}

.content {
    flex: 1;
    padding: 2rem 2.5rem;
    max-width: 1000px;
}

.page-head {
    margin-bottom: 1.5rem;
}

.page-head h1 {
    margin: 0 0 0.25rem;
    color: var(--green-dark);
    font-size: 1.6rem;
}

.page-head p {
    margin: 0;
    color: var(--muted);
}

/* ---------- Cards / panels ---------- */
.cards {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 1.25rem;
    margin-bottom: 1.75rem;
}

.stat {
    background: #fff;
    border-radius: var(--radius);
    padding: 1.4rem;
    box-shadow: var(--shadow);
    border-top: 4px solid var(--gold);
}

.stat .label {
    color: var(--muted);
    font-size: 0.8rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.stat .value {
    font-size: 2rem;
    font-weight: 800;
    color: var(--green-dark);
    margin-top: 0.25rem;
}

.stat .sub {
    color: var(--muted);
    font-size: 0.85rem;
    margin-top: 0.25rem;
}

.panel {
    background: #fff;
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    overflow: hidden;
}

.panel-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 1.1rem 1.4rem;
    border-bottom: 1px solid var(--line);
}

.panel-head h2 {
    margin: 0;
    font-size: 1.1rem;
    color: var(--green-dark);
}

.panel-body {
    padding: 1.4rem;
}

/* ---------- Tables ---------- */
.table {
    width: 100%;
    border-collapse: collapse;
}

.table th,
.table td {
    text-align: left;
    padding: 0.85rem 1.4rem;
    border-bottom: 1px solid var(--line);
    font-size: 0.92rem;
}

.table th {
    background: var(--gold-soft);
    color: var(--green-dark);
    font-size: 0.78rem;
    text-transform: uppercase;
    letter-spacing: 0.04em;
}

.table tbody tr:hover {
    background: #fafaf6;
}

.table .num {
    text-align: right;
    font-variant-numeric: tabular-nums;
}

.amount-pos {
    color: var(--green-light);
    font-weight: 600;
}

.amount-neg {
    color: var(--danger);
    font-weight: 600;
}

.empty {
    text-align: center;
    color: var(--muted);
    padding: 2.5rem 1rem;
}

.card-pill {
    display: inline-block;
    background: var(--green);
    color: var(--gold-soft);
    font-variant-numeric: tabular-nums;
    letter-spacing: 0.12em;
    padding: 0.3rem 0.8rem;
    border-radius: 8px;
    font-size: 0.85rem;
}

.notice {
    background: var(--gold-soft);
    border: 1px solid #e6d6a6;
    color: #6b5a18;
    border-radius: 10px;
    padding: 0.8rem 1rem;
    font-size: 0.88rem;
    margin-bottom: 1.25rem;
}

@media (max-width: 720px) {
    .app {
        flex-direction: column;
    }

    .sidebar {
        width: 100%;
    }

    .content {
        padding: 1.25rem;
    }

    .form-row {
        flex-direction: column;
        gap: 0;
    }
}
