:root {
    --bg: #f5f7fa;
    --panel: #ffffff;
    --text: #1f2937;
    --muted: #64748b;
    --line: #d8dee8;
    --primary: #126c83;
    --primary-dark: #0e5364;
    --danger: #9f2f39;
}

* {
    box-sizing: border-box;
}

body {
    margin: 0;
    background: var(--bg);
    color: var(--text);
    font-family: Arial, Helvetica, sans-serif;
    font-size: 15px;
}

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

.topbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 20px;
    padding: 14px 28px;
    background: #17313b;
    color: #fff;
}

.brand {
    font-weight: 700;
    white-space: nowrap;
}

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

.topbar nav a {
    padding: 8px 10px;
    border-radius: 6px;
    color: #e9f2f4;
}

.topbar nav a:hover {
    background: rgba(255, 255, 255, .12);
}

.container {
    width: min(1180px, calc(100% - 32px));
    margin: 24px auto 48px;
}

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

h1, h2 {
    margin: 0 0 12px;
}

h1 {
    font-size: 26px;
}

h2 {
    font-size: 18px;
}

.panel, .card {
    background: var(--panel);
    border: 1px solid var(--line);
    border-radius: 8px;
    padding: 18px;
    margin-bottom: 18px;
}

.cards {
    display: grid;
    gap: 16px;
    margin-bottom: 18px;
}

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

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

.card p {
    display: flex;
    justify-content: space-between;
    margin: 8px 0;
}

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

.danger strong {
    color: var(--danger);
}

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

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

th {
    color: var(--muted);
    font-size: 13px;
    font-weight: 700;
}

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

input, textarea {
    width: 100%;
    margin-top: 6px;
    padding: 10px 11px;
    border: 1px solid var(--line);
    border-radius: 6px;
    background: #fff;
}

textarea {
    min-height: 86px;
    resize: vertical;
}

label {
    display: block;
    color: var(--muted);
    font-weight: 700;
}

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

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

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

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

.form-grid h2, .wide {
    grid-column: 1 / -1;
}

.actions {
    display: flex;
    justify-content: flex-end;
}

.search {
    display: flex;
    gap: 10px;
    margin-bottom: 18px;
}

.search input {
    margin-top: 0;
}

.inline {
    display: flex;
    gap: 8px;
    align-items: center;
}

.inline input {
    width: 130px;
    margin-top: 0;
}

.badge {
    display: inline-block;
    padding: 4px 8px;
    border-radius: 999px;
    background: #e8eef2;
    color: #344451;
    font-size: 13px;
}

.login-page {
    min-height: 100vh;
    display: grid;
    place-items: center;
    background: #17313b;
}

.login-card {
    width: min(380px, calc(100% - 32px));
    padding: 28px;
    border-radius: 8px;
    background: #fff;
}

.login-card h1 {
    margin-bottom: 22px;
}

.login-card label {
    margin-bottom: 14px;
}

.login-card button {
    width: 100%;
}

.alert {
    padding: 10px;
    border-radius: 6px;
    background: #ffe9ec;
    color: #8a2630;
}

.print-head {
    display: flex;
    justify-content: space-between;
    gap: 16px;
    border-bottom: 2px solid var(--text);
    padding-bottom: 12px;
    margin-bottom: 14px;
}

.print-head img {
    width: 110px;
    height: 70px;
    object-fit: contain;
}

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

.box {
    padding: 10px;
    min-height: 58px;
    border: 1px solid var(--line);
    border-radius: 6px;
}

@media (max-width: 760px) {
    .topbar {
        align-items: flex-start;
        flex-direction: column;
    }

    .cards.three, .cards.two, .form-grid, .print-grid {
        grid-template-columns: 1fr;
    }

    .inline, .search {
        flex-direction: column;
    }

    .inline input {
        width: 100%;
    }

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

@media print {
    @page {
        size: A5 portrait;
        margin: 8mm;
    }

    body {
        background: #fff;
        font-size: 11px;
    }

    .topbar, .no-print, .button, button {
        display: none !important;
    }

    .container {
        width: 100%;
        margin: 0;
    }

    .panel, .print-sheet {
        border: 0;
        padding: 0;
        margin: 0;
    }

    th, td {
        padding: 5px;
    }
}
