:root {
    color-scheme: dark;
    --bg: #080b12;
    --surface: #101622;
    --surface-2: #151d2c;
    --surface-3: #1b2536;
    --border: rgba(148, 163, 184, .18);
    --text: #e5edf7;
    --muted: #91a0b8;
    --blue: #3b82f6;
    --green: #22c55e;
    --orange: #f59e0b;
    --red: #ef4444;
    --gray: #64748b;
    --shadow: 0 18px 60px rgba(0, 0, 0, .38);
}

* { box-sizing: border-box; }
html { min-height: 100%; }
body {
    margin: 0;
    min-height: 100%;
    background: radial-gradient(circle at top left, rgba(59, 130, 246, .12), transparent 34%), var(--bg);
    color: var(--text);
    font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
    font-size: 15px;
    line-height: 1.5;
}
a { color: inherit; text-decoration: none; }
small, .muted { color: var(--muted); }
h1, h2, h3, p { margin-top: 0; }
h1 { margin-bottom: 0; font-size: 30px; letter-spacing: 0; }
h2 { font-size: 20px; margin-bottom: 16px; }
h3 { font-size: 16px; margin-bottom: 8px; }

.app-shell { display: grid; grid-template-columns: 280px minmax(0, 1fr); min-height: 100vh; }
.sidebar {
    position: sticky;
    top: 0;
    height: 100vh;
    padding: 22px;
    border-right: 1px solid var(--border);
    background: rgba(12, 17, 27, .92);
    backdrop-filter: blur(20px);
    display: flex;
    flex-direction: column;
    gap: 24px;
}
.brand, .sidebar-footer { display: flex; align-items: center; gap: 12px; }
.brand small, .sidebar-footer small { display: block; color: var(--muted); }
.brand-mark {
    display: grid;
    place-items: center;
    width: 44px;
    height: 44px;
    border-radius: 8px;
    background: linear-gradient(135deg, #38bdf8, #22c55e);
    color: #061018;
    font-weight: 900;
}
.brand-mark.large { width: 66px; height: 66px; font-size: 23px; }
.nav { display: grid; gap: 6px; }
.nav a, .nav-button {
    width: 100%;
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 11px 12px;
    border: 1px solid transparent;
    border-radius: 8px;
    color: var(--muted);
    background: transparent;
    font: inherit;
    text-align: left;
    cursor: pointer;
}
.nav a:hover, .nav a.active, .nav-button:hover { color: var(--text); border-color: var(--border); background: var(--surface-2); }
.logout-form { margin-top: 10px; }
.sidebar-footer { margin-top: auto; padding-top: 18px; border-top: 1px solid var(--border); }
.avatar { width: 36px; height: 36px; border-radius: 8px; display: grid; place-items: center; background: var(--avatar); color: #061018; font-weight: 800; }

.main { padding: 26px; min-width: 0; }
.topbar { display: flex; align-items: center; justify-content: space-between; gap: 16px; margin-bottom: 22px; }
.eyebrow { margin-bottom: 4px; color: #7dd3fc; text-transform: uppercase; font-size: 12px; font-weight: 800; letter-spacing: .08em; }
.topbar-actions, .toolbar, .button-row { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.toolbar { justify-content: space-between; margin-bottom: 16px; }

.panel, .project-card, .detail-hero, .auth-card {
    border: 1px solid var(--border);
    background: linear-gradient(180deg, rgba(21, 29, 44, .95), rgba(13, 19, 31, .95));
    border-radius: 8px;
    box-shadow: var(--shadow);
}
.panel { padding: 18px; min-width: 0; }
.panel-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.panel-head.outside { margin: 20px 0 12px; }
.panel-head h2, .panel-head h3 { margin-bottom: 0; }
.grid { display: grid; gap: 18px; margin-bottom: 18px; }
.grid.two { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.grid.three { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.metric-grid { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.cards-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); gap: 18px; }

.metric-grid { display: grid; gap: 16px; margin-bottom: 18px; }
.metric, .stat { padding: 18px; border-radius: 8px; background: var(--surface); border: 1px solid var(--border); }
.metric span, .stat span { display: block; font-size: 30px; font-weight: 900; }
.metric p, .stat p { margin: 0; color: var(--muted); }
.metric.danger span { color: var(--red); }
.metric.warning span { color: var(--orange); }
.metric.info span { color: var(--blue); }
.metric.success span { color: var(--green); }

.project-card { padding: 18px; transition: transform .16s ease, border-color .16s ease; }
.project-card:hover { transform: translateY(-2px); border-color: rgba(59, 130, 246, .55); }
.project-card dl, .variant dl { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; margin: 16px 0 0; }
dt { color: var(--muted); font-size: 12px; }
dd { margin: 0; font-weight: 700; }
.details { display: grid; gap: 12px; }
.details div { display: flex; justify-content: space-between; gap: 16px; border-bottom: 1px solid var(--border); padding-bottom: 10px; }

.detail-hero { padding: 22px; margin-bottom: 16px; display: flex; justify-content: space-between; gap: 18px; }
.detail-hero p { max-width: 900px; color: var(--muted); }
.overdue-hero { border-color: rgba(239, 68, 68, .55); }
.tabs { display: flex; gap: 8px; overflow-x: auto; margin-bottom: 18px; }
.tabs a { white-space: nowrap; padding: 10px 12px; border-radius: 8px; color: var(--muted); border: 1px solid var(--border); background: var(--surface); }
.tabs a.active, .tabs a:hover { color: var(--text); background: var(--surface-3); }

.table-wrap { overflow-x: auto; border: 1px solid var(--border); border-radius: 8px; background: rgba(16, 22, 34, .72); }
table { width: 100%; border-collapse: collapse; min-width: 780px; }
th, td { text-align: left; padding: 13px 14px; border-bottom: 1px solid var(--border); vertical-align: top; }
th { color: #b8c4d8; font-size: 12px; text-transform: uppercase; letter-spacing: .08em; background: rgba(27, 37, 54, .8); }
td a { color: #bfdbfe; font-weight: 750; }
td small { display: block; max-width: 520px; margin-top: 3px; }
tr.is-overdue { background: rgba(239, 68, 68, .08); }
.empty { color: var(--muted); text-align: center; padding: 24px; }

.badge { display: inline-flex; align-items: center; min-height: 26px; padding: 4px 9px; border-radius: 999px; font-size: 12px; font-weight: 800; border: 1px solid transparent; white-space: nowrap; }
.badge.success, .btn.success { background: rgba(34, 197, 94, .14); color: #86efac; border-color: rgba(34, 197, 94, .35); }
.badge.warning { background: rgba(245, 158, 11, .14); color: #fcd34d; border-color: rgba(245, 158, 11, .35); }
.badge.danger, .btn.danger { background: rgba(239, 68, 68, .14); color: #fca5a5; border-color: rgba(239, 68, 68, .35); }
.badge.info { background: rgba(59, 130, 246, .14); color: #93c5fd; border-color: rgba(59, 130, 246, .35); }
.badge.muted { background: rgba(100, 116, 139, .14); color: #cbd5e1; border-color: rgba(100, 116, 139, .35); }

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    min-height: 40px;
    padding: 9px 14px;
    border: 1px solid var(--border);
    border-radius: 8px;
    background: var(--surface-2);
    color: var(--text);
    font-weight: 800;
    cursor: pointer;
}
.btn.primary { background: linear-gradient(135deg, #2563eb, #0891b2); border-color: transparent; color: white; }
.btn.ghost { background: transparent; color: #cbd5e1; }
.btn.wide { width: 100%; }

input, select, textarea {
    width: 100%;
    margin-top: 7px;
    border: 1px solid var(--border);
    background: #0b101a;
    color: var(--text);
    border-radius: 8px;
    padding: 11px 12px;
    font: inherit;
}
textarea { resize: vertical; }
label { display: block; color: #cbd5e1; font-weight: 750; }
.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; }
.form-panel { display: grid; gap: 14px; }
.span-2 { grid-column: span 2; }
.check { display: flex; align-items: center; gap: 8px; }
.check input { width: auto; margin: 0; }

.list, .activity, .variant-list { display: grid; gap: 10px; }
.list-row { display: flex; justify-content: space-between; gap: 12px; align-items: center; padding: 12px; border: 1px solid var(--border); border-radius: 8px; background: rgba(11, 16, 26, .72); }
.list-row small { display: block; }
.activity div { display: grid; grid-template-columns: 12px 1fr; gap: 12px; }
.activity span { width: 10px; height: 10px; margin-top: 7px; border-radius: 999px; background: var(--blue); box-shadow: 0 0 0 5px rgba(59, 130, 246, .12); }
.activity p { margin: 0; color: #cbd5e1; }
.activity strong, .activity small { display: block; }

.timeline { position: relative; display: grid; gap: 14px; }
.timeline-item { display: grid; grid-template-columns: 150px 1fr; gap: 18px; }
.timeline-item time { color: var(--muted); font-size: 13px; }
.timeline-item > div { padding: 14px; border: 1px solid var(--border); border-radius: 8px; background: rgba(11, 16, 26, .72); }
.timeline-item h3 { margin: 8px 0 2px; }
.timeline-item p { margin: 0; color: var(--muted); }

.variant { padding: 14px; border: 1px solid var(--border); border-radius: 8px; background: rgba(11, 16, 26, .78); }
.variant.selected { border-color: rgba(59, 130, 246, .55); }
.action-card { display: grid; place-items: center; min-height: 90px; border: 1px dashed rgba(125, 211, 252, .45); border-radius: 8px; color: #bfdbfe; background: rgba(59, 130, 246, .08); font-weight: 900; }
hr { border: 0; border-top: 1px solid var(--border); margin: 18px 0; }

.modal-backdrop {
    position: fixed;
    inset: 0;
    z-index: 50;
    display: grid;
    place-items: center;
    padding: 18px;
    background: rgba(2, 6, 23, .72);
    backdrop-filter: blur(10px);
}
.modal { width: min(620px, 100%); }

.flash { margin: 0 0 16px; padding: 12px 14px; border-radius: 8px; border: 1px solid var(--border); background: var(--surface-2); }
.flash.success { border-color: rgba(34, 197, 94, .35); color: #86efac; }
.flash.error { border-color: rgba(239, 68, 68, .35); color: #fca5a5; }

.auth-body { min-height: 100vh; display: grid; place-items: center; padding: 24px; }
.auth-card { width: min(980px, 100%); padding: 24px; display: grid; grid-template-columns: 1.1fr .9fr; gap: 24px; }
.auth-hero { padding: 30px; display: grid; align-content: center; }
.auth-hero h1 { font-size: 48px; margin: 18px 0 10px; }
.auth-hero p { max-width: 520px; color: var(--muted); font-size: 18px; }
.demo-users { display: grid; gap: 4px; padding-top: 10px; color: var(--muted); }
.demo-users strong { color: var(--text); }

@media (max-width: 980px) {
    .app-shell { grid-template-columns: 1fr; }
    .sidebar { position: static; height: auto; }
    .nav { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .grid.two, .grid.three, .metric-grid, .auth-card { grid-template-columns: 1fr; }
    .topbar, .detail-hero { align-items: flex-start; flex-direction: column; }
    .form-grid { grid-template-columns: 1fr; }
    .span-2 { grid-column: auto; }
}

@media (max-width: 620px) {
    .main, .sidebar { padding: 16px; }
    h1 { font-size: 24px; }
    .nav { grid-template-columns: 1fr; }
    .timeline-item { grid-template-columns: 1fr; }
    .auth-hero { padding: 8px; }
    .auth-hero h1 { font-size: 36px; }
}
