:root {
    --bg: #f6f7f9;
    --surface: #fff;
    --border: #e1e4e8;
    --text: #1f2328;
    --muted: #6b7280;
    --accent: #2563eb;
    --danger: #b91c1c;
    --warn: #b45309;
    --ok: #047857;
    --urgent-bg: #fff7ed;
    --overdue-bg: #fef2f2;
    --radius: 6px;
    --shadow: 0 1px 2px rgba(0, 0, 0, .04);
}

* {
    box-sizing: border-box;
}

html,
body {
    margin: 0;
    padding: 0;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    font-size: 14px;
    color: var(--text);
    background: var(--bg);
    line-height: 1.45;
}

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

a:hover {
    text-decoration: underline;
}

.topbar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 10px 16px;
    background: var(--surface);
    border: 1px solid var(--border);
    box-shadow: var(--shadow);
    border-radius: var(--radius);
    border-top-left-radius: 0;
    border-top-right-radius: 0;
    max-width: 1052px;
    width: 100%;
    margin-inline: auto;
}

.brand a {
    font-weight: 600;
    color: var(--text);
}

.nav {
    display: flex;
    align-items: center;
    gap: 18px;
}

.nav a,
.nav button.link {
    font-size: 14px;
}

.container {
    max-width: 1100px;
    margin: 0 auto;
    padding: 24px;
}

h1 {
    font-size: 22px;
    margin: 0 0 12px;
}

h2 {
    font-size: 16px;
    margin: 24px 0 8px;
}

section {
    margin-bottom: 32px;
}

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

.small {
    font-size: 12px;
}

.flash {
    padding: 10px 14px;
    border-radius: var(--radius);
    margin-bottom: 16px;
    border: 1px solid transparent;
}

.flash-ok {
    background: #ecfdf5;
    border-color: #a7f3d0;
    color: var(--ok);
}

.flash-error {
    background: #fef2f2;
    border-color: #fecaca;
    color: var(--danger);
}

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

table.data {
    width: 100%;
    border-collapse: collapse;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    overflow: hidden;
    box-shadow: var(--shadow);
}

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

table.data th {
    background: #fafbfc;
    font-weight: 600;
    font-size: 12px;
    text-transform: uppercase;
    color: var(--muted);
    letter-spacing: .03em;
}

table.data tbody tr:last-child td {
    border-bottom: none;
}

table.data .num {
    text-align: left;
    white-space: nowrap;
}

table.data tr.urgent td {
    background: var(--urgent-bg);
}

table.data tr.overdue td {
    background: var(--overdue-bg);
    color: var(--danger);
}

table.data input[type="text"],
table.data input[type="date"],
table.data input[type="number"] {
    width: 100%;
    border: 1px solid transparent;
    background: transparent;
    border-radius: 4px;
    font: inherit;
    color: inherit;
}

table.data input:focus {
    border-color: var(--accent);
    background: #fff;
    outline: none;
}

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

table.data .actions button {
    margin-left: 4px;
}

.actions {
    display: flex;
    gap: 12px;
    align-items: center;
    justify-content: flex-end;
}

button,
.btn {
    display: inline-block;
    background: var(--accent);
    color: #fff;
    border: none;
    padding: 7px 14px;
    border-radius: var(--radius);
    cursor: pointer;
    font: inherit;
    text-decoration: none;
}

button:hover,
.btn:hover {
    background: #1d4ed8;
    text-decoration: none;
}

button.link {
    background: transparent;
    color: var(--accent);
    padding: 0;
}

button.link:hover {
    background: transparent;
    text-decoration: underline;
}

button.link.danger,
a.danger {
    color: var(--danger);
}

.btn-link {
    color: var(--accent);
    padding: 7px 0;
}

.inline {
    display: inline;
}

.form {
    max-width: 520px;
    background: var(--surface);
    padding: 20px;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
}

.form label {
    display: block;
    margin-bottom: 12px;
    font-weight: 500;
}

.form input[type="text"],
.form input[type="password"],
.form input[type="number"],
.form input[type="date"],
.form select,
.form textarea {
    width: 100%;
    padding: 7px 10px;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    font: inherit;
    background: #fff;
    margin-top: 4px;
}

.form textarea {
    resize: vertical;
}

.form-actions {
    display: flex;
    gap: 12px;
    align-items: center;
    margin-top: 8px;
}

.form-inline {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    align-items: center;
    margin-top: 12px;
    padding: 12px;
    background: var(--surface);
    border: 1px dashed var(--border);
    border-radius: var(--radius);
}

.form-inline input {
    padding: 6px 8px;
    border: 1px solid var(--border);
    border-radius: 4px;
    font: inherit;
    background: #fff;
}

.form-inline input[type="text"] {
    flex: 1 1 160px;
    min-width: 120px;
}

dl.kv {
    display: grid;
    grid-template-columns: 200px 1fr;
    gap: 6px 16px;
    max-width: 600px;
}

dl.kv dt {
    color: var(--muted);
}

/* Login */
.login-page {
    display: flex;
    min-height: 100vh;
    align-items: start;
    justify-content: center;
    background: var(--bg);
    margin-top: 120px;
}

.login-box {
    background: var(--surface);
    padding: 32px;
    border: 1px solid var(--border);
    border-radius: 8px;
    box-shadow: var(--shadow);
    width: 320px;
}

.login-box h1 {
    margin: 0 0 16px;
    text-align: center;
}

.login-box label {
    display: block;
    margin-bottom: 12px;
    font-weight: 500;
}

.login-box input {
    width: 100%;
    padding: 8px 10px;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    font: inherit;
    margin-top: 4px;
}

.login-box button {
    width: 100%;
    padding: 10px;
    margin-top: 4px;
}