:root {
    --bg: #eef0f2;
    --card: #ffffff;
    --text: #1d2327;
    --muted: #5b6670;
    --line: #d3d8dd;
    --input-line: #aab3bb;
    --accent: #1f4e79;
    --accent-dark: #163a5a;
    --ok-bg: #e7f5ec;
    --ok-text: #14532d;
    --err-bg: #fbeaea;
    --err-text: #8a1c1c;
    --radius: 8px;
    font-family: system-ui, -apple-system, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}

* { box-sizing: border-box; }

body {
    margin: 0;
    background: var(--bg);
    color: var(--text);
    line-height: 1.5;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

a { color: var(--accent); }

.site-header {
    background: var(--accent);
    color: #fff;
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 12px;
    padding: 14px 24px;
}
.site-header a { color: #fff; text-decoration: none; }
.site-header .brand { font-weight: 700; font-size: 1.05rem; }
.site-header nav a { margin-left: 18px; opacity: 0.9; }
.site-header nav a:hover { opacity: 1; text-decoration: underline; }

.container {
    flex: 1;
    width: 100%;
    max-width: 1000px;
    margin: 28px auto;
    padding: 0 20px;
}

h1 { font-size: 1.6rem; margin: 0 0 16px; }
h2 { font-size: 1.15rem; margin: 0 0 12px; }

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

.form-section {
    background: var(--card);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    padding: 18px 20px;
    margin-bottom: 16px;
}
.form-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 14px 18px;
}
.field { display: flex; flex-direction: column; gap: 4px; }
.field span { font-weight: 600; font-size: 0.95rem; }

input, select {
    font: inherit;
    width: 100%;
    padding: 8px 10px;
    border: 1px solid var(--input-line);
    border-radius: 6px;
    background: #fff;
    color: var(--text);
}
input:focus, select:focus {
    outline: 2px solid #8fb4d9;
    border-color: var(--accent);
}

.btn {
    display: inline-block;
    font: inherit;
    line-height: 1.2;
    padding: 9px 16px;
    border-radius: 6px;
    border: 1px solid transparent;
    text-decoration: none;
    cursor: pointer;
}
.btn-primary { background: var(--accent); color: #fff; }
.btn-primary:hover { background: var(--accent-dark); }
.btn-secondary { background: #fff; color: var(--text); border-color: var(--input-line); }
.btn-secondary:hover { background: #f5f7f9; }
.btn-small {
    padding: 4px 10px;
    font-size: 0.875rem;
    background: #fff;
    color: var(--accent);
    border-color: var(--accent);
}
.btn-small:hover { background: #eef4fa; }

.actions {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    align-items: center;
    margin-top: 18px;
}
.actions-cell { white-space: nowrap; }
.actions-cell .btn-small + .btn-small { margin-left: 6px; }

.alert { padding: 12px 16px; border-radius: 6px; margin-bottom: 18px; }
.alert ul { margin: 0; padding-left: 20px; }
.alert-error { background: var(--err-bg); color: var(--err-text); }
.alert-success { background: var(--ok-bg); color: var(--ok-text); }

.review {
    display: grid;
    grid-template-columns: max-content 1fr;
    gap: 8px 22px;
    background: var(--card);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    padding: 18px 20px;
    margin: 0;
}
.review dt { font-weight: 600; color: var(--muted); }
.review dd { margin: 0; }

.summary {
    display: flex;
    flex-wrap: wrap;
    gap: 14px;
    margin-bottom: 28px;
}
.stat {
    background: var(--card);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    padding: 14px 18px;
    min-width: 160px;
    color: var(--muted);
    font-size: 0.9rem;
}
.stat strong {
    display: block;
    font-size: 1.6rem;
    color: var(--accent);
    line-height: 1.2;
}

.term { margin-bottom: 32px; }
.term h2 {
    border-bottom: 2px solid var(--accent);
    padding-bottom: 6px;
}

.table-wrap {
    overflow-x: auto;
    background: var(--card);
    border: 1px solid var(--line);
    border-radius: var(--radius);
}
table { width: 100%; border-collapse: collapse; }
th, td {
    text-align: left;
    padding: 10px 12px;
    border-bottom: 1px solid var(--line);
    vertical-align: middle;
}
tbody tr:last-child td { border-bottom: none; }
th {
    font-size: 0.8rem;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: var(--muted);
}
.num { text-align: right; font-variant-numeric: tabular-nums; }

.badge {
    display: inline-block;
    font-size: 0.75rem;
    background: #fff3cd;
    color: #7a5b00;
    border-radius: 999px;
    padding: 1px 8px;
    margin-left: 8px;
    vertical-align: middle;
}

.site-footer {
    text-align: center;
    color: var(--muted);
    font-size: 0.85rem;
    padding: 20px;
}

@media (max-width: 600px) {
    .site-header nav a { margin-left: 0; margin-right: 16px; }
    .review { grid-template-columns: 1fr; gap: 2px 0; }
    .review dt { margin-top: 10px; }
}

.form-label {
    display: inline-block;
    font-size: 0.8rem;
    color: var(--muted);
    margin: 0 4px 0 0;
    min-width: 66px;
}
.actions-cell .btn-small { margin-bottom: 4px; }
