:root {
    --bg: #f6f7f4;
    --panel: #ffffff;
    --text: #20231f;
    --muted: #6b7168;
    --line: #dfe3da;
    --accent: #2d6a4f;
    --accent-strong: #1f563f;
    --danger: #b42318;
    --warn-bg: #fff7db;
    --radius: 8px;
    --shadow: 0 16px 46px rgba(31, 40, 28, .12);
    --font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Arial, sans-serif;
}

* { box-sizing: border-box; }
body {
    margin: 0;
    min-height: 100vh;
    background: var(--bg);
    color: var(--text);
    font-family: var(--font);
    letter-spacing: 0;
}

button, input, select, textarea { font: inherit; letter-spacing: 0; }
button { cursor: pointer; }
.hidden { display: none !important; }

.login-screen {
    min-height: 100vh;
    display: grid;
    place-items: center;
    padding: 24px;
    background:
        linear-gradient(135deg, rgba(45, 106, 79, .08), transparent 45%),
        var(--bg);
}
.login-box {
    width: min(380px, 100%);
    background: var(--panel);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    padding: 28px;
    display: grid;
    gap: 18px;
}
.eyebrow {
    margin: 0 0 4px;
    color: var(--muted);
    font-size: 12px;
    font-weight: 700;
    text-transform: uppercase;
}
h1, h2 { margin: 0; line-height: 1.1; }
h1 { font-size: 28px; }
h2 { font-size: 20px; }

label span {
    display: block;
    color: var(--muted);
    font-size: 13px;
    margin-bottom: 6px;
}
.field-hint {
    display: block;
    margin-top: 5px;
    color: var(--muted);
    font-size: 12px;
}
input, select, textarea {
    width: 100%;
    border: 1px solid var(--line);
    background: #fff;
    border-radius: 6px;
    padding: 10px 11px;
    color: var(--text);
}
textarea { resize: vertical; }
input:focus, select:focus, textarea:focus {
    outline: 2px solid rgba(45, 106, 79, .18);
    border-color: var(--accent);
}

.btn {
    border: 1px solid var(--line);
    border-radius: 6px;
    background: #fff;
    color: var(--text);
    min-height: 38px;
    padding: 0 14px;
    font-weight: 650;
}
.btn:hover { border-color: #bfc8bb; }
.btn.primary {
    background: var(--accent);
    border-color: var(--accent);
    color: #fff;
}
.btn.primary:hover {
    background: var(--accent-strong);
    border-color: var(--accent-strong);
}
.btn.ghost {
    background: transparent;
}
.btn.danger {
    color: var(--danger);
}
.btn.full { width: 100%; }
.icon-btn {
    width: 34px;
    height: 34px;
    display: grid;
    place-items: center;
    border: 1px solid var(--line);
    border-radius: 6px;
    background: #fff;
    font-size: 24px;
    line-height: 1;
}
.form-error {
    min-height: 18px;
    margin: 0;
    color: var(--danger);
    font-size: 13px;
}

.topbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 20px;
    padding: 24px 28px 16px;
}
.top-actions {
    display: flex;
    align-items: center;
    gap: 10px;
}
.user-chip {
    display: inline-flex;
    align-items: center;
    min-height: 34px;
    padding: 0 12px;
    border: 1px solid var(--line);
    border-radius: 999px;
    color: var(--muted);
    background: rgba(255, 255, 255, .7);
    font-size: 13px;
}
.tabs {
    display: flex;
    gap: 4px;
    padding: 0 28px;
    border-bottom: 1px solid var(--line);
}
.tab {
    border: 0;
    border-bottom: 2px solid transparent;
    background: transparent;
    padding: 12px 14px;
    color: var(--muted);
    font-weight: 700;
}
.tab.is-active {
    color: var(--text);
    border-bottom-color: var(--accent);
}

.workspace { padding: 18px 28px 28px; }
.view { display: none; }
.view.is-active { display: block; }
.toolbar {
    display: grid;
    grid-template-columns: minmax(260px, 1fr) 220px 140px auto auto;
    gap: 10px;
    align-items: center;
    margin-bottom: 14px;
}
.search input { background: #fff; }
.summary-row {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
    margin-bottom: 14px;
}
.stat {
    padding: 8px 10px;
    border: 1px solid var(--line);
    border-radius: 6px;
    background: rgba(255, 255, 255, .7);
    color: var(--muted);
    font-size: 13px;
}
.stat strong {
    color: var(--text);
    font-size: 16px;
    margin-right: 5px;
}

.table-wrap {
    overflow: auto;
    background: var(--panel);
    border: 1px solid var(--line);
    border-radius: var(--radius);
}
.data-table {
    width: 100%;
    border-collapse: collapse;
    min-width: 960px;
}
.data-table th, .data-table td {
    padding: 11px 12px;
    border-bottom: 1px solid var(--line);
    text-align: left;
    vertical-align: top;
}
.data-table th {
    position: sticky;
    top: 0;
    z-index: 1;
    background: #fbfcf9;
    color: var(--muted);
    font-size: 12px;
    text-transform: uppercase;
}
.data-table tr:last-child td { border-bottom: 0; }
.data-table tr.is-archived { color: var(--muted); background: #fafafa; }
.row-actions {
    display: flex;
    justify-content: flex-end;
    gap: 8px;
    white-space: nowrap;
}
.muted { color: var(--muted); }
.password-cell {
    display: inline-block;
    min-width: 112px;
    font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
    font-size: 13px;
    color: var(--text);
}
.note-cell {
    max-width: 330px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.plate {
    display: inline-flex;
    align-items: baseline;
    gap: 2px;
    font-family: Arial, sans-serif;
    white-space: nowrap;
    color: #111;
}
.plate strong {
    font-size: 1.22em;
    letter-spacing: 0;
}
.plate em {
    margin-left: 3px;
    padding-left: 3px;
    border-left: 1px solid currentColor;
    font-style: normal;
    font-size: .74em;
}

.modal {
    border: 0;
    padding: 0;
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    width: min(760px, calc(100vw - 24px));
}
.modal::backdrop {
    background: rgba(32, 35, 31, .42);
}
.modal-box {
    padding: 0;
    background: #fff;
}
.modal-box header,
.modal-box footer {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 18px 20px;
    border-bottom: 1px solid var(--line);
}
.modal-box footer {
    border-top: 1px solid var(--line);
    border-bottom: 0;
    justify-content: flex-end;
}
.form-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 14px;
    padding: 18px 20px;
}
.span-2 { grid-column: 1 / -1; }
.modal .form-error,
.generated-password {
    margin: 0 20px 16px;
}
.generated-password {
    color: var(--accent-strong);
    font-size: 14px;
    font-weight: 700;
}

.audit-list {
    display: grid;
    gap: 8px;
}
.audit-item {
    background: #fff;
    border: 1px solid var(--line);
    border-radius: 6px;
    padding: 12px;
}
.audit-item time {
    color: var(--muted);
    font-size: 12px;
}
.audit-item p {
    margin: 4px 0 0;
}

.print-page {
    background: #fff;
    color: #000;
}
.print-header {
    display: flex;
    justify-content: space-between;
    align-items: start;
    gap: 20px;
    padding: var(--print-header-top, 7mm) var(--print-page-x, 8mm) var(--print-header-bottom, 3mm);
}
.print-header h1 {
    font-size: var(--print-title-size, 14pt);
    margin: 0 0 2mm;
}
.print-header p {
    margin: 0;
    font-size: var(--print-meta-size, 8.5pt);
}
.print-grid {
    display: grid;
    grid-template-columns: repeat(10, minmax(0, 1fr));
    gap: var(--print-gap-y, .8mm) var(--print-gap-x, 1.1mm);
    padding: 0 var(--print-page-x, 8mm) var(--print-page-bottom, 5mm);
}
.print-digit-grid {
    align-items: start;
}
.print-digit-column {
    min-width: 0;
    display: flex;
    flex-direction: column;
    gap: var(--print-gap-y, .45mm);
}
.print-plate {
    min-height: var(--print-row-height, 6mm);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: var(--print-font-size, 11pt);
    line-height: 1;
    break-inside: avoid;
}
.print-plate .plate strong {
    font-size: 1.18em;
    font-weight: 800;
}
.print-page .plate {
    gap: 1px;
}

@page {
    size: A4 landscape;
    margin: 0;
}
@media print {
    .no-print { display: none !important; }
    .print-header { padding-top: var(--print-header-top, 7mm); }
}

@media (max-width: 820px) {
    .topbar {
        align-items: flex-start;
        padding: 18px 16px 12px;
    }
    .top-actions {
        flex-direction: column;
        align-items: flex-end;
    }
    .tabs { padding: 0 16px; overflow-x: auto; }
    .workspace { padding: 14px 16px 22px; }
    .toolbar {
        grid-template-columns: 1fr 1fr;
    }
    .toolbar .search { grid-column: 1 / -1; }
    .form-grid {
        grid-template-columns: 1fr;
    }
    .span-2 { grid-column: auto; }
}
