:root {
    --ink: #18211c;
    --muted: #6e7972;
    --line: #dce4df;
    --surface: #ffffff;
    --background: #f2f5f1;
    --accent: #ff6f47;
    --accent-dark: #ce4d2d;
    --green: #2d7852;
    --amber: #a45b13;
    --sidebar: #15251e;
    --sidebar-muted: #9eada5;
    --radius: 18px;
    --shadow: 0 18px 45px rgba(28, 47, 38, .08);
    color-scheme: light;
    font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* { box-sizing: border-box; }

html { min-height: 100%; background: var(--background); }

body {
    min-height: 100vh;
    margin: 0;
    background: var(--background);
    color: var(--ink);
}

a { color: inherit; text-decoration: none; }
button, input, select { font: inherit; }

.sidebar {
    position: fixed;
    inset: 0 auto 0 0;
    z-index: 10;
    display: flex;
    width: 248px;
    flex-direction: column;
    padding: 28px 20px;
    overflow-y: auto;
    color: #f5faf6;
    background:
        radial-gradient(circle at 0 0, rgba(255, 111, 71, .22), transparent 36%),
        var(--sidebar);
}

.brand { display: flex; align-items: center; gap: 12px; margin: 0 8px 36px; }
.brand strong { display: block; font-size: 19px; letter-spacing: .02em; }
.brand small { display: block; margin-top: 2px; color: var(--sidebar-muted); font-size: 11px; text-transform: uppercase; letter-spacing: .16em; }
.brand-mark { display: grid; width: 42px; height: 42px; place-items: center; border-radius: 13px; background: var(--accent); color: white; font-weight: 800; box-shadow: 0 10px 25px rgba(255, 111, 71, .25); }

.sidebar nav { display: grid; gap: 5px; }
.sidebar nav a { display: flex; align-items: center; gap: 12px; padding: 11px 13px; border-radius: 11px; color: #c5d0ca; font-size: 14px; transition: .15s ease; }
.sidebar nav a span { display: grid; width: 24px; place-items: center; color: #819289; font-size: 17px; }
.sidebar nav a:hover, .sidebar nav a.active { background: rgba(255, 255, 255, .09); color: white; }
.sidebar nav a.active span { color: var(--accent); }

.sidebar-bottom { display: grid; gap: 14px; margin-top: auto; padding: 28px 8px 0; font-size: 13px; }
.sidebar-bottom > a { color: #d8e1dc; }
.database-pill { width: max-content; padding: 7px 10px; border: 1px solid rgba(255,255,255,.12); border-radius: 999px; color: var(--sidebar-muted); font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 11px; }

.page { min-height: 100vh; margin-left: 248px; padding: 36px clamp(24px, 4vw, 64px) 64px; }
.topbar { display: flex; align-items: center; justify-content: space-between; gap: 24px; margin-bottom: 30px; }
.topbar h1 { margin: 4px 0 0; font-size: clamp(27px, 3vw, 42px); line-height: 1.1; letter-spacing: -.035em; }
.eyebrow { display: block; color: var(--accent-dark); font-size: 11px; font-weight: 800; text-transform: uppercase; letter-spacing: .15em; }
.user-area { display: flex; align-items: center; gap: 14px; color: var(--muted); font-size: 13px; }
.user-area form { margin: 0; }
.user-area button { padding: 8px 12px; border: 1px solid var(--line); border-radius: 9px; background: white; color: var(--ink); cursor: pointer; }

.metrics-grid { display: grid; grid-template-columns: repeat(6, minmax(120px, 1fr)); gap: 14px; margin-bottom: 18px; }
.metric-card { display: flex; min-height: 130px; flex-direction: column; justify-content: space-between; padding: 20px; border: 1px solid rgba(24, 33, 28, .06); border-radius: var(--radius); background: var(--surface); box-shadow: var(--shadow); transition: transform .15s ease, box-shadow .15s ease; }
.metric-card:hover { transform: translateY(-2px); box-shadow: 0 22px 50px rgba(28, 47, 38, .12); }
.metric-card span { color: var(--muted); font-size: 13px; }
.metric-card strong { font-size: 30px; letter-spacing: -.04em; }

.panel { margin-bottom: 18px; padding: 24px; border: 1px solid rgba(24, 33, 28, .07); border-radius: var(--radius); background: var(--surface); box-shadow: var(--shadow); }
.panel.flush { padding: 0; overflow: hidden; }
.panel h2 { margin: 3px 0 0; font-size: 20px; letter-spacing: -.02em; }
.panel p { color: var(--muted); line-height: 1.65; }
.panel code { padding: 2px 6px; border-radius: 5px; background: #edf1ee; font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: .9em; }
.panel-head { display: flex; align-items: center; justify-content: space-between; gap: 18px; margin-bottom: 20px; }
.panel-head > a, .panel-head > span { color: var(--muted); font-size: 13px; }
.split-grid { display: grid; grid-template-columns: minmax(0, 1.55fr) minmax(280px, .75fr); gap: 18px; }
.accent-panel { background: linear-gradient(135deg, #fff 55%, #f0f7f2); }
.note-panel { background: #fdf4ee; }
.fact-grid { display: grid; grid-template-columns: repeat(3, minmax(100px, 1fr)); gap: 22px; }
.fact-grid div { display: grid; gap: 4px; }
.fact-grid strong { font-size: 22px; letter-spacing: -.03em; }
.fact-grid span { color: var(--muted); font-size: 12px; line-height: 1.4; }

.filterbar { display: flex; align-items: end; gap: 12px; margin-bottom: 18px; padding: 18px; border: 1px solid var(--line); border-radius: 14px; background: rgba(255,255,255,.72); }
.filterbar label, .login-form label { display: grid; gap: 7px; color: var(--muted); font-size: 11px; font-weight: 750; text-transform: uppercase; letter-spacing: .08em; }
.filterbar label.grow { flex: 1; }
input, select { min-height: 42px; padding: 9px 12px; border: 1px solid #cfd9d3; border-radius: 9px; outline: none; background: white; color: var(--ink); }
input:focus, select:focus { border-color: var(--green); box-shadow: 0 0 0 3px rgba(45, 120, 82, .1); }
.button { min-height: 42px; padding: 9px 17px; border: 0; border-radius: 9px; background: var(--sidebar); color: white; font-weight: 700; cursor: pointer; }
.button.primary { width: 100%; background: var(--accent); }
.result-count { margin-left: auto; align-self: center; color: var(--muted); font-size: 13px; }
.request-summary { display: grid; grid-template-columns: repeat(2, minmax(200px, 1fr)); gap: 14px; margin-bottom: 18px; }
.request-summary a { display: flex; align-items: center; justify-content: space-between; padding: 18px 20px; border: 1px solid var(--line); border-radius: 14px; background: white; color: var(--muted); }
.request-summary a.active { border-color: var(--accent); box-shadow: 0 0 0 3px rgba(255, 111, 71, .08); color: var(--ink); }
.request-summary strong { font-size: 22px; }

.table-wrap { width: 100%; overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
th { padding: 12px 16px; border-bottom: 1px solid var(--line); background: #f7f9f7; color: var(--muted); font-size: 10px; text-align: left; text-transform: uppercase; letter-spacing: .1em; white-space: nowrap; }
td { padding: 14px 16px; border-bottom: 1px solid #edf0ee; font-size: 13px; vertical-align: middle; }
tbody tr:last-child td { border-bottom: 0; }
tbody tr:hover td { background: #fbfcfb; }
td small { display: block; margin-top: 4px; color: var(--muted); }
td.empty { padding: 36px; color: var(--muted); text-align: center; }
.tag { display: inline-flex; margin: 2px; padding: 4px 8px; border-radius: 999px; background: #e9eef0; color: #4b5960; font-size: 10px; font-weight: 750; text-transform: uppercase; letter-spacing: .05em; }
.tag.green { background: #e3f2e8; color: var(--green); }
.tag.amber { background: #fff0d9; color: var(--amber); }
.tag.muted { background: #eceeed; color: #78817c; }

.compact-list { display: grid; }
.compact-list > div { display: grid; grid-template-columns: 10px minmax(160px, 1fr) minmax(160px, 1fr) auto; align-items: center; gap: 12px; padding: 12px 0; border-bottom: 1px solid #edf0ee; font-size: 13px; }
.compact-list > div:last-child { border-bottom: 0; }
.compact-list > div > span:not(.dot), .compact-list time { color: var(--muted); }
.dot { width: 7px; height: 7px; border-radius: 50%; background: var(--accent); }

.schedule-grid { display: grid; grid-template-columns: repeat(2, minmax(320px, 1fr)); gap: 18px; }
.day-card { overflow: hidden; border: 1px solid rgba(24, 33, 28, .07); border-radius: var(--radius); background: white; box-shadow: var(--shadow); }
.day-card > header { display: grid; grid-template-columns: 44px 1fr auto; align-items: center; gap: 12px; padding: 18px 20px; border-bottom: 1px solid var(--line); }
.day-card > header > span { display: grid; width: 38px; height: 38px; place-items: center; border-radius: 11px; background: var(--sidebar); color: white; font-weight: 800; }
.day-card h2 { margin: 0; font-size: 18px; }
.day-card header small { color: var(--muted); }
.day-rows article { display: grid; grid-template-columns: 58px 1fr; gap: 14px; padding: 14px 20px; border-bottom: 1px solid #edf0ee; }
.day-rows article:last-child { border-bottom: 0; }
.day-rows time { color: var(--accent-dark); font-weight: 800; }
.day-rows div { display: grid; gap: 3px; }
.day-rows span, .day-rows small { color: var(--muted); font-size: 12px; }

.people-grid { display: grid; grid-template-columns: repeat(3, minmax(240px, 1fr)); gap: 16px; }
.person-card { padding: 20px; border: 1px solid rgba(24,33,28,.07); border-radius: var(--radius); background: white; box-shadow: var(--shadow); }
.avatar { display: grid; width: 46px; height: 46px; place-items: center; margin-bottom: 18px; border-radius: 50%; background: #e8efe9; color: var(--green); font-weight: 800; }
.person-head { display: flex; justify-content: space-between; gap: 12px; }
.person-head h2 { margin: 0; font-size: 17px; }
.person-head span { color: var(--muted); font-size: 11px; }
.status-dot { width: 9px; height: 9px; margin-top: 5px; border-radius: 50%; background: #aab2ad; }
.status-dot.active { background: #36a269; box-shadow: 0 0 0 4px #e4f5eb; }
.person-card > p { min-height: 54px; color: var(--muted); font-size: 12px; line-height: 1.5; }
.person-card dl { display: grid; grid-template-columns: 70px 1fr; gap: 8px; margin: 18px 0 0; font-size: 11px; }
.person-card dt { color: var(--muted); }
.person-card dd { margin: 0; }

.category-grid { display: grid; grid-template-columns: repeat(4, minmax(160px, 1fr)); gap: 14px; }
.category-grid article { position: relative; overflow: hidden; padding: 18px; border: 1px solid var(--line); border-radius: 13px; }
.color-bar { position: absolute; inset: 0 auto 0 0; width: 5px; background: var(--category-color, var(--accent)); }
.category-grid h3 { margin: 0 0 3px; font-size: 15px; }
.category-grid small { color: var(--muted); }
.category-grid ul { margin: 14px 0 0; padding-left: 18px; color: var(--muted); font-size: 12px; line-height: 1.65; }
.media-grid { display: grid; grid-template-columns: repeat(2, minmax(260px, 1fr)); gap: 14px; }
.media-grid article { display: grid; grid-template-columns: 100px 1fr; gap: 16px; overflow: hidden; border: 1px solid var(--line); border-radius: 13px; }
.media-grid img, .image-placeholder { width: 100px; height: 100%; min-height: 130px; object-fit: cover; background: #e8efe9; }
.image-placeholder { display: grid; place-items: center; color: var(--green); font-size: 28px; font-weight: 800; }
.media-grid article > div:last-child { padding: 16px 16px 16px 0; }
.media-grid h3 { margin: 0 0 7px; font-size: 15px; }
.media-grid p { margin: 0 0 8px; font-size: 12px; line-height: 1.5; }
.article-list { display: grid; gap: 10px; }
.article-list > div { display: flex; gap: 12px; align-items: center; padding-bottom: 10px; border-bottom: 1px solid #edf0ee; }
.article-list img { width: 54px; height: 54px; border-radius: 9px; object-fit: cover; }
.article-list span { display: grid; gap: 4px; }
.article-list strong { font-size: 13px; }
.article-list small { color: var(--muted); font-size: 10px; }
.article-list p { margin: 3px 0 0; font-size: 11px; line-height: 1.4; }
.photo-grid { display: grid; grid-template-columns: repeat(6, minmax(100px, 1fr)); gap: 10px; }
.photo-grid figure { margin: 0; overflow: hidden; border: 1px solid var(--line); border-radius: 11px; background: #f4f6f4; }
.photo-grid img { display: block; width: 100%; aspect-ratio: 1; object-fit: cover; }
.photo-grid figcaption { padding: 8px; overflow: hidden; color: var(--muted); font-size: 10px; text-overflow: ellipsis; white-space: nowrap; }

.table-groups { display: grid; grid-template-columns: repeat(2, minmax(350px, 1fr)); gap: 18px; }
.group-head { display: flex; justify-content: space-between; align-items: center; padding: 18px 20px; border-bottom: 1px solid var(--line); }
.group-head h2 { margin: 0; font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 16px; }
.group-head span { display: grid; min-width: 26px; height: 26px; place-items: center; border-radius: 50%; background: #edf2ee; color: var(--muted); font-size: 11px; }
.pagination { display: flex; align-items: center; justify-content: space-between; padding: 16px 20px; border-top: 1px solid var(--line); color: var(--muted); font-size: 12px; }
.empty-state { padding: 38px; border: 1px dashed #cad4ce; border-radius: var(--radius); color: var(--muted); text-align: center; }

.login-page { display: grid; place-items: center; padding: 24px; background: radial-gradient(circle at 20% 10%, rgba(255,111,71,.2), transparent 32%), var(--sidebar); }
.login-card { width: min(440px, 100%); padding: 38px; border-radius: 24px; background: white; box-shadow: 0 30px 90px rgba(0,0,0,.3); }
.login-brand { margin-bottom: 26px; }
.login-card h1 { margin: 6px 0 8px; font-size: 34px; letter-spacing: -.04em; }
.login-card > p { margin: 0 0 24px; color: var(--muted); line-height: 1.6; }
.login-form { display: grid; gap: 16px; }
.form-error { margin-bottom: 16px; padding: 11px 13px; border-radius: 9px; background: #ffebe6; color: #9d351f; font-size: 13px; }

@media (max-width: 1250px) {
    .metrics-grid { grid-template-columns: repeat(3, 1fr); }
    .people-grid { grid-template-columns: repeat(2, 1fr); }
    .photo-grid { grid-template-columns: repeat(4, 1fr); }
}

@media (max-width: 850px) {
    .sidebar { position: static; width: 100%; padding: 18px; }
    .brand { margin-bottom: 16px; }
    .sidebar nav { display: flex; overflow-x: auto; }
    .sidebar nav a { flex: 0 0 auto; }
    .sidebar-bottom { display: none; }
    .page { margin-left: 0; padding: 24px 18px 48px; }
    .split-grid, .schedule-grid, .table-groups { grid-template-columns: 1fr; }
    .category-grid { grid-template-columns: repeat(2, 1fr); }
}

@media (max-width: 580px) {
    .topbar { align-items: flex-start; }
    .user-area > span { display: none; }
    .metrics-grid { grid-template-columns: repeat(2, 1fr); }
    .fact-grid, .people-grid, .media-grid, .category-grid { grid-template-columns: 1fr; }
    .request-summary { grid-template-columns: 1fr; }
    .filterbar { align-items: stretch; flex-direction: column; }
    .result-count { margin-left: 0; }
    .photo-grid { grid-template-columns: repeat(2, 1fr); }
    .compact-list > div { grid-template-columns: 10px 1fr; }
    .compact-list time { grid-column: 2; }
}
