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

:root {
  --bg:          #f0f2f5;
  --surface:     #ffffff;
  --border:      #e2e6ea;
  --text:        #111827;
  --muted:       #6b7280;
  --primary:     #2563eb;
  --primary-h:   #1d4ed8;
  --success:     #16a34a;
  --danger:      #dc2626;
  --radius:      10px;
  --shadow:      0 1px 3px rgba(0,0,0,.08), 0 1px 2px rgba(0,0,0,.05);
  --shadow-lg:   0 10px 40px rgba(0,0,0,.15);
  font-size:     15px;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  line-height: 1.5;
}

a { color: var(--primary); }

/* ── Header ──────────────────────────────────────────────────── */
header {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  padding: 14px 24px;
  position: sticky;
  top: 0;
  z-index: 50;
}
.header-inner {
  max-width: 900px;
  margin: 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}
.logo {
  font-size: 1.1rem;
  font-weight: 700;
  letter-spacing: -.01em;
}
.status-bar {
  font-size: .78rem;
  color: var(--muted);
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 3px;
}
.sep { opacity: .35; }

/* ── Tabs ────────────────────────────────────────────────────── */
.tabs {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  padding: 0 24px;
  display: flex;
}
.tab {
  padding: 11px 18px;
  border: none;
  border-bottom: 2px solid transparent;
  background: none;
  cursor: pointer;
  font-size: .875rem;
  font-weight: 500;
  color: var(--muted);
  transition: color .15s, border-color .15s;
}
.tab:hover  { color: var(--text); }
.tab.active { color: var(--primary); border-bottom-color: var(--primary); }

/* ── Main / panes ────────────────────────────────────────────── */
main {
  max-width: 900px;
  margin: 28px auto;
  padding: 0 24px;
}
.tab-pane          { display: none; }
.tab-pane.active   { display: block; }
.pane-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 18px;
}
.pane-header h2 {
  font-size: 1rem;
  font-weight: 600;
}

/* ── Card ────────────────────────────────────────────────────── */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  box-shadow: var(--shadow);
}

/* ── Watchlist items ─────────────────────────────────────────── */
.wl-list { display: flex; flex-direction: column; gap: 10px; }

.wl-item {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px 18px;
  display: flex;
  align-items: center;
  gap: 14px;
  box-shadow: var(--shadow);
  transition: border-color .15s;
}
.wl-item:hover { border-color: #c5ccd5; }

.wl-info { flex: 1; min-width: 0; }
.wl-name {
  font-weight: 600;
  font-size: .9rem;
  margin-bottom: 2px;
}
.wl-url {
  font-size: .73rem;
  color: var(--muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.wl-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
}

/* ── Toggle switch ───────────────────────────────────────────── */
.toggle { position: relative; display: inline-block; width: 38px; height: 21px; }
.toggle input { opacity: 0; width: 0; height: 0; }
.toggle-track {
  position: absolute; inset: 0;
  background: #d1d5db;
  border-radius: 11px;
  cursor: pointer;
  transition: background .2s;
}
.toggle-track::before {
  content: '';
  position: absolute;
  width: 15px; height: 15px;
  left: 3px; bottom: 3px;
  background: #fff;
  border-radius: 50%;
  transition: transform .2s;
}
.toggle input:checked ~ .toggle-track            { background: var(--success); }
.toggle input:checked ~ .toggle-track::before    { transform: translateX(17px); }

/* ── Buttons ─────────────────────────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 7px 15px;
  border-radius: 7px;
  border: none;
  cursor: pointer;
  font-size: .85rem;
  font-weight: 500;
  white-space: nowrap;
  transition: background .15s, opacity .15s, box-shadow .15s;
}
.btn:disabled { opacity: .55; cursor: not-allowed; }

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

.btn-secondary {
  background: #f3f4f6; color: var(--text);
  border: 1px solid var(--border);
}
.btn-secondary:hover:not(:disabled) { background: #e5e7eb; }

.btn-ghost   { background: transparent; color: var(--muted); }
.btn-ghost:hover:not(:disabled) { background: #f3f4f6; color: var(--text); }

.btn-icon {
  background: transparent;
  color: var(--muted);
  padding: 5px 9px;
  font-size: .8rem;
}
.btn-icon:hover:not(:disabled) { background: #f3f4f6; color: var(--text); }

.btn-icon.danger:hover { background: #fee2e2; color: var(--danger); }

/* ── Settings ────────────────────────────────────────────────── */
.settings-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 16px;
}
.card h3 { font-size: .875rem; font-weight: 600; margin-bottom: 16px; }

.field { margin-bottom: 14px; }
.field label {
  display: block;
  font-size: .72rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .05em;
  color: var(--muted);
  margin-bottom: 5px;
}
.field input {
  width: 100%;
  padding: 8px 11px;
  border: 1px solid var(--border);
  border-radius: 6px;
  font-size: .875rem;
  outline: none;
  transition: border-color .15s, box-shadow .15s;
}
.field input:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(37,99,235,.12);
}

.field-row { display: flex; gap: 12px; }
.field-row .field { flex: 1; }

.hint { font-size: .72rem; color: var(--muted); margin-top: 5px; }
.hint a { text-decoration: none; }
.muted { color: var(--muted); font-weight: 400; }

/* ── History table ───────────────────────────────────────────── */
.history-table {
  width: 100%;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  border-collapse: collapse;
  overflow: hidden;
}
.history-table th,
.history-table td {
  padding: 11px 16px;
  text-align: left;
  border-bottom: 1px solid var(--border);
  font-size: .8rem;
}
.history-table th {
  background: #f9fafb;
  font-size: .7rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .05em;
  color: var(--muted);
}
.history-table tr:last-child td { border-bottom: none; }

/* ── Badges ──────────────────────────────────────────────────── */
.badge {
  display: inline-block;
  padding: 2px 9px;
  border-radius: 20px;
  font-size: .72rem;
  font-weight: 600;
}
.badge-success  { background: #dcfce7; color: #166534; }
.badge-error    { background: #fee2e2; color: #991b1b; }
.badge-new      { background: #dbeafe; color: #1e40af; }
.badge-running  { background: #fef9c3; color: #854d0e; }
.hidden         { display: none !important; }

/* ── Modal ───────────────────────────────────────────────────── */
.modal {
  position: fixed; inset: 0;
  display: flex; align-items: center; justify-content: center;
  z-index: 100;
}
.modal-backdrop {
  position: absolute; inset: 0;
  background: rgba(0,0,0,.45);
}
.modal-box {
  position: relative;
  background: var(--surface);
  border-radius: var(--radius);
  padding: 24px;
  width: 100%; max-width: 520px;
  margin: 16px;
  box-shadow: var(--shadow-lg);
}
.modal-box h3 { font-size: .95rem; font-weight: 600; margin-bottom: 18px; }
.modal-actions {
  display: flex; gap: 10px; justify-content: flex-end;
  margin-top: 18px;
}

/* ── Password gate ───────────────────────────────────────────── */
.pw-modal-box   { max-width: 360px; text-align: center; }
.pw-icon        { font-size: 2rem; margin-bottom: 10px; }
.pw-modal-box h3 { margin-bottom: 6px; }
.pw-hint        { margin-bottom: 18px; }
.pw-modal-box .field { text-align: left; }
.pw-modal-box .modal-actions { justify-content: center; }
.pw-error {
  color: var(--danger);
  font-size: .75rem;
  margin-top: 5px;
}

/* ── Toast ───────────────────────────────────────────────────── */
.toast {
  position: fixed; bottom: 22px; right: 22px;
  padding: 11px 18px;
  border-radius: 8px;
  font-size: .85rem;
  background: #1f2937; color: #fff;
  box-shadow: var(--shadow-lg);
  z-index: 200;
  animation: slideUp .2s ease;
  max-width: 320px;
  will-change: transform, opacity;
}
.toast.ok    { background: #15803d; }
.toast.err   { background: var(--danger); }

@keyframes slideUp {
  from { transform: translateY(8px); opacity: 0; }
  to   { transform: translateY(0);   opacity: 1; }
}

/* ── Settings extras ─────────────────────────────────────────── */
.card-hint        { margin-bottom: 12px; }
.save-settings-btn { margin-top: 20px; }

/* ── Empty & loading states ──────────────────────────────────── */
.empty {
  text-align: center; padding: 48px 24px;
  color: var(--muted);
}
.empty h3 { font-size: .95rem; margin-bottom: 6px; color: var(--text); }
.empty p  { font-size: .8rem; margin-bottom: 18px; }

.loading {
  text-align: center; padding: 32px;
  color: var(--muted); font-size: .85rem;
}
