:root {
    color-scheme: light;
    --bg: #f4f6f8;
    --panel: #ffffff;
    --text: #17202a;
    --muted: #667085;
    --line: #dfe4ea;
    --primary: #2457c5;
    --primary-dark: #183f98;
    --danger: #b42318;
    --danger-bg: #fff1f0;
    --shadow: 0 1px 3px rgba(16, 24, 40, 0.08);
}
* { box-sizing: border-box; }
body { margin: 0; background: var(--bg); color: var(--text); font: 15px/1.5 system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif; }
a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }
.container { width: min(1500px, calc(100% - 32px)); margin: 0 auto; }
.topbar { background: #17202a; color: #fff; }
.topbar-inner { min-height: 58px; display: flex; align-items: center; justify-content: space-between; gap: 24px; }
.brand { color: #fff; font-size: 18px; font-weight: 700; }
.brand:hover { text-decoration: none; }
.main-nav { display: flex; align-items: center; gap: 18px; }
.main-nav a, .link-button { color: #fff; }
.user-label { color: #c7d0da; }
.inline-form { display: inline; margin: 0; }
.link-button { border: 0; padding: 0; background: none; font: inherit; cursor: pointer; }
.link-button:hover { text-decoration: underline; }
.page-content { padding: 28px 0 48px; }
h1 { margin: 0 0 6px; font-size: clamp(24px, 3vw, 34px); }
h2 { margin: 0; font-size: 20px; }
h3 { margin: 18px 0 4px; font-size: 15px; }
.muted { color: var(--muted); }
.page-heading { display: flex; align-items: flex-start; justify-content: space-between; gap: 24px; margin-bottom: 24px; }
.heading-actions { display: flex; gap: 10px; flex-wrap: wrap; }
.back-link { display: inline-block; margin-bottom: 8px; }
.button { display: inline-flex; align-items: center; justify-content: center; min-height: 38px; padding: 7px 13px; border: 1px solid #b9c1cc; border-radius: 7px; background: #fff; color: var(--text); font: inherit; font-weight: 600; cursor: pointer; }
.button:hover { text-decoration: none; background: #f8fafc; }
.button.primary { background: var(--primary); border-color: var(--primary); color: #fff; }
.button.primary:hover { background: var(--primary-dark); }
.button.subtle { color: var(--muted); }
.panel { background: var(--panel); border: 1px solid var(--line); border-radius: 10px; box-shadow: var(--shadow); padding: 20px; margin-bottom: 20px; }
.summary-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 14px; margin-bottom: 20px; }
.summary-card { background: var(--panel); border: 1px solid var(--line); border-radius: 10px; box-shadow: var(--shadow); padding: 16px 18px; }
.summary-card span { display: block; color: var(--muted); }
.summary-card strong { display: block; margin-top: 2px; font-size: 30px; }
.summary-card.danger strong { color: var(--danger); }
.filters { display: flex; align-items: end; gap: 12px; flex-wrap: wrap; }
.filter-field { min-width: 170px; }
.filter-field.grow { flex: 1 1 260px; }
.filter-field label, .form-row label { display: block; margin-bottom: 5px; font-weight: 600; }
input, select, textarea { width: 100%; min-height: 38px; padding: 7px 9px; border: 1px solid #b9c1cc; border-radius: 6px; background: #fff; color: var(--text); font: inherit; }
.checkbox-field { display: flex; align-items: center; gap: 8px; min-height: 38px; white-space: nowrap; }
.checkbox-field input { width: auto; min-height: auto; }
.table-panel { padding: 0; overflow: hidden; }
.panel-heading { padding: 16px 20px; display: flex; align-items: center; justify-content: space-between; border-bottom: 1px solid var(--line); }
.table-scroll { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
th, td { padding: 12px 14px; border-bottom: 1px solid var(--line); text-align: left; vertical-align: top; }
th { background: #f8fafc; color: #475467; font-size: 13px; white-space: nowrap; }
tbody tr:last-child td { border-bottom: 0; }
.overdue-row { background: var(--danger-bg); }
.strong-link { font-weight: 700; color: var(--text); }
.status-pill { display: inline-block; padding: 3px 8px; border-radius: 999px; background: #e9effd; white-space: nowrap; }
.muted-pill { background: #eceff3; color: var(--muted); }
.danger-text { color: var(--danger); }
.row-actions { white-space: nowrap; }
.row-actions a { margin-right: 8px; }
.empty-state { padding: 28px; text-align: center; color: var(--muted); }
code { padding: 2px 5px; border-radius: 4px; background: #eef1f5; }
.detail-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 20px; }
.detail-list { display: grid; grid-template-columns: minmax(100px, auto) 1fr; gap: 8px 14px; margin-bottom: 0; }
.detail-list dt { color: var(--muted); }
.detail-list dd { margin: 0; }
.login-wrap { display: grid; min-height: calc(100vh - 160px); place-items: center; }
.login-panel { width: min(420px, 100%); }
.form-row { margin: 16px 0; }
.form-errors, .errorlist { color: var(--danger); }
.errorlist { margin: 5px 0; padding-left: 20px; }
.messages { margin-bottom: 16px; }
.message { padding: 12px 14px; border-radius: 8px; background: #eef4ff; border: 1px solid #c7d7fe; }
.message.warning { background: #fffaeb; border-color: #fedf89; }
@media (max-width: 900px) {
    .detail-grid { grid-template-columns: 1fr; gap: 0; }
    .page-heading { flex-direction: column; }
}
@media (max-width: 620px) {
    .container { width: min(100% - 20px, 1500px); }
    .topbar-inner { align-items: flex-start; flex-direction: column; padding: 12px 0; gap: 8px; }
    .main-nav { flex-wrap: wrap; gap: 12px; }
    .summary-grid { grid-template-columns: 1fr 1fr; }
    .filters > * { width: 100%; }
}
.state-block { padding: 12px 0; border-bottom: 1px solid var(--line); }
.state-block:last-of-type { border-bottom: 0; }
.state-block h3 { margin-top: 0; }
.state-overdue { background: var(--danger-bg); margin: 8px -10px; padding: 12px 10px; border-radius: 8px; }
