/* Toshtaxi dashboard — small hand-written stylesheet, light and dark. */
:root {
    --bg: #f5f6f8;
    --surface: #ffffff;
    --surface-2: #f0f2f5;
    --text: #1d2430;
    --muted: #6b7280;
    --border: #e2e5ea;
    --primary: #2f6fdb;
    --primary-text: #ffffff;
    --primary-soft: #e8f0fd;
    --danger: #c63d3d;
    --ok-bg: #e7f6ec;
    --ok-text: #1f6b3a;
    --err-bg: #fdecec;
    --err-text: #9b2c2c;
    --sidebar: #17202e;
    --sidebar-text: #c9d1dc;
    --sidebar-active: #2a3649;
    --radius: 8px;
    --shadow: 0 1px 2px rgba(16, 24, 40, .06);
    color-scheme: light;
}

@media (prefers-color-scheme: dark) {
    :root:not([data-theme="light"]) {
        --bg: #10151d; --surface: #18202b; --surface-2: #202a37; --text: #e3e8ef; --muted: #96a0ae;
        --border: #2a3442; --primary: #5b8ff0; --primary-soft: #1f2e49; --ok-bg: #173323; --ok-text: #9fd9b3;
        --err-bg: #3a1c1c; --err-text: #f0a8a8; --sidebar: #0c1118; --sidebar-active: #1d2735; color-scheme: dark;
    }
}

:root[data-theme="dark"] {
    --bg: #10151d; --surface: #18202b; --surface-2: #202a37; --text: #e3e8ef; --muted: #96a0ae;
    --border: #2a3442; --primary: #5b8ff0; --primary-soft: #1f2e49; --ok-bg: #173323; --ok-text: #9fd9b3;
    --err-bg: #3a1c1c; --err-text: #f0a8a8; --sidebar: #0c1118; --sidebar-active: #1d2735; color-scheme: dark;
}

* { box-sizing: border-box; }

html, body { margin: 0; }

body {
    font: 14px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
    background: var(--bg);
    color: var(--text);
}

a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }

h1 { font-size: 22px; margin: 0 0 12px; }
h2 { font-size: 16px; margin: 0 0 12px; }
h3 { font-size: 14px; margin: 0 0 8px; }

.muted { color: var(--muted); }
.mono { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 13px; }
.nowrap { white-space: nowrap; }
.pre { white-space: pre-wrap; word-break: break-word; }
.num { text-align: right; font-variant-numeric: tabular-nums; }
.center { justify-content: center; }
form.inline { display: inline; margin: 0; }

/* Shell */
.shell { display: flex; min-height: 100vh; }

.sidebar {
    width: 220px;
    flex: 0 0 220px;
    background: var(--sidebar);
    color: var(--sidebar-text);
    padding: 14px 10px;
    position: sticky;
    top: 0;
    height: 100vh;
    overflow-y: auto;
}

.brand {
    display: flex; align-items: center; gap: 10px;
    color: #fff; font-weight: 600; font-size: 16px; padding: 4px 8px 14px;
}
.brand:hover { text-decoration: none; }
.brand img { border-radius: 6px; }

.nav { display: flex; flex-direction: column; gap: 2px; }
.nav a { color: var(--sidebar-text); padding: 8px 10px; border-radius: 6px; }
.nav a:hover { background: var(--sidebar-active); text-decoration: none; color: #fff; }
.nav a.active { background: var(--sidebar-active); color: #fff; font-weight: 600; }
.nav-section {
    font-size: 11px; text-transform: uppercase; letter-spacing: .06em;
    color: #7d8796; padding: 14px 10px 4px;
}

.main { flex: 1; min-width: 0; display: flex; flex-direction: column; }

.topbar {
    display: flex; align-items: center; gap: 12px;
    padding: 8px 20px; background: var(--surface); border-bottom: 1px solid var(--border);
    position: sticky; top: 0; z-index: 5;
}
.topbar .spacer { flex: 1; }
.who { display: flex; align-items: center; gap: 6px; }
.menu-toggle { display: none; }

.content { padding: 20px; max-width: 1500px; width: 100%; }

.lang-switch { display: flex; gap: 2px; }
.lang-switch a { padding: 3px 7px; border-radius: 5px; color: var(--muted); font-size: 12px; font-weight: 600; }
.lang-switch a.active { background: var(--primary-soft); color: var(--primary); }

/* Building blocks */
.card {
    background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
    padding: 16px; box-shadow: var(--shadow); margin-bottom: 16px;
}
.narrow { max-width: 480px; }
.page-head { display: flex; justify-content: space-between; align-items: center; gap: 12px; margin-bottom: 12px; }
.page-head h1 { margin: 0; }

.btn {
    display: inline-flex; align-items: center; justify-content: center;
    padding: 7px 14px; border-radius: 6px; border: 1px solid var(--border);
    background: var(--surface); color: var(--text); font: inherit; cursor: pointer; white-space: nowrap;
}
.btn:hover { background: var(--surface-2); text-decoration: none; }
.btn-primary { background: var(--primary); border-color: var(--primary); color: var(--primary-text); }
.btn-primary:hover { background: var(--primary); filter: brightness(1.08); }
.btn-danger { color: var(--danger); border-color: var(--danger); background: transparent; }
.btn-ghost { border-color: transparent; background: transparent; }
.btn-sm { padding: 3px 9px; font-size: 12px; }
.icon-btn {
    border: 1px solid var(--border); background: var(--surface); color: var(--text);
    border-radius: 6px; width: 32px; height: 32px; cursor: pointer; font-size: 16px;
}

.badge {
    display: inline-block; padding: 1px 7px; border-radius: 10px; font-size: 11px; font-weight: 600;
    background: var(--primary-soft); color: var(--primary);
}
.pill { display: inline-block; padding: 1px 8px; border-radius: 10px; font-size: 12px; background: var(--surface-2); }

.flash { padding: 10px 14px; border-radius: var(--radius); margin-bottom: 14px; }
.flash-ok { background: var(--ok-bg); color: var(--ok-text); }
.flash-error { background: var(--err-bg); color: var(--err-text); }

/* Forms */
.stack { display: flex; flex-direction: column; gap: 12px; }
.filters { display: flex; flex-wrap: wrap; gap: 12px; align-items: flex-end; }
.field { display: flex; flex-direction: column; gap: 4px; min-width: 160px; }
.field.grow { flex: 1; min-width: 220px; }
.field > span { font-size: 12px; color: var(--muted); font-weight: 600; }
.check { display: flex; align-items: center; gap: 8px; }
.actions { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }

input[type=text], input[type=search], input[type=password], input[type=date], select {
    font: inherit; color: var(--text); background: var(--surface);
    border: 1px solid var(--border); border-radius: 6px; padding: 7px 9px; min-height: 34px;
}
input:focus, select:focus { outline: 2px solid var(--primary-soft); border-color: var(--primary); }

/* Tables */
.table-wrap { overflow-x: auto; padding: 0; }
.table-wrap > .table, .table-wrap > h2, .table-wrap > p, .table-wrap > .pager { margin: 12px 16px; }
.table-wrap > .table { margin: 0; }
.table { width: 100%; border-collapse: collapse; }
.table th, .table td { padding: 8px 10px; border-bottom: 1px solid var(--border); text-align: left; vertical-align: top; }
.table th { font-size: 12px; color: var(--muted); font-weight: 600; background: var(--surface-2); }
.table th.num { text-align: right; }
.table tbody tr:hover { background: var(--surface-2); }
.table tr.selected { background: var(--primary-soft); }
.table tr.disabled td { color: var(--muted); }
.table tfoot th { background: transparent; color: var(--text); }
.excerpt { max-width: 560px; }

.props { display: grid; grid-template-columns: max-content 1fr; gap: 6px 16px; margin: 0; }
.props dt { color: var(--muted); }
.props dd { margin: 0; word-break: break-word; }

pre.json {
    background: var(--surface-2); border-radius: 6px; padding: 12px; overflow: auto;
    max-height: 520px; font-size: 12px; white-space: pre-wrap; word-break: break-word;
}
.message-text { font-size: 15px; }

.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--border); margin-bottom: 16px; flex-wrap: wrap; }
.tabs a { padding: 8px 14px; color: var(--muted); border-bottom: 2px solid transparent; margin-bottom: -1px; }
.tabs a:hover { text-decoration: none; color: var(--text); }
.tabs a.active { color: var(--primary); border-bottom-color: var(--primary); font-weight: 600; }

.pager { display: flex; gap: 10px; align-items: center; margin: 12px 0; }
.crumbs { margin-bottom: 10px; font-weight: 600; }

.assign summary { display: inline-flex; list-style: none; margin: 12px 0; }
.assign summary::-webkit-details-marker { display: none; }

/* Layout grids */
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 16px; }
.stat-label { color: var(--muted); font-size: 12px; font-weight: 600; text-transform: uppercase; letter-spacing: .04em; }
.stat-value { font-size: 28px; font-weight: 700; margin-top: 4px; font-variant-numeric: tabular-nums; }
.grid-2 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; }
.grid-2 > .card { margin-bottom: 0; }
.grid-2 { margin-bottom: 16px; }
.split { display: grid; grid-template-columns: minmax(280px, 2fr) minmax(0, 3fr); gap: 16px; align-items: start; }
.chart-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 16px; }
.chart-grid.single { grid-template-columns: 1fr; }
.chart-grid > .card { margin-bottom: 0; }
.chart { width: 100%; height: 300px; }
.chart-tall { height: 480px; }
.chart-grid.single .chart { height: 420px; }

/* Login / error */
.login-page { display: flex; align-items: center; justify-content: center; min-height: 100vh; padding: 16px; }
.login-box { width: 100%; max-width: 380px; }
.login-head { display: flex; flex-direction: column; align-items: center; gap: 8px; margin-bottom: 16px; }
.login-head h1 { font-size: 20px; margin: 0; }
.login-box .lang-switch { margin-top: 16px; }

@media (max-width: 1200px) {
    .chart-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

@media (max-width: 900px) {
    .sidebar { position: fixed; left: -240px; z-index: 20; transition: left .15s; }
    body.sidebar-open .sidebar { left: 0; }
    .menu-toggle { display: inline-block; }
    .grid-2, .split, .chart-grid { grid-template-columns: 1fr; }
    .content { padding: 14px; }
    .who span:first-child { display: none; }
}
