:root {
    --bg: #edf3f6;
    --bg-accent: #dceaf0;
    --surface: #ffffff;
    --surface-alt: #f7fbfc;
    --surface-strong: #f2f8fa;
    --ink: #173042;
    --muted: #5f7382;
    --line: #d6e3ea;
    --line-strong: #b7ccd7;
    --brand: #005b7f;
    --brand-deep: #09324f;
    --brand-soft: #d9edf5;
    --accent: #0f8b8d;
    --accent-soft: #ddf4f1;
    --success: #1d7a5a;
    --danger: #b63a3a;
    --shadow: 0 20px 50px rgba(9, 50, 79, 0.08);
}

* {
    box-sizing: border-box;
}

html {
    color-scheme: light;
}

body {
    margin: 0;
    color: var(--ink);
    font-family: "Segoe UI Variable", "Trebuchet MS", "Gill Sans", sans-serif;
    background:
        radial-gradient(circle at top left, rgba(15, 139, 141, 0.12), transparent 24rem),
        linear-gradient(135deg, #f8fcfd 0%, var(--bg) 52%, var(--bg-accent) 100%);
}

a {
    color: inherit;
}

h1,
h2,
h3,
h4 {
    margin: 0;
    font-family: Georgia, "Times New Roman", serif;
    color: var(--brand-deep);
}

hr {
    border: 0;
    border-top: 1px solid var(--line);
    margin: 1.5rem 0;
}

.shell {
    min-height: 100vh;
    display: grid;
    grid-template-columns: minmax(250px, 290px) 1fr;
}

.sidebar {
    display: flex;
    flex-direction: column;
    gap: 1.25rem;
    padding: 2rem 1.5rem;
    color: #f4fbff;
    background:
        linear-gradient(180deg, rgba(255, 255, 255, 0.06), transparent 20%),
        linear-gradient(180deg, var(--brand-deep) 0%, var(--brand) 100%);
    box-shadow: inset -1px 0 0 rgba(255, 255, 255, 0.08);
}

.brand-block {
    padding-bottom: 1.25rem;
    border-bottom: 1px solid rgba(255, 255, 255, 0.16);
}

.brand-kicker,
.topbar-kicker,
.lang-label {
    text-transform: uppercase;
    letter-spacing: 0.16em;
    font-size: 0.72rem;
}

.brand-kicker {
    color: rgba(244, 251, 255, 0.72);
}

.sidebar h1 {
    margin-top: 0.7rem;
    font-size: clamp(1.8rem, 3vw, 2.4rem);
    line-height: 1.02;
    color: #ffffff;
}

.brand-subtitle {
    margin: 0.8rem 0 0;
    color: rgba(244, 251, 255, 0.78);
}

.sidebar-nav {
    display: grid;
    gap: 0.35rem;
}

.sidebar-nav a,
.sidebar-link {
    display: block;
    padding: 0.85rem 1rem;
    text-decoration: none;
    border-radius: 0.95rem;
    color: #f4fbff;
    border: 1px solid transparent;
    transition: background-color 140ms ease, border-color 140ms ease, transform 140ms ease;
}

.sidebar-nav a:hover,
.sidebar-nav a:focus-visible,
.sidebar-link:hover,
.sidebar-link:focus-visible {
    background: rgba(255, 255, 255, 0.09);
    border-color: rgba(255, 255, 255, 0.14);
    transform: translateX(2px);
}

.sidebar-nav a.is-active {
    background: rgba(255, 255, 255, 0.14);
    border-color: rgba(255, 255, 255, 0.18);
    font-weight: 600;
}

.sidebar-meta {
    margin-top: auto;
    padding: 1rem;
    border-radius: 1rem;
    background: rgba(255, 255, 255, 0.08);
    border: 1px solid rgba(255, 255, 255, 0.12);
}

.sidebar-meta strong {
    display: block;
    margin: 0.25rem 0;
    color: #ffffff;
}

.sidebar-actions {
    margin-top: -0.5rem;
}

.lang-switch {
    padding-top: 1.25rem;
    border-top: 1px solid rgba(255, 255, 255, 0.14);
}

.lang-links {
    display: flex;
    flex-wrap: wrap;
    gap: 0.65rem;
    margin-top: 0.75rem;
}

.lang-links a {
    padding: 0.45rem 0.8rem;
    text-decoration: none;
    color: #f4fbff;
    border-radius: 999px;
    border: 1px solid rgba(255, 255, 255, 0.18);
    background: rgba(255, 255, 255, 0.05);
}

.content {
    padding: 1.5rem clamp(1rem, 2vw, 2.25rem) 2.25rem;
}

.topbar {
    display: flex;
    justify-content: space-between;
    align-items: end;
    gap: 1rem;
    padding: 0 0 1.5rem;
    margin-bottom: 1.75rem;
    border-bottom: 1px solid var(--line);
}

.topbar-kicker {
    color: var(--brand);
}

.topbar-title {
    margin-top: 0.45rem;
    font-size: clamp(1.3rem, 2vw, 1.8rem);
    font-weight: 600;
    color: var(--brand-deep);
}

.topbar-links {
    display: flex;
    flex-wrap: wrap;
    justify-content: flex-end;
    gap: 0.85rem 1.25rem;
    color: var(--muted);
    font-size: 0.92rem;
}

.page-header {
    display: flex;
    justify-content: space-between;
    align-items: end;
    gap: 1rem;
    margin-bottom: 1.5rem;
}

.page-header h2 {
    font-size: clamp(1.7rem, 3vw, 2.4rem);
    line-height: 1.05;
}

.section-title {
    margin-bottom: 1rem;
    font-size: 1.2rem;
}

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

.grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 1rem;
    margin-bottom: 1.5rem;
}

.stack {
    display: grid;
    gap: 1.5rem;
}

.card,
.panel {
    background: linear-gradient(180deg, rgba(255, 255, 255, 0.98), rgba(247, 251, 252, 0.98));
    border: 1px solid var(--line);
    border-radius: 1.25rem;
    padding: 1.35rem;
    box-shadow: var(--shadow);
}

.card {
    position: relative;
    overflow: hidden;
}

.card::before {
    content: "";
    position: absolute;
    inset: 0 auto auto 0;
    width: 100%;
    height: 0.3rem;
    background: linear-gradient(90deg, var(--brand), var(--accent));
}

.metric {
    margin: 0.4rem 0 0;
    font-size: clamp(2rem, 4vw, 2.6rem);
    font-weight: 700;
    color: var(--brand-deep);
}

form {
    display: grid;
    gap: 1rem;
}

.form-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: 1rem;
}

label {
    display: grid;
    gap: 0.4rem;
    font-size: 0.95rem;
    color: var(--brand-deep);
}

input,
select,
textarea,
button {
    font: inherit;
}

input,
select,
textarea {
    width: 100%;
    padding: 0.82rem 0.92rem;
    color: var(--ink);
    background: var(--surface);
    border: 1px solid var(--line-strong);
    border-radius: 0.95rem;
    outline: none;
}

input:focus,
select:focus,
textarea:focus {
    border-color: var(--brand);
    box-shadow: 0 0 0 4px rgba(0, 91, 127, 0.12);
}

textarea {
    min-height: 7rem;
    resize: vertical;
}

button {
    width: fit-content;
    padding: 0.82rem 1.2rem;
    color: #ffffff;
    background: linear-gradient(135deg, var(--brand) 0%, var(--accent) 100%);
    border: 0;
    border-radius: 999px;
    font-weight: 600;
    letter-spacing: 0.01em;
    cursor: pointer;
    box-shadow: 0 12px 24px rgba(0, 91, 127, 0.18);
    transition: transform 140ms ease, box-shadow 140ms ease, filter 140ms ease;
}

button:hover,
button:focus-visible {
    transform: translateY(-1px);
    box-shadow: 0 16px 28px rgba(0, 91, 127, 0.22);
    filter: saturate(1.05);
}

table {
    width: 100%;
    border-collapse: collapse;
    overflow: hidden;
}

thead {
    background: var(--surface-strong);
}

th,
td {
    padding: 0.9rem 0.75rem;
    text-align: left;
    border-bottom: 1px solid var(--line);
    vertical-align: top;
}

th {
    font-size: 0.8rem;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: var(--brand);
}

tbody tr:hover {
    background: rgba(217, 237, 245, 0.28);
}

.badge {
    display: inline-block;
    padding: 0.38rem 0.72rem;
    border-radius: 999px;
    font-size: 0.82rem;
    font-weight: 600;
    background: var(--brand-soft);
    color: var(--brand);
}

.badge-success {
    background: #dcf4e8;
    color: var(--success);
}

.flash {
    margin-bottom: 1rem;
    padding: 0.9rem 1rem;
    border-radius: 1rem;
    border: 1px solid transparent;
}

.flash-success {
    color: var(--success);
    background: #e4f6ec;
    border-color: #b8e0ca;
}

.flash-error {
    color: var(--danger);
    background: #fce7e7;
    border-color: #efb9b9;
}

.line-items {
    display: grid;
    gap: 0.75rem;
}

.line-row {
    display: grid;
    grid-template-columns: 2fr 1fr;
    gap: 0.75rem;
}

.line-row-receipt {
    grid-template-columns: 2fr 1fr 1fr;
}

.button-row {
    margin-top: 1rem;
}

.receipt-mode-picker {
    display: flex;
    gap: 0.75rem;
    flex-wrap: wrap;
    margin-bottom: 1rem;
}

.mode-chip {
    width: auto;
    padding: 0.65rem 1rem;
    color: var(--brand-deep);
    background: var(--surface);
    border: 1px solid var(--line-strong);
    border-radius: 999px;
    cursor: pointer;
    box-shadow: none;
    font-weight: 600;
    letter-spacing: 0;
    transition: background-color 140ms ease, border-color 140ms ease, color 140ms ease;
}

.mode-chip.is-active {
    background: linear-gradient(135deg, var(--brand) 0%, var(--accent) 100%);
    color: #fff;
    border-color: transparent;
    box-shadow: 0 12px 24px rgba(0, 91, 127, 0.18);
}

.mode-chip:hover,
.mode-chip:focus-visible {
    transform: none;
    filter: none;
    color: var(--brand);
    border-color: var(--brand);
    box-shadow: 0 0 0 4px rgba(0, 91, 127, 0.08);
}

.mode-chip.is-active:hover,
.mode-chip.is-active:focus-visible {
    color: #fff;
    border-color: transparent;
    box-shadow: 0 12px 24px rgba(0, 91, 127, 0.18);
}

.receipt-mode-panel {
    display: none;
}

.receipt-mode-panel.is-active {
    display: block;
}

.button-link {
    display: inline-flex;
    align-items: center;
    margin-left: 0.75rem;
    color: var(--brand);
    font-weight: 600;
    text-decoration: none;
}

.action-row {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.6rem;
}

.action-row form {
    display: block;
    margin: 0;
}

.action-row button {
    padding: 0.5rem 0.9rem;
    box-shadow: none;
}

.line-row-receipt-search {
    grid-template-columns: 2fr 1fr 1fr;
    align-items: start;
}

.receipt-search-field {
    position: relative;
}

.autocomplete-list {
    position: absolute;
    left: 0;
    right: 0;
    top: calc(100% + 0.35rem);
    background: #fff;
    border: 1px solid var(--line-strong);
    border-radius: 0.85rem;
    box-shadow: 0 12px 30px rgba(15, 23, 42, 0.12);
    overflow: hidden;
    z-index: 20;
}

.autocomplete-option {
    width: 100%;
    text-align: left;
    border: 0;
    border-bottom: 1px solid var(--line);
    background: #fff;
    color: var(--ink);
    padding: 0.75rem 0.9rem;
    cursor: pointer;
    border-radius: 0;
    box-shadow: none;
    font-weight: 500;
    letter-spacing: 0;
}

.autocomplete-option:last-child {
    border-bottom: 0;
}

.autocomplete-option:hover,
.autocomplete-option:focus-visible {
    transform: none;
    filter: none;
    background: var(--brand-soft);
    color: var(--brand-deep);
    box-shadow: none;
}

@media (max-width: 980px) {
    .shell {
        grid-template-columns: 1fr;
    }

    .sidebar {
        gap: 1rem;
        padding: 1.25rem 1rem;
    }

    .sidebar-meta {
        margin-top: 0;
    }

    .content {
        padding-top: 1rem;
    }

    .topbar {
        flex-direction: column;
        align-items: start;
    }

    .topbar-links {
        justify-content: flex-start;
    }
}

@media (max-width: 720px) {
    .content {
        padding-inline: 0.8rem;
    }

    .panel,
    .card {
        padding: 1rem;
        border-radius: 1rem;
    }

    .line-row,
    .line-row-receipt,
    .line-row-receipt-search,
    .form-grid {
        grid-template-columns: 1fr;
    }

    th,
    td {
        padding-inline: 0.55rem;
    }
}
