:root {
    --bg: #faf7f2;
    --surface: #fffdf8;
    --ink: #111111;
    --muted: #6f6a63;
    --line: #e8e1d8;
    --accent: #8b3f50;
    --accent-strong: #5f2634;
    --gold: #8b5e3c;
    --green: #426b55;
    --red: #9b3d3d;
    --shadow: 0 18px 50px rgba(25, 20, 16, 0.08);
}

* {
    box-sizing: border-box;
}

body {
    margin: 0;
    background: var(--bg);
    color: var(--ink);
    font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
    font-size: 15px;
    line-height: 1.5;
}

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

a:hover {
    color: var(--accent-strong);
}

.app-shell {
    display: grid;
    grid-template-columns: 260px 1fr;
    min-height: 100vh;
}

.sidebar {
    position: sticky;
    top: 0;
    height: 100vh;
    border-right: 1px solid var(--line);
    background: #fffaf4;
    padding: 28px 20px;
}

.brand,
.login-brand {
    display: flex;
    gap: 12px;
    align-items: center;
}

.brand {
    color: var(--ink);
    margin-bottom: 36px;
}

.brand-mark {
    display: grid;
    place-items: center;
    width: 42px;
    height: 42px;
    border: 1px solid var(--ink);
    border-radius: 50%;
    color: var(--ink);
    font-family: Georgia, serif;
    font-size: 14px;
    letter-spacing: 0;
}

.brand strong,
.brand small {
    display: block;
}

.brand small,
.eyebrow,
small {
    color: var(--muted);
}

.eyebrow {
    margin: 0 0 5px;
    font-size: 12px;
    text-transform: uppercase;
    letter-spacing: 0.08em;
}

.nav {
    display: grid;
    gap: 5px;
}

.nav a {
    border-radius: 8px;
    color: var(--muted);
    padding: 10px 12px;
}

.nav a.active,
.nav a:hover {
    background: var(--surface);
    color: var(--ink);
}

.main {
    padding: 28px;
    min-width: 0;
}

.topbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    margin-bottom: 24px;
}

h1,
h2 {
    margin: 0;
    font-family: Georgia, "Times New Roman", serif;
    font-weight: 500;
    letter-spacing: 0;
}

h1 {
    font-size: clamp(30px, 4vw, 46px);
    line-height: 1;
}

h2 {
    font-size: 22px;
}

.topbar-user,
.toolbar,
.form-actions {
    display: flex;
    align-items: center;
    gap: 10px;
}

.toolbar {
    justify-content: flex-end;
    margin-bottom: 16px;
}

.button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 40px;
    border: 1px solid var(--line);
    border-radius: 8px;
    padding: 9px 14px;
    background: var(--surface);
    color: var(--ink);
    font-weight: 650;
    cursor: pointer;
}

.button-primary {
    border-color: var(--accent);
    background: var(--accent);
    color: #ffffff;
}

.button-primary:hover {
    background: var(--accent-strong);
    color: #ffffff;
}

.button-ghost:hover {
    border-color: var(--accent);
}

.stats-grid {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 14px;
    margin-bottom: 18px;
}

.stats-grid.finance {
    grid-template-columns: repeat(5, minmax(0, 1fr));
}

.metric,
.panel,
.login-panel {
    border: 1px solid var(--line);
    border-radius: 8px;
    background: var(--surface);
    box-shadow: var(--shadow);
}

.metric {
    padding: 18px;
}

.metric span {
    display: block;
    color: var(--muted);
    font-size: 13px;
    margin-bottom: 8px;
}

.metric strong {
    display: block;
    font-family: Georgia, "Times New Roman", serif;
    font-size: 25px;
    font-weight: 500;
}

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

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

.panel {
    margin-bottom: 18px;
    overflow: hidden;
}

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

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

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

th {
    color: var(--muted);
    font-size: 12px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

tr:last-child td {
    border-bottom: 0;
}

td small {
    display: block;
    margin-top: 3px;
}

.actions {
    text-align: right;
    white-space: nowrap;
}

.badge {
    display: inline-flex;
    align-items: center;
    min-height: 26px;
    border-radius: 999px;
    padding: 4px 10px;
    background: #f3ece4;
    color: var(--gold);
    font-size: 12px;
    font-weight: 700;
}

.badge-client,
.badge-accepted,
.badge-paid,
.badge-done {
    background: #eaf3ed;
    color: var(--green);
}

.badge-lost,
.badge-rejected,
.badge-overdue {
    background: #f7e8e6;
    color: var(--red);
}

.badge-sent,
.badge-quote_sent,
.badge-partial {
    background: #f5ecf0;
    color: var(--accent);
}

.badge-paused,
.badge-expired,
.badge-skipped {
    background: #efefed;
    color: #6c6c66;
}

.form {
    padding: 18px;
}

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

label {
    display: grid;
    gap: 7px;
    color: var(--muted);
    font-size: 13px;
    font-weight: 700;
}

input,
select,
textarea {
    width: 100%;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: #ffffff;
    color: var(--ink);
    font: inherit;
    padding: 10px 11px;
}

textarea {
    resize: vertical;
}

input:focus,
select:focus,
textarea:focus {
    border-color: var(--accent);
    box-shadow: 0 0 0 3px rgba(139, 63, 80, 0.11);
    outline: 0;
}

.checkbox {
    display: flex;
    align-items: center;
    gap: 9px;
    padding-top: 26px;
}

.checkbox input {
    width: auto;
}

.section-title {
    margin: 18px 0 10px;
    color: var(--ink);
    font-family: Georgia, "Times New Roman", serif;
    font-size: 20px;
}

.form-actions {
    margin-top: 18px;
}

.inline-form select {
    min-width: 145px;
    padding: 7px 9px;
}

.alert {
    border: 1px solid var(--line);
    border-radius: 8px;
    margin-bottom: 16px;
    padding: 12px 14px;
    background: var(--surface);
}

.alert-error {
    border-color: #edc7c0;
    color: var(--red);
}

.alert-success {
    border-color: #bfd8c9;
    color: var(--green);
}

.login-page {
    display: grid;
    place-items: center;
    min-height: 100vh;
    padding: 22px;
    background:
        linear-gradient(120deg, rgba(139, 63, 80, 0.08), transparent 42%),
        var(--bg);
}

.login-panel {
    width: min(100%, 430px);
    padding: 28px;
}

.login-brand {
    margin-bottom: 24px;
}

.login-brand h1 {
    font-size: 34px;
}

@media (max-width: 1050px) {
    .stats-grid,
    .stats-grid.finance {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }
}

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

    .sidebar {
        position: static;
        height: auto;
        border-right: 0;
        border-bottom: 1px solid var(--line);
        padding: 18px;
    }

    .brand {
        margin-bottom: 16px;
    }

    .nav {
        grid-template-columns: repeat(3, minmax(0, 1fr));
    }

    .nav a {
        text-align: center;
    }

    .main {
        padding: 18px;
    }

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

    .content-grid,
    .form-grid,
    .stats-grid,
    .stats-grid.finance {
        grid-template-columns: 1fr;
    }

    .wide {
        grid-column: auto;
    }

    table {
        display: block;
        overflow-x: auto;
    }
}
