/* dashboard.css — Phase 7 mobile-first control room.
   Hebrew/RTL, dark theme, 44px touch targets, single-column on phone.
   No external CSS framework. */

:root {
  color-scheme: dark;
  --bg: #0b0f14;
  --panel: #111821;
  --panel2: #151f2b;
  --panel3: #1a2634;
  --line: #263241;
  --line2: #324155;
  --text: #e9eef5;
  --muted: #93a4b8;
  --dim: #607289;
  --good: #34d399;
  --warn: #fbbf24;
  --bad: #fb7185;
  --info: #60a5fa;
  --critical: #ef4444;
  --accent: #93c5fd;
  --shadow: 0 2px 12px rgba(0, 0, 0, .35);
}

*, *::before, *::after { box-sizing: border-box; }

html, body { margin: 0; padding: 0; }

body {
  background: var(--bg);
  color: var(--text);
  font-family: Heebo, "Segoe UI", "Helvetica Neue", Arial, sans-serif;
  font-size: 15px;
  line-height: 1.4;
  min-height: 100vh;
  padding-bottom: 88px; /* leave room for mobile bottom nav */
}

/* ===== Header ===== */
header.app-header {
  position: sticky;
  top: 0;
  z-index: 30;
  background: rgba(11, 15, 20, .96);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--line);
  padding: 10px 12px;
}

.header-row {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 10px;
  align-items: center;
  max-width: 1320px;
  margin: 0 auto;
}

.title-block {
  min-width: 0;
}

.title-block h1 {
  margin: 0;
  font-size: 18px;
  font-weight: 700;
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.title-block h1 .status-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--dim);
  display: inline-block;
}

.status-dot.green { background: var(--good); box-shadow: 0 0 8px rgba(52, 211, 153, .55); }
.status-dot.yellow { background: var(--warn); box-shadow: 0 0 8px rgba(251, 191, 36, .55); }
.status-dot.red { background: var(--bad); box-shadow: 0 0 8px rgba(251, 113, 133, .55); animation: pulse 1.4s infinite; }
.status-dot.unknown { background: var(--dim); }

@keyframes pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: .45; }
}

.header-meta {
  margin-top: 4px;
  color: var(--muted);
  font-size: 12px;
  display: flex;
  gap: 8px;
  align-items: center;
  flex-wrap: wrap;
}

.age-pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 3px 8px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--panel2);
  font-weight: 600;
  font-size: 11px;
  white-space: nowrap;
}

.age-pill.fresh { color: var(--good); border-color: rgba(52, 211, 153, .35); }
.age-pill.warning { color: var(--warn); border-color: rgba(251, 191, 36, .35); }
.age-pill.stale { color: var(--bad); border-color: rgba(251, 113, 133, .35); }
.age-pill.offline { color: var(--critical); border-color: rgba(239, 68, 68, .45); background: rgba(239, 68, 68, .08); }
.age-pill.unknown { color: var(--muted); }

.refresh-btn {
  min-width: 44px;
  min-height: 44px;
  padding: 0 14px;
  background: var(--panel3);
  color: var(--text);
  border: 1px solid var(--line2);
  border-radius: 10px;
  font: inherit;
  font-weight: 600;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  white-space: nowrap;
  transition: background .12s ease, transform .12s ease;
}

.refresh-btn:hover { background: #213044; }
.refresh-btn:active { transform: scale(.96); }
.refresh-btn.loading::before {
  content: "";
  width: 14px;
  height: 14px;
  border: 2px solid #3c4d63;
  border-top-color: var(--text);
  border-radius: 50%;
  animation: spin 800ms linear infinite;
}

@keyframes spin { to { transform: rotate(360deg); } }

/* ===== Tab nav ===== */
nav.tabs {
  display: flex;
  gap: 4px;
  padding: 8px 12px 0;
  overflow-x: auto;
  scrollbar-width: thin;
  scroll-snap-type: x proximity;
  -webkit-overflow-scrolling: touch;
  max-width: 1320px;
  margin: 0 auto;
}

nav.tabs button {
  background: transparent;
  color: var(--muted);
  border: 1px solid transparent;
  border-bottom: 2px solid transparent;
  padding: 10px 12px;
  font: inherit;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  min-height: 44px;
  white-space: nowrap;
  scroll-snap-align: start;
  border-radius: 8px 8px 0 0;
  transition: color .1s ease, background .1s ease;
}

nav.tabs button:hover { color: var(--text); background: var(--panel2); }

nav.tabs button.active {
  color: var(--text);
  background: var(--panel);
  border-color: var(--line);
  border-bottom-color: var(--accent);
}

nav.tabs button .pill {
  display: inline-flex;
  align-items: center;
  margin-inline-start: 6px;
  padding: 1px 6px;
  background: var(--panel3);
  border-radius: 999px;
  font-size: 11px;
  color: var(--muted);
}

nav.tabs button .pill.danger { background: rgba(251, 113, 133, .2); color: var(--bad); }
nav.tabs button .pill.warning { background: rgba(251, 191, 36, .2); color: var(--warn); }

/* ===== Main ===== */
main {
  max-width: 1320px;
  margin: 14px auto 0;
  padding: 0 12px 24px;
}

/* Mobile bottom nav (≤ 720px) */
nav.mobile-bottom {
  display: none;
  position: fixed;
  bottom: 0;
  inset-inline: 0;
  background: rgba(11, 15, 20, .98);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  border-top: 1px solid var(--line);
  padding: 6px 4px;
  z-index: 30;
}

nav.mobile-bottom .row {
  display: flex;
  gap: 2px;
  overflow-x: auto;
  scrollbar-width: none;
  -webkit-overflow-scrolling: touch;
}

nav.mobile-bottom .row::-webkit-scrollbar { display: none; }

nav.mobile-bottom button {
  flex: 0 0 auto;
  min-width: 64px;
  min-height: 52px;
  background: transparent;
  color: var(--muted);
  border: none;
  font: inherit;
  font-size: 11px;
  font-weight: 600;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  padding: 4px 8px;
  border-radius: 8px;
}

nav.mobile-bottom button.active {
  background: var(--panel2);
  color: var(--accent);
}

nav.mobile-bottom .icon {
  font-size: 18px;
  line-height: 1;
}

/* ===== Cards / Grid ===== */
.grid {
  display: grid;
  gap: 10px;
}

.grid.kpi-grid { grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); }
.grid.cards-2 { grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); }
.grid.cards-3 { grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); }
.grid.cards-stack { grid-template-columns: 1fr; }

.card {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 12px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  min-width: 0;
}

.card.danger { border-color: rgba(239, 68, 68, .35); background: linear-gradient(180deg, rgba(239, 68, 68, .06), transparent 60%); }
.card.warning { border-color: rgba(251, 191, 36, .35); background: linear-gradient(180deg, rgba(251, 191, 36, .06), transparent 60%); }
.card.success { border-color: rgba(52, 211, 153, .35); }

.card h2, .card h3 {
  margin: 0;
  font-size: 14px;
  font-weight: 700;
  display: flex;
  align-items: center;
  gap: 8px;
}

.card h2 .small, .card h3 .small {
  font-size: 11px;
  font-weight: 500;
  color: var(--muted);
}

.kpi-card .label {
  color: var(--muted);
  font-size: 12px;
}
.kpi-card .value {
  font-size: 28px;
  font-weight: 800;
  line-height: 1;
  letter-spacing: -.02em;
  overflow-wrap: anywhere;
}
.kpi-card .sub {
  color: var(--dim);
  font-size: 11px;
}

.kpi-card.green .value { color: var(--good); }
.kpi-card.yellow .value { color: var(--warn); }
.kpi-card.red .value { color: var(--bad); }
.kpi-card.info .value { color: var(--info); }

/* ===== Rows / Items ===== */
.row {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 10px;
  padding: 6px 0;
  border-top: 1px solid rgba(255, 255, 255, .05);
  font-size: 13px;
}

.row:first-of-type { border-top: 0; padding-top: 0; }

.row .k { color: var(--muted); }
.row .v { font-weight: 600; }

.item {
  border: 1px solid var(--line);
  background: var(--panel2);
  border-radius: 8px;
  padding: 10px;
  display: flex;
  flex-direction: column;
  gap: 4px;
  font-size: 13px;
  overflow-wrap: anywhere;
}

.item .item-title {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
  font-weight: 700;
}

.item.danger { border-color: rgba(239, 68, 68, .35); }
.item.warning { border-color: rgba(251, 191, 36, .35); }
.item.success { border-color: rgba(52, 211, 153, .35); }
.item.info { border-color: rgba(96, 165, 250, .35); }
.item.unknown { border-style: dashed; }

.item .meta {
  color: var(--muted);
  font-size: 11px;
}

.item .actions {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
  margin-top: 6px;
}

.icon-btn {
  padding: 6px 10px;
  background: var(--panel3);
  color: var(--text);
  border: 1px solid var(--line);
  border-radius: 6px;
  font: inherit;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  min-height: 32px;
}

.icon-btn:hover { background: var(--panel); }

/* ===== Badges ===== */
.badge {
  display: inline-flex;
  align-items: center;
  padding: 2px 8px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 600;
  border: 1px solid var(--line);
  color: var(--muted);
  white-space: nowrap;
}

.badge.green { color: var(--good); border-color: rgba(52, 211, 153, .35); background: rgba(52, 211, 153, .08); }
.badge.yellow { color: var(--warn); border-color: rgba(251, 191, 36, .35); background: rgba(251, 191, 36, .08); }
.badge.red { color: var(--bad); border-color: rgba(251, 113, 133, .35); background: rgba(251, 113, 133, .08); }
.badge.info { color: var(--info); border-color: rgba(96, 165, 250, .35); background: rgba(96, 165, 250, .08); }
.badge.unknown { color: var(--muted); border-style: dashed; }
.badge.critical { color: #fff; background: var(--critical); border-color: var(--critical); }

/* ===== Inputs / search ===== */
.toolbar {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  align-items: center;
  margin-bottom: 10px;
}

.toolbar input[type="text"], .toolbar input[type="search"], .toolbar select {
  flex: 1 1 200px;
  min-height: 44px;
  background: var(--panel2);
  color: var(--text);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 0 12px;
  font: inherit;
}

.toolbar select {
  flex: 0 1 180px;
}

.filter-field {
  display: flex;
  flex-direction: column;
  gap: 4px;
  color: var(--muted);
  font-size: 11px;
  font-weight: 600;
}

.toolbar .chip {
  min-height: 36px;
  padding: 6px 10px;
  background: var(--panel2);
  color: var(--muted);
  border: 1px solid var(--line);
  border-radius: 999px;
  font: inherit;
  font-size: 13px;
  cursor: pointer;
}

.toolbar .chip.active {
  color: var(--text);
  background: var(--accent);
  color: #0b1118;
  border-color: var(--accent);
}

/* ===== Empty / loading ===== */
.empty {
  color: var(--muted);
  font-size: 13px;
  padding: 14px;
  border: 1px dashed var(--line);
  border-radius: 8px;
  text-align: center;
}

.empty strong { color: var(--text); display: block; margin-bottom: 4px; }

.loading-card {
  color: var(--muted);
  font-size: 14px;
  padding: 18px;
  text-align: center;
}

/* ===== Mono / pre ===== */
.mono {
  direction: ltr;
  text-align: left;
  font-family: Consolas, "Courier New", monospace;
  font-size: 12px;
  overflow-wrap: anywhere;
}

pre {
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  direction: ltr;
  text-align: left;
  color: #cfdcef;
  margin: 0;
  font-size: 12px;
  background: var(--panel2);
  padding: 8px;
  border-radius: 6px;
  border: 1px solid var(--line);
}

details {
  border: 1px solid var(--line);
  background: var(--panel2);
  border-radius: 8px;
  padding: 10px;
}

details summary {
  cursor: pointer;
  font-weight: 600;
  min-height: 28px;
  display: flex;
  align-items: center;
  gap: 8px;
}

details + details { margin-top: 6px; }

a {
  color: var(--accent);
  text-decoration: none;
  word-break: break-all;
}

a:hover { text-decoration: underline; }

.toast {
  position: fixed;
  bottom: 100px;
  inset-inline: 16px;
  background: #172233;
  border: 1px solid #3c4d63;
  border-radius: 10px;
  padding: 12px 14px;
  text-align: center;
  font-weight: 600;
  z-index: 40;
  display: none;
  box-shadow: var(--shadow);
}

.toast.show { display: block; animation: toastIn .15s ease-out; }

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

/* ===== Mobile breakpoints ===== */
@media (max-width: 720px) {
  body { padding-bottom: 76px; }
  nav.tabs { display: none; }
  nav.mobile-bottom { display: block; }
  .grid.cards-2, .grid.cards-3 { grid-template-columns: 1fr; }
  .grid.kpi-grid { grid-template-columns: repeat(2, 1fr); }
  .kpi-card .value { font-size: 24px; }
  .title-block h1 { font-size: 16px; }
  main { padding: 0 10px 12px; margin-top: 10px; }
  .toolbar input[type="text"], .toolbar input[type="search"] { flex-basis: 100%; }
  table.scroll { display: block; overflow-x: auto; }
}

@media (max-width: 380px) {
  .grid.kpi-grid { grid-template-columns: 1fr; }
}

@media (min-width: 721px) {
  nav.mobile-bottom { display: none; }
}

/* Make table-like layouts wrap into cards on phones */
.kv-table { width: 100%; border-collapse: collapse; font-size: 13px; }
.kv-table th, .kv-table td { padding: 6px 8px; text-align: start; border-bottom: 1px solid var(--line); }
.kv-table th { color: var(--muted); font-weight: 600; }

/* Refresh now FAB visible on phones */
.fab-refresh {
  display: none;
  position: fixed;
  bottom: 80px;
  inset-inline-end: 12px;
  width: 56px;
  height: 56px;
  border-radius: 50%;
  background: var(--accent);
  color: #0b1118;
  border: none;
  cursor: pointer;
  z-index: 35;
  box-shadow: var(--shadow);
  font-size: 22px;
  font-weight: 700;
}

@media (max-width: 720px) {
  .fab-refresh { display: flex; align-items: center; justify-content: center; }
}

/* Stale banner (above main when overall freshness is bad) */
.stale-banner {
  display: none;
  margin: 0 auto 12px;
  max-width: 1320px;
  padding: 10px 14px;
  border-radius: 10px;
  font-weight: 700;
  text-align: center;
  border: 1px solid var(--warn);
  background: rgba(251, 191, 36, .08);
  color: var(--warn);
}

.stale-banner.show { display: block; }
.stale-banner.red {
  border-color: var(--bad);
  background: rgba(251, 113, 133, .08);
  color: var(--bad);
}

/* ===== System registry phonebook ===== */
.registry-sticky {
  position: sticky;
  top: 112px;
  z-index: 20;
  margin-bottom: 10px;
  padding: 8px;
  background: rgba(11, 15, 20, .96);
  border: 1px solid var(--line);
  border-radius: 10px;
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
}

.registry-toolbar {
  margin-bottom: 0;
}

.registry-kpis,
.registry-samples,
.registry-list {
  margin-top: 12px;
}

.registry-card {
  border-radius: 8px;
}

.registry-card.safe {
  border-color: rgba(52, 211, 153, .28);
}

.registry-card.review {
  border-color: rgba(251, 191, 36, .42);
  background: linear-gradient(180deg, rgba(251, 191, 36, .05), transparent 60%);
}

.registry-card.forbidden {
  border-color: rgba(239, 68, 68, .6);
  background: linear-gradient(180deg, rgba(239, 68, 68, .11), rgba(239, 68, 68, .03));
  box-shadow: inset 4px 0 0 rgba(239, 68, 68, .7);
}

.registry-badges {
  display: inline-flex;
  gap: 4px;
  flex-wrap: wrap;
  margin-inline-start: auto;
}

.safe-command {
  border: 1px solid rgba(96, 165, 250, .28);
  background: rgba(96, 165, 250, .08);
  border-radius: 6px;
  padding: 8px;
}

@media (max-width: 720px) {
  .registry-sticky {
    top: 76px;
    margin-inline: -2px;
  }
  .registry-toolbar {
    display: grid;
    grid-template-columns: 1fr 1fr;
  }
  .registry-toolbar input[type="search"] {
    grid-column: 1 / -1;
  }
  .registry-toolbar select {
    width: 100%;
  }
  .filter-field {
    min-width: 0;
  }
}
