/* ─────────────────────────────────────────────────────────
   Алик — пульт · Mira-inspired dark glass theme
   ───────────────────────────────────────────────────────── */

:root {
  /* Telegram theme (fallback to dark) */
  --bg:      var(--tg-theme-bg-color, #0d1117);
  --bg-2:    #0f1620;
  --fg:      var(--tg-theme-text-color, #f4f5f7);
  --hint:    var(--tg-theme-hint-color, #8b96a8);
  --link:    var(--tg-theme-link-color, #6ab3f3);

  --card-bg: rgba(255, 255, 255, 0.04);
  --card-br: rgba(255, 255, 255, 0.07);
  --card-hi: rgba(255, 255, 255, 0.10);

  --accent:    #6ab3f3;
  --accent-2:  #7c3aed;
  --grad:      linear-gradient(135deg, #7c3aed 0%, #4f7cff 50%, #38bdf8 100%);
  --grad-soft: linear-gradient(135deg, rgba(124,58,237,0.18), rgba(56,189,248,0.18));

  --ok:   #34d399;
  --warn: #fbbf24;
  --bad:  #f87171;

  --radius-l: 20px;
  --radius:   14px;
  --radius-s: 10px;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }

html, body {
  margin: 0; padding: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Inter", "Segoe UI", Roboto, sans-serif;
  background:
    radial-gradient(1200px 600px at 0% -10%, rgba(124,58,237,0.10), transparent 60%),
    radial-gradient(1000px 500px at 100% 110%, rgba(56,189,248,0.08), transparent 60%),
    var(--bg);
  background-attachment: fixed;
  color: var(--fg);
  font-size: 15px;
  line-height: 1.4;
  min-height: 100vh;
  padding-bottom: calc(76px + env(safe-area-inset-bottom));
}

/* ── Header ────────────────────────────────────────────── */
header {
  position: sticky; top: 0; z-index: 20;
  padding: 14px 16px;
  display: flex; align-items: center; gap: 12px;
  background: rgba(13, 17, 23, 0.72);
  backdrop-filter: saturate(180%) blur(18px);
  -webkit-backdrop-filter: saturate(180%) blur(18px);
  border-bottom: 1px solid var(--card-br);
}
header .avatar {
  width: 38px; height: 38px; border-radius: 50%;
  background: var(--grad);
  display: flex; align-items: center; justify-content: center;
  font-size: 18px; font-weight: 700; color: #fff;
  box-shadow: 0 6px 20px rgba(79,124,255,0.35), inset 0 1px 0 rgba(255,255,255,0.2);
  flex: 0 0 auto;
}
header .head-text { display: flex; flex-direction: column; gap: 2px; flex: 1; min-width: 0; }
header h1 {
  margin: 0; font-size: 16px; font-weight: 600;
  display: flex; align-items: center; gap: 6px;
}
header h1 .verified {
  display: inline-flex; align-items: center; justify-content: center;
  width: 16px; height: 16px; border-radius: 50%;
  background: var(--accent); color: #0d1117; font-size: 10px;
}
header h1 .sub { color: var(--hint); font-weight: 400; font-size: 12px; }
header #user { color: var(--hint); font-size: 11px; }

/* ── Main ──────────────────────────────────────────────── */
main { padding: 14px 14px 24px; max-width: 720px; margin: 0 auto; }
section.tab { display: none; }
section.tab.active { display: block; animation: fadeUp .25s ease; }
@keyframes fadeUp { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }

/* ── Card ──────────────────────────────────────────────── */
.card {
  background: var(--card-bg);
  border: 1px solid var(--card-br);
  border-radius: var(--radius-l);
  padding: 16px;
  margin-bottom: 12px;
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
}
.card h2 { margin: 0 0 10px; font-size: 15px; font-weight: 600; letter-spacing: 0.1px; }
.card pre {
  margin: 4px 0; font-family: "SF Mono", Menlo, Consolas, monospace;
  font-size: 12px; white-space: pre-wrap; color: var(--hint);
}

/* ── Tables ────────────────────────────────────────────── */
table { width: 100%; border-collapse: collapse; }
th, td {
  padding: 9px 6px; text-align: left;
  border-bottom: 1px solid var(--card-br); font-size: 13px;
}
th { color: var(--hint); font-weight: 500; font-size: 11px; text-transform: uppercase; letter-spacing: 0.5px; }

/* ── Buttons ───────────────────────────────────────────── */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  width: 100%;
  padding: 12px 16px;
  background: var(--grad);
  color: #fff;
  border: none;
  border-radius: 12px;
  font-size: 14px; font-weight: 600;
  cursor: pointer;
  margin-top: 8px;
  transition: transform .12s ease, box-shadow .15s ease, opacity .12s;
  box-shadow: 0 6px 20px rgba(79,124,255,0.25);
}
.btn:hover { transform: translateY(-1px); }
.btn:active { transform: translateY(0); opacity: .9; }
.btn.secondary {
  background: var(--card-bg);
  color: var(--fg);
  border: 1px solid var(--card-br);
  box-shadow: none;
}
.btn.secondary:hover { background: var(--card-hi); }

/* Inputs */
input[type=text], input[type=number], select, textarea {
  background: rgba(255,255,255,0.03);
  color: var(--fg);
  border: 1px solid var(--card-br);
  border-radius: 10px;
  padding: 10px 12px;
  font-size: 14px;
  font-family: inherit;
  outline: none;
  transition: border-color .15s, background .15s;
}
input:focus, select:focus, textarea:focus {
  border-color: var(--accent);
  background: rgba(255,255,255,0.06);
}
textarea { resize: vertical; min-height: 64px; }

/* ── Action grid (Mira-style tiles) ───────────────────── */
#actions-list { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
#actions-list h3 {
  grid-column: 1 / -1;
  margin: 14px 0 4px;
  color: var(--hint);
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.6px;
}
#actions-list button, #actions-list a {
  display: flex; flex-direction: column; align-items: flex-start; justify-content: center; gap: 4px;
  padding: 14px;
  background: var(--card-bg);
  border: 1px solid var(--card-br);
  border-radius: var(--radius);
  color: var(--fg);
  text-decoration: none;
  font-size: 13px;
  font-weight: 500;
  text-align: left;
  cursor: pointer;
  margin: 0;
  min-height: 64px;
  transition: background .15s, transform .12s, border-color .15s;
}
#actions-list button:hover, #actions-list a:hover {
  background: var(--card-hi);
  border-color: rgba(255,255,255,0.14);
  transform: translateY(-1px);
}

/* Inline rows */
.row { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.row > .btn { flex: 1 1 calc(33% - 6px); margin: 0; padding: 10px; font-size: 13px; }

/* ── Logs ──────────────────────────────────────────────── */
#tab-logs label { display: inline-block; margin-right: 12px; margin-bottom: 10px; font-size: 12px; color: var(--hint); }
#tab-logs select, #tab-logs input { background: var(--card-bg); }
#tab-logs input { width: 100%; margin-bottom: 10px; padding: 10px 12px; }

#logs-output, #action-output {
  background: rgba(0,0,0,0.30);
  border: 1px solid var(--card-br);
  padding: 12px;
  border-radius: 12px;
  font-size: 11px;
  font-family: "SF Mono", Menlo, Consolas, monospace;
  white-space: pre-wrap;
  overflow: auto;
  max-height: 60vh;
  color: var(--hint);
}
#action-output { max-height: 40vh; font-size: 12px; }

/* ── Chart wrap ────────────────────────────────────────── */
.chart-wrap { position: relative; height: 180px; width: 100%; }

/* ── Tasks ─────────────────────────────────────────────── */
.task-form { margin-bottom: 14px; }
.task-form input { width: 100%; padding: 12px; margin-bottom: 8px; }
.task-form select { padding: 10px; flex: 1; }
.task-col { margin-bottom: 18px; }
.task-col h3 { margin: 6px 0 8px; font-size: 11px; color: var(--hint); text-transform: uppercase; letter-spacing: 0.6px; font-weight: 600; }
.task-card {
  background: var(--card-bg);
  border: 1px solid var(--card-br);
  padding: 12px;
  margin-bottom: 8px;
  border-radius: var(--radius);
  border-left: 3px solid var(--hint);
  transition: transform .12s, background .15s;
}
.task-card:hover { background: var(--card-hi); transform: translateY(-1px); }
.task-card.prio-5 { border-left-color: var(--bad); }
.task-card.prio-4 { border-left-color: #fb923c; }
.task-card.prio-3 { border-left-color: var(--warn); }
.task-card.prio-2 { border-left-color: var(--ok); }
.task-card.prio-1 { border-left-color: var(--hint); }
.task-title { font-size: 14px; font-weight: 500; margin-bottom: 4px; }
.task-desc { font-size: 12px; color: var(--hint); margin-bottom: 4px; }
.task-tags { font-size: 11px; color: var(--accent); margin-bottom: 6px; }

/* ── Memory ────────────────────────────────────────────── */
textarea.mem-edit {
  background: rgba(255,255,255,0.03);
  color: var(--fg);
  border: 1px solid var(--card-br);
  padding: 10px;
  border-radius: 10px;
  font-size: 13px;
  resize: vertical;
}

/* ── Focus tab ─────────────────────────────────────────── */
.focus-head {
  display: flex; justify-content: space-between; align-items: center; gap: 12px;
  background: var(--grad-soft);
  border: 1px solid var(--card-br);
  padding: 16px;
  border-radius: var(--radius-l);
  margin-bottom: 12px;
}
.focus-date { font-size: 16px; font-weight: 700; text-transform: capitalize; }
.focus-phase { font-size: 12px; color: var(--hint); }
.focus-phase b {
  color: #fff;
  background: var(--grad);
  padding: 3px 10px;
  border-radius: 999px;
  text-transform: uppercase;
  letter-spacing: 0.6px;
  font-size: 10px;
  font-weight: 700;
  margin-left: 4px;
  display: inline-block;
}

/* MIT */
.mit-list { list-style: none; padding: 0; margin: 0; }
.mit-item {
  display: flex; align-items: center; justify-content: space-between; gap: 8px;
  padding: 10px 0;
  border-bottom: 1px solid var(--card-br);
}
.mit-item:last-child { border-bottom: none; }
.mit-item label { display: flex; align-items: center; gap: 12px; flex: 1; cursor: pointer; }
.mit-item input[type=checkbox] {
  width: 22px; height: 22px;
  accent-color: var(--accent);
  cursor: pointer;
}
.mit-item.done span { text-decoration: line-through; color: var(--hint); }
.mit-del {
  background: transparent; border: none; color: var(--hint);
  font-size: 22px; cursor: pointer; padding: 2px 8px;
  transition: color .12s;
}
.mit-del:hover { color: var(--bad); }
.mit-empty, .mon-empty { color: var(--hint); font-style: italic; padding: 8px 0; font-size: 13px; }

/* Monitoring (health systems) */
.mon-list { list-style: none; padding: 0; margin: 0; }
.mon-item {
  display: flex; align-items: center; gap: 12px;
  padding: 8px 0;
  border-bottom: 1px solid var(--card-br);
  font-size: 13px;
}
.mon-item:last-child { border-bottom: none; }
.mon-icon {
  font-size: 8px;
  width: 10px; height: 10px;
  border-radius: 50%;
  background: var(--ok);
  flex: 0 0 auto;
  box-shadow: 0 0 0 3px rgba(52,211,153,0.18);
}
.mon-item.bad .mon-icon { background: var(--bad); box-shadow: 0 0 0 3px rgba(248,113,113,0.18); }
.mon-name { flex: 1; font-weight: 500; }
.mon-meta { color: var(--hint); font-family: "SF Mono", Menlo, Consolas, monospace; font-size: 11px; }
.mon-item.bad .mon-name { color: var(--bad); }
#mon-age { font-weight: normal; font-size: 11px; color: var(--hint); margin-left: 6px; }

/* ── Bottom navigation ─────────────────────────────────── */
nav.tabs {
  position: fixed;
  left: 50%; bottom: 12px;
  transform: translateX(-50%);
  z-index: 30;
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 2px;
  padding: 6px;
  background: rgba(20, 24, 33, 0.72);
  backdrop-filter: saturate(180%) blur(22px);
  -webkit-backdrop-filter: saturate(180%) blur(22px);
  border: 1px solid var(--card-br);
  border-radius: 12px;
  box-shadow: 0 12px 40px rgba(0,0,0,0.45);
  max-width: calc(100vw - 24px);
}

nav.tabs button {
  width: 48px;
  height: 48px;
  padding: 0;
  background: transparent;
  border: none;
  color: var(--hint);
  cursor: pointer;
  font-size: 22px;
  line-height: 1;
  border-radius: 8px;
  transition: background .18s ease, color .15s, transform .12s, box-shadow .18s;
  font-family: inherit;
  display: flex;
  align-items: center;
  justify-content: center;
}
nav.tabs button:hover { color: var(--fg); background: var(--card-hi); }
nav.tabs button:active { transform: scale(0.92); }
nav.tabs button.active {
  color: #fff;
  background: var(--grad);
  box-shadow: 0 6px 18px rgba(79,124,255,0.45), inset 0 1px 0 rgba(255,255,255,0.18);
  transform: scale(1.06);
}

/* ── Рестарт агентов (вкладка Сервера): icon-only, как нижняя навигация ── */
.agent-strip {
  display: flex;
  justify-content: space-between;
  gap: 8px;
  margin: 0 0 14px;
}
.agent-strip button {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  padding: 0;
  background: transparent;
  border: none;
  color: var(--hint);
  cursor: pointer;
  font-family: inherit;
}
.agent-strip button span {
  width: 52px;
  height: 52px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 24px;
  line-height: 1;
  border-radius: 14px;
  background: var(--card-bg);
  border: 1px solid var(--card-br);
  transition: background .18s ease, transform .12s;
}
.agent-strip button:hover span { background: var(--card-hi); }
.agent-strip button:active span { transform: scale(0.92); }
.agent-strip button small { font-size: 11px; }

/* ── Section heading (eyebrow + large title) ───────────── */
.section-heading {
  padding: 6px 4px 14px;
}
.section-eyebrow {
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 1.6px;
  text-transform: uppercase;
  color: var(--hint);
  opacity: 0.7;
  margin-bottom: 4px;
}
.section-title {
  font-size: 30px;
  font-weight: 700;
  margin: 0;
  letter-spacing: -0.6px;
  line-height: 1.1;
  background: linear-gradient(135deg, #ffffff 0%, #c5d0e0 100%);
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
}

/* ── Footer (status text) ──────────────────────────────── */
footer {
  padding: 8px 16px 90px;
  color: var(--hint);
  font-size: 11px;
  text-align: center;
}

/* ── Helpers ───────────────────────────────────────────── */
.metric-row { display: flex; align-items: center; justify-content: space-between; padding: 10px 0; border-bottom: 1px solid var(--card-br); font-size: 13px; }
.metric-row:last-child { border-bottom: none; }
.metric-row .label { color: var(--hint); }
.metric-row .value { font-weight: 600; }

/* light-theme fallback (Telegram light) */
@media (prefers-color-scheme: light) {
  :root {
    --bg-2: #f5f7fb;
    --card-bg: rgba(0,0,0,0.04);
    --card-br: rgba(0,0,0,0.08);
    --card-hi: rgba(0,0,0,0.06);
  }
  body {
    background:
      radial-gradient(1200px 600px at 0% -10%, rgba(124,58,237,0.06), transparent 60%),
      var(--bg);
  }
  header { background: rgba(255,255,255,0.72); }
  nav.tabs { background: rgba(255,255,255,0.78); }
  #logs-output, #action-output { background: rgba(0,0,0,0.04); color: #444; }
}
