:root{
  color-scheme:dark;
  --bg:#07101c;
  --bg-deep:#040b13;
  --surface:#0d1929;
  --surface-2:#111f32;
  --surface-3:#162740;
  --line:#223752;
  --line-strong:#315171;
  --text:#edf5ff;
  --muted:#91a4bb;
  --muted-2:#6f839b;
  --accent:#4aa8ff;
  --accent-strong:#287fd1;
  --accent-soft:rgba(74,168,255,.12);
  --ok:#42d5a0;
  --ok-soft:rgba(66,213,160,.11);
  --bad:#ff7182;
  --bad-soft:rgba(255,113,130,.11);
  --warn:#f1c36a;
  --warn-soft:rgba(241,195,106,.11);
  --shadow:0 28px 80px rgba(0,0,0,.34);
  --radius:18px;
  --radius-sm:12px;
}

*{box-sizing:border-box}
html{min-height:100%;background:var(--bg-deep)}
body{
  margin:0;
  min-height:100vh;
  color:var(--text);
  font-family:Inter,ui-sans-serif,system-ui,-apple-system,"Segoe UI",sans-serif;
  background:
    radial-gradient(circle at 12% 0,rgba(42,102,158,.22),transparent 34%),
    radial-gradient(circle at 100% 20%,rgba(31,80,129,.12),transparent 28%),
    linear-gradient(160deg,#06101b 0%,#081322 52%,#050c15 100%);
}
body::before{
  content:"";
  position:fixed;
  inset:0;
  pointer-events:none;
  opacity:.18;
  background-image:linear-gradient(rgba(255,255,255,.018) 1px,transparent 1px),linear-gradient(90deg,rgba(255,255,255,.018) 1px,transparent 1px);
  background-size:42px 42px;
  mask-image:linear-gradient(to bottom,black,transparent 70%);
}
button,input,select,textarea{font:inherit}
button{color:inherit}
a{color:inherit}
[hidden]{display:none!important}
:focus-visible{outline:3px solid rgba(74,168,255,.28);outline-offset:2px}

.app-shell{
  width:min(1480px,calc(100% - 36px));
  margin:18px auto;
  display:grid;
  grid-template-columns:236px minmax(0,1fr);
  gap:18px;
  position:relative;
  z-index:1;
}

.sidebar{
  min-height:calc(100vh - 36px);
  position:sticky;
  top:18px;
  align-self:start;
  display:flex;
  flex-direction:column;
  padding:16px;
  border:1px solid var(--line);
  border-radius:20px;
  background:linear-gradient(180deg,rgba(15,29,47,.98),rgba(8,17,29,.98));
  box-shadow:var(--shadow);
  overflow:hidden;
}
.sidebar::after{
  content:"";
  position:absolute;
  width:180px;
  height:180px;
  top:-110px;
  right:-80px;
  border-radius:50%;
  background:rgba(74,168,255,.11);
  filter:blur(2px);
  pointer-events:none;
}
.brand-link{
  display:flex;
  align-items:center;
  gap:12px;
  min-width:0;
  padding:4px 4px 18px;
  text-decoration:none;
  position:relative;
  z-index:1;
}
.brand-mark{
  width:42px;
  height:42px;
  flex:0 0 42px;
  display:grid;
  place-items:center;
  border-radius:13px;
  background:linear-gradient(145deg,#62b8ff,#586cff);
  box-shadow:0 12px 28px rgba(61,127,255,.28);
  font-weight:900;
  letter-spacing:-.04em;
}
.brand-copy{min-width:0}
.brand-copy strong,.brand-copy small{display:block}
.brand-copy strong{font-size:.88rem;line-height:1.2;white-space:nowrap;overflow:hidden;text-overflow:ellipsis}
.brand-copy small{margin-top:4px;color:var(--muted);font-size:.69rem}

.sidebar-section-label{
  margin:8px 10px 7px;
  color:var(--muted-2);
  font-size:.65rem;
  font-weight:850;
  text-transform:uppercase;
  letter-spacing:.14em;
}
.sidebar-nav{display:grid;gap:5px}
.sidebar-nav a{
  display:flex;
  align-items:center;
  gap:11px;
  min-height:44px;
  padding:10px 11px;
  border:1px solid transparent;
  border-radius:12px;
  color:var(--muted);
  text-decoration:none;
  font-size:.84rem;
  font-weight:720;
  transition:background .18s ease,border-color .18s ease,color .18s ease,transform .18s ease;
}
.sidebar-nav a:hover{background:rgba(255,255,255,.035);color:var(--text);transform:translateX(2px)}
.sidebar-nav a.active{
  color:#fff;
  border-color:rgba(74,168,255,.24);
  background:linear-gradient(90deg,rgba(74,168,255,.17),rgba(74,168,255,.06));
  box-shadow:inset 3px 0 0 var(--accent);
}
.nav-icon{width:19px;height:19px;flex:0 0 19px;stroke:currentColor;fill:none;stroke-width:1.8;stroke-linecap:round;stroke-linejoin:round}
.sidebar-spacer{flex:1}
.sidebar-status{
  display:flex;
  align-items:center;
  gap:9px;
  margin-top:20px;
  padding:11px;
  border:1px solid var(--line);
  border-radius:12px;
  background:rgba(255,255,255,.025);
}
.status-dot{width:8px;height:8px;border-radius:50%;background:var(--ok);box-shadow:0 0 0 5px rgba(66,213,160,.08)}
.sidebar-status strong,.sidebar-status small{display:block}
.sidebar-status strong{font-size:.73rem}.sidebar-status small{margin-top:2px;color:var(--muted);font-size:.65rem}
.sidebar-footer{display:flex;align-items:center;justify-content:space-between;gap:10px;margin-top:10px;padding-top:12px;border-top:1px solid var(--line)}
.version{color:var(--muted-2);font-size:.68rem;white-space:nowrap}
.logout-button{
  border:0;
  background:transparent;
  color:var(--muted);
  padding:8px 9px;
  border-radius:9px;
  cursor:pointer;
  font-size:.76rem;
}
.logout-button:hover{background:rgba(255,113,130,.08);color:#ffd6dc}
.logout-button:disabled{opacity:.55;cursor:wait}

.workspace{min-width:0}
.workspace-topbar{
  min-height:76px;
  display:flex;
  align-items:center;
  justify-content:space-between;
  gap:18px;
  padding:13px 16px 13px 20px;
  border:1px solid var(--line);
  border-radius:18px;
  background:rgba(13,25,41,.92);
  backdrop-filter:blur(12px);
  box-shadow:0 18px 55px rgba(0,0,0,.24);
}
.page-identity{min-width:0}
.page-identity span{display:block;color:var(--muted-2);font-size:.67rem;font-weight:800;text-transform:uppercase;letter-spacing:.13em}
.page-identity strong{display:block;margin-top:4px;font-size:1rem;white-space:nowrap;overflow:hidden;text-overflow:ellipsis}
.context-area{display:flex;align-items:center;gap:10px;min-width:0}
.context-copy{text-align:right;min-width:0}
.context-copy span,.context-copy strong{display:block}
.context-copy span{color:var(--muted-2);font-size:.64rem;font-weight:800;text-transform:uppercase;letter-spacing:.1em}
.context-copy strong{margin-top:3px;color:var(--muted);font-size:.74rem;font-weight:650;white-space:nowrap;overflow:hidden;text-overflow:ellipsis}
.company-select-wrap{position:relative}
.company-select-wrap::after{
  content:"";
  position:absolute;
  right:13px;
  top:50%;
  width:7px;
  height:7px;
  border-right:2px solid var(--muted);
  border-bottom:2px solid var(--muted);
  transform:translateY(-70%) rotate(45deg);
  pointer-events:none;
}
.company-select{
  width:min(260px,34vw);
  min-width:180px;
  appearance:none;
  border:1px solid var(--line-strong);
  background:#091525;
  color:var(--text);
  border-radius:11px;
  padding:10px 36px 10px 12px;
  font-weight:720;
  cursor:pointer;
}
.company-select:disabled{opacity:.6;cursor:wait}

.page-content{padding:24px 0 40px}
.page-header{
  display:flex;
  justify-content:space-between;
  align-items:flex-end;
  gap:24px;
  margin:0 2px 20px;
}
.page-header-copy{min-width:0}
.eyebrow{margin:0 0 8px;color:#79bcf8;font-size:.69rem;font-weight:900;letter-spacing:.17em;text-transform:uppercase}
.page-header h1{margin:0;font-size:clamp(2rem,4vw,3.45rem);line-height:1.02;letter-spacing:-.047em}
.page-header p{max-width:720px;margin:11px 0 0;color:var(--muted);line-height:1.58;font-size:.95rem}
.page-actions{display:flex;gap:9px;flex-wrap:wrap;justify-content:flex-end}

.button{
  min-height:42px;
  display:inline-flex;
  align-items:center;
  justify-content:center;
  gap:8px;
  border:1px solid var(--line);
  border-radius:11px;
  padding:10px 14px;
  background:var(--surface-2);
  color:var(--text);
  text-decoration:none;
  font-weight:800;
  font-size:.82rem;
  cursor:pointer;
  transition:transform .16s ease,background .16s ease,border-color .16s ease,opacity .16s ease;
}
.button:hover{transform:translateY(-1px);border-color:var(--line-strong);background:var(--surface-3)}
.button.primary{border-color:transparent;background:linear-gradient(145deg,var(--accent),var(--accent-strong));box-shadow:0 13px 30px rgba(40,127,209,.24)}
.button.primary:hover{background:linear-gradient(145deg,#63b5ff,#2f89dd)}
.button.danger{color:#ffd9df;border-color:rgba(255,113,130,.26);background:rgba(255,113,130,.07)}
.button:disabled{opacity:.5;cursor:not-allowed;transform:none}
.button svg{width:16px;height:16px;stroke:currentColor;fill:none;stroke-width:2;stroke-linecap:round;stroke-linejoin:round}

.surface{
  border:1px solid var(--line);
  border-radius:var(--radius);
  background:linear-gradient(145deg,rgba(17,31,50,.97),rgba(9,18,31,.98));
  box-shadow:0 20px 55px rgba(0,0,0,.21);
}
.surface-header{display:flex;align-items:flex-start;justify-content:space-between;gap:18px}
.surface-header h2{margin:0;font-size:1.1rem;letter-spacing:-.02em}
.surface-header p{margin:6px 0 0;color:var(--muted);font-size:.82rem;line-height:1.5}

.metric-grid{display:grid;grid-template-columns:repeat(4,minmax(0,1fr));gap:12px;margin-bottom:16px}
.metric-card{min-width:0;padding:17px;border:1px solid var(--line);border-radius:15px;background:rgba(14,28,46,.88)}
.metric-card-head{display:flex;align-items:center;justify-content:space-between;gap:10px}
.metric-card span{color:var(--muted);font-size:.72rem;font-weight:700}
.metric-card strong{display:block;margin-top:12px;font-size:1.15rem;letter-spacing:-.025em;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}
.metric-card small{display:block;margin-top:6px;color:var(--muted-2);font-size:.68rem;line-height:1.4}
.metric-icon{width:31px;height:31px;display:grid;place-items:center;border:1px solid rgba(74,168,255,.2);border-radius:10px;background:var(--accent-soft);color:#8cc8ff}
.metric-icon svg{width:16px;height:16px;stroke:currentColor;fill:none;stroke-width:1.8}

.badge{
  display:inline-flex;
  align-items:center;
  gap:7px;
  min-height:27px;
  padding:5px 9px;
  border:1px solid var(--line);
  border-radius:999px;
  color:var(--muted);
  background:rgba(255,255,255,.025);
  font-size:.69rem;
  font-weight:800;
  white-space:nowrap;
}
.badge::before{content:"";width:6px;height:6px;border-radius:50%;background:currentColor;opacity:.8}
.badge.ok{color:var(--ok);border-color:rgba(66,213,160,.28);background:var(--ok-soft)}
.badge.bad{color:var(--bad);border-color:rgba(255,113,130,.28);background:var(--bad-soft)}
.badge.warn{color:var(--warn);border-color:rgba(241,195,106,.28);background:var(--warn-soft)}
.badge.neutral{color:var(--muted)}

.notice{
  margin-bottom:14px;
  padding:12px 14px;
  border:1px solid rgba(66,213,160,.3);
  border-radius:12px;
  background:var(--ok-soft);
  color:#c9ffeb;
  font-size:.83rem;
}
.notice.bad{border-color:rgba(255,113,130,.34);background:var(--bad-soft);color:#ffd7dd}
.notice.warn{border-color:rgba(241,195,106,.34);background:var(--warn-soft);color:#ffe8b7}

.page-loading{
  min-height:calc(100vh - 126px);
  display:flex;
  align-items:center;
  justify-content:center;
  gap:12px;
  color:var(--muted);
}
.loader{width:22px;height:22px;border:3px solid rgba(145,164,187,.24);border-top-color:var(--accent);border-radius:50%;animation:spin .75s linear infinite}
@keyframes spin{to{transform:rotate(360deg)}}

.dialog{
  width:min(680px,calc(100% - 24px));
  max-height:calc(100vh - 40px);
  padding:0;
  border:1px solid var(--line-strong);
  border-radius:20px;
  background:linear-gradient(160deg,#12243a,#091522);
  color:var(--text);
  box-shadow:0 40px 110px rgba(0,0,0,.62);
  overflow:auto;
}
.dialog::backdrop{background:rgba(2,7,13,.76);backdrop-filter:blur(6px)}
.dialog-header{position:sticky;top:0;z-index:2;display:flex;justify-content:space-between;align-items:flex-start;gap:18px;padding:20px 22px;border-bottom:1px solid var(--line);background:rgba(14,28,46,.96);backdrop-filter:blur(10px)}
.dialog-header h2{margin:0;font-size:1.25rem}.dialog-header p{margin:6px 0 0;color:var(--muted);font-size:.8rem;line-height:1.45}
.dialog-close{width:36px;height:36px;display:grid;place-items:center;border:1px solid var(--line);border-radius:10px;background:transparent;color:var(--muted);cursor:pointer;font-size:1.25rem}
.dialog-close:hover{color:var(--text);background:rgba(255,255,255,.04)}
.dialog-body{padding:22px}
.dialog-actions{display:flex;justify-content:flex-end;gap:9px;margin-top:20px;padding-top:17px;border-top:1px solid var(--line)}

.empty-state{
  padding:36px 20px;
  border:1px dashed var(--line-strong);
  border-radius:15px;
  text-align:center;
  background:rgba(7,16,28,.34);
}
.empty-icon{width:48px;height:48px;display:grid;place-items:center;margin:0 auto 13px;border:1px solid rgba(74,168,255,.2);border-radius:15px;background:var(--accent-soft);color:#8cc8ff}
.empty-icon svg{width:23px;height:23px;stroke:currentColor;fill:none;stroke-width:1.7}
.empty-state strong{display:block}.empty-state p{max-width:480px;margin:8px auto 0;color:var(--muted);font-size:.82rem;line-height:1.52}

@media(max-width:1080px){
  .app-shell{grid-template-columns:210px minmax(0,1fr)}
  .metric-grid{grid-template-columns:repeat(2,minmax(0,1fr))}
}
@media(max-width:900px){
  .app-shell{width:min(100% - 24px,1100px);margin:12px auto;grid-template-columns:1fr;gap:12px}
  .sidebar{position:static;min-height:auto;padding:12px}
  .sidebar::after,.sidebar-section-label,.sidebar-status{display:none}
  .brand-link{padding:2px 2px 11px}
  .sidebar-nav{grid-template-columns:repeat(3,minmax(0,1fr));gap:7px}
  .sidebar-nav a{justify-content:center;min-height:40px;padding:8px;font-size:.76rem}
  .sidebar-nav a:hover{transform:none}
  .sidebar-spacer{display:none}
  .sidebar-footer{position:absolute;top:12px;right:12px;margin:0;padding:0;border:0}
  .sidebar-footer .version{display:none}
  .workspace-topbar{min-height:68px}
  .page-content{padding-top:18px}
}
@media(max-width:680px){
  .app-shell{width:calc(100% - 16px);margin:8px auto}
  .brand-copy small{display:none}
  .brand-mark{width:38px;height:38px;flex-basis:38px}
  .sidebar-nav a{gap:7px}.nav-icon{width:17px;height:17px;flex-basis:17px}
  .workspace-topbar{align-items:flex-start;flex-direction:column;padding:13px}
  .context-area{width:100%}.context-copy{display:none}.company-select-wrap{width:100%}.company-select{width:100%;max-width:none}
  .page-header{align-items:stretch;flex-direction:column;margin-bottom:16px}.page-actions{justify-content:flex-start}.page-actions .button{flex:1}
  .metric-grid{grid-template-columns:1fr}
  .dialog{max-height:calc(100vh - 16px)}
}
@media(max-width:470px){
  .sidebar-nav a{font-size:0;gap:0}.sidebar-nav a::after{font-size:.69rem}.sidebar-nav a[data-short]::after{content:attr(data-short)}
  .nav-icon{margin-right:6px}
  .page-header h1{font-size:2rem}
}
.dialog-notice{margin-bottom:14px;padding:11px 12px;border:1px solid rgba(255,113,130,.34);border-radius:10px;background:var(--bad-soft);color:#ffd7dd;font-size:.78rem;line-height:1.45}
