@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700;800;900&display=swap');

/* ═══════════════════════════════════════════════
   TOKENS
═══════════════════════════════════════════════ */
:root {
  --blue:        #2563eb;
  --blue-h:      #1d4ed8;
  --blue-l:      #3b82f6;
  --blue-glow:   rgba(37,99,235,.25);
  --green:       #16a34a;
  --green-l:     #22c55e;
  --red:         #dc2626;
  --red-l:       #ef4444;
  --amber:       #d97706;
  --amber-l:     #f59e0b;
  --cyan:        #0891b2;
  --cyan-l:      #06b6d4;

  /* surfaces */
  --bg:          #0d0d0f;
  --surface:     #111115;
  --surface-2:   #18181d;
  --surface-3:   #1f1f27;
  --border:      rgba(255,255,255,.07);
  --border-2:    rgba(255,255,255,.12);

  /* sidebar */
  --nav-w:       220px;
  --nav-bg:      #0a0a14;
  --nav-accent:  var(--blue);
  --nav-sm:      64px;

  /* text */
  --t:           #f0f0f5;
  --t2:          #8b8b9a;
  --t3:          #55555f;

  /* radii */
  --r:           12px;
  --r-sm:        8px;
  --r-xs:        5px;

  /* transitions */
  --ease:        .18s cubic-bezier(.4,0,.2,1);
  --ease-spring: .3s cubic-bezier(.34,1.56,.64,1);
}

/* ═══════════════════════════════════════════════
   BASE
═══════════════════════════════════════════════ */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { height: 100%; scroll-behavior: smooth; }
body {
  font-family: 'Inter', system-ui, sans-serif;
  font-size: 13.5px;
  line-height: 1.6;
  color: var(--t);
  background: var(--bg);
  min-height: 100vh;
  display: flex;
  -webkit-font-smoothing: antialiased;
}

a { color: var(--blue-l); text-decoration: none; }

/* ═══════════════════════════════════════════════
   SIDEBAR
═══════════════════════════════════════════════ */
.sidebar {
  width: var(--nav-w);
  position: fixed;
  inset: 0 auto 0 0;
  z-index: 400;
  background: var(--nav-bg);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  transition: width var(--ease);
  border-right: 1px solid var(--border);
}

/* brand */
.brand {
  display: flex;
  align-items: center;
  gap: 11px;
  padding: 0 16px;
  height: 60px;
  flex-shrink: 0;
  text-decoration: none;
  border-bottom: 1px solid var(--border);
}
.brand-mark {
  width: 32px; height: 32px;
  border-radius: var(--r-xs);
  background: var(--blue);
  display: grid;
  place-items: center;
  color: #fff;
  font-weight: 900;
  font-size: 13px;
  letter-spacing: -.5px;
  flex-shrink: 0;
}
.brand b {
  font-size: 13px;
  font-weight: 700;
  color: var(--t);
  white-space: nowrap;
  overflow: hidden;
  line-height: 1.2;
}
.brand small {
  font-size: 10px;
  color: var(--t3);
  display: block;
  white-space: nowrap;
}

/* nav label */
.nav-label {
  font-size: 10px;
  font-weight: 600;
  letter-spacing: .1em;
  text-transform: uppercase;
  color: var(--t3);
  padding: 18px 16px 6px;
  white-space: nowrap;
  overflow: hidden;
}

/* nav links */
nav { flex: 1; padding: 0 8px; }
nav a {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 10px;
  border-radius: var(--r-sm);
  color: var(--t2);
  text-decoration: none;
  font-size: 13px;
  font-weight: 500;
  margin-bottom: 2px;
  transition: background var(--ease), color var(--ease);
  white-space: nowrap;
  overflow: hidden;
  position: relative;
}
nav a svg { width: 17px; height: 17px; flex-shrink: 0; stroke-width: 1.8; transition: var(--ease); }
nav a span { overflow: hidden; white-space: nowrap; }

nav a:hover { color: var(--t); background: rgba(255,255,255,.05); }
nav a.active {
  color: #fff;
  background: var(--blue);
  font-weight: 600;
}
nav a.active svg { opacity: 1; }

/* sidebar bottom */
.sidebar-bottom {
  padding: 8px;
  border-top: 1px solid var(--border);
  flex-shrink: 0;
}
.sidebar-bottom a {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px;
  border-radius: var(--r-sm);
  color: var(--t3);
  text-decoration: none;
  font-size: 13px;
  font-weight: 500;
  transition: var(--ease);
  white-space: nowrap;
}
.sidebar-bottom a svg { width: 17px; height: 17px; flex-shrink: 0; }
.sidebar-bottom a:hover { color: var(--red-l); background: rgba(239,68,68,.07); }

/* ═══════════════════════════════════════════════
   OVERLAY
═══════════════════════════════════════════════ */
.sidebar-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.7);
  z-index: 390;
  opacity: 0;
  transition: opacity var(--ease);
  pointer-events: none;
  backdrop-filter: blur(2px);
}

/* ═══════════════════════════════════════════════
   APP WRAPPER
═══════════════════════════════════════════════ */
.app {
  margin-left: var(--nav-w);
  flex: 1;
  display: flex;
  flex-direction: column;
  min-width: 0;
  transition: margin-left var(--ease);
}

/* ═══════════════════════════════════════════════
   TOPBAR
═══════════════════════════════════════════════ */
.topbar {
  height: 60px;
  position: sticky;
  top: 0;
  z-index: 300;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 0 24px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}

.mobile-menu { display: none; }

.topbar-title {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 14px;
  color: var(--t2);
  font-weight: 500;
}
.topbar-title strong { color: var(--t); font-weight: 700; }
.topbar-title span::after {
  content: '/';
  margin: 0 6px;
  color: var(--t3);
}

.topbar-actions {
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: 10px;
}

.profile {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 5px 12px 5px 5px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 99px;
}
.profile .avatar {
  width: 28px; height: 28px;
  border-radius: 50%;
  background: var(--blue);
  display: grid;
  place-items: center;
  font-size: 12px;
  font-weight: 700;
  color: #fff;
  flex-shrink: 0;
}
.profile span { color: var(--t2); font-size: 12px; font-weight: 500; }
.profile b { display: block; color: var(--t); font-size: 13px; line-height: 1.2; }
.profile small { color: var(--t3); font-size: 10.5px; }

.icon-button {
  width: 34px; height: 34px;
  display: grid; place-items: center;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--r-sm);
  color: var(--t2);
  cursor: pointer;
  transition: var(--ease);
}
.icon-button svg { width: 16px; height: 16px; }
.icon-button:hover { color: var(--t); background: var(--surface-3); border-color: var(--border-2); }

/* ═══════════════════════════════════════════════
   MAIN
═══════════════════════════════════════════════ */
main { flex: 1; }

.page-shell {
  padding: 24px 28px 36px;
  display: flex;
  flex-direction: column;
  gap: 22px;
}

/* ═══════════════════════════════════════════════
   PAGE HEADING CARD
═══════════════════════════════════════════════ */
.page-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r);
  padding: 24px;
}

.hero-card {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  background: linear-gradient(135deg, var(--surface) 0%, rgba(37,99,235,.08) 100%);
  border-color: rgba(37,99,235,.2);
  padding: 26px 28px;
}
.hero-card .eyebrow {
  font-size: 11px;
  font-weight: 600;
  letter-spacing: .08em;
  text-transform: uppercase;
  color: var(--blue-l);
  display: block;
  margin-bottom: 6px;
}
.hero-card h1 { font-size: 22px; font-weight: 800; letter-spacing: -.4px; margin-bottom: 4px; }
.hero-card p { color: var(--t2); font-size: 13.5px; }

.page-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}
.page-heading .eyebrow {
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .08em;
  color: var(--blue-l);
  display: block;
  margin-bottom: 4px;
}
.page-heading h1 { font-size: 18px; font-weight: 700; }
.page-heading p { color: var(--t2); margin-top: 2px; }

/* ═══════════════════════════════════════════════
   STAT CARDS
═══════════════════════════════════════════════ */
.stats {
  display: grid;
  grid-template-columns: repeat(4,1fr);
  gap: 14px;
}
.stat {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r);
  padding: 20px;
  display: flex;
  align-items: center;
  gap: 16px;
  transition: border-color var(--ease), transform var(--ease);
}
.stat:hover { border-color: var(--border-2); transform: translateY(-1px); }
.stat-icon {
  width: 42px; height: 42px;
  border-radius: var(--r-sm);
  display: grid;
  place-items: center;
  background: rgba(37,99,235,.1);
  border: 1px solid rgba(37,99,235,.2);
  color: var(--blue-l);
  flex-shrink: 0;
}
.stat-icon.green { background: rgba(22,163,74,.1); border-color: rgba(22,163,74,.2); color: var(--green-l); }
.stat-icon.cyan  { background: rgba(8,145,178,.1); border-color: rgba(8,145,178,.2); color: var(--cyan-l); }
.stat-icon svg { width: 19px; height: 19px; stroke-width: 1.8; }
.stat div {}
.stat b { display: block; font-size: 24px; font-weight: 800; line-height: 1.1; letter-spacing: -.5px; }
.stat span { font-size: 12px; color: var(--t2); font-weight: 500; }

/* ═══════════════════════════════════════════════
   PANEL (Widget card — styled like EXP Machine)
═══════════════════════════════════════════════ */
.panel {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r);
  overflow: hidden;
}
.panel-title {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 0 18px;
  height: 48px;
  background: var(--blue);
  color: #fff;
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .07em;
}
.panel-title .panel-icon { display: grid; place-items: center; }
.panel-title svg { width: 15px; height: 15px; }
.panel-content { padding: 22px 20px; }

/* dashboard grid */
.dashboard-grid {
  display: grid;
  grid-template-columns: minmax(0,2fr) minmax(240px,1fr);
  gap: 18px;
}

/* ═══════════════════════════════════════════════
   SECTION HEADING + PROGRESS
═══════════════════════════════════════════════ */
h2 { font-size: 16px; font-weight: 700; line-height: 1.2; }
h3 { font-size: 14px; font-weight: 600; color: var(--t); }
p  { color: var(--t2); font-size: 13px; margin-top: 3px; }

.section-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 14px;
}
.usage {
  font-size: 18px;
  font-weight: 800;
  color: var(--blue-l);
  letter-spacing: -.5px;
}
.progress {
  height: 6px;
  background: var(--surface-3);
  border-radius: 99px;
  overflow: hidden;
  margin-bottom: 20px;
}
.progress i {
  display: block;
  height: 100%;
  background: linear-gradient(90deg, var(--blue), var(--blue-l));
  border-radius: 99px;
  transition: width .6s cubic-bezier(.4,0,.2,1);
}

/* ═══════════════════════════════════════════════
   QUICK LINKS
═══════════════════════════════════════════════ */
.quick-actions { display: flex; flex-direction: column; gap: 10px; }
.quick-link {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 14px 16px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--r-sm);
  text-decoration: none;
  transition: var(--ease);
}
.quick-link:hover { background: var(--surface-3); border-color: var(--border-2); transform: translateX(2px); }
.quick-link > span {
  width: 36px; height: 36px;
  border-radius: var(--r-xs);
  background: rgba(37,99,235,.1);
  border: 1px solid rgba(37,99,235,.2);
  display: grid;
  place-items: center;
  color: var(--blue-l);
  flex-shrink: 0;
}
.quick-link > span.green { background: rgba(22,163,74,.1); border-color: rgba(22,163,74,.2); color: var(--green-l); }
.quick-link > span svg { width: 16px; height: 16px; stroke-width: 2; }
.quick-link div { flex: 1; }
.quick-link b { display: block; font-size: 13.5px; font-weight: 600; color: var(--t); }
.quick-link small { font-size: 12px; color: var(--t2); }
.quick-link > svg { width: 14px; height: 14px; color: var(--t3); }

/* ═══════════════════════════════════════════════
   BUTTONS
═══════════════════════════════════════════════ */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  height: 38px;
  padding: 0 16px;
  border-radius: var(--r-sm);
  font: 600 13px 'Inter', sans-serif;
  cursor: pointer;
  transition: var(--ease);
  text-decoration: none;
  border: 1px solid transparent;
  white-space: nowrap;
  flex-shrink: 0;
}
.btn svg { width: 15px; height: 15px; flex-shrink: 0; }
.btn:active { transform: scale(.97); }
.btn:disabled { opacity: .4; cursor: not-allowed; pointer-events: none; }

.btn.primary { background: var(--blue); color: #fff; }
.btn.primary:hover { background: var(--blue-h); }

.btn.success { background: var(--green); color: #fff; }
.btn.success:hover { background: #15803d; }

.btn.danger { background: rgba(220,38,38,.1); border-color: rgba(220,38,38,.2); color: var(--red-l); }
.btn.danger:hover { background: rgba(220,38,38,.18); border-color: rgba(220,38,38,.35); }

.btn.secondary { background: var(--surface-2); border-color: var(--border); color: var(--t); }
.btn.secondary:hover { background: var(--surface-3); border-color: var(--border-2); }

.btn.block { display: flex; width: 100%; margin-bottom: 8px; }
.btn.block:last-child { margin-bottom: 0; }

/* text button */
.text-button {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: none;
  border: none;
  color: var(--blue-l);
  font: 500 12.5px 'Inter', sans-serif;
  cursor: pointer;
  transition: var(--ease);
  padding: 4px 2px;
}
.text-button svg { width: 14px; height: 14px; }
.text-button:hover { color: var(--t); }

/* icon button (table) */
.icon {
  width: 30px; height: 30px;
  display: grid; place-items: center;
  border-radius: var(--r-xs);
  border: 1px solid var(--border);
  background: var(--surface-2);
  color: var(--t2);
  cursor: pointer;
  transition: var(--ease);
}
.icon svg { width: 14px; height: 14px; }
.icon:hover { background: var(--surface-3); color: var(--t); }
.icon.danger { background: rgba(220,38,38,.07); border-color: rgba(220,38,38,.2); color: var(--red-l); }
.icon.danger:hover { background: rgba(220,38,38,.15); }

/* ═══════════════════════════════════════════════
   FORMS
═══════════════════════════════════════════════ */
label {
  display: block;
  font-size: 12px;
  font-weight: 600;
  color: var(--t2);
  margin-bottom: 14px;
}
label:last-child { margin-bottom: 0; }

input, select, textarea {
  display: block;
  width: 100%;
  height: 38px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--r-sm);
  padding: 0 12px;
  color: var(--t);
  font: 13.5px 'Inter', sans-serif;
  outline: none;
  transition: border-color var(--ease), background var(--ease);
  margin-top: 5px;
  -webkit-appearance: none;
  appearance: none;
}
input::placeholder { color: var(--t3); }
input:focus, select:focus { border-color: var(--blue); background: var(--surface-3); }

select {
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%238b8b9a' stroke-width='2.5' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 12px center;
  padding-right: 36px;
  cursor: pointer;
}
select option { background: #1f1f27; }

.form-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0 18px;
}

/* switch toggle */
.switch-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 12px 14px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--r-sm);
  cursor: pointer;
  margin-bottom: 0;
  margin-top: 12px;
}
.switch-row.compact { margin-top: 6px; }
.switch-row span { flex: 1; }
.switch-row b { display: block; font-size: 13px; font-weight: 600; color: var(--t); }
.switch-row small { display: block; font-size: 12px; color: var(--t2); margin-top: 1px; }

.switch-row input[type="checkbox"] {
  display: none;
}
.switch-row i {
  width: 40px; height: 22px;
  border-radius: 99px;
  background: var(--surface-3);
  border: 1px solid var(--border-2);
  position: relative;
  transition: var(--ease);
  flex-shrink: 0;
  cursor: pointer;
  display: block;
  margin: 0;
}
.switch-row i::after {
  content: '';
  position: absolute;
  width: 16px; height: 16px;
  top: 2px; left: 2px;
  border-radius: 50%;
  background: var(--t3);
  transition: var(--ease);
}
.switch-row input:checked ~ i { background: var(--blue); border-color: var(--blue); }
.switch-row input:checked ~ i::after { left: 20px; background: #fff; }

/* ═══════════════════════════════════════════════
   ACCOUNT PICKER
═══════════════════════════════════════════════ */
.session-layout {
  display: grid;
  grid-template-columns: minmax(220px,1fr) 1.3fr;
  gap: 28px;
}

.form-section {}
.section-title {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  margin-bottom: 14px;
}
.section-title > span {
  width: 24px; height: 24px;
  border-radius: 50%;
  background: var(--blue);
  color: #fff;
  font-size: 12px;
  font-weight: 700;
  display: grid;
  place-items: center;
  flex-shrink: 0;
  margin-top: 1px;
}
.section-title h3 { font-size: 14px; font-weight: 700; margin-bottom: 2px; }
.section-title p { font-size: 12px; color: var(--t2); margin: 0; }

.picker-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 8px;
}
.picker-count { font-size: 12px; color: var(--t2); font-weight: 500; }

.account-picker {
  border: 1px solid var(--border);
  border-radius: var(--r-sm);
  overflow: hidden;
  max-height: 240px;
  overflow-y: auto;
  background: var(--surface-2);
}

.account-picker label {
  display: flex;
  align-items: center;
  gap: 11px;
  padding: 11px 14px;
  margin: 0;
  cursor: pointer;
  border-bottom: 1px solid var(--border);
  transition: background var(--ease);
  font-size: 13.5px;
  color: var(--t);
  font-weight: 500;
  position: relative;
}
.account-picker label:last-child { border-bottom: 0; }
.account-picker label:hover { background: var(--surface-3); }
.account-picker label.is-checked { background: rgba(37,99,235,.09); }

.account-picker input[type="checkbox"] {
  width: 17px; height: 17px;
  border-radius: 4px;
  border: 1.5px solid var(--border-2);
  background: var(--surface-3);
  flex-shrink: 0;
  cursor: pointer;
  transition: var(--ease);
  display: block;
  padding: 0;
  margin: 0;
  min-height: unset;
  -webkit-appearance: none;
  appearance: none;
  position: relative;
}
.account-picker input[type="checkbox"]:checked {
  background: var(--blue);
  border-color: var(--blue);
}
.account-picker input[type="checkbox"]:checked::after {
  content: '';
  display: block;
  width: 4px; height: 8px;
  border: 2px solid #fff;
  border-top: 0;
  border-left: 0;
  transform: rotate(45deg) translate(2px,-1px);
  position: absolute;
  left: 4px; top: 1px;
}

.account-avatar {
  width: 26px; height: 26px;
  border-radius: 50%;
  background: var(--blue);
  color: #fff;
  font-size: 11px;
  font-weight: 700;
  display: grid;
  place-items: center;
  flex-shrink: 0;
}

.account-picker label > i[data-lucide] {
  margin-left: auto;
  opacity: 0;
  width: 14px; height: 14px;
  color: var(--blue-l);
  transition: var(--ease);
}
.account-picker label.is-checked > i[data-lucide] { opacity: 1; }
.account-picker label > i[data-lucide] svg { width: 14px; height: 14px; }

.empty-mini {
  padding: 24px;
  text-align: center;
  color: var(--t3);
  font-size: 13px;
}

/* ═══════════════════════════════════════════════
   FORM FOOTER
═══════════════════════════════════════════════ */
.form-footer {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 12px;
  padding-top: 20px;
  margin-top: 20px;
  border-top: 1px solid var(--border);
}
.form-footer > span { font-size: 12.5px; color: var(--t3); margin-right: auto; }

/* ═══════════════════════════════════════════════
   SESSION CONTROLS
═══════════════════════════════════════════════ */
.session-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 20px;
  flex-wrap: wrap;
}
.session-toolbar div { display: flex; flex-direction: column; gap: 2px; }
.session-toolbar strong { font-size: 14px; font-weight: 700; }
.session-toolbar small { font-size: 12px; color: var(--t2); }
.status-dot {
  display: none; /* JS controlled */
}

.control-grid {
  display: grid;
  grid-template-columns: repeat(2,1fr) 1fr;
  gap: 16px;
}

.control-card {
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--r-sm);
  padding: 18px;
  display: flex;
  flex-direction: column;
}
.control-icon {
  width: 34px; height: 34px;
  border-radius: var(--r-xs);
  background: rgba(37,99,235,.1);
  border: 1px solid rgba(37,99,235,.2);
  color: var(--blue-l);
  display: grid;
  place-items: center;
  flex-shrink: 0;
  margin-bottom: 10px;
}
.control-icon.green { background: rgba(22,163,74,.1); border-color: rgba(22,163,74,.2); color: var(--green-l); }
.control-icon.cyan  { background: rgba(8,145,178,.1); border-color: rgba(8,145,178,.2); color: var(--cyan-l); }
.control-icon svg { width: 16px; height: 16px; stroke-width: 1.8; }
.control-copy { margin-bottom: 14px; }
.control-copy h3 { font-size: 13.5px; font-weight: 700; margin-bottom: 2px; }
.control-copy p { font-size: 12px; color: var(--t2); margin: 0; }

.log-card { grid-column: span 3; }
.log-title {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 10px;
}
.log-title > div { display: flex; align-items: center; gap: 10px; }
.log-title .control-icon { margin-bottom: 0; }

/* ═══════════════════════════════════════════════
   LOG
═══════════════════════════════════════════════ */
.log {
  height: 180px;
  background: #09090b;
  border: 1px solid var(--border);
  border-radius: var(--r-xs);
  font: 12.5px/1.75 'Fira Code', 'Cascadia Code', Consolas, monospace;
  color: #7dd3fc;
  white-space: pre-wrap;
  overflow-y: auto;
  padding: 12px 14px;
}

/* ═══════════════════════════════════════════════
   TABLE
═══════════════════════════════════════════════ */
.list-summary {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 0 14px;
  font-size: 13px;
  color: var(--t2);
  font-weight: 500;
}
.list-summary strong { color: var(--t); font-weight: 700; }

.table-wrap { border: 1px solid var(--border); border-radius: var(--r-sm); overflow: hidden; }
table { width: 100%; border-collapse: collapse; }
thead tr { background: var(--surface-2); }
th {
  padding: 11px 16px;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: .05em;
  text-transform: uppercase;
  color: var(--t2);
  text-align: left;
  border-bottom: 1px solid var(--border);
}
td {
  padding: 14px 16px;
  font-size: 13px;
  color: var(--t);
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
}
tbody tr:last-child td { border-bottom: 0; }
tbody tr { transition: background var(--ease); }
tbody tr:hover { background: var(--surface-2); }
td small { display: block; font-size: 11.5px; color: var(--t3); margin-top: 2px; }
td strong { font-weight: 600; }
.align-right { text-align: right; }

.account-cell { display: flex; align-items: center; gap: 10px; }

.region-pill {
  display: inline-block;
  padding: 3px 9px;
  background: var(--surface-3);
  border: 1px solid var(--border);
  border-radius: var(--r-xs);
  font-size: 11.5px;
  font-weight: 600;
  color: var(--t2);
}

/* ═══════════════════════════════════════════════
   BADGES
═══════════════════════════════════════════════ */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 4px 10px;
  border-radius: var(--r-xs);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: .02em;
}
.badge::before { content: ''; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.badge.online  { background: rgba(22,163,74,.12); color: var(--green-l); border: 1px solid rgba(22,163,74,.25); }
.badge.offline { background: rgba(100,100,120,.12); color: var(--t2); border: 1px solid var(--border); }
.badge.muted   { background: rgba(100,100,120,.12); color: var(--t2); border: 1px solid var(--border); }
.badge.pending { background: rgba(217,119,6,.12); color: var(--amber-l); border: 1px solid rgba(217,119,6,.25); }

/* ═══════════════════════════════════════════════
   DIALOG / MODAL
═══════════════════════════════════════════════ */
dialog {
  background: var(--surface);
  border: 1px solid var(--border-2);
  border-radius: var(--r);
  box-shadow: 0 24px 80px rgba(0,0,0,.8);
  color: var(--t);
  width: min(460px,94vw);
  padding: 0;
  position: fixed;
  top: 50%;
  left: 50%;
  transform: translate(-50%,-50%);
  margin: 0;
}
dialog::backdrop { background: rgba(0,0,0,.75); backdrop-filter: blur(4px); }

.dialog-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  padding: 22px 22px 16px;
  border-bottom: 1px solid var(--border);
}
.dialog-head .eyebrow {
  font-size: 10.5px;
  font-weight: 700;
  letter-spacing: .08em;
  text-transform: uppercase;
  color: var(--blue-l);
  display: block;
  margin-bottom: 4px;
}
.dialog-head h2 { font-size: 17px; font-weight: 700; }
.dialog-close {
  width: 30px; height: 30px;
  display: grid; place-items: center;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--r-xs);
  color: var(--t2);
  cursor: pointer;
  transition: var(--ease);
  flex-shrink: 0;
}
.dialog-close svg { width: 15px; height: 15px; }
.dialog-close:hover { color: var(--t); background: var(--surface-3); }
.dialog-body { padding: 20px 22px 24px; }

/* ═══════════════════════════════════════════════
   TOAST
═══════════════════════════════════════════════ */
#toast {
  position: fixed;
  right: 20px; bottom: 20px;
  background: var(--surface-2);
  border: 1px solid var(--border-2);
  padding: 12px 18px;
  border-radius: var(--r-sm);
  font-size: 13.5px;
  font-weight: 500;
  color: var(--t);
  opacity: 0;
  transform: translateY(8px) scale(.97);
  transition: opacity var(--ease), transform var(--ease);
  pointer-events: none;
  z-index: 9000;
  max-width: 340px;
  box-shadow: 0 8px 32px rgba(0,0,0,.6);
}
#toast.show { opacity: 1; transform: none; }
#toast.error { background: rgba(220,38,38,.1); border-color: rgba(220,38,38,.25); color: var(--red-l); }

/* ═══════════════════════════════════════════════
   MACHINE STATUS BADGE INLINE
═══════════════════════════════════════════════ */
#machineBadge { font-size: 13px; padding: 5px 14px; }

/* ═══════════════════════════════════════════════
   LOGIN
═══════════════════════════════════════════════ */
.login-page {
  display: block;
  background: var(--bg);
  min-height: 100vh;
  display: grid;
  place-items: center;
}
.login-card {
  width: min(420px,94vw);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r);
  padding: 40px;
  box-shadow: 0 24px 80px rgba(0,0,0,.7);
}
.login-logo {
  width: 48px; height: 48px;
  background: var(--blue);
  border-radius: var(--r-sm);
  display: grid;
  place-items: center;
  font-size: 20px;
  font-weight: 900;
  color: #fff;
  margin: 0 auto 20px;
}
.login-card h1 { text-align: center; font-size: 22px; font-weight: 800; margin-bottom: 4px; }
.login-card > p { text-align: center; color: var(--t2); font-size: 13px; margin-bottom: 24px; }
.alert { padding: 11px 14px; border-radius: var(--r-xs); font-size: 13px; font-weight: 500; margin-bottom: 16px; }
.alert.error { background: rgba(220,38,38,.1); color: var(--red-l); border: 1px solid rgba(220,38,38,.2); }

/* ═══════════════════════════════════════════════
   EMPTY STATE
═══════════════════════════════════════════════ */
.empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 10px;
  padding: 40px 20px;
  text-align: center;
}
.empty-state svg { width: 32px; height: 32px; color: var(--t3); }
.empty-state b { font-size: 15px; font-weight: 700; color: var(--t2); }
.empty-state span { font-size: 13px; color: var(--t3); }

/* ═══════════════════════════════════════════════
   SCROLLBAR
═══════════════════════════════════════════════ */
::-webkit-scrollbar { width: 5px; height: 5px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--surface-3); border-radius: 99px; }
::-webkit-scrollbar-thumb:hover { background: var(--border-2); }

/* ═══════════════════════════════════════════════
   RESPONSIVE — MEDIUM (collapse sidebar)
═══════════════════════════════════════════════ */
@media (max-width: 1100px) {
  :root { --nav-w: var(--nav-sm); }
  .brand b, .brand small, .nav-label, nav a span, .sidebar-bottom a span { display: none; }
  .brand { justify-content: center; }
  .brand-mark { margin: 0; }
  nav a, .sidebar-bottom a { justify-content: center; padding: 11px; }
  nav a gap, .sidebar-bottom a { gap: 0; }
  .control-grid { grid-template-columns: 1fr 1fr; }
  .log-card { grid-column: span 2; }
}

/* ═══════════════════════════════════════════════
   RESPONSIVE — MOBILE (off-canvas)
═══════════════════════════════════════════════ */
@media (max-width: 768px) {
  :root { --nav-w: 0px; }
  body { display: block; }

  .sidebar {
    width: 240px !important;
    transform: translateX(-100%);
    transition: transform var(--ease);
  }
  .sidebar.open { transform: translateX(0); }
  .sidebar-overlay { display: block; }
  .sidebar.open ~ .sidebar-overlay { opacity: 1; pointer-events: all; }

  /* restore labels inside open sidebar */
  .sidebar.open .brand { justify-content: flex-start; }
  .sidebar.open .brand b, .sidebar.open .brand small,
  .sidebar.open .nav-label, .sidebar.open nav a span,
  .sidebar.open .sidebar-bottom a span { display: block; }
  .sidebar.open nav a, .sidebar.open .sidebar-bottom a { justify-content: flex-start; padding: 10px 10px; }

  .app { margin-left: 0; }
  .mobile-menu { display: grid; }

  .page-shell { padding: 16px 14px 28px; gap: 16px; }
  .stats { grid-template-columns: 1fr 1fr; }
  .hero-card { flex-direction: column; align-items: flex-start; }
  .dashboard-grid { grid-template-columns: 1fr; }
  .session-layout { grid-template-columns: 1fr; }
  .control-grid { grid-template-columns: 1fr; }
  .log-card { grid-column: span 1; }
  .form-grid { grid-template-columns: 1fr; }
  .page-heading { flex-direction: column; align-items: flex-start; }
  dialog { width: 95vw; }
  .login-card { padding: 28px 22px; }
}

@media (max-width: 480px) {
  .stats { grid-template-columns: 1fr; }
  .topbar { padding: 0 14px; }
}
.nickname-option {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-top: 18px;
  color: var(--t1);
  font-size: 13px;
  font-weight: 700;
}
.nickname-option input { max-width: 100%; }
.nickname-option small {
  color: var(--t2);
  font-size: 12px;
  font-weight: 500;
  line-height: 1.5;
}
