:root {
    --ink: #191716;
    --primary: #561013;
    --primary-deep: #430c0f;
    --accent: #7f494b;
    --steel: #708090;
    --paper: #faf3f0;
    --panel: #fffaf8;
    --panel-alt: #f4ece9;
    --line: #d8c6c0;
    --success-bg: #e8f4ef;
    --success-line: #b8d7c8;
    --success-text: #1f5a43;
    --danger-bg: #fbecec;
    --danger-line: #efc0bf;
    --danger-text: #7e1f23;
    --warning-bg: #fcf0e4;
    --warning-line: #edcfac;
    --warning-text: #885117;
    --shadow: 0 20px 48px rgba(25, 23, 22, 0.08);
    --radius: 20px;
    --radius-small: 14px;
    --transition: 180ms ease;
}

* {
    box-sizing: border-box;
}

html {
    scroll-behavior: smooth;
}

body {
    margin: 0;
    color: var(--ink);
    font-family: "Segoe UI", Tahoma, Geneva, Verdana, sans-serif;
    background:
        radial-gradient(circle at top left, rgba(127, 73, 75, 0.16), transparent 22%),
        linear-gradient(180deg, #fff8f5 0%, var(--paper) 54%, #f5ece8 100%);
}

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

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

small {
    color: var(--steel);
}

.login-body {
    min-height: 100vh;
    display: grid;
    place-items: center;
    padding: 2rem;
}

.login-shell {
    width: min(100%, 500px);
}

.login-card,
.panel,
.stat-card,
.report-card {
    background: rgba(255, 250, 248, 0.96);
    border: 1px solid rgba(216, 198, 192, 0.92);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    backdrop-filter: blur(10px);
}

.login-card {
    padding: 2.25rem;
}

.brand-block {
    padding-bottom: 0.6rem;
    border-bottom: 1px solid rgba(216, 198, 192, 0.6);
    margin-bottom: 1.2rem;
}

.privacy-notice,
.muted,
.login-help,
.field-help {
    color: var(--steel);
}

.login-help {
    margin-bottom: 0.5rem;
    font-size: 0.95rem;
}

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

label {
    display: grid;
    gap: 0.4rem;
    font-weight: 600;
}

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

input,
select,
textarea {
    width: 100%;
    border: 1px solid var(--line);
    border-radius: 13px;
    padding: 0.82rem 0.95rem;
    background: #fff;
    color: var(--ink);
    transition: border-color var(--transition), box-shadow var(--transition), transform var(--transition);
}

input:focus,
select:focus,
textarea:focus {
    border-color: rgba(86, 16, 19, 0.6);
    box-shadow: 0 0 0 4px rgba(86, 16, 19, 0.12);
    outline: none;
}

textarea {
    resize: vertical;
}

.checkbox-field {
    display: flex;
    align-items: center;
    gap: 0.65rem;
    align-self: end;
    min-height: 52px;
    font-weight: 600;
}

.checkbox-field input {
    width: auto;
    margin: 0;
}

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    padding: 0.82rem 1.18rem;
    border-radius: 999px;
    border: none;
    cursor: pointer;
    font-weight: 700;
    transition: transform var(--transition), box-shadow var(--transition), background var(--transition);
}

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

.btn-small {
    padding: 0.56rem 0.92rem;
    font-size: 0.92rem;
}

.btn-block {
    width: 100%;
}

.btn-primary {
    background: linear-gradient(135deg, var(--primary) 0%, var(--accent) 100%);
    color: #fff;
    box-shadow: 0 14px 28px rgba(86, 16, 19, 0.18);
}

.btn-primary:hover {
    background: linear-gradient(135deg, var(--primary-deep) 0%, var(--primary) 100%);
}

.btn-secondary {
    background: var(--panel-alt);
    color: var(--ink);
    border: 1px solid var(--line);
}

.btn-danger {
    background: #8a1f24;
    color: #fff;
}

.alert {
    border-radius: var(--radius-small);
    padding: 0.95rem 1rem;
    margin-bottom: 1rem;
}

.alert p:last-child {
    margin-bottom: 0;
}

.alert-success {
    background: var(--success-bg);
    border: 1px solid var(--success-line);
    color: var(--success-text);
}

.alert-danger {
    background: var(--danger-bg);
    border: 1px solid var(--danger-line);
    color: var(--danger-text);
}

.alert-warning {
    background: var(--warning-bg);
    border: 1px solid var(--warning-line);
    color: var(--warning-text);
}

.eyebrow {
    margin-bottom: 0.35rem;
    font-size: 0.78rem;
    letter-spacing: 0.16em;
    text-transform: uppercase;
    color: var(--accent);
}

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

.sidebar {
    padding: 2rem 1.5rem;
    background:
        linear-gradient(180deg, rgba(25, 23, 22, 0.98) 0%, rgba(86, 16, 19, 0.98) 100%),
        var(--primary);
    color: #faf3f0;
    display: flex;
    flex-direction: column;
    gap: 2rem;
    position: sticky;
    top: 0;
    min-height: 100vh;
}

.sidebar h2 {
    margin-bottom: 0;
}

.nav {
    display: grid;
    gap: 0.6rem;
}

.nav a {
    padding: 0.9rem 1rem;
    border-radius: 14px;
    background: rgba(255, 255, 255, 0.06);
    border: 1px solid transparent;
    transition: background var(--transition), border-color var(--transition), transform var(--transition);
}

.nav a:hover,
.nav a.active {
    background: rgba(250, 243, 240, 0.15);
    border-color: rgba(250, 243, 240, 0.22);
    transform: translateX(2px);
}

.main-area {
    padding: 1.5rem;
}

.topbar,
.page-header,
.panel-header,
.actions-row,
.filter-actions,
.form-actions {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    flex-wrap: wrap;
}

.topbar {
    margin-bottom: 1rem;
    padding: 0.4rem 0 1rem;
    border-bottom: 1px solid rgba(216, 198, 192, 0.7);
}

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

.back-link {
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
    margin-bottom: 0.55rem;
    color: var(--primary);
    font-weight: 700;
}

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

.stat-card,
.report-card {
    padding: 1.3rem;
}

.stat-card span {
    color: var(--steel);
    font-weight: 600;
}

.stat-card strong {
    display: block;
    margin-top: 0.35rem;
    font-size: 2rem;
    color: var(--primary);
}

.panel {
    padding: 1.45rem;
}

.table-wrap {
    overflow-x: auto;
}

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

th,
td {
    padding: 0.95rem 0.8rem;
    border-bottom: 1px solid rgba(216, 198, 192, 0.72);
    text-align: left;
    vertical-align: top;
}

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

tbody tr:hover {
    background: rgba(244, 236, 233, 0.5);
}

.empty-state {
    text-align: center;
    color: var(--steel);
}

.filters,
.form-grid,
.detail-grid {
    display: grid;
    gap: 1rem;
}

.filters {
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    align-items: end;
}

.compact {
    grid-template-columns: repeat(auto-fit, minmax(180px, max-content));
}

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

.full-width {
    grid-column: 1 / -1;
}

.detail-grid {
    grid-template-columns: 1.3fr 0.95fr;
}

.details {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 1rem;
    margin: 0;
}

.details div {
    background: var(--panel-alt);
    border-radius: var(--radius-small);
    padding: 0.95rem;
    border: 1px solid rgba(216, 198, 192, 0.55);
}

.details dt {
    font-size: 0.79rem;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: var(--steel);
    margin-bottom: 0.42rem;
}

.details dd {
    margin: 0;
    font-weight: 600;
}

.badge {
    display: inline-flex;
    align-items: center;
    border-radius: 999px;
    padding: 0.35rem 0.75rem;
    font-size: 0.84rem;
    font-weight: 700;
}

.badge-received { background: #ede3dd; color: #6a2c2e; }
.badge-quote { background: #f8ecde; color: #8a531d; }
.badge-approved { background: #eee6f3; color: #6d4180; }
.badge-sent { background: #e5eef2; color: #49606d; }
.badge-repair { background: #dfe7ee; color: #415364; }
.badge-returned { background: #f2e3e4; color: #7d3c42; }
.badge-ready { background: #efe4df; color: #6a2c2e; }
.badge-collected { background: #e7efe8; color: #365945; }
.badge-cancelled { background: #f6dddd; color: #8a1f24; }
.badge-default { background: #ece7e4; color: #3d4044; }

.timeline {
    display: grid;
    gap: 0.95rem;
}

.timeline-item {
    border-left: 4px solid var(--primary);
    padding: 0.85rem 1rem;
    background: var(--panel-alt);
    border-radius: 0 14px 14px 0;
}

.timeline-meta {
    display: flex;
    justify-content: space-between;
    gap: 1rem;
    flex-wrap: wrap;
}

.pagination {
    display: flex;
    gap: 0.5rem;
    justify-content: flex-end;
    margin-top: 1rem;
    flex-wrap: wrap;
}

.pagination-link {
    padding: 0.6rem 0.9rem;
    border-radius: 999px;
    border: 1px solid var(--line);
    background: var(--panel-alt);
}

.pagination-link.active {
    background: var(--primary);
    border-color: var(--primary);
    color: #fff;
}

.report-links {
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
}

.report-card {
    min-height: 118px;
    display: grid;
    place-items: center;
    font-weight: 700;
    text-align: center;
    background:
        linear-gradient(135deg, rgba(86, 16, 19, 0.06) 0%, rgba(127, 73, 75, 0.1) 100%),
        var(--panel);
}

.narrow {
    max-width: 560px;
}

.form-panel {
    max-width: 900px;
}

.field-help {
    display: block;
    margin-top: 0.15rem;
    font-size: 0.9rem;
}

.numbered-list,
.plain-list {
    margin: 0;
    padding-left: 1.2rem;
}

.numbered-list li,
.plain-list li {
    margin-bottom: 0.55rem;
}

.print-body {
    background: #fff;
    padding: 2rem;
}

.print-card {
    max-width: 760px;
    margin: 0 auto;
    border: 1px solid #ddd;
    border-radius: 16px;
    padding: 2rem;
}

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

    .sidebar {
        position: static;
        min-height: auto;
    }
}

@media (max-width: 720px) {
    .main-area {
        padding: 1rem;
    }

    .form-grid,
    .details {
        grid-template-columns: 1fr;
    }

    .login-body {
        padding: 1rem;
    }

    .panel,
    .login-card {
        padding: 1.1rem;
    }
}

@media print {
    .sidebar,
    .topbar,
    .btn,
    .back-link,
    form {
        display: none !important;
    }

    .app-shell,
    .main-area,
    .content,
    body {
        display: block;
        background: #fff;
        padding: 0;
    }

    .panel,
    .stat-card,
    .report-card {
        box-shadow: none;
        border: 1px solid #ccc;
    }
}
