:root {
  color-scheme: dark;
  --background: #0b0e11;
  --surface: #11161c;
  --surface-raised: #171d24;
  --surface-hover: #1d252e;
  --border: #29313b;
  --border-soft: #202832;
  --text: #f0f2f4;
  --muted: #8b96a5;
  --subtle: #5f6b79;
  --yellow: #f0b90b;
  --yellow-soft: rgba(240, 185, 11, .12);
  --green: #0ecb81;
  --green-soft: rgba(14, 203, 129, .12);
  --red: #f6465d;
  --red-soft: rgba(246, 70, 93, .12);
  --blue: #5b9cf6;
  --blue-soft: rgba(91, 156, 246, .12);
  --radius: 12px;
  --shadow: 0 12px 32px rgba(0, 0, 0, .18);
}

* { box-sizing: border-box; }
html { min-width: 320px; background: var(--background); }
body { margin: 0; background: var(--background); color: var(--text); font-family: Dana, Tahoma, sans-serif; font-size: 14px; line-height: 1.8; }
body.sidebar-open { overflow: hidden; }
a { color: var(--yellow); text-decoration: none; }
a:hover { color: #ffd54f; }
button, input, select { font: inherit; }
button { cursor: pointer; }
button:disabled { cursor: not-allowed; opacity: .55; }
svg { display: block; width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-linecap: round; stroke-linejoin: round; stroke-width: 1.8; }

@font-face { font-family: Dana; src: url('/fonts/Dana-FaNum-Regular.ttf') format('truetype'); font-weight: 400; font-style: normal; font-display: swap; }
@font-face { font-family: Dana; src: url('/fonts/Dana-FaNum-DemiBold.ttf') format('truetype'); font-weight: 600; font-style: normal; font-display: swap; }
@font-face { font-family: Dana; src: url('/fonts/Dana-FaNum-Bold.ttf') format('truetype'); font-weight: 700; font-style: normal; font-display: swap; }

.app-shell { min-height: 100vh; }
.topbar { position: sticky; top: 0; z-index: 30; height: 72px; background: rgba(11, 14, 17, .94); border-bottom: 1px solid var(--border-soft); backdrop-filter: blur(18px); }
.topbar-inner { height: 100%; display: flex; align-items: center; gap: 18px; padding: 0 28px; }
.brand { display: inline-flex; align-items: center; gap: 12px; color: var(--text); min-width: 240px; }
.brand:hover { color: var(--text); }
.brand-mark { width: 40px; height: 40px; display: grid; place-items: center; border-radius: 11px; background: var(--yellow-soft); overflow: hidden; }
.brand-mark img { width: 32px; height: 32px; object-fit: contain; }
.brand-copy { display: flex; flex-direction: column; line-height: 1.2; }
.brand-copy strong { font-size: 17px; font-weight: 700; letter-spacing: -.25px; }
.brand-copy small { margin-top: 4px; color: var(--muted); font-size: 10px; }
.topbar-actions { display: flex; align-items: center; gap: 14px; margin-right: auto; }
.status-pill, .identity-chip { display: inline-flex; align-items: center; gap: 8px; border: 1px solid var(--border); border-radius: 999px; padding: 4px 11px; color: var(--muted); white-space: nowrap; font-size: 12px; }
.status-warning { border-color: rgba(240, 185, 11, .32); background: var(--yellow-soft); color: #f6cf57; }
.status-dot { width: 7px; height: 7px; border-radius: 50%; background: var(--yellow); box-shadow: 0 0 0 3px rgba(240, 185, 11, .12); }
.identity-chip { padding: 4px 9px 4px 12px; color: var(--text); background: var(--surface); }
.avatar { display: grid; place-items: center; width: 25px; height: 25px; border-radius: 50%; background: var(--yellow); color: #121212; font-size: 12px; font-weight: 700; }
.identity-name { max-width: 220px; overflow: hidden; text-overflow: ellipsis; direction: ltr; }
.mobile-menu-toggle { display: none; }

.page-layout { display: grid; grid-template-columns: 256px minmax(0, 1fr); min-height: calc(100vh - 72px); }
.login-page-layout { display: block; min-height: 100vh; }
.sidebar { display: flex; flex-direction: column; background: var(--surface); border-left: 1px solid var(--border-soft); }
.sidebar-scroll { flex: 1; padding: 26px 14px 18px; }
.nav-heading { margin: 0 11px 9px; color: var(--subtle); font-size: 11px; font-weight: 600; letter-spacing: .25px; }
.nav-heading:not(:first-child) { margin-top: 27px; }
.nav-list { display: grid; gap: 3px; }
.nav-item { position: relative; display: flex; align-items: center; gap: 12px; width: 100%; min-height: 42px; padding: 8px 12px; border: 0; border-radius: 8px; background: transparent; color: var(--muted); text-align: right; font-size: 13px; transition: background .18s ease, color .18s ease, transform .18s ease; }
.nav-item svg { flex: 0 0 18px; color: var(--subtle); }
.nav-item:hover { background: var(--surface-hover); color: var(--text); }
.nav-item.active { background: var(--yellow-soft); color: var(--yellow); font-weight: 600; }
.nav-item.active::before { content: ''; position: absolute; right: 0; top: 9px; bottom: 9px; width: 3px; border-radius: 3px 0 0 3px; background: var(--yellow); }
.nav-item.active svg { color: var(--yellow); }
.sidebar-footer { padding: 13px 14px 18px; border-top: 1px solid var(--border-soft); }
.logout-form { margin: 3px 0 0; }
.nav-button { appearance: none; }
.sidebar-backdrop { display: none; }

.main-content { min-width: 0; background: radial-gradient(circle at 86% 0, rgba(240, 185, 11, .04), transparent 30%), var(--background); }
.content-wrap { width: min(100%, 1380px); margin: 0 auto; padding: 38px 44px 56px; }
.page-header { display: flex; align-items: flex-start; justify-content: space-between; gap: 18px; margin-bottom: 28px; }
.page-header h1 { margin: 0; }
.page-header .page-actions { margin-top: 4px; }
h1 { color: var(--text); font-size: clamp(22px, 3vw, 30px); font-weight: 700; line-height: 1.4; letter-spacing: -.35px; }
h2 { margin: 0 0 16px; color: var(--text); font-size: 17px; font-weight: 600; line-height: 1.5; }
h3 { margin: 0 0 10px; color: var(--text); font-size: 15px; }
p { margin: 0 0 14px; color: var(--muted); }
.muted { color: var(--muted); }
.eyebrow { margin-bottom: 7px; color: var(--yellow); font-size: 11px; font-weight: 600; letter-spacing: .4px; }
.subtitle { max-width: 720px; color: var(--muted); }

.card { margin: 16px 0; padding: 22px; background: var(--surface); border: 1px solid var(--border-soft); border-radius: var(--radius); box-shadow: 0 4px 15px rgba(0, 0, 0, .08); }
.card:first-child { margin-top: 0; }
.card-header { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; margin-bottom: 18px; }
.card-header h2, .card-header h3 { margin: 0; }
.card-header p { margin: 4px 0 0; font-size: 12px; }
.card-accent { border-top: 2px solid var(--yellow); }
.card-danger { border-color: rgba(246, 70, 93, .38); }
.card-success { border-color: rgba(14, 203, 129, .35); }
.hero-card { position: relative; overflow: hidden; padding: 30px; background: linear-gradient(135deg, rgba(240, 185, 11, .13), transparent 42%), var(--surface); }
.hero-card::after { content: ''; position: absolute; left: -40px; bottom: -70px; width: 220px; height: 220px; border: 1px solid rgba(240, 185, 11, .15); border-radius: 50%; box-shadow: 0 0 0 22px rgba(240, 185, 11, .035), 0 0 0 44px rgba(240, 185, 11, .02); }
.hero-card > * { position: relative; z-index: 1; }
.hero-grid { display: grid; grid-template-columns: minmax(0, 1.3fr) minmax(260px, .7fr); align-items: center; gap: 22px; }

.metrics { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 13px; margin: 22px 0; }
.metric { position: relative; min-height: 125px; margin: 0; padding: 19px; overflow: hidden; }
.metric::before { content: ''; position: absolute; top: 0; right: 0; left: 0; height: 2px; background: var(--border); }
.metric:nth-child(1)::before { background: var(--yellow); }
.metric:nth-child(2)::before { background: var(--green); }
.metric:nth-child(3)::before { background: var(--blue); }
.metric-label { display: flex; align-items: center; gap: 8px; color: var(--muted); font-size: 12px; }
.metric-label svg { width: 16px; height: 16px; color: var(--subtle); }
.metric strong { display: block; margin-top: 8px; color: var(--text); font-size: clamp(21px, 3vw, 28px); font-weight: 700; line-height: 1.2; }
.metric .unit { margin-right: 4px; color: var(--muted); font-size: 11px; font-weight: 400; }
.value-positive { color: var(--green) !important; }
.value-negative { color: var(--red) !important; }
.value-neutral { color: var(--text) !important; }

.toolbar, .form-row { display: flex; flex-wrap: wrap; align-items: end; gap: 10px; }
.toolbar { margin: 18px 0; padding: 13px; border: 1px solid var(--border-soft); border-radius: var(--radius); background: rgba(17, 22, 28, .7); }
.toolbar-spacer { flex: 1 1 auto; }
.toolbar .field { min-width: 150px; flex: 1 1 150px; }
.field { display: grid; gap: 5px; }
label { display: block; color: var(--muted); font-size: 12px; font-weight: 500; }
.form-check { display: inline-flex; align-items: center; gap: 7px; min-height: 39px; padding: 0 3px; }
input, select, textarea { width: 100%; min-height: 40px; padding: 8px 11px; border: 1px solid var(--border); border-radius: 8px; outline: none; background: #0d1116; color: var(--text); transition: border-color .18s ease, box-shadow .18s ease; }
input::placeholder, textarea::placeholder { color: var(--subtle); }
input:focus, select:focus, textarea:focus { border-color: var(--yellow); box-shadow: 0 0 0 3px rgba(240, 185, 11, .11); }
input[type='checkbox'] { width: 16px; min-height: 16px; accent-color: var(--yellow); }
input[type='date'], input[type='datetime-local'] { direction: ltr; text-align: right; }
.stack { display: grid; gap: 12px; max-width: 560px; padding: 24px; background: var(--surface); border: 1px solid var(--border-soft); border-radius: var(--radius); }
.stack label { margin-top: 2px; }
.stack .btn { margin-top: 7px; }
.stack .validation-summary-errors { margin-bottom: 4px; }

.btn { display: inline-flex; align-items: center; justify-content: center; gap: 7px; min-height: 38px; padding: 7px 14px; border: 1px solid transparent; border-radius: 8px; font-weight: 600; font-size: 12px; line-height: 1.5; transition: all .18s ease; }
.btn:hover { transform: translateY(-1px); }
.btn-primary { background: var(--yellow); color: #181a1d; border-color: var(--yellow); }
.btn-primary:hover { background: #f8c62b; color: #181a1d; }
.btn-outline-primary { background: transparent; color: var(--yellow); border-color: rgba(240, 185, 11, .5); }
.btn-outline-primary:hover { background: var(--yellow-soft); color: #f8ca39; }
.btn-outline-secondary { background: transparent; color: var(--muted); border-color: var(--border); }
.btn-outline-secondary:hover { background: var(--surface-hover); color: var(--text); }
.btn-outline-danger { background: transparent; color: var(--red); border-color: rgba(246, 70, 93, .42); }
.btn-outline-danger:hover { background: var(--red-soft); color: #ff7181; }
.btn-success { background: var(--green); color: #071d15; border-color: var(--green); }
.btn-sm { min-height: 32px; padding: 5px 10px; }
.icon-button { display: inline-grid; place-items: center; width: 38px; height: 38px; padding: 0; border: 1px solid var(--border); border-radius: 8px; background: var(--surface); color: var(--text); }
.icon-button:hover { background: var(--surface-hover); }
.btn svg { width: 16px; height: 16px; }

.table-wrap { width: 100%; overflow-x: auto; margin: 16px 0; border: 1px solid var(--border-soft); border-radius: var(--radius); background: var(--surface); }
table { width: 100%; min-width: 620px; margin: 0; border-collapse: collapse; color: var(--text); }
th { padding: 13px 16px; border-bottom: 1px solid var(--border); color: var(--subtle); background: var(--surface-raised); font-size: 11px; font-weight: 600; text-align: right; white-space: nowrap; }
td { padding: 14px 16px; border-bottom: 1px solid var(--border-soft); color: var(--muted); font-size: 12px; vertical-align: middle; }
tbody tr:last-child td { border-bottom: 0; }
tbody tr:hover td { background: rgba(255, 255, 255, .018); color: var(--text); }
td a { color: var(--text); font-weight: 600; }
td a:hover { color: var(--yellow); }
.table-compact td, .table-compact th { padding: 10px 12px; }
.empty { padding: 34px 20px; margin: 0; color: var(--subtle); text-align: center; }
.table-actions { display: flex; flex-wrap: wrap; gap: 7px; }

.badge, .state-badge { display: inline-flex; align-items: center; gap: 5px; padding: 3px 9px; border: 1px solid var(--border); border-radius: 999px; background: var(--surface-raised); color: var(--muted); font-size: 11px; white-space: nowrap; }
.badge::before, .state-badge::before { content: ''; width: 6px; height: 6px; border-radius: 50%; background: currentColor; opacity: .8; }
.badge-warning, .state-pending { color: #f6cf57; border-color: rgba(240, 185, 11, .3); background: var(--yellow-soft); }
.badge-success, .state-ok { color: var(--green); border-color: rgba(14, 203, 129, .3); background: var(--green-soft); }
.badge-danger, .state-error { color: var(--red); border-color: rgba(246, 70, 93, .3); background: var(--red-soft); }
.badge-info { color: var(--blue); border-color: rgba(91, 156, 246, .3); background: var(--blue-soft); }
.status-line { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 14px; color: var(--muted); font-size: 12px; }
.status-line strong { color: var(--text); }
.divider { height: 1px; margin: 20px 0; background: var(--border-soft); }
.info-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 12px; }
.info-item { padding: 13px; border: 1px solid var(--border-soft); border-radius: 9px; background: rgba(255, 255, 255, .015); }
.info-item span { display: block; margin-bottom: 3px; color: var(--subtle); font-size: 11px; }
.info-item strong { color: var(--text); font-size: 14px; overflow-wrap: anywhere; }
small { color: var(--muted); font-size: 11px; }
.split-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; }
.command-grid { display: flex; flex-wrap: wrap; align-items: end; gap: 8px; }
.command-grid .command { display: flex; flex: 1 1 190px; align-items: center; gap: 5px; }
.command-grid .command input { min-width: 0; }
.command-result { min-height: 44px; margin: 14px 0 0; padding: 10px 12px; border: 1px dashed var(--border); border-radius: 8px; background: #0d1116; color: var(--muted); font-size: 11px; }
.timeline { margin: 10px 0; padding: 10px 13px; border-right: 3px solid var(--yellow); border-radius: 6px; background: var(--surface-raised); color: var(--muted); }
pre { max-width: 100%; overflow: auto; margin: 10px 0; padding: 13px; border: 1px solid var(--border-soft); border-radius: 8px; background: #0a0d10; color: #b7c2ce; direction: ltr; text-align: left; white-space: pre-wrap; overflow-wrap: anywhere; font: 11px/1.7 ui-monospace, SFMono-Regular, Consolas, monospace; }
code { direction: ltr; display: inline-block; max-width: 100%; color: #c1cad5; overflow-wrap: anywhere; font: 11px/1.6 ui-monospace, SFMono-Regular, Consolas, monospace; }

.alert { display: flex; align-items: flex-start; gap: 10px; margin-bottom: 18px; padding: 12px 14px; border: 1px solid var(--border); border-radius: 9px; background: var(--surface); color: var(--muted); font-size: 12px; }
.alert svg { flex: 0 0 18px; margin-top: 3px; }
.alert-info { border-color: rgba(91, 156, 246, .35); background: var(--blue-soft); color: #9fc5ff; }
.alert-success { border-color: rgba(14, 203, 129, .35); background: var(--green-soft); color: #7ee5bb; }
.alert-warning { border-color: rgba(240, 185, 11, .35); background: var(--yellow-soft); color: #f6cf57; }
.alert-danger, .validation-summary-errors { border-color: rgba(246, 70, 93, .35); background: var(--red-soft); color: #ff8b98; }
.validation-summary-errors { padding: 9px 11px; border: 1px solid rgba(246, 70, 93, .35); border-radius: 8px; font-size: 12px; }
.validation-summary-errors ul { margin: 0; padding: 0 18px 0 0; }
.text-danger { color: var(--red) !important; }
.text-center { text-align: center; }
.d-inline-block { display: inline-block; }

.auth-page { display: grid; grid-template-columns: minmax(0, 1.05fr) minmax(360px, .95fr); min-height: calc(100vh - 128px); align-items: center; gap: 70px; max-width: 1100px; margin: 0 auto; padding: 26px 0; }
.auth-intro { max-width: 540px; }
.auth-intro .brand-mark { width: 62px; height: 62px; margin-bottom: 24px; border-radius: 17px; }
.auth-intro .brand-mark img { width: 51px; height: 51px; }
.auth-intro h1 { margin: 0 0 13px; font-size: clamp(28px, 5vw, 46px); }
.auth-points { display: grid; gap: 10px; margin-top: 26px; padding: 0; list-style: none; }
.auth-points li { display: flex; align-items: center; gap: 9px; color: var(--muted); font-size: 12px; }
.auth-points svg { color: var(--green); }
.auth-card { margin: 0; box-shadow: var(--shadow); }
.auth-card h1 { margin: 0 0 5px; font-size: 24px; }
.auth-card .stack { padding: 0; border: 0; background: transparent; }
.auth-card .btn-primary { width: 100%; min-height: 44px; margin-top: 10px; }
.auth-note { margin-top: 20px; padding-top: 16px; border-top: 1px solid var(--border-soft); color: var(--subtle); font-size: 11px; }

.app-footer { padding: 21px 28px 27px; border-top: 1px solid var(--border-soft); background: var(--surface); color: var(--subtle); font-size: 11px; text-align: center; }
.app-footer span { margin: 0 7px; color: var(--border); }

@media (max-width: 1100px) {
  .content-wrap { padding: 32px 27px 48px; }
  .brand { min-width: 0; }
  .identity-name { max-width: 150px; }
  .page-layout { grid-template-columns: 226px minmax(0, 1fr); }
}
@media (max-width: 820px) {
  .topbar { height: 64px; }
  .topbar-inner { padding: 0 16px; gap: 11px; }
  .mobile-menu-toggle { display: inline-grid; }
  .brand-copy small, .identity-name { display: none; }
  .brand-copy strong { font-size: 16px; }
  .status-pill { padding: 4px 8px; font-size: 10px; }
  .page-layout { display: block; min-height: calc(100vh - 64px); }
  .sidebar { position: fixed; top: 64px; right: 0; bottom: 0; z-index: 50; width: min(84vw, 286px); transform: translateX(105%); transition: transform .22s ease; box-shadow: -18px 0 40px rgba(0, 0, 0, .25); }
  body.sidebar-open .sidebar { transform: translateX(0); }
  .sidebar-backdrop { position: fixed; inset: 64px 0 0; z-index: 40; background: rgba(0, 0, 0, .6); opacity: 0; pointer-events: none; transition: opacity .22s ease; }
  body.sidebar-open .sidebar-backdrop { display: block; opacity: 1; pointer-events: auto; }
  .content-wrap { padding: 25px 16px 38px; }
  .page-header { align-items: stretch; flex-direction: column; gap: 12px; margin-bottom: 21px; }
  .page-header .page-actions { margin: 0; }
  .page-header .page-actions .btn { width: 100%; }
  .hero-grid, .split-grid { grid-template-columns: 1fr; }
  .metrics { grid-template-columns: 1fr; gap: 9px; }
  .metric { min-height: 98px; }
  .info-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .table-wrap { margin-left: -1px; margin-right: -1px; width: calc(100% + 2px); }
  .card { padding: 17px; }
  .card-header { flex-direction: column; gap: 8px; }
  .toolbar { align-items: stretch; }
  .toolbar .field { flex-basis: 100%; }
  .auth-page { display: block; min-height: auto; padding: 14px 0 30px; }
  .auth-intro { margin-bottom: 28px; }
  .auth-intro h1 { font-size: 30px; }
  .auth-points { margin-top: 17px; }
}
@media (max-width: 520px) {
  .topbar-actions { gap: 6px; }
  .status-pill { max-width: 108px; overflow: hidden; }
  .brand-mark { width: 36px; height: 36px; }
  .brand-mark img { width: 29px; height: 29px; }
  .content-wrap { padding-right: 12px; padding-left: 12px; }
  h1 { font-size: 22px; }
  .hero-card { padding: 22px 18px; }
  .info-grid { grid-template-columns: 1fr; }
  .form-row > .btn, .toolbar > .btn { width: 100%; }
  .stack { padding: 18px; }
  .command-grid .command { flex-basis: 100%; align-items: stretch; flex-direction: column; }
  .command-grid .command .btn { width: 100%; }
  .app-footer { padding-right: 14px; padding-left: 14px; line-height: 2; }
  .app-footer span { display: none; }
}
