:root {
  --blue: #005ed2;
  --sky: #00a0f2;
  --red: #dd162a;
  --ink: #16202e;
  --ink-2: #495057;
  --muted: #6c757d;
  --line: #e3e8ee;
  --bg: #f3f6fa;
  --card: #ffffff;
  --good: #1a8a4a;
  --open: #00a0f2;
  --lost: #dd162a;
  --radius: 5px;
  --brand-grad: linear-gradient(0deg, #005ed2 25%, #00a0f2 125%);
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  font-family: "Montserrat", Arial, sans-serif;
  color: var(--ink);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
}
[hidden] { display: none !important; }

/* ---------- lock screen ---------- */
.lock {
  position: relative;
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
  background: var(--brand-grad);
  overflow: hidden;
}
.lock__waves {
  position: absolute; inset: auto -10% -2px -10%; height: 46vh;
  background:
    radial-gradient(120% 60% at 20% 100%, rgba(255,255,255,.14) 0 40%, transparent 41%),
    radial-gradient(110% 70% at 80% 110%, rgba(255,255,255,.10) 0 45%, transparent 46%),
    radial-gradient(140% 55% at 50% 120%, rgba(0,30,80,.25) 0 50%, transparent 51%);
  pointer-events: none;
}
.lock__card {
  position: relative;
  width: min(400px, 100%);
  background: var(--card);
  border-radius: 14px;
  padding: 36px 32px 22px;
  box-shadow: 0 30px 60px -20px rgba(0, 30, 80, .55);
  text-align: center;
  animation: rise .5s cubic-bezier(.2,.8,.2,1) both;
}
.lock__logo { display: block; margin: 0 auto 14px; width: 111px; height: auto; }
.lock__title {
  margin: 0;
  font-size: 22px; font-weight: 800; letter-spacing: -.01em; color: var(--blue);
}
.lock__title { margin-bottom: 26px; }
.lock__title span { display: flex; align-items: center; justify-content: center; gap: 8px; font-size: 15px; font-weight: 600; color: var(--ink); letter-spacing: .14em; text-transform: uppercase; margin-top: 8px; }
.ai {
  display: inline-block; font-weight: 800; letter-spacing: .04em; color: #fff;
  background: linear-gradient(135deg, var(--red), #ff4a3d); border-radius: var(--radius);
  padding: 3px 8px 2px; box-shadow: 0 4px 12px -4px rgba(221, 22, 42, .6);
}
.lock__title .ai { font-size: 18px; }
.field { display: block; text-align: left; }
.field span { display: block; font-size: 12px; font-weight: 600; color: var(--ink-2); margin-bottom: 6px; }
.field input {
  width: 100%; font: inherit; font-size: 15px;
  padding: 12px 14px; border: 1px solid #ced4da; border-radius: var(--radius);
  outline: none; transition: border-color .15s, box-shadow .15s;
}
.field input:focus { border-color: var(--sky); box-shadow: 0 0 0 3px rgba(0,160,242,.2); }
.lock__error { margin: 10px 0 0; color: var(--red); font-size: 13px; font-weight: 600; text-align: left; }
.btn {
  margin-top: 18px; width: 100%;
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  font: inherit; font-weight: 700; font-size: 15px; color: #fff;
  background: var(--brand-grad); border: 0; border-radius: var(--radius);
  padding: 13px 16px; cursor: pointer; transition: filter .15s, transform .05s;
}
.btn:hover { filter: brightness(1.08); }
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: .6; cursor: wait; }
.lock__foot { margin: 22px 0 0; font-size: 11px; color: #adb5bd; letter-spacing: .08em; }
@keyframes rise { from { opacity: 0; transform: translateY(16px); } }

/* ---------- top bar ---------- */
.top {
  position: sticky; top: 0; z-index: 5;
  display: flex; align-items: center; justify-content: space-between; gap: 16px;
  padding: 10px 24px; background: var(--brand-grad); color: #fff;
  box-shadow: 0 2px 12px rgba(0, 40, 100, .2);
}
.top__brand { display: flex; align-items: center; gap: 12px; }
.top__brand img { background: #fff; border-radius: 8px; padding: 3px 6px; width: 62px; height: auto; }
.top__brand strong { display: block; font-size: 16px; font-weight: 800; }
.top__brand span { display: block; font-size: 11px; letter-spacing: .14em; text-transform: uppercase; opacity: .95; }
.top__brand .ai { padding: 1px 5px; margin-right: 2px; font-size: 11px; box-shadow: none; }
.top__controls { display: flex; align-items: center; gap: 8px; }
.seg { display: inline-flex; background: rgba(255,255,255,.16); border-radius: var(--radius); padding: 3px; }
.seg button {
  font: inherit; font-size: 13px; font-weight: 600; color: #fff;
  background: transparent; border: 0; border-radius: 4px; padding: 7px 12px; cursor: pointer;
}
.seg button.is-on { background: #fff; color: var(--blue); }
.icon-btn {
  display: inline-grid; place-items: center; width: 36px; height: 36px;
  color: #fff; background: rgba(255,255,255,.16); border: 0; border-radius: var(--radius); cursor: pointer;
}
.icon-btn:hover { background: rgba(255,255,255,.28); }
.icon-btn.spin svg { animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

/* ---------- layout ---------- */
.wrap { max-width: 1240px; margin: 0 auto; padding: 20px 24px 40px; }
.status-line { margin: 0 0 14px; font-size: 12px; color: var(--muted); }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; margin-top: 16px; }
@media (max-width: 900px) { .grid2 { grid-template-columns: 1fr; } }

.panel { background: var(--card); border: 1px solid var(--line); border-radius: 10px; padding: 18px 20px; }
.panel--wide { margin-top: 16px; }
.panel__head { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; flex-wrap: wrap; margin-bottom: 12px; }
.panel__head--sub { margin-top: 22px; }
.panel__head h2 { margin: 0; font-size: 15px; font-weight: 700; }
.panel__head p { margin: 0; font-size: 12px; color: var(--muted); }
.legend { display: flex; gap: 12px; }
.legend span { display: inline-flex; align-items: center; gap: 6px; }
.sw { display: inline-block; width: 10px; height: 10px; border-radius: 3px; }
.sw--success { background: var(--good); }
.sw--open { background: var(--open); }
.sw--lost { background: var(--lost); }

/* ---------- KPI tiles ---------- */
.kpis { display: grid; grid-template-columns: repeat(4, 1fr); gap: 16px; }
@media (max-width: 900px) { .kpis { grid-template-columns: repeat(2, 1fr); } }
.kpi {
  position: relative; background: var(--card); border: 1px solid var(--line); border-radius: 10px;
  padding: 16px 18px 14px; overflow: hidden; animation: rise .45s both;
}
.kpi::before { content: ""; position: absolute; inset: 0 auto 0 0; width: 4px; background: var(--brand-grad); }
.kpi:nth-child(2) { animation-delay: .05s; } .kpi:nth-child(3) { animation-delay: .1s; } .kpi:nth-child(4) { animation-delay: .15s; }
.kpi__label { font-size: 12px; font-weight: 600; color: var(--muted); }
.kpi__value { font-size: 28px; font-weight: 800; letter-spacing: -.02em; margin: 6px 0 4px; font-variant-numeric: tabular-nums; }
.kpi__delta { font-size: 12px; font-weight: 600; color: var(--ink-2); display: block; }
.kpi__delta.up { color: var(--good); }
.kpi__delta.down { color: var(--red); }
.kpi__delta small { color: var(--muted); font-weight: 500; }

/* ---------- daily chart ---------- */
.chart { position: relative; width: 100%; height: 260px; }
.chart svg { display: block; width: 100%; height: 100%; overflow: visible; }
.chart .grid line { stroke: #edf0f4; }
.chart .axis text { font-size: 11px; fill: var(--muted); }
.chart .bar { fill: var(--blue); }
.chart .bar.dim { fill: #9ec3f0; }
.chart .hit { fill: transparent; cursor: crosshair; }
.chart .hit:hover + .bar, .chart .bar.hover { fill: var(--sky); }

/* ---------- horizontal bars ---------- */
.hbars { display: grid; gap: 8px; }
.hbar { display: grid; grid-template-columns: 150px 1fr 110px; align-items: center; gap: 10px; font-size: 13px; }
.hbar__name { color: var(--ink-2); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.hbar__track { display: block; height: 14px; background: #f1f4f8; border-radius: 4px; overflow: hidden; }
.hbar__fill { display: block; height: 100%; border-radius: 0 4px 4px 0; background: var(--blue); transform-origin: left; animation: grow .6s cubic-bezier(.2,.8,.2,1) both; }
.hbar__fill.success { background: var(--good); }
.hbar__fill.open { background: var(--open); }
.hbar__fill.lost { background: var(--lost); }
.hbar__val { text-align: right; font-variant-numeric: tabular-nums; font-weight: 600; }
.hbar__val small { color: var(--muted); font-weight: 500; }
@keyframes grow { from { transform: scaleX(0); } }

/* ---------- tables ---------- */
.tbl { width: 100%; border-collapse: collapse; font-size: 13px; }
.tbl th { text-align: left; font-size: 11px; font-weight: 600; color: var(--muted); text-transform: uppercase; letter-spacing: .06em; padding: 0 8px 8px; border-bottom: 1px solid var(--line); }
.tbl td { padding: 8px; border-bottom: 1px solid #f1f3f6; vertical-align: top; }
.tbl tr:last-child td { border-bottom: 0; }
.tbl .num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.tbl .name { max-width: 320px; }
.pill { display: inline-block; font-size: 11px; font-weight: 600; padding: 2px 8px; border-radius: 99px; background: #e8f3fd; color: var(--blue); white-space: nowrap; }
.pill.lost { background: #fde8ea; color: var(--red); }

.foot { margin-top: 20px; font-size: 12px; color: var(--muted); }

/* ---------- tooltip ---------- */
.tip {
  position: fixed; z-index: 20; pointer-events: none;
  background: var(--ink); color: #fff; font-size: 12px; line-height: 1.5;
  padding: 8px 10px; border-radius: 6px; box-shadow: 0 8px 20px rgba(0,0,0,.2);
  transform: translate(-50%, calc(-100% - 12px));
}
.tip b { font-weight: 700; }

@media (max-width: 600px) {
  .top { padding: 10px 14px; }
  .top__brand span, .top__brand strong { display: none; }
  .top__brand img { width: 50px; }
  .seg button { padding: 7px 8px; white-space: nowrap; }
  .kpis { gap: 10px; }
  .kpi { padding: 12px 12px 10px; }
  .kpi__value { font-size: 22px; }
  .kpi__delta small { display: block; }
  .wrap { padding: 16px 14px 32px; }
  .hbar { grid-template-columns: 110px 1fr 90px; }
}
