:root {
  color-scheme: light;
  --bg: #f1f5f9;
  --panel: #ffffff;
  --ink: #0f172a;
  --muted: #64748b;
  --line: #e2e8f0;
  --teal: #0f766e;
  --teal-dark: #0b5f59;
  --green: #16a34a;
  --red: #dc2626;
  --shadow: 0 1px 3px rgba(15, 23, 42, 0.06), 0 1px 2px rgba(15, 23, 42, 0.04);
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font: 15px/1.5 system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

/* ── topbar ── */
.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 16px 24px;
  background: var(--panel);
  border-bottom: 1px solid var(--line);
}
.brand { display: flex; align-items: center; gap: 12px; }
.logo { font-size: 30px; }
h1 { margin: 0; font-size: 20px; }
.status { margin: 2px 0 0; display: flex; align-items: center; gap: 7px; color: var(--muted); font-size: 13px; }
.dot { width: 9px; height: 9px; border-radius: 50%; background: #cbd5e1; }
.dot.ok { background: var(--green); box-shadow: 0 0 0 3px rgba(22,163,74,.15); }
.dot.warn { background: #f59e0b; box-shadow: 0 0 0 3px rgba(245,158,11,.2); }
.dot.bad { background: var(--red); box-shadow: 0 0 0 3px rgba(220,38,38,.15); }

button { cursor: pointer; font: inherit; }
.ghost {
  height: 38px; padding: 0 16px;
  border: 1px solid var(--line); border-radius: 9px;
  background: var(--panel); color: var(--ink); font-weight: 600;
}
.ghost:hover { background: #f8fafc; }
.topbar-actions { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.topbar-actions a.ghost { display: flex; align-items: center; text-decoration: none; color: inherit; }
.last-seen { margin: 4px 0 0; font-size: 12px; color: var(--muted); }
.last-seen.warn { color: #b45309; font-weight: 600; }

.alert-banner {
  max-width: min(960px, calc(100vw - 32px));
  margin: 0 auto;
  padding: 12px 16px;
  background: #fef3c7;
  border: 1px solid #fcd34d;
  border-radius: 10px;
  color: #92400e;
  font-weight: 600;
  font-size: 14px;
}

.phone-status { margin-bottom: 16px; }
.status-list { margin-top: 12px; display: flex; flex-direction: column; gap: 8px; }
.status-row { display: flex; align-items: flex-start; gap: 10px; font-size: 14px; }
.status-row .status-dot {
  width: 10px; height: 10px; border-radius: 50%; margin-top: 5px; flex: none;
  background: #cbd5e1;
}
.status-row.ok .status-dot { background: var(--green); }
.status-row.bad .status-dot { background: var(--red); }
.status-row.warn .status-dot { background: #f59e0b; }
.status-fix { display: block; color: var(--muted); font-weight: 400; font-size: 12px; margin-top: 2px; }

main { width: min(960px, calc(100vw - 32px)); margin: 24px auto 60px; }

/* ── cards ── */
.cards {
  display: grid;
  grid-template-columns: 1.3fr 1fr 1fr;
  gap: 16px;
}
.card {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 16px;
  box-shadow: var(--shadow);
  display: flex;
  flex-direction: column;
}
.card .label {
  color: var(--muted);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: .04em;
  text-transform: uppercase;
}
.card strong { font-size: 20px; margin-top: 10px; overflow-wrap: anywhere; }
.card small { color: var(--muted); margin-top: 6px; }
.card-link { margin-top: 10px; color: var(--teal-dark); font-weight: 700; text-decoration: none; }
.card-link:hover { text-decoration: underline; }

.live-chat { margin-bottom: 16px; }
.live-badge {
  font-size: 12px;
  font-weight: 700;
  letter-spacing: .02em;
}
.live-badge.live { color: #059669; }
.live-badge.recent { color: #d97706; }
.chat-preview {
  margin-top: 12px;
  background: #f1f5f9;
  border: 1px solid var(--line);
  border-radius: 12px;
  max-height: 420px;
  overflow: auto;
}
.chat-thread {
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding: 14px;
}
.chat-bubble {
  max-width: 88%;
  padding: 10px 12px;
  border-radius: 14px;
  font-size: 14px;
  line-height: 1.4;
  word-break: break-word;
}
.chat-bubble p { margin: 4px 0 0; }
.chat-bubble-label {
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .04em;
  opacity: .75;
}
.chat-bubble--sent {
  align-self: flex-end;
  background: #ccfbf1;
  border: 1px solid #99f6e4;
  border-bottom-right-radius: 4px;
}
.chat-bubble--received {
  align-self: flex-start;
  background: #fff;
  border: 1px solid #e2e8f0;
  border-bottom-left-radius: 4px;
}
.chat-bubble--unknown {
  align-self: center;
  background: #fef3c7;
  border: 1px solid #fde68a;
}

.screen-view { margin-bottom: 16px; }
.screen-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 4px;
}
.ghost-sm { height: 32px; padding: 0 12px; font-size: 13px; }
.screen-preview { margin-top: 12px; display: flex; justify-content: center; }
.phone-frame {
  position: relative;
  width: min(280px, 100%);
  background: #0f172a;
  border-radius: 28px;
  padding: 10px 8px 12px;
  box-shadow: 0 8px 32px rgba(15, 23, 42, 0.25);
}
.phone-notch {
  width: 80px;
  height: 5px;
  background: #334155;
  border-radius: 999px;
  margin: 0 auto 8px;
}
.phone-screen {
  position: relative;
  width: 100%;
  background: #f8fafc;
  border-radius: 16px;
  overflow: hidden;
  min-height: 320px;
}
.phone-screen--empty,
.phone-screen--fallback {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 16px;
  color: var(--muted);
  font-size: 13px;
  text-align: center;
  gap: 8px;
}
.fallback-line {
  width: 100%;
  text-align: left;
  padding: 6px 10px;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 8px;
  font-size: 12px;
  color: var(--ink);
}
.layout-node {
  position: absolute;
  overflow: hidden;
  padding: 1px 3px;
  border-radius: 3px;
  line-height: 1.15;
  color: #0f172a;
  background: rgba(255, 255, 255, 0.88);
  border: 1px solid rgba(15, 23, 42, 0.08);
  pointer-events: none;
  word-break: break-word;
}
.layout-node--button {
  background: rgba(15, 118, 110, 0.15);
  border-color: rgba(15, 118, 110, 0.35);
  font-weight: 600;
  text-align: center;
  display: flex;
  align-items: center;
  justify-content: center;
}
.layout-node--input {
  background: #fff;
  border: 1px solid #94a3b8;
  border-radius: 6px;
}
.layout-node--image {
  background: #e2e8f0;
  color: transparent;
  min-height: 12px;
}
.layout-node--list {
  background: rgba(241, 245, 249, 0.9);
}
.layout-node--text {
  background: transparent;
  border-color: transparent;
}

.screen-lines {
  margin-top: 12px;
  padding: 12px 14px;
  background: #f8fafc;
  border: 1px solid var(--line);
  border-radius: 10px;
  max-height: 280px;
  overflow: auto;
}
.screen-lines p {
  margin: 0 0 8px;
  white-space: pre-wrap;
  word-break: break-word;
}
.screen-lines p:last-child { margin-bottom: 0; }

.map-card .label { margin-bottom: 10px; }
.map-wrap {
  height: 150px;
  border-radius: 10px;
  overflow: hidden;
  border: 1px solid var(--line);
  background: #e8eef2;
}
.map-wrap iframe { width: 100%; height: 100%; border: 0; display: block; }
.map-empty {
  height: 100%;
  display: flex; align-items: center; justify-content: center;
  color: var(--muted); font-size: 13px;
}
.map-card strong { font-size: 16px; }

/* ── feed head ── */
.feed-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin: 28px 0 14px;
  flex-wrap: wrap;
}
.filters { display: flex; gap: 8px; flex-wrap: wrap; }
.chip {
  height: 34px; padding: 0 14px;
  border: 1px solid var(--line); border-radius: 999px;
  background: var(--panel); color: var(--muted); font-weight: 600;
}
.chip:hover { color: var(--ink); }
.chip.active { background: var(--teal); border-color: var(--teal); color: #fff; }
.updated { color: var(--muted); font-size: 12px; }

/* ── feed ── */
.feed { display: flex; flex-direction: column; gap: 8px; }
.day {
  margin: 14px 2px 2px;
  font-size: 12px; font-weight: 700; letter-spacing: .04em;
  text-transform: uppercase; color: var(--muted);
}
.item {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 13px 15px;
  box-shadow: var(--shadow);
}
.item .ic {
  font-size: 20px;
  width: 34px; height: 34px;
  flex: none;
  display: flex; align-items: center; justify-content: center;
  border-radius: 9px;
  background: #f1f5f9;
}
.item.messages .ic { background: #ecfdf5; }
.item.location .ic { background: #eff6ff; }
.item.apps .ic { background: #fef3c7; }
.item.calls .ic { background: #f3e8ff; }
.item.screen .ic { background: #e0f2fe; }
.item .body { flex: 1; min-width: 0; }
.line1 { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.line1 strong { font-size: 15px; font-weight: 600; }
.pill {
  font-size: 11px; font-weight: 700;
  padding: 2px 8px; border-radius: 999px;
  background: #e6f4f1; color: var(--teal-dark);
}
.lines { margin-top: 4px; }
.lines p { margin: 2px 0; color: #334155; overflow-wrap: anywhere; }
.row-link { display: inline-block; margin-top: 5px; color: var(--teal-dark); font-size: 13px; font-weight: 600; text-decoration: none; }
.row-link:hover { text-decoration: underline; }
.item time { flex: none; color: var(--muted); font-size: 12px; white-space: nowrap; }

.empty { text-align: center; color: var(--muted); padding: 40px 0; }
.muted { color: var(--muted); margin: 4px 0; }

/* ── screen time ── */
.screentime { margin-top: 16px; }
.st-head { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; }
.st-head strong { margin: 0; font-size: 24px; }
.st-list { margin-top: 14px; display: flex; flex-direction: column; gap: 9px; }
.st-row { display: grid; grid-template-columns: 130px 1fr 56px; align-items: center; gap: 12px; }
.st-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-weight: 600; }
.st-bar { height: 10px; background: #eef2f6; border-radius: 999px; overflow: hidden; }
.st-bar i { display: block; height: 100%; background: var(--teal); border-radius: 999px; }
.st-dur { text-align: right; color: var(--muted); font-variant-numeric: tabular-nums; }

@media (max-width: 760px) {
  .st-row { grid-template-columns: 96px 1fr 48px; gap: 8px; }
}

/* ── responsive ── */
@media (max-width: 760px) {
  .topbar { padding: 14px 16px; }
  .cards { grid-template-columns: 1fr; }
  .item time { font-size: 11px; }
}
