:root {
    --bg: #e9edf2;
    --surface: #ffffff;
    --surface-alt: #f3f5f7;
    --text: #202832;
    --muted: #687481;
    --border: #b9c2cc;
    --primary: #315f86;
    --primary-hover: #24496a;
    --success: #276c43;
    --danger: #a52d2d;
    color-scheme: light;
    font-family: Arial, Helvetica, sans-serif;
}

:root[data-theme="dark"] {
    --bg: #20262d;
    --surface: #2b333c;
    --surface-alt: #252c33;
    --text: #e4e8ec;
    --muted: #aeb8c2;
    --border: #56616d;
    --primary: #6f9fc7;
    --primary-hover: #8cb7da;
    --success: #78c694;
    --danger: #f08a86;
    color-scheme: dark;
}

* { box-sizing: border-box; }
html { min-height: 100%; background: var(--bg) !important; }
body {
    max-width: none !important;
    width: 100% !important;
    min-height: 100vh;
    margin: 0 auto !important;
    padding: 0 !important;
    color: var(--text) !important;
    background: var(--bg) !important;
    font-size: 14px;
    line-height: 1.35;
}
.app-shell { display: flex; min-height: 100vh; width: 100%; }
.app-sidebar { flex: 0 0 220px; background: #273746; color: #ecf0f1; border-right: 1px solid #18232d; }
.app-sidebar .brand { padding: 1rem; font-size: 1.25rem; font-weight: 700; border-bottom: 1px solid #40515f; }
.app-sidebar nav { display: block; padding: .5rem 0; background: transparent; border: 0; }
.app-sidebar nav a { display: block; color: #d7e0e8; border: 0; padding: .7rem 1rem; }
.app-sidebar nav a:hover { color: #fff; background: #344b5e; }
.app-main { flex: 1 1 auto; min-width: 0; background: var(--bg); }
.app-toolbar { display: flex; justify-content: space-between; align-items: center; gap: 1rem; min-height: 54px; padding: .6rem 1rem; color: #fff; background: var(--primary); border-bottom: 1px solid var(--primary-hover); }
.app-content { padding: 1rem; }
a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }
h1 { font-size: 1.45rem; margin: 0; }
h2 { font-size: 1.1rem; margin: 0 0 .75rem; }
nav {
    display: flex;
    align-items: center;
    gap: 0;
    flex-wrap: wrap;
    min-height: 38px;
    padding: 0 .75rem;
    background: var(--surface);
    border-bottom: 1px solid var(--border);
}
nav a { padding: .55rem .8rem; border-right: 1px solid var(--border); }
nav a:hover { background: var(--surface-alt); text-decoration: none; }
.bar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    padding: .65rem .9rem;
    background: var(--primary);
    color: #fff;
    border-bottom: 1px solid var(--primary-hover);
}
.bar h1, .bar .muted { color: #fff !important; }
.card {
    background: var(--surface) !important;
    border: 1px solid var(--border) !important;
    border-radius: 2px !important;
    box-shadow: none !important;
    padding: .9rem !important;
    margin: .75rem;
}
.grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(22rem, 1fr)); gap: .75rem; }
.stat-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(13rem, 1fr)); gap: .5rem; margin: .75rem; }
.stat { display: block; padding: .8rem; color: var(--text); background: var(--surface); border: 1px solid var(--border); border-radius: 2px; }
.stat:hover { background: var(--surface-alt); text-decoration: none; }
.stat strong { display: block; font-size: 1rem; }
.muted { color: var(--muted); }
.status, .success { color: var(--success) !important; }
.error { color: var(--danger) !important; }
label { display: block; margin: .45rem 0 .15rem; font-weight: 700; }
input, select, textarea {
    min-height: 31px;
    color: var(--text) !important;
    background: var(--surface) !important;
    border: 1px solid var(--border) !important;
    border-radius: 2px;
    padding: .35rem .45rem !important;
    margin: 0;
}
input:focus, select:focus, textarea:focus { outline: 2px solid color-mix(in srgb, var(--primary) 35%, transparent); border-color: var(--primary) !important; }
button {
    min-height: 31px;
    color: #fff;
    background: var(--primary);
    border: 1px solid var(--primary-hover);
    border-radius: 2px;
    padding: .35rem .7rem;
    font-weight: 700;
    cursor: pointer;
}
button:hover { background: var(--primary-hover); }
form { color: var(--text); background: var(--surface) !important; }
table { width: 100%; border-collapse: collapse; }
th, td { padding: .42rem .55rem; text-align: left; border: 1px solid var(--border); vertical-align: middle; }
th { color: var(--text); background: var(--surface-alt); font-weight: 700; white-space: nowrap; }
tbody tr:nth-child(even) { background: color-mix(in srgb, var(--surface-alt) 55%, transparent); }
tbody tr:hover { background: color-mix(in srgb, var(--primary) 12%, var(--surface)); }
.table-wrap { overflow: auto; }
.filterbar { display: grid; grid-template-columns: minmax(16rem, 2fr) minmax(12rem, 1fr) auto auto; gap: .5rem; align-items: end; }
.actions { display: flex; gap: .4rem; flex-wrap: wrap; align-items: center; }
.modal-backdrop { position: fixed; inset: 0; z-index: 20; display: none; align-items: center; justify-content: center; padding: 1rem; background: rgba(0,0,0,.48); }
.modal-backdrop.is-open { display: flex; }
.modal { width: min(36rem, 100%); max-height: calc(100vh - 2rem); overflow: auto; padding: 1rem; background: var(--surface); border: 1px solid var(--border); border-radius: 2px; }
.modal-header { display: flex; justify-content: space-between; align-items: center; border-bottom: 1px solid var(--border); padding-bottom: .6rem; }
.modal-close { min-width: 2rem; padding: .25rem .5rem; background: transparent; color: var(--text); border: 1px solid var(--border); }
.theme-toggle { position: fixed; right: 1rem; bottom: 1rem; z-index: 10; }
@media (max-width: 800px) {
    .app-shell { display: block; }
    .app-sidebar { position: static; }
    .app-sidebar nav { display: flex; overflow-x: auto; }
    .app-sidebar nav a { white-space: nowrap; }
    .app-content { padding: .5rem; }
    .filterbar { grid-template-columns: 1fr; }
    .card { margin: .5rem; }
    .bar { align-items: flex-start; }
    table { min-width: 760px; }
}
