:root {
  --ink: #172338;
  --muted: #6c788b;
  --line: #e2e7ef;
  --canvas: #f3f6fa;
  --panel: #ffffff;
  --nav: #10223f;
  --nav-2: #173056;
  --blue: #2f6fed;
  --blue-dark: #1f56c1;
  --cyan: #17a6b8;
  --green: #1f9d6d;
  --amber: #d98c18;
  --red: #d64e58;
  --shadow: 0 8px 28px rgba(24, 42, 73, .07);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  color: var(--ink);
  background: var(--canvas);
  font-synthesis: none;
}

* { box-sizing: border-box; }
html, body { min-height: 100%; margin: 0; }
body { background: var(--canvas); }
button, input, select { font: inherit; }
button { cursor: pointer; }
[hidden] { display: none !important; }
h1, h2, h3, p { margin-top: 0; }
h1 { margin-bottom: 0; font-size: 1.25rem; letter-spacing: -.02em; }
h2 { margin-bottom: .35rem; font-size: 1.55rem; letter-spacing: -.035em; }
h3 { margin-bottom: .5rem; font-size: 1rem; }
a { color: var(--blue); }

.login-screen {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
  background:
    radial-gradient(circle at 20% 15%, rgba(47, 111, 237, .24), transparent 32rem),
    radial-gradient(circle at 90% 80%, rgba(23, 166, 184, .18), transparent 28rem),
    var(--nav);
}
.login-card {
  width: min(420px, 100%);
  padding: 38px;
  border: 1px solid rgba(255,255,255,.11);
  border-radius: 20px;
  background: rgba(255,255,255,.97);
  box-shadow: 0 32px 80px rgba(0,0,0,.28);
}
.login-card .brand-mark { margin-bottom: 24px; }
.login-card h1 { font-size: 1.8rem; margin-bottom: 10px; }
.login-card .stack { margin-top: 26px; }

.app-shell { min-height: 100vh; display: grid; grid-template-columns: 238px 1fr; }
.sidebar {
  position: fixed;
  inset: 0 auto 0 0;
  z-index: 10;
  width: 238px;
  display: flex;
  flex-direction: column;
  padding: 24px 14px 18px;
  color: #fff;
  background: linear-gradient(180deg, var(--nav), #0b1a31);
}
.brand { display: flex; align-items: center; gap: 12px; padding: 0 10px 28px; }
.brand-mark {
  width: 42px;
  height: 42px;
  display: grid;
  place-items: center;
  flex: 0 0 auto;
  border-radius: 12px;
  color: #fff;
  font-size: 1.35rem;
  font-weight: 800;
  background: linear-gradient(145deg, var(--blue), var(--cyan));
  box-shadow: 0 8px 18px rgba(47,111,237,.25);
}
.brand strong, .brand span { display: block; }
.brand strong { font-size: 1.05rem; }
.brand span { margin-top: 2px; color: #91a3bd; font-size: .72rem; letter-spacing: .06em; text-transform: uppercase; }
.sidebar nav { display: grid; gap: 5px; }
.nav-item {
  width: 100%;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 11px 13px;
  border: 0;
  border-radius: 10px;
  color: #aebbd0;
  text-align: left;
  background: transparent;
  transition: .16s ease;
}
.nav-item span { width: 19px; text-align: center; font-size: 1.05rem; }
.nav-item:hover, .nav-item.active { color: #fff; background: var(--nav-2); }
.nav-item.active { box-shadow: inset 3px 0 var(--cyan); }
.sidebar-foot {
  margin-top: auto;
  display: flex;
  gap: 10px;
  align-items: center;
  padding: 14px 12px;
  border: 1px solid rgba(255,255,255,.08);
  border-radius: 12px;
  background: rgba(255,255,255,.04);
}
.sidebar-foot strong, .sidebar-foot small { display: block; }
.sidebar-foot strong { font-size: .78rem; }
.sidebar-foot small { margin-top: 3px; color: #8fa1bb; font-size: .67rem; }
.safety-dot { width: 9px; height: 9px; flex: 0 0 auto; border-radius: 50%; background: var(--green); box-shadow: 0 0 0 4px rgba(31,157,109,.14); }

.workspace { grid-column: 2; min-width: 0; }
.topbar {
  position: sticky;
  top: 0;
  z-index: 8;
  height: 78px;
  display: flex;
  align-items: center;
  gap: 20px;
  padding: 0 30px;
  border-bottom: 1px solid var(--line);
  background: rgba(255,255,255,.94);
  backdrop-filter: blur(10px);
}
.topbar .eyebrow { margin-bottom: 3px; }
.topbar-actions { margin-left: auto; display: flex; align-items: center; gap: 12px; }
.admin-name { font-size: .82rem; color: var(--muted); }
.menu-button { display: none; }
main { padding: 28px 30px 48px; max-width: 1540px; margin: 0 auto; }
.view { display: none; animation: enter .18s ease; }
.view.active { display: block; }
@keyframes enter { from { opacity: .4; transform: translateY(3px); } to { opacity: 1; transform: none; } }
.page-intro { display: flex; align-items: end; justify-content: space-between; gap: 20px; margin-bottom: 22px; }
.page-intro p { margin-bottom: 0; color: var(--muted); font-size: .9rem; }
.eyebrow { color: #718198; font-size: .69rem; font-weight: 750; letter-spacing: .115em; text-transform: uppercase; }
.muted { color: var(--muted); line-height: 1.55; }

button.primary, button.secondary, button.ghost {
  min-height: 40px;
  padding: 0 16px;
  border-radius: 9px;
  font-weight: 650;
}
button.primary { border: 1px solid var(--blue); color: #fff; background: var(--blue); box-shadow: 0 5px 12px rgba(47,111,237,.18); }
button.primary:hover { background: var(--blue-dark); }
button.secondary { border: 1px solid #cdd6e4; color: var(--ink); background: #fff; }
button.ghost { border: 1px solid transparent; color: var(--muted); background: transparent; }
button.danger { color: var(--red); }
button:disabled { opacity: .48; cursor: not-allowed; }
.icon-button { width: 38px; height: 38px; display: grid; place-items: center; padding: 0; border: 1px solid var(--line); border-radius: 9px; color: var(--ink); background: #fff; }
.link-button { border: 0; padding: 3px; color: var(--blue); background: transparent; font-size: .8rem; font-weight: 650; }

.pill, .status {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  width: max-content;
  border-radius: 999px;
  font-size: .72rem;
  font-weight: 700;
  white-space: nowrap;
}
.pill { padding: 7px 10px; border: 1px solid var(--line); background: #f7f9fc; }
.pill i { width: 7px; height: 7px; border-radius: 50%; background: #98a4b5; }
.pill.good i { background: var(--green); box-shadow: 0 0 0 3px rgba(31,157,109,.12); }
.pill.bad i { background: var(--red); }
.status { padding: 5px 9px; }
.status.good { color: #13764f; background: #e9f7f1; }
.status.warning { color: #94600d; background: #fff5df; }
.status.bad { color: #a82f3a; background: #fdecef; }
.status.info { color: #1e58b8; background: #eaf1ff; }
.status.neutral { color: #667387; background: #eef1f5; }

.notice { margin-bottom: 20px; padding: 13px 15px; border: 1px solid; border-radius: 10px; line-height: 1.45; font-size: .82rem; }
.notice.info { border-color: #cbdcfb; color: #244c8c; background: #edf4ff; }
.notice.warning { border-color: #f0d59e; color: #79500e; background: #fff8e8; }
.notice.compact { margin: 20px 0 0; font-size: .76rem; }

.metric-grid { display: grid; grid-template-columns: repeat(6, minmax(135px, 1fr)); gap: 14px; margin-bottom: 16px; }
.metric-card { min-height: 126px; padding: 18px; border: 1px solid var(--line); border-radius: 14px; background: var(--panel); box-shadow: var(--shadow); }
.metric-card .metric-label { margin-bottom: 13px; color: var(--muted); font-size: .73rem; font-weight: 650; }
.metric-card strong { display: block; margin-bottom: 5px; font-size: 1.65rem; letter-spacing: -.04em; }
.metric-card small { color: #8a95a5; font-size: .68rem; line-height: 1.3; }

.content-grid { display: grid; grid-template-columns: repeat(3, minmax(0,1fr)); gap: 16px; }
.span-2 { grid-column: span 2; }
.span-3 { grid-column: span 3; }
.panel { padding: 21px; border: 1px solid var(--line); border-radius: 14px; background: var(--panel); box-shadow: var(--shadow); }
.panel-head { display: flex; justify-content: space-between; align-items: start; gap: 16px; margin-bottom: 19px; }
.panel-head .eyebrow { margin-bottom: 5px; }
.panel-head h3 { margin-bottom: 0; }
.run-progress progress { width: 100%; height: 11px; overflow: hidden; border: 0; border-radius: 99px; background: #e7ecf3; }
progress::-webkit-progress-bar { border-radius: 99px; background: #e7ecf3; }
progress::-webkit-progress-value { border-radius: 99px; background: linear-gradient(90deg,var(--blue),var(--cyan)); }
progress::-moz-progress-bar { border-radius: 99px; background: var(--blue); }
.progress-labels { display: flex; justify-content: space-between; margin-top: 8px; color: var(--muted); font-size: .72rem; }
.progress-labels strong { color: var(--ink); }
.traffic-summary { display: grid; grid-template-columns: repeat(4,1fr); gap: 10px; margin-top: 20px; }
.mini-stat { padding: 11px; border-radius: 9px; background: #f6f8fb; }
.mini-stat span, .mini-stat strong { display: block; }
.mini-stat span { color: var(--muted); font-size: .66rem; }
.mini-stat strong { margin-top: 5px; font-size: .92rem; }
.device-summary { display: grid; gap: 10px; }
.device-line { display: flex; justify-content: space-between; gap: 10px; padding: 11px 0; border-bottom: 1px solid var(--line); font-size: .8rem; }
.device-line:last-child { border-bottom: 0; }
.device-line span { color: var(--muted); }

.event-list { display: grid; }
.event-row { display: grid; grid-template-columns: 9px minmax(150px,1.2fr) minmax(160px,2fr) auto; align-items: center; gap: 12px; min-height: 48px; border-top: 1px solid var(--line); font-size: .78rem; }
.event-row:first-child { border-top: 0; }
.event-row .event-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--blue); }
.event-row.warning .event-dot { background: var(--amber); }
.event-row.error .event-dot { background: var(--red); }
.event-row time { color: var(--muted); font-variant-numeric: tabular-nums; }
.empty-state { padding: 24px 0; color: var(--muted); text-align: center; font-size: .82rem; }

label { display: grid; gap: 7px; color: #4e5b70; font-size: .75rem; font-weight: 650; }
input, select {
  width: 100%;
  height: 42px;
  padding: 0 11px;
  border: 1px solid #ccd5e2;
  border-radius: 8px;
  color: var(--ink);
  background: #fff;
  outline: none;
}
input:focus, select:focus { border-color: var(--blue); box-shadow: 0 0 0 3px rgba(47,111,237,.1); }
.stack { display: grid; gap: 16px; }
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 17px; }
.form-grid .wide { grid-column: span 2; }
.form-actions { display: flex !important; grid-template-columns: auto 1fr; align-items: center; gap: 14px; margin-top: 2px; }
.form-error { min-height: 18px; margin: 0; color: var(--red); font-size: .75rem; }
.form-message { margin: 0; color: var(--green); font-size: .76rem; }
.safety-fieldset { display: flex; flex-wrap: wrap; gap: 8px; padding: 13px; border: 1px solid var(--line); border-radius: 9px; }
.safety-fieldset legend { padding: 0 5px; color: var(--muted); font-size: .72rem; }
.safety-fieldset span { padding: 5px 8px; border-radius: 6px; color: #425168; background: #f0f3f7; font-size: .7rem; }
.definition-list { display: grid; grid-template-columns: auto 1fr; gap: 9px 13px; margin: 22px 0 0; font-size: .76rem; }
.definition-list dt { color: var(--muted); }
.definition-list dd { margin: 0; text-align: right; font-weight: 650; }

.table-panel { padding: 0; overflow: hidden; }
.table-wrap { max-width: 100%; overflow: auto; }
table { width: 100%; border-collapse: collapse; font-size: .78rem; }
th { padding: 13px 15px; color: #718096; text-align: left; font-size: .66rem; letter-spacing: .06em; text-transform: uppercase; background: #f7f9fc; }
td { padding: 14px 15px; border-top: 1px solid var(--line); vertical-align: middle; }
td strong, td small { display: block; }
td small { margin-top: 4px; color: var(--muted); }
.table-actions { display: flex; justify-content: flex-end; gap: 6px; }
.table-actions button { min-height: 31px; padding: 0 9px; border: 1px solid var(--line); border-radius: 7px; color: var(--ink); background: #fff; font-size: .7rem; font-weight: 650; }
.table-progress { min-width: 130px; }
.table-progress progress { width: 100%; height: 7px; }
.table-progress small { text-align: right; }

.pairing-panel { display: grid; grid-template-columns: minmax(340px,1.4fr) minmax(230px,1fr); gap: 28px; margin-bottom: 16px; }
.pairing-result { display: grid; place-items: center; align-content: center; min-height: 190px; padding: 20px; border: 1px dashed #9bb8ed; border-radius: 12px; text-align: center; background: #f4f8ff; }
.pairing-result p { margin-bottom: 10px; color: var(--muted); font-size: .74rem; }
.pairing-result strong { color: var(--blue-dark); font-size: 2.2rem; letter-spacing: .12em; font-variant-numeric: tabular-nums; }
.pairing-result span { margin-top: 12px; color: var(--muted); font-size: .72rem; }
.card-grid { display: grid; grid-template-columns: repeat(3,minmax(0,1fr)); gap: 16px; }
.device-card { padding: 20px; border: 1px solid var(--line); border-radius: 14px; background: #fff; box-shadow: var(--shadow); }
.device-card-head { display: flex; justify-content: space-between; gap: 12px; margin-bottom: 18px; }
.device-card-head h3 { margin-bottom: 4px; }
.device-card-head p { margin: 0; color: var(--muted); font-size: .68rem; word-break: break-all; }
.device-stats { display: grid; grid-template-columns: 1fr 1fr; gap: 1px; overflow: hidden; border: 1px solid var(--line); border-radius: 9px; background: var(--line); }
.device-stats div { padding: 11px; background: #f9fafc; }
.device-stats span, .device-stats strong { display: block; }
.device-stats span { color: var(--muted); font-size: .64rem; }
.device-stats strong { margin-top: 5px; font-size: .78rem; }
.device-error { margin: 12px 0 0; color: var(--red); font-size: .7rem; }

.method-grid { display: grid; grid-template-columns: repeat(2,minmax(0,1fr)); gap: 16px; margin-bottom: 16px; }
.method-grid p:last-child { margin-bottom: 0; color: var(--muted); font-size: .82rem; line-height: 1.65; }
.step-number { margin-bottom: 15px; color: var(--blue); font-size: 1.45rem; font-weight: 800; }
.sources p { color: var(--muted); line-height: 1.6; font-size: .82rem; }
.source-links { display: flex; flex-wrap: wrap; gap: 9px; }
.source-links a { padding: 8px 10px; border: 1px solid var(--line); border-radius: 8px; text-decoration: none; font-size: .73rem; font-weight: 650; }

dialog { width: min(1050px, calc(100% - 32px)); max-height: calc(100vh - 50px); padding: 0; border: 0; border-radius: 16px; color: var(--ink); box-shadow: 0 30px 90px rgba(10,25,49,.32); }
dialog::backdrop { background: rgba(8,20,39,.56); backdrop-filter: blur(2px); }
.dialog-head { position: sticky; top: 0; z-index: 2; display: flex; justify-content: space-between; align-items: start; padding: 21px 23px; border-bottom: 1px solid var(--line); background: #fff; }
.dialog-head .eyebrow { margin-bottom: 4px; }
.dialog-head h2 { margin: 0; }
.dialog-summary { display: grid; grid-template-columns: repeat(5,1fr); gap: 10px; padding: 18px 23px; }
.call-table { max-height: 58vh; border-top: 1px solid var(--line); }

.toast-region { position: fixed; z-index: 30; right: 18px; bottom: 18px; display: grid; gap: 8px; width: min(370px,calc(100% - 36px)); }
.toast { padding: 13px 15px; border: 1px solid #b8c9e5; border-radius: 10px; color: #23446f; background: #f2f7ff; box-shadow: var(--shadow); font-size: .78rem; }
.toast.error { border-color: #efb4bb; color: #8f2632; background: #fff1f3; }

@media (max-width: 1180px) {
  .metric-grid { grid-template-columns: repeat(3,1fr); }
  .card-grid { grid-template-columns: repeat(2,1fr); }
}
@media (max-width: 820px) {
  .app-shell { display: block; }
  .sidebar { transform: translateX(-100%); transition: transform .2s ease; }
  body.menu-open .sidebar { transform: none; box-shadow: 20px 0 50px rgba(0,0,0,.24); }
  .workspace { min-width: 0; }
  .menu-button { display: grid; }
  .topbar { height: 70px; padding: 0 16px; }
  .topbar .pill, .admin-name { display: none; }
  main { padding: 21px 16px 40px; }
  .content-grid { grid-template-columns: 1fr; }
  .span-2, .span-3 { grid-column: auto; }
  .pairing-panel { grid-template-columns: 1fr; }
  .card-grid { grid-template-columns: 1fr; }
  .dialog-summary { grid-template-columns: repeat(2,1fr); }
}
@media (max-width: 560px) {
  .metric-grid { grid-template-columns: repeat(2,1fr); }
  .metric-card { min-height: 112px; padding: 15px; }
  .form-grid { grid-template-columns: 1fr; }
  .form-grid .wide { grid-column: auto; }
  .traffic-summary { grid-template-columns: repeat(2,1fr); }
  .method-grid { grid-template-columns: 1fr; }
  .page-intro { align-items: start; }
  .page-intro .secondary { display: none; }
  .login-card { padding: 28px 23px; }
}
