:root {
    color-scheme: light;
    --bg: #f3f5f8;
    --panel: #ffffff;
    --text: #18212f;
    --muted: #667085;
    --border: #d9dee7;
    --primary: #2f5bea;
    --primary-dark: #2447b9;
    --success: #16803b;
    --success-soft: #eaf8ef;
    --warning: #9a5b00;
    --warning-soft: #fff5db;
    --danger: #b42318;
    --danger-soft: #fff0ee;
    --neutral-soft: #eef1f5;
    --sidebar: #111827;
    --sidebar-soft: #1f2937;
    --shadow: 0 8px 28px rgba(16, 24, 40, .06);
    --radius: 14px;
}

* { box-sizing: border-box; }
html { min-height: 100%; }
body {
    margin: 0;
    min-height: 100vh;
    background: var(--bg);
    color: var(--text);
    font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
    line-height: 1.45;
}
a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }
button, input, select, textarea { font: inherit; }
button { cursor: pointer; }

.app-shell { display: flex; min-height: 100vh; }
.sidebar {
    position: fixed;
    inset: 0 auto 0 0;
    z-index: 20;
    display: flex;
    width: 260px;
    flex-direction: column;
    padding: 22px 16px;
    overflow-y: auto;
    background: var(--sidebar);
    color: white;
}
.brand {
    display: flex;
    align-items: center;
    gap: 12px;
    margin: 0 6px 24px;
    color: white;
    text-decoration: none;
}
.brand:hover { text-decoration: none; }
.brand-mark {
    display: inline-flex;
    width: 44px;
    height: 44px;
    align-items: center;
    justify-content: center;
    border-radius: 12px;
    background: linear-gradient(135deg, #5f7fff, #2f5bea);
    color: white;
    font-weight: 800;
    letter-spacing: .03em;
}
.brand strong, .brand small { display: block; }
.brand small { margin-top: 2px; color: #aab5c5; font-size: 12px; }
.nav { display: flex; flex: 1; flex-direction: column; gap: 4px; }
.nav a {
    padding: 10px 12px;
    border-radius: 9px;
    color: #d1d5db;
    font-size: 14px;
    text-decoration: none;
}
.nav a:hover, .nav a.active { background: var(--sidebar-soft); color: white; }
.nav-section {
    margin: 18px 12px 5px;
    color: #7f8a9b;
    font-size: 11px;
    font-weight: 800;
    letter-spacing: .08em;
    text-transform: uppercase;
}
.sidebar-footer { margin-top: 24px; border-top: 1px solid #2f3948; padding-top: 16px; }
.user-card { margin: 0 4px 12px; }
.user-card strong, .user-card small { display: block; }
.user-card small { margin-top: 2px; color: #9ca3af; }

.content-shell { width: calc(100% - 260px); margin-left: 260px; }
.topbar {
    display: flex;
    min-height: 92px;
    align-items: center;
    justify-content: space-between;
    gap: 20px;
    padding: 18px 30px;
    border-bottom: 1px solid var(--border);
    background: rgba(255, 255, 255, .92);
    backdrop-filter: blur(10px);
}
.topbar h1 { margin: 0; font-size: 25px; }
.topbar p { margin: 4px 0 0; color: var(--muted); }
.topbar-user { text-align: right; }
.topbar-user span, .topbar-user small { display: block; }
.topbar-user small { color: var(--muted); }
.mobile-menu { display: none; border: 0; background: transparent; font-size: 24px; }
.main-content { width: min(1600px, 100%); margin: 0 auto; padding: 28px 30px 60px; }

.notice {
    margin-bottom: 20px;
    padding: 13px 15px;
    border: 1px solid transparent;
    border-radius: 10px;
    font-weight: 600;
}
.notice-success { border-color: #8dd7a5; background: var(--success-soft); color: #11622e; }
.notice-error { border-color: #f2a9a3; background: var(--danger-soft); color: var(--danger); }
.notice-warning { border-color: #efcc7f; background: var(--warning-soft); color: var(--warning); }

.stats-grid {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 16px;
    margin-bottom: 22px;
}
.stat-card {
    display: block;
    min-height: 140px;
    padding: 19px;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: var(--panel);
    box-shadow: var(--shadow);
    color: var(--text);
    text-decoration: none;
}
.stat-card:hover { border-color: #a9b9ef; text-decoration: none; transform: translateY(-1px); }
.stat-card span, .stat-card small { display: block; }
.stat-card span { color: var(--muted); font-size: 13px; font-weight: 700; }
.stat-card strong { display: block; margin: 8px 0 4px; font-size: 34px; line-height: 1; }
.stat-card small { color: var(--muted); }
.stat-card-success { border-left: 5px solid var(--success); }
.stat-card-warning { border-left: 5px solid #e4a11b; }
.stat-card-danger { border-left: 5px solid var(--danger); }

.grid-two { display: grid; grid-template-columns: 1.2fr .8fr; gap: 20px; }
.panel {
    margin-bottom: 22px;
    padding: 22px;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: var(--panel);
    box-shadow: var(--shadow);
}
.compact-panel { padding-bottom: 18px; }
.panel h2, .panel h3 { margin-top: 0; }
.panel-header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 18px;
    margin-bottom: 18px;
}
.panel-header h2 { margin: 0 0 4px; font-size: 19px; }
.panel-header p { margin: 0; color: var(--muted); }
.count-badge {
    display: inline-flex;
    min-width: 34px;
    height: 34px;
    align-items: center;
    justify-content: center;
    border-radius: 999px;
    background: var(--neutral-soft);
    font-weight: 800;
}
.action-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
.action-card {
    padding: 16px;
    border: 1px solid var(--border);
    border-radius: 11px;
    background: #fafbfc;
    color: var(--text);
    text-decoration: none;
}
.action-card:hover { border-color: #9db0ed; text-decoration: none; }
.action-card strong, .action-card span { display: block; }
.action-card span { margin-top: 5px; color: var(--muted); font-size: 13px; }
.timeline { display: grid; gap: 12px; }
.timeline-item { padding-bottom: 11px; border-bottom: 1px solid #edf0f4; }
.timeline-item:last-child { padding-bottom: 0; border-bottom: 0; }
.timeline-item strong, .timeline-item span, .timeline-item small { display: block; }
.timeline-item span { margin: 2px 0; }
.timeline-item small { color: var(--muted); }

.toolbar { display: flex; flex-wrap: wrap; gap: 10px; }
.button {
    display: inline-flex;
    min-height: 39px;
    align-items: center;
    justify-content: center;
    gap: 7px;
    padding: 9px 13px;
    border: 1px solid transparent;
    border-radius: 9px;
    font-weight: 750;
    text-decoration: none;
}
.button:hover { text-decoration: none; filter: brightness(.98); }
.button-primary { border-color: var(--primary); background: var(--primary); color: white; }
.button-primary:hover { background: var(--primary-dark); }
.button-secondary { border-color: var(--border); background: #f7f8fa; color: var(--text); }
.button-success { background: var(--success); color: white; }
.button-danger { background: var(--danger); color: white; }
.button-ghost { border-color: #384454; background: transparent; color: #d1d5db; }
.button-small { min-height: 33px; padding: 6px 10px; font-size: 12px; }
.button-full { width: 100%; }

.table-wrap { width: 100%; overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
th, td { padding: 12px 11px; border-bottom: 1px solid #e9edf2; text-align: left; vertical-align: top; }
th { background: #f8f9fb; color: #475467; font-size: 12px; letter-spacing: .02em; text-transform: uppercase; }
tbody tr:hover { background: #fbfcfe; }
.small-cell { max-width: 320px; color: var(--muted); font-size: 12px; }
.json-cell { max-width: 420px; overflow-wrap: anywhere; }
code { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: 12px; }
.muted { color: var(--muted); font-size: 12px; }
.status-pill {
    display: inline-flex;
    align-items: center;
    padding: 4px 8px;
    border-radius: 999px;
    font-size: 11px;
    font-weight: 800;
}
.status-success { background: var(--success-soft); color: var(--success); }
.status-warning { background: var(--warning-soft); color: var(--warning); }
.status-danger { background: var(--danger-soft); color: var(--danger); }
.status-neutral { background: var(--neutral-soft); color: #596273; }
.inline-action { margin-top: 7px; }

.cards-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 14px; }
.property-card { padding: 18px; border: 1px solid var(--border); border-radius: 12px; background: #fbfcfe; }
.property-card-head { display: flex; justify-content: space-between; gap: 12px; }
.property-card h3 { margin: 0; font-size: 16px; }
.property-card-head span { color: var(--muted); font-size: 12px; }
.property-card p { min-height: 40px; color: var(--muted); }

.stack-form { display: grid; gap: 13px; }
.form-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 14px; }
.form-actions { display: flex; align-items: flex-end; }
.inline-form { display: flex; flex-wrap: wrap; align-items: center; gap: 7px; }
.wide-form { min-width: 560px; }
label { display: grid; gap: 6px; color: #344054; font-size: 13px; font-weight: 750; }
input, select, textarea {
    width: 100%;
    min-height: 40px;
    padding: 9px 10px;
    border: 1px solid #cfd5df;
    border-radius: 8px;
    background: white;
    color: var(--text);
    outline: none;
}
input:focus, select:focus, textarea:focus { border-color: #6d88e9; box-shadow: 0 0 0 3px rgba(47, 91, 234, .11); }
.inline-form input, .inline-form select { width: auto; min-width: 150px; }
.wide-form select { min-width: 260px; }
.wide-form input { min-width: 180px; }

.link-list { display: flex; flex-wrap: wrap; gap: 8px 12px; font-size: 12px; }
.link-list.vertical { flex-direction: column; align-items: flex-start; }
.empty-state { padding: 24px; border-radius: 10px; background: #f7f8fa; color: var(--muted); text-align: center; }
.success-state { background: var(--success-soft); color: var(--success); }
.check-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 12px; }
.check-card { display: flex; justify-content: space-between; gap: 10px; padding: 16px; border-radius: 10px; }
.check-ok { background: var(--success-soft); color: var(--success); }
.check-error { background: var(--danger-soft); color: var(--danger); }

.login-page { display: grid; min-height: 100vh; place-items: center; padding: 24px; background: radial-gradient(circle at top, #e8edff, var(--bg) 52%); }
.login-card { width: min(430px, 100%); padding: 32px; border: 1px solid var(--border); border-radius: 18px; background: white; box-shadow: 0 24px 80px rgba(16, 24, 40, .12); }
.login-brand { display: flex; align-items: center; gap: 12px; margin-bottom: 30px; }
.login-brand strong, .login-brand small { display: block; }
.login-brand small { color: var(--muted); }
.login-card h1 { margin: 0 0 6px; }
.login-card > .muted { margin: 0 0 22px; }

@media (max-width: 1250px) {
    .stats-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .cards-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .form-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

@media (max-width: 900px) {
    .sidebar { transform: translateX(-100%); transition: transform .2s ease; }
    body.menu-open .sidebar { transform: translateX(0); }
    .content-shell { width: 100%; margin-left: 0; }
    .mobile-menu { display: inline-block; }
    .topbar { padding: 16px 18px; }
    .topbar-user { display: none; }
    .main-content { padding: 20px 16px 50px; }
    .grid-two, .cards-grid, .check-grid { grid-template-columns: 1fr; }
    .wide-form { min-width: 650px; }
}

@media (max-width: 620px) {
    .stats-grid, .action-grid, .form-grid { grid-template-columns: 1fr; }
    .panel { padding: 16px; }
    .topbar h1 { font-size: 20px; }
}
