/* ── Reset ────────────────────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

/* ── MD3 Typeface refs ───────────────────────────────────────────────────── */
:root {
  --font: 'Roboto', -apple-system, sans-serif;
  --mono: 'Roboto Mono', 'SF Mono', monospace;
  --radius:        12px;
  --radius-sm:     8px;
  --radius-xs:     4px;
  --radius-full:   999px;
  --radius-dialog: 28px;
}

/* ─── Light theme ─────────────────────────────────────────────────────────── */
html, html[data-theme="light"] {
  --bg:              #F0F4F9;
  --surface:         #FAFCFF;
  --surface-1:       #EEF3FA;
  --surface-2:       #E3ECF7;
  --surface-3:       #D9E5F3;
  --on-surface:      #1A1C20;
  --on-surface-var:  #44474F;
  --outline:         #74777F;
  --outline-var:     #C3C7CF;

  --primary:         #0061A4;
  --on-primary:      #FFFFFF;
  --primary-cont:    #D1E4FF;
  --on-primary-cont: #001D36;

  --green:           #006D36;
  --green-dim:       rgba(0,109,54,.1);
  --green-on:        #FFFFFF;
  --red:             #BA1A1A;
  --red-dim:         rgba(186,26,26,.1);
  --red-on:          #FFFFFF;
  --amber:           #695F00;
  --amber-dim:       rgba(105,95,0,.1);
  --unknown:         #44474F;
  --unknown-dim:     rgba(68,71,79,.08);

  --shadow-1: 0 1px 2px rgba(0,0,0,.1), 0 2px 4px rgba(0,0,0,.06);
  --shadow-2: 0 2px 6px rgba(0,0,0,.1), 0 4px 16px rgba(0,0,0,.07);
  --shadow-3: 0 4px 12px rgba(0,0,0,.1), 0 8px 32px rgba(0,0,0,.08);
  --scrim:    rgba(0,0,0,.32);

  color-scheme: light;
}

/* ─── Dark theme ──────────────────────────────────────────────────────────── */
html[data-theme="dark"] {
  --bg:              #111318;
  --surface:         #1A1C20;
  --surface-1:       #1F2329;
  --surface-2:       #252B32;
  --surface-3:       #2C333B;
  --on-surface:      #E1E2E8;
  --on-surface-var:  #C3C7CF;
  --outline:         #8D9199;
  --outline-var:     #43474E;

  --primary:         #9ECAFF;
  --on-primary:      #003258;
  --primary-cont:    #004A7F;
  --on-primary-cont: #D1E4FF;

  --green:           #78DC91;
  --green-dim:       rgba(120,220,145,.15);
  --green-on:        #003919;
  --red:             #FFB4AB;
  --red-dim:         rgba(255,180,171,.15);
  --red-on:          #690005;
  --amber:           #DFC844;
  --amber-dim:       rgba(223,200,68,.12);
  --unknown:         #C3C7CF;
  --unknown-dim:     rgba(195,199,207,.1);

  --shadow-1: 0 1px 3px rgba(0,0,0,.5), 0 2px 6px rgba(0,0,0,.4);
  --shadow-2: 0 2px 8px rgba(0,0,0,.5), 0 4px 18px rgba(0,0,0,.35);
  --shadow-3: 0 6px 20px rgba(0,0,0,.5), 0 12px 40px rgba(0,0,0,.35);
  --scrim:    rgba(0,0,0,.55);

  color-scheme: dark;
}

/* ─── Base ────────────────────────────────────────────────────────────────── */
html { font-size: 15px; }

body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--on-surface);
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
  transition: background .25s, color .25s;
}

a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }

/* ─── Top App Bar ─────────────────────────────────────────────────────────── */
header {
  position: sticky;
  top: 0;
  z-index: 100;
  background: var(--surface-1);
  transition: background .25s, box-shadow .2s;
}
header.scrolled { box-shadow: var(--shadow-2); }

.header-inner {
  max-width: 1140px;
  margin: 0 auto;
  padding: 0 16px;
  height: 64px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.logo {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 1.1rem;
  font-weight: 500;
  letter-spacing: .01em;
  color: var(--on-surface);
  user-select: none;
}
.logo svg { color: var(--primary); flex-shrink: 0; }

.header-actions {
  display: flex;
  align-items: center;
  gap: 4px;
}

/* ─── Summary strip ───────────────────────────────────────────────────────── */
.summary-bar {
  max-width: 1140px;
  margin: 20px auto 0;
  padding: 0 16px;
  display: flex;
  align-items: stretch;
  background: var(--surface);
  border-radius: var(--radius);
  box-shadow: var(--shadow-1);
  overflow: hidden;
  transition: background .25s;
}

.summary-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 16px 24px;
  flex: 1;
  transition: background .15s;
}
.summary-item:hover { background: var(--surface-1); }

.summary-num {
  font-size: 1.6rem;
  font-weight: 400;
  letter-spacing: -.02em;
  line-height: 1;
  margin-bottom: 4px;
  font-variant-numeric: tabular-nums;
  color: var(--on-surface);
}
.summary-num.green { color: var(--green); }
.summary-num.red   { color: var(--red); }
.summary-num.muted { color: var(--outline); }

.summary-label {
  font-size: .7rem;
  text-transform: uppercase;
  letter-spacing: .08em;
  color: var(--outline);
  font-weight: 500;
}
.summary-divider {
  width: 1px;
  background: var(--outline-var);
  margin: 12px 0;
  flex-shrink: 0;
}

/* ─── MD3 Buttons ─────────────────────────────────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 0 20px;
  height: 40px;
  border-radius: var(--radius-full);
  border: none;
  font-size: .875rem;
  font-weight: 500;
  font-family: var(--font);
  letter-spacing: .01em;
  cursor: pointer;
  white-space: nowrap;
  position: relative;
  overflow: hidden;
  transition: box-shadow .2s, background .15s;
  -webkit-tap-highlight-color: transparent;
}
.btn::after {
  content: '';
  position: absolute;
  inset: 0;
  background: currentColor;
  opacity: 0;
  transition: opacity .15s;
  pointer-events: none;
}
.btn:hover::after  { opacity: .08; }
.btn:active::after { opacity: .12; }
.btn:disabled { opacity: .38; cursor: not-allowed; pointer-events: none; }

/* Filled */
.btn-primary {
  background: var(--primary);
  color: var(--on-primary);
  box-shadow: var(--shadow-1);
}
.btn-primary:hover { box-shadow: var(--shadow-2); }

/* Tonal (secondary action) */
.btn-ghost {
  background: var(--surface-2);
  color: var(--on-surface-var);
  border: 1px solid var(--outline-var);
}
.btn-ghost:hover { background: var(--surface-3); }

/* Error tonal */
.btn-danger {
  background: var(--red-dim);
  color: var(--red);
}
.btn-danger:hover { background: rgba(186,26,26,.18); }
html[data-theme="dark"] .btn-danger:hover { background: rgba(255,180,171,.22); }

/* Icon button */
.btn-icon {
  background: none;
  border: none;
  cursor: pointer;
  color: var(--on-surface-var);
  display: flex;
  align-items: center;
  justify-content: center;
  width: 40px;
  height: 40px;
  border-radius: var(--radius-full);
  padding: 0;
  position: relative;
  overflow: hidden;
  transition: background .15s;
  flex-shrink: 0;
  font-family: var(--font);
}
.btn-icon::after {
  content: '';
  position: absolute;
  inset: 0;
  background: currentColor;
  opacity: 0;
  transition: opacity .15s;
  pointer-events: none;
  border-radius: inherit;
}
.btn-icon:hover::after  { opacity: .08; }
.btn-icon:active::after { opacity: .12; }
.btn-icon:hover { color: var(--on-surface); }

/* ─── Badge / chip ────────────────────────────────────────────────────────── */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: .75rem;
  font-weight: 500;
  padding: 4px 12px;
  border-radius: var(--radius-full);
  letter-spacing: .01em;
  white-space: nowrap;
}
.badge-warn {
  background: var(--amber-dim);
  color: var(--amber);
  border: 1px solid color-mix(in srgb, var(--amber) 25%, transparent);
}

/* ─── Main ────────────────────────────────────────────────────────────────── */
main {
  max-width: 1140px;
  margin: 0 auto;
  padding: 20px 16px 72px;
}

/* ─── Sites grid ──────────────────────────────────────────────────────────── */
.sites-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
  gap: 12px;
  margin-top: 12px;
}

/* ─── Site card (MD3 Elevated Card) ──────────────────────────────────────── */
.site-card {
  background: var(--surface);
  border-radius: var(--radius);
  padding: 16px 20px 14px;
  cursor: pointer;
  box-shadow: var(--shadow-1);
  position: relative;
  overflow: hidden;
  transition: box-shadow .2s, transform .15s, background .25s;
  /* State layer */
}
.site-card::before {
  content: '';
  position: absolute;
  inset: 0;
  background: var(--on-surface);
  opacity: 0;
  transition: opacity .15s;
  pointer-events: none;
}
.site-card:hover { box-shadow: var(--shadow-2); transform: translateY(-2px); }
.site-card:hover::before { opacity: .04; }
.site-card:active::before { opacity: .08; }

/* Status accent stripe */
.site-card::after {
  content: '';
  position: absolute;
  top: 0; left: 0; right: 0;
  height: 4px;
  border-radius: var(--radius) var(--radius) 0 0;
}
.site-card.up::after      { background: var(--green); }
.site-card.down::after    { background: var(--red); }
.site-card.unknown::after { background: var(--outline-var); }

.card-top {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 14px;
}

.card-name {
  font-size: .95rem;
  font-weight: 500;
  color: var(--on-surface);
  line-height: 1.35;
  word-break: break-word;
}
.card-url {
  font-size: .75rem;
  color: var(--outline);
  margin-top: 2px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* Status chip */
.status-pill {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-size: .72rem;
  font-weight: 500;
  letter-spacing: .02em;
  padding: 4px 10px;
  border-radius: var(--radius-full);
  flex-shrink: 0;
  border: 1px solid transparent;
}
.status-pill .dot {
  width: 6px; height: 6px;
  border-radius: 50%;
  flex-shrink: 0;
}
.status-pill.up {
  background: var(--green-dim);
  color: var(--green);
  border-color: color-mix(in srgb, var(--green) 20%, transparent);
}
.status-pill.up .dot {
  background: var(--green);
  animation: md-pulse 2.4s ease-in-out infinite;
}
.status-pill.down {
  background: var(--red-dim);
  color: var(--red);
  border-color: color-mix(in srgb, var(--red) 20%, transparent);
}
.status-pill.down .dot { background: var(--red); }
.status-pill.unknown {
  background: var(--unknown-dim);
  color: var(--unknown);
  border-color: color-mix(in srgb, var(--unknown) 18%, transparent);
}
.status-pill.unknown .dot { background: var(--outline); }

@keyframes md-pulse {
  0%, 100% { opacity: 1; transform: scale(1); }
  50% { opacity: .45; transform: scale(.85); }
}

.card-metrics {
  display: flex;
  gap: 20px;
}
.metric { display: flex; flex-direction: column; gap: 2px; }
.metric-val {
  font-size: .875rem;
  font-weight: 500;
  color: var(--on-surface);
  font-variant-numeric: tabular-nums;
}
.metric-lbl {
  font-size: .67rem;
  color: var(--outline);
  text-transform: uppercase;
  letter-spacing: .06em;
}

.card-footer {
  margin-top: 14px;
  padding-top: 12px;
  border-top: 1px solid var(--outline-var);
  font-size: .72rem;
  color: var(--outline);
}
.error-msg {
  font-size: .72rem;
  color: var(--red);
  margin-top: 8px;
  font-family: var(--mono);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* ─── Empty state ─────────────────────────────────────────────────────────── */
.empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 12px;
  padding: 96px 24px;
  color: var(--outline);
  text-align: center;
}
.empty-state svg { opacity: .4; }
.empty-state h3 { font-size: 1.1rem; font-weight: 400; color: var(--on-surface-var); }
.empty-state p  { font-size: .875rem; }

/* ─── MD3 Dialog (Modal) ──────────────────────────────────────────────────── */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: var(--scrim);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 200;
  animation: md-fade-in .15s;
  padding: 24px;
}

.modal {
  background: var(--surface);
  border-radius: var(--radius-dialog);
  padding: 24px 0 0;
  width: 100%;
  max-width: 440px;
  box-shadow: var(--shadow-3);
  animation: md-slide-up .2s cubic-bezier(0.2,0,0,1);
  overflow: hidden;
  transition: background .25s;
}
.modal-sm { max-width: 380px; }

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 24px 16px;
}
.modal-header h2 {
  font-size: 1.1rem;
  font-weight: 500;
  color: var(--on-surface);
  letter-spacing: .005em;
}

.modal-footer {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  padding: 16px 24px;
  background: var(--surface-1);
  border-top: 1px solid var(--outline-var);
}

/* ─── Tag filter bar ──────────────────────────────────────────────────────── */
.filter-bar {
  max-width: 1140px;
  margin: 12px auto 0;
  padding: 0 16px;
}
.filter-bar-inner {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}
.filter-chip {
  display: inline-flex;
  align-items: center;
  height: 32px;
  padding: 0 14px;
  border-radius: var(--radius-full);
  border: 1px solid var(--outline-var);
  background: var(--surface);
  color: var(--on-surface-var);
  font-size: .8rem;
  font-weight: 500;
  font-family: var(--font);
  cursor: pointer;
  transition: background .15s, border-color .15s, color .15s;
}
.filter-chip:hover { background: var(--surface-2); border-color: var(--outline); }
.filter-chip.active {
  background: var(--primary-cont);
  color: var(--on-primary-cont);
  border-color: transparent;
}

/* ─── MD3 Secondary Tabs ──────────────────────────────────────────────────── */
.modal-tabs {
  display: flex;
  padding: 0 16px;
  border-bottom: 1px solid var(--outline-var);
  margin-bottom: 0;
}
.modal-tab {
  background: none;
  border: none;
  border-bottom: 2px solid transparent;
  color: var(--on-surface-var);
  cursor: pointer;
  font-size: .875rem;
  font-weight: 500;
  font-family: var(--font);
  letter-spacing: .01em;
  padding: 12px 16px;
  margin-bottom: -1px;
  transition: color .15s, border-color .15s, background .15s;
  border-radius: var(--radius-sm) var(--radius-sm) 0 0;
  position: relative;
  overflow: hidden;
}
.modal-tab::after {
  content: '';
  position: absolute;
  inset: 0;
  background: var(--primary);
  opacity: 0;
  transition: opacity .15s;
  pointer-events: none;
}
.modal-tab:hover::after { opacity: .06; }
.modal-tab.active { color: var(--primary); border-bottom-color: var(--primary); }

/* ─── Form (inside modal) ─────────────────────────────────────────────────── */
#site-form, #bulk-form {
  padding: 20px 24px 0;
}

.field {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-bottom: 16px;
}
.field label {
  font-size: .78rem;
  font-weight: 500;
  color: var(--on-surface-var);
  letter-spacing: .04em;
}

/* MD3 Outlined Text Field */
.field input,
.field textarea {
  background: transparent;
  border: 1px solid var(--outline-var);
  border-radius: var(--radius-sm);
  color: var(--on-surface);
  padding: 11px 16px;
  font-size: .9rem;
  font-family: var(--font);
  outline: none;
  transition: border-color .15s, box-shadow .15s;
  width: 100%;
}
.field textarea {
  font-family: var(--mono);
  font-size: .82rem;
  line-height: 1.6;
  resize: vertical;
}
.field input:hover,
.field textarea:hover { border-color: var(--on-surface-var); }
.field input:focus,
.field textarea:focus {
  border-color: var(--primary);
  border-width: 2px;
  padding: 10px 15px; /* compensate for wider border */
  box-shadow: none;
}
.field textarea:focus { padding: 10px 15px; }
.field input::placeholder,
.field textarea::placeholder { color: var(--outline); }

/* ─── Form row (side-by-side fields) ─────────────────────────────────────── */
.form-row {
  display: flex;
  gap: 12px;
}
.form-row .field { margin-bottom: 16px; }

.label-hint {
  font-weight: 400;
  text-transform: none;
  letter-spacing: 0;
  color: var(--outline);
  font-size: .72rem;
}

/* ─── Tag chips on cards ─────────────────────────────────────────────────── */
.card-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
  margin-top: 10px;
}
.tag-chip {
  display: inline-flex;
  align-items: center;
  height: 22px;
  padding: 0 8px;
  border-radius: var(--radius-full);
  background: var(--surface-2);
  color: var(--on-surface-var);
  font-size: .68rem;
  font-weight: 500;
  letter-spacing: .02em;
  border: 1px solid var(--outline-var);
}

/* ─── Expected status badge on card ─────────────────────────────────────── */
.expected-badge {
  display: inline-block;
  font-size: .68rem;
  color: var(--outline);
  background: var(--surface-2);
  border: 1px solid var(--outline-var);
  border-radius: var(--radius-xs);
  padding: 2px 6px;
  margin-bottom: 10px;
  font-family: var(--mono);
}

/* ─── Paused card state ──────────────────────────────────────────────────── */
.site-card.paused { opacity: .65; }
.site-card.paused::after { background: var(--outline-var); }
.status-pill.paused {
  background: var(--unknown-dim);
  color: var(--outline);
  border-color: var(--outline-var);
}
.status-pill.paused .dot { background: var(--outline); }

/* ─── Gmail-style email chip field ──────────────────────────────────────────── */
.email-to-wrap {
  border: 1px solid var(--outline-var);
  border-radius: var(--radius-sm);
  padding: 6px 8px;
  min-height: 44px;
  cursor: text;
  transition: border-color .15s, border-width .1s, padding .1s;
}
.email-to-wrap:focus-within {
  border-color: var(--primary);
  border-width: 2px;
  padding: 5px 7px;
}
.email-chips-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 5px;
  width: 100%;
}
.email-chip-item {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  background: var(--primary-cont);
  color: var(--on-primary-cont);
  border-radius: var(--radius-full);
  padding: 3px 6px 3px 10px;
  font-size: .8rem;
  font-weight: 500;
  max-width: 260px;
  flex-shrink: 0;
  animation: chip-in .12s ease-out;
}
.email-chip-item.invalid {
  background: var(--red-dim);
  color: var(--red);
}
.email-chip-item > span {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.email-chip-remove {
  background: none;
  border: none;
  cursor: pointer;
  color: inherit;
  opacity: .6;
  padding: 2px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  flex-shrink: 0;
  transition: opacity .12s, background .12s;
}
.email-chip-remove:hover { opacity: 1; background: rgba(0,0,0,.1); }
.email-chip-input {
  border: none;
  outline: none;
  background: transparent;
  color: var(--on-surface);
  font-size: .88rem;
  font-family: var(--font);
  min-width: 140px;
  flex: 1;
  padding: 3px 4px;
  line-height: 1.5;
}
.email-chip-input::placeholder { color: var(--outline); }

@keyframes chip-in {
  from { opacity: 0; transform: scale(.85); }
  to   { opacity: 1; transform: scale(1); }
}

.bulk-hint {
  font-size: .75rem;
  color: var(--outline);
  margin-bottom: 4px;
  line-height: 1.5;
}
.bulk-hint code {
  font-family: var(--mono);
  background: var(--surface-2);
  padding: 1px 5px;
  border-radius: var(--radius-xs);
  color: var(--on-surface-var);
}

/* ── Multi-select ────────────────────────────────────────────────────────── */
.card-checkbox {
  position: absolute;
  top: 12px;
  left: 12px;
  width: 20px;
  height: 20px;
  border-radius: 6px;
  border: 2px solid var(--outline-var);
  background: var(--surface);
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 2;
  pointer-events: none;
  transition: border-color .15s, background .15s;
}
.card-checkbox svg { opacity: 0; transition: opacity .1s; }

body.selection-mode .card-checkbox { display: flex; }
body.selection-mode .site-card { user-select: none; }
body.selection-mode .site-card:hover .card-checkbox { border-color: var(--primary); }

.site-card.selected .card-checkbox {
  background: var(--primary);
  border-color: var(--primary);
}
.site-card.selected .card-checkbox svg { opacity: 1; stroke: var(--on-primary); }
.site-card.selected { outline: 2px solid var(--primary); outline-offset: -1px; }

/* Bulk action bar */
.bulk-bar {
  position: fixed;
  bottom: 28px;
  left: 50%;
  transform: translateX(-50%);
  background: var(--surface-2);
  border: 1px solid var(--outline-var);
  border-radius: var(--radius-full);
  box-shadow: var(--shadow-3);
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 8px 6px 18px;
  z-index: 200;
  white-space: nowrap;
}
.bulk-bar.hidden { display: none; }
.bulk-bar-count {
  font-size: .85rem;
  font-weight: 500;
  color: var(--on-surface-var);
  min-width: 120px;
}
.bulk-bar-divider { width: 1px; height: 18px; background: var(--outline-var); }
.bulk-bar-btn { height: 34px; padding: 0 14px; font-size: .82rem; }

.form-error {
  background: var(--red-dim);
  color: var(--red);
  border: 1px solid color-mix(in srgb, var(--red) 20%, transparent);
  border-radius: var(--radius-sm);
  padding: 10px 14px;
  font-size: .8rem;
  margin-bottom: 4px;
  line-height: 1.5;
}
.form-info {
  background: var(--green-dim);
  color: var(--green);
  border: 1px solid color-mix(in srgb, var(--green) 20%, transparent);
  border-radius: var(--radius-sm);
  padding: 10px 14px;
  font-size: .8rem;
  margin-bottom: 4px;
  line-height: 1.5;
}

/* ─── Side Sheet / Drawer ─────────────────────────────────────────────────── */
.drawer-overlay {
  position: fixed;
  inset: 0;
  background: var(--scrim);
  z-index: 150;
  animation: md-fade-in .2s;
}

.drawer {
  position: fixed;
  top: 0; right: 0; bottom: 0;
  width: min(480px, 96vw);
  background: var(--surface);
  z-index: 151;
  display: flex;
  flex-direction: column;
  overflow-y: auto;
  animation: md-slide-right .25s cubic-bezier(0.2,0,0,1);
  box-shadow: var(--shadow-3);
  transition: background .25s;
}

.drawer-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  padding: 20px 16px 16px 24px;
  gap: 8px;
  border-bottom: 1px solid var(--outline-var);
}
.drawer-header h2 { font-size: 1.05rem; font-weight: 500; margin-bottom: 2px; }
.drawer-header a  { font-size: .78rem; color: var(--outline); word-break: break-all; }
.drawer-header a:hover { color: var(--primary); text-decoration: none; }

.drawer-stats {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  background: var(--outline-var);
  gap: 1px;
  border-bottom: 1px solid var(--outline-var);
}
.drawer-stat {
  background: var(--surface-1);
  padding: 16px 20px;
  display: flex;
  flex-direction: column;
  gap: 4px;
  transition: background .25s;
}
.drawer-stat-val {
  font-size: 1.25rem;
  font-weight: 400;
  letter-spacing: -.01em;
  font-variant-numeric: tabular-nums;
  color: var(--on-surface);
}
.drawer-stat-lbl {
  font-size: .68rem;
  color: var(--outline);
  text-transform: uppercase;
  letter-spacing: .07em;
}

.drawer-section {
  padding: 20px 24px;
  border-bottom: 1px solid var(--outline-var);
}
.drawer-section h4 {
  font-size: .72rem;
  text-transform: uppercase;
  letter-spacing: .07em;
  color: var(--outline);
  margin-bottom: 14px;
  font-weight: 500;
}

.sparkline-wrap { width: 100%; height: 60px; }
#sparkline-canvas { width: 100%; height: 100%; }

.history-list {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 2px;
  max-height: 240px;
  overflow-y: auto;
}
.history-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 7px 10px;
  border-radius: var(--radius-sm);
  font-size: .78rem;
  transition: background .12s;
}
.history-item:hover { background: var(--surface-1); }
.history-dot {
  width: 7px; height: 7px;
  border-radius: 50%;
  flex-shrink: 0;
}
.history-dot.up   { background: var(--green); }
.history-dot.down { background: var(--red); }
.history-time { color: var(--outline); flex: 1; }
.history-ms   { color: var(--on-surface-var); font-variant-numeric: tabular-nums; font-family: var(--mono); }
.history-code { color: var(--outline); font-family: var(--mono); margin-left: 4px; }

.drawer-actions {
  padding: 16px 24px;
  display: flex;
  gap: 8px;
  margin-top: auto;
  border-top: 1px solid var(--outline-var);
  background: var(--surface-1);
  transition: background .25s;
}

/* ─── Animations ──────────────────────────────────────────────────────────── */
@keyframes md-fade-in    { from { opacity: 0; } to { opacity: 1; } }
@keyframes md-slide-up   { from { opacity: 0; transform: translateY(16px) scale(.98); } to { opacity: 1; transform: none; } }
@keyframes md-slide-right { from { transform: translateX(100%); } to { transform: none; } }

/* ─── Helpers ─────────────────────────────────────────────────────────────── */
.hidden { display: none !important; }

/* ─── Workspace switcher ─────────────────────────────────────────────────── */
.workspace-switcher {
  position: relative;
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 0 12px;
  height: 36px;
  border-radius: var(--radius-full);
  background: var(--surface-2);
  border: 1px solid var(--outline-var);
  cursor: pointer;
  font-size: .85rem;
  font-weight: 500;
  color: var(--on-surface);
  white-space: nowrap;
  max-width: 180px;
  user-select: none;
  transition: background .15s, border-color .15s;
}
.workspace-switcher:hover { background: var(--surface-3); border-color: var(--outline); }
.workspace-switcher #ws-name {
  overflow: hidden;
  text-overflow: ellipsis;
  flex: 1;
  min-width: 0;
}
.workspace-switcher > svg { flex-shrink: 0; color: var(--outline); }

.ws-dropdown {
  position: absolute;
  top: calc(100% + 6px);
  left: 0;
  min-width: 200px;
  background: var(--surface);
  border: 1px solid var(--outline-var);
  border-radius: var(--radius);
  box-shadow: var(--shadow-3);
  z-index: 300;
  overflow: hidden;
  animation: md-slide-up .15s;
}
.ws-dropdown-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 11px 16px;
  cursor: pointer;
  font-size: .875rem;
  color: var(--on-surface);
  transition: background .12s;
  border: none;
  background: none;
  width: 100%;
  font-family: var(--font);
  text-align: left;
}
.ws-dropdown-item:hover { background: var(--surface-2); }
.ws-dropdown-item.active { color: var(--primary); font-weight: 500; }
.ws-dropdown-item.danger  { color: var(--red); }
.ws-dropdown-divider {
  height: 1px;
  background: var(--outline-var);
  margin: 4px 0;
}

/* ─── Responsive ──────────────────────────────────────────────────────────── */
@media (max-width: 600px) {
  .header-inner  { padding: 0 8px 0 16px; height: 56px; }
  .summary-item  { padding: 14px 16px; }
  .summary-num   { font-size: 1.3rem; }
  main           { padding: 16px 12px 80px; }
  .sites-grid    { grid-template-columns: 1fr; gap: 10px; }
  .modal { border-radius: var(--radius-dialog) var(--radius-dialog) 0 0; margin: auto 0 0; max-width: 100%; }
  .modal-overlay { align-items: flex-end; padding: 0; }
}
