/* ═══════════════════════════════════════════════════════════
   YMaps Monitor — Theme System
   Light theme is default. Dark via [data-theme="dark"]
   ═══════════════════════════════════════════════════════════ */

:root {
  /* Brand — consistent across themes */
  --accent:        #c8f135;       /* legacy green accent — kept for compat */
  --accent-dark:   #9bbe22;       /* darker green for light theme contrast */
  --primary:       #1b3a5c;       /* navy primary (matches fireproof-doors footer) */
  --primary-dark:  #133050;
  --red:           #ef4444;
  --green:         #22c55e;
  --blue:          #3b82f6;
  --yellow:        #eab308;
  --orange:        #f97316;

  /* Light theme — DEFAULT */
  --bg:            #F5F6F8;
  --surface:       #FFFFFF;
  --card:          #FFFFFF;
  --surface-2:     #FAFBFC;
  --surface-3:     #EEF1F4;
  --text:          #14171A;
  --muted:         #6B7378;
  --text-soft:     #98A1A8;
  --border:        rgba(20,23,26,0.10);
  --border-strong: rgba(20,23,26,0.16);
  --input-bg:      #FFFFFF;
  --input-border:  rgba(20,23,26,0.16);
  --hover-bg:      rgba(20,23,26,0.04);

  /* Status colors stay vivid on light bg */
  --green-soft:    rgba(34,197,94,0.10);
  --red-soft:      rgba(239,68,68,0.10);
  --blue-soft:     rgba(59,130,246,0.10);
  --yellow-soft:   rgba(234,179,8,0.10);

  /* Shadows */
  --shadow-sm:     0 1px 2px rgba(0,0,0,0.04);
  --shadow-md:     0 2px 8px rgba(0,0,0,0.06);
  --shadow-lg:     0 8px 24px rgba(0,0,0,0.08);
  --shadow-card:   0 2px 6px rgba(20,23,26,0.05);

  /* Accent text — primary accent for headings/links */
  --accent-text:   var(--primary);
}

[data-theme="dark"] {
  --bg:            #050507;
  --surface:       #0e0e12;
  --card:          #111114;
  --surface-2:     #16161c;
  --surface-3:     #1a1a1f;
  --text:          #f0f0f4;
  --muted:         #6b6b80;
  --text-soft:     #71717a;
  --border:        #2a2a35;
  --border-strong: #3a3a4a;
  --input-bg:      rgba(255,255,255,0.04);
  --input-border:  #2a2a35;
  --hover-bg:      rgba(255,255,255,0.07);
  --green-soft:    rgba(34,197,94,0.15);
  --red-soft:      rgba(239,68,68,0.15);
  --blue-soft:     rgba(59,130,246,0.15);
  --yellow-soft:   rgba(234,179,8,0.15);
  --shadow-sm:     none;
  --shadow-md:     none;
  --shadow-lg:     none;
  --shadow-card:   none;
  --accent-text:   var(--accent);
}

* { box-sizing: border-box; margin: 0; padding: 0; }

body {
  background: var(--bg);
  color: var(--text);
  font-family: 'Space Grotesk', 'Segoe UI', Arial, sans-serif;
  font-size: 14px;
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
}

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

/* ─── Navigation ─── */
nav.app-nav {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  padding: 0 24px;
  height: 56px;
  display: flex;
  align-items: center;
  gap: 8px;
  position: sticky;
  top: 0;
  z-index: 100;
  box-shadow: var(--shadow-sm);
}
.app-nav .logo { font-size: 16px; font-weight: 900; color: var(--text); }
.app-nav .logo span { color: var(--accent-text); }
.app-nav .nav-links { display: flex; gap: 2px; margin-left: 16px; }
.app-nav .nav-links a {
  color: var(--muted);
  font-size: 13px;
  padding: 6px 14px;
  border-radius: 8px;
  transition: all .15s;
  text-decoration: none;
}
.app-nav .nav-links a:hover {
  color: var(--text);
  background: var(--hover-bg);
}
.app-nav .nav-links a.on {
  color: var(--accent-text);
  background: var(--hover-bg);
  font-weight: 600;
}
.app-nav .nav-right {
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: 10px;
}
.app-nav .user-pill {
  font-size: 12px;
  color: var(--muted);
  padding: 5px 10px;
  background: var(--surface-2);
  border-radius: 6px;
  border: 1px solid var(--border);
}

/* ─── Theme toggle button ─── */
.theme-toggle {
  background: transparent;
  border: 1px solid var(--border-strong);
  color: var(--muted);
  width: 34px;
  height: 34px;
  border-radius: 8px;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 16px;
  transition: all .15s;
}
.theme-toggle:hover { color: var(--text); border-color: var(--accent-text); }

/* ─── Container ─── */
.container {
  max-width: 1400px;
  margin: 0 auto;
  padding: 28px 24px;
}

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

/* ─── Buttons ─── */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 9px 18px;
  border-radius: 8px;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  border: none;
  font-family: inherit;
  transition: all .15s;
  text-decoration: none;
}
.btn-primary {
  background: var(--primary);
  color: #fff;
}
.btn-primary:hover {
  background: var(--primary-dark);
  text-decoration: none;
}
.btn-primary:disabled {
  opacity: .5;
  cursor: not-allowed;
}
.btn-accent {
  background: var(--accent);
  color: #09090b;
}
.btn-accent:hover { opacity: .9; text-decoration: none; }
.btn-ghost {
  background: var(--surface-2);
  color: var(--text);
  border: 1px solid var(--border);
}
.btn-ghost:hover {
  background: var(--hover-bg);
  text-decoration: none;
}
.btn-danger {
  background: var(--red-soft);
  color: var(--red);
  border: 1px solid rgba(239,68,68,0.25);
}
.btn-danger:hover {
  background: rgba(239,68,68,0.18);
  text-decoration: none;
}

/* ─── Form controls ─── */
input[type="text"],
input[type="password"],
input[type="number"],
input[type="email"],
input[type="search"],
input[type="url"],
textarea,
select {
  background: var(--input-bg);
  border: 1px solid var(--input-border);
  border-radius: 8px;
  color: var(--text);
  font-family: inherit;
  font-size: 13px;
  padding: 9px 12px;
  outline: none;
  transition: border-color .15s, box-shadow .15s;
  width: 100%;
}
input:focus, textarea:focus, select:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(27,58,92,0.10);
}
[data-theme="dark"] input:focus,
[data-theme="dark"] textarea:focus,
[data-theme="dark"] select:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(200,241,53,0.12);
}
::placeholder { color: var(--text-soft); }

/* ─── Tables ─── */
.table-wrap {
  overflow-x: auto;
  border-radius: 12px;
  border: 1px solid var(--border);
  background: var(--card);
  box-shadow: var(--shadow-card);
}
table {
  width: 100%;
  border-collapse: collapse;
}
thead { background: var(--surface-2); }
th {
  padding: 12px 14px;
  text-align: left;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: .07em;
  color: var(--muted);
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
  font-weight: 600;
}
td {
  padding: 11px 14px;
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
}
tr:last-child td { border-bottom: none; }
tr:hover td { background: var(--hover-bg); }

/* ─── Status badges ─── */
.badge-pill {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-size: 11px;
  font-weight: 600;
  padding: 3px 10px;
  border-radius: 20px;
  white-space: nowrap;
}
.bp-idle { background: var(--hover-bg); color: var(--muted); }
.bp-run { background: var(--blue-soft); color: var(--blue); }
.bp-done { background: var(--green-soft); color: var(--green); }
.bp-error { background: var(--red-soft); color: var(--red); }
.bp-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: currentColor;
}
.bp-run .bp-dot { animation: blink-dot 1s ease-in-out infinite; }
@keyframes blink-dot {
  0%, 100% { opacity: 1; }
  50%      { opacity: .3; }
}

/* ─── Logs ─── */
.log-box {
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 14px;
  font-family: 'JetBrains Mono', monospace;
  font-size: 11px;
  line-height: 1.8;
  height: 320px;
  overflow-y: auto;
}
.log-box::-webkit-scrollbar { width: 6px; }
.log-box::-webkit-scrollbar-track { background: transparent; }
.log-box::-webkit-scrollbar-thumb { background: var(--border-strong); border-radius: 3px; }
.log-ok    { color: var(--green); }
.log-info  { color: var(--blue); }
.log-warn  { color: var(--yellow); }
.log-error { color: var(--red); }
.log-muted { color: var(--muted); }

/* ─── Position pills (for ranking results) ─── */
.pos {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  border-radius: 50%;
  font-weight: 900;
  font-size: 15px;
}
.pos-1 { background: var(--accent); color: #09090b; }
.pos-2 { background: var(--accent-dark); color: #fff; }
.pos-3 { background: var(--primary); color: #fff; }
.pos-top10 { background: var(--blue-soft); color: var(--blue); }
.pos-out { background: var(--red-soft); color: var(--red); }

/* ─── Page title ─── */
.page-title {
  font-size: 24px;
  font-weight: 700;
  margin-bottom: 24px;
  color: var(--text);
}
.page-title-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 12px;
  margin-bottom: 24px;
}

/* ─── Grid utilities ─── */
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.grid3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 16px; }
.grid4 { display: grid; grid-template-columns: repeat(4, 1fr); gap: 16px; }
@media (max-width: 900px) {
  .grid2, .grid3, .grid4 { grid-template-columns: 1fr; }
}

/* ─── Card title ─── */
.card-title {
  font-size: 14px;
  font-weight: 700;
  margin-bottom: 14px;
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--text);
}

/* ─── Stat boxes ─── */
.stat-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 10px;
  margin-bottom: 14px;
}
.stat {
  background: var(--surface-2);
  border-radius: 8px;
  padding: 12px;
  text-align: center;
  border: 1px solid var(--border);
}
.stat-val {
  font-size: 24px;
  font-weight: 700;
  line-height: 1;
  color: var(--text);
}
.stat-label {
  font-size: 10px;
  color: var(--muted);
  margin-top: 4px;
  letter-spacing: .04em;
  text-transform: uppercase;
}
