/* Flight Watcher — панель. Mobile-first, светлая и тёмная тема. */

:root {
  --bg: #f6f7f9;
  --surface: #ffffff;
  --border: #e2e5ea;
  --text: #1a1d23;
  --muted: #6b7280;
  --accent: #2563eb;
  --ok: #16a34a;
  --warn: #d97706;
  --err: #dc2626;
  --radius: 10px;
  --shadow: 0 1px 3px rgba(0, 0, 0, .06);
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #14161a;
    --surface: #1c1f25;
    --border: #2b2f37;
    --text: #e8eaed;
    --muted: #9aa1ac;
    --accent: #60a5fa;
    --ok: #4ade80;
    --warn: #fbbf24;
    --err: #f87171;
    --shadow: none;
  }
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 15px/1.55 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}

/* --- Шапка --- */
.topbar {
  display: flex;
  flex-wrap: wrap;
  gap: .5rem 1rem;
  align-items: center;
  justify-content: space-between;
  padding: .75rem 1rem;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
}

.brand { font-weight: 600; text-decoration: none; color: var(--text); }

nav { display: flex; flex-wrap: wrap; gap: .25rem; }

nav a {
  padding: .35rem .7rem;
  border-radius: var(--radius);
  text-decoration: none;
  color: var(--muted);
  font-size: .92rem;
}

nav a:hover { background: var(--bg); color: var(--text); }
nav a.active { background: var(--accent); color: #fff; }
nav a:focus-visible, a:focus-visible, button:focus-visible, input:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

main { max-width: 1000px; margin: 0 auto; padding: 1.25rem 1rem 3rem; }

h1 { font-size: 1.4rem; margin: 0 0 1rem; }
h2 { font-size: 1.1rem; margin: 1.75rem 0 .75rem; }

/* --- Карточки и сетки --- */
.grid {
  display: grid;
  gap: .75rem;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  margin-bottom: 1.5rem;
}

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1rem;
  box-shadow: var(--shadow);
}

.stat .value { font-size: 1.7rem; font-weight: 650; letter-spacing: -.02em; }
.stat .label { color: var(--muted); font-size: .85rem; }

.rule-card { margin-bottom: .75rem; }
.rule-card header {
  display: flex;
  flex-wrap: wrap;
  gap: .5rem;
  align-items: baseline;
  justify-content: space-between;
}
.rule-card .route { font-size: 1.1rem; font-weight: 600; }
.rule-card dl {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: .2rem .75rem;
  margin: .6rem 0 0;
  font-size: .9rem;
}
.rule-card dt { color: var(--muted); }
.rule-card dd { margin: 0; }

/* --- Бейджи --- */
.badge {
  display: inline-block;
  padding: .12rem .5rem;
  border-radius: 999px;
  font-size: .75rem;
  font-weight: 600;
  border: 1px solid var(--border);
}
.badge.active { color: var(--ok); border-color: currentColor; }
.badge.paused { color: var(--warn); border-color: currentColor; }
.badge.completed { color: var(--muted); }
.badge.live { color: var(--ok); border-color: currentColor; }
.badge.cached { color: var(--warn); border-color: currentColor; }

.ok { color: var(--ok); }
.warn { color: var(--warn); }
.err { color: var(--err); }
.muted { color: var(--muted); }
.mono { font-variant-numeric: tabular-nums; }

/* --- Таблицы (скроллятся, а не ломают вёрстку) --- */
.table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }

table { width: 100%; border-collapse: collapse; font-size: .9rem; }
th, td { padding: .55rem .6rem; text-align: left; border-bottom: 1px solid var(--border); white-space: nowrap; }
th { color: var(--muted); font-weight: 600; font-size: .8rem; text-transform: uppercase; letter-spacing: .03em; }
tbody tr:hover { background: var(--bg); }

/* --- Формы и кнопки --- */
form.inline { display: inline; }

button, .btn {
  font: inherit;
  padding: .4rem .8rem;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  cursor: pointer;
  text-decoration: none;
  display: inline-block;
}
button:hover, .btn:hover { border-color: var(--accent); color: var(--accent); }
button.primary { background: var(--accent); color: #fff; border-color: var(--accent); }
button.danger:hover { border-color: var(--err); color: var(--err); }

input[type="text"], input[type="password"], input[type="search"], select {
  font: inherit;
  padding: .45rem .6rem;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--text);
  width: 100%;
}

.filters { display: flex; flex-wrap: wrap; gap: .5rem; margin-bottom: 1rem; }
.filters > * { flex: 1 1 140px; }
.actions { display: flex; flex-wrap: wrap; gap: .4rem; margin-top: .75rem; }

/* --- Логин --- */
.login-box { max-width: 340px; margin: 12vh auto; }
.login-box label { display: block; margin: .75rem 0 .25rem; font-size: .85rem; color: var(--muted); }
.login-box button { width: 100%; margin-top: 1rem; }
.error-msg {
  background: color-mix(in srgb, var(--err) 12%, transparent);
  color: var(--err);
  padding: .6rem .8rem;
  border-radius: var(--radius);
  font-size: .9rem;
  margin-bottom: .5rem;
}

/* --- Пустые состояния --- */
.empty {
  text-align: center;
  padding: 2.5rem 1rem;
  color: var(--muted);
  border: 1px dashed var(--border);
  border-radius: var(--radius);
}

/* --- График --- */
.chart { width: 100%; height: auto; overflow: visible; }
.chart .line { fill: none; stroke: var(--accent); stroke-width: 2; }
.chart .area { fill: var(--accent); opacity: .1; }
.chart .dot { fill: var(--accent); }
.chart .threshold { stroke: var(--err); stroke-width: 1.5; stroke-dasharray: 5 4; }
.chart .axis { stroke: var(--border); stroke-width: 1; }
.chart text { fill: var(--muted); font-size: 10px; }

footer {
  max-width: 1000px;
  margin: 0 auto;
  padding: 1rem;
  display: flex;
  flex-wrap: wrap;
  gap: .5rem;
  justify-content: space-between;
  border-top: 1px solid var(--border);
  font-size: .8rem;
  color: var(--muted);
}
