:root {
    color-scheme: light;
    --ink: #17202a;
    --muted: #607080;
    --line: #d8e0e8;
    --panel: #ffffff;
    --page: #f4f7fa;
    --brand: #23615b;
    --brand-dark: #17423e;
    --accent: #b86b2b;
    --danger: #9e2f2f;
    font-family: Inter, "Segoe UI", Roboto, Arial, sans-serif;
}

* {
    box-sizing: border-box;
}

body {
    margin: 0;
    min-height: 100vh;
    color: var(--ink);
    background: var(--page);
    -webkit-text-size-adjust: 100%;
}

a {
    color: inherit;
}

.sidebar {
    position: fixed;
    inset: 0 auto 0 0;
    width: 245px;
    padding: 20px 16px;
    background: #ffffff;
    border-right: 1px solid var(--line);
    display: flex;
    flex-direction: column;
    gap: 24px;
}

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

.brand-mark {
    width: 42px;
    height: 42px;
    display: grid;
    place-items: center;
    border-radius: 6px;
    background: var(--brand);
    color: #fff;
    font-weight: 700;
}

.brand-logo {
    width: 48px;
    height: 48px;
    object-fit: contain;
    flex: 0 0 auto;
}

.login-logo {
    display: block;
    width: min(180px, 70%);
    max-height: 96px;
    object-fit: contain;
    margin: 0 auto 18px;
}

.brand small,
.page-head p,
small,
.label {
    color: var(--muted);
}

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

nav {
    display: grid;
    gap: 6px;
}

nav a {
    padding: 10px 12px;
    border-radius: 6px;
    text-decoration: none;
}

nav a:hover,
nav a:focus {
    background: #eef4f3;
    outline: none;
}

.logout {
    margin-top: auto;
}

.app {
    margin-left: 245px;
    padding: 28px;
}

.login-shell {
    min-height: 100vh;
    display: grid;
    place-items: center;
    padding: 20px;
}

.login-card,
.panel,
.table-wrap,
.stats > div {
    background: var(--panel);
    border: 1px solid var(--line);
    border-radius: 8px;
}

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

h1 {
    margin: 0 0 8px;
    font-size: 28px;
}

p {
    margin: 0 0 18px;
}

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

.flash {
    margin-bottom: 18px;
    padding: 12px 14px;
    border: 1px solid #d8c18f;
    background: #fff8e7;
    border-radius: 6px;
}

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

.stats > div {
    padding: 18px;
}

.stats strong {
    display: block;
    font-size: 30px;
}

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

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

table {
    width: 100%;
    border-collapse: collapse;
    min-width: 760px;
}

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

th {
    font-size: 13px;
    color: var(--muted);
    background: #fbfcfd;
}

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

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

.panel {
    padding: 18px;
    margin-bottom: 18px;
}

.stack,
.form-grid {
    display: grid;
    gap: 14px;
}

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

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

label {
    display: grid;
    gap: 6px;
    font-weight: 700;
}

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

input:focus,
select:focus,
textarea:focus {
    border-color: var(--brand);
    outline: 3px solid rgba(35, 97, 91, .16);
}

button,
.button {
    min-height: 38px;
    border: 1px solid var(--line);
    border-radius: 6px;
    padding: 9px 13px;
    background: #fff;
    color: var(--ink);
    font: inherit;
    text-decoration: none;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    white-space: nowrap;
}

button:hover,
.button:hover {
    border-color: #aebbc8;
    background: #f8fafb;
}

.primary {
    border-color: var(--brand);
    background: var(--brand);
    color: #fff;
    font-weight: 700;
}

.primary:hover {
    background: var(--brand-dark);
}

.small {
    min-height: 32px;
    padding: 6px 10px;
    font-size: 14px;
}

.actions {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
}

.badge {
    display: inline-block;
    min-width: 68px;
    padding: 5px 8px;
    border-radius: 999px;
    text-align: center;
    font-size: 13px;
    font-weight: 700;
}

.badge.open {
    color: #7b3d00;
    background: #fff0df;
}

.badge.done {
    color: #1f5b33;
    background: #e8f5ec;
}

.label {
    display: block;
    margin-bottom: 6px;
    font-size: 13px;
    font-weight: 700;
}

.signature {
    border: 1px solid var(--line);
    border-radius: 8px;
    background: #fbfcfd;
    overflow: hidden;
}

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

.signature canvas {
    display: block;
    width: 100%;
    height: 190px;
    background: #fff;
    touch-action: none;
}

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

.signature-image,
.missing-signature {
    width: 100%;
    min-height: 150px;
    border: 1px solid var(--line);
    border-radius: 6px;
    background: #fff;
}

.signature-image {
    object-fit: contain;
}

.missing-signature {
    display: grid;
    place-items: center;
    color: var(--muted);
}

@media print {
    .sidebar,
    .page-head button {
        display: none;
    }

    .app {
        margin: 0;
        padding: 0;
    }

    body {
        background: #fff;
    }
}

@media (max-width: 820px) {
    .sidebar {
        position: sticky;
        top: 0;
        z-index: 20;
        width: auto;
        padding: 12px;
        border-right: 0;
        border-bottom: 1px solid var(--line);
        gap: 12px;
    }

    .app {
        margin-left: 0;
        padding: 16px 12px 96px;
    }

    .page-head,
    .brand {
        align-items: flex-start;
    }

    .page-head {
        flex-direction: column;
        gap: 10px;
        margin-bottom: 14px;
    }

    .page-head .button,
    .page-head button,
    .primary.wide {
        width: 100%;
    }

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

    .brand {
        gap: 10px;
    }

    .brand-mark {
        width: 36px;
        height: 36px;
    }

    .brand-logo {
        width: 40px;
        height: 40px;
    }

    .login-logo {
        width: min(160px, 74%);
        max-height: 84px;
        margin-bottom: 14px;
    }

    nav {
        display: flex;
        gap: 8px;
        overflow-x: auto;
        padding-bottom: 2px;
        scrollbar-width: none;
    }

    nav::-webkit-scrollbar {
        display: none;
    }

    nav a {
        flex: 0 0 auto;
        min-height: 40px;
        padding: 10px 12px;
        border: 1px solid var(--line);
        background: #fff;
    }

    .logout {
        margin-top: 0;
    }

    .logout button {
        width: 100%;
    }

    h1 {
        font-size: 24px;
    }

    .login-shell {
        align-items: start;
        padding: 14px;
    }

    .login-card,
    .panel,
    .stats > div {
        border-radius: 7px;
    }

    .login-card,
    .panel {
        padding: 16px;
    }

    input,
    select,
    textarea,
    button,
    .button {
        min-height: 46px;
    }

    .signature-head {
        align-items: stretch;
        flex-direction: column;
    }

    .signature-head button {
        width: 100%;
    }

    .signature canvas {
        height: 240px;
    }

    .table-wrap {
        overflow: visible;
        border: 0;
        background: transparent;
    }

    table,
    thead,
    tbody,
    tr,
    th,
    td {
        display: block;
    }

    table {
        min-width: 0;
    }

    thead {
        display: none;
    }

    tr {
        margin-bottom: 12px;
        border: 1px solid var(--line);
        border-radius: 8px;
        background: #fff;
        overflow: hidden;
    }

    td {
        display: grid;
        grid-template-columns: minmax(92px, 38%) 1fr;
        gap: 10px;
        align-items: center;
        padding: 11px 12px;
        border-bottom: 1px solid var(--line);
    }

    td.actions {
        display: grid;
    }

    td.actions .button,
    td.actions button {
        width: 100%;
    }

    td::before {
        content: attr(data-label);
        color: var(--muted);
        font-size: 13px;
        font-weight: 700;
    }

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

    td:last-child .button,
    td:last-child button {
        width: 100%;
    }

    .empty {
        display: block;
        text-align: center;
    }

    .empty::before {
        content: "";
    }
}
