/* Frank iPhone PWA — dark + coral, Cabinet Grotesk + Inter + JetBrains Mono */
:root {
  --bg: #0a0a0c;
  --surface: #111114;
  --surface-2: #1a1a20;
  --border: rgba(255,255,255,0.08);
  --border-2: rgba(255,255,255,0.14);
  --text: #f5f5f7;
  --text-2: #a1a1aa;
  --text-3: #71717a;
  --text-4: #52525b;
  --accent: #ff4d2e;
  --accent-2: #ffb02e;
  --accent-soft: rgba(255,77,46,0.12);
  --accent-border: rgba(255,77,46,0.3);
  --ok: #10b981;
  --warn: #f59e0b;
  --err: #ef4444;
  --info: #3b82f6;
  --font: "Inter", -apple-system, BlinkMacSystemFont, system-ui, sans-serif;
  --display: "Cabinet Grotesk", "Inter", system-ui, sans-serif;
  --mono: "JetBrains Mono", "SF Mono", Menlo, monospace;
  --safe-top: env(safe-area-inset-top, 0);
  --safe-bottom: env(safe-area-inset-bottom, 0);
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body {
  margin: 0; padding: 0; background: #050507; color: var(--text);
  font-family: var(--font); -webkit-font-smoothing: antialiased;
  overscroll-behavior: none; -webkit-text-size-adjust: 100%;
  min-height: 100vh; min-height: 100dvh;
}
body {
  background:
    radial-gradient(900px 500px at 12% -10%, rgba(255,77,46,0.10), transparent 60%),
    radial-gradient(800px 400px at 88% 8%, rgba(255,176,46,0.06), transparent 60%),
    #050507;
}

button { font-family: inherit; cursor: pointer; }
input, textarea { font-family: inherit; }

#root { min-height: 100vh; min-height: 100dvh; display: flex; flex-direction: column; }

/* BOOT */
.boot {
  flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 18px;
}
.boot-mark {
  width: 72px; height: 72px; border-radius: 18px;
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  display: grid; place-items: center; font-family: var(--display); font-weight: 800;
  color: white; font-size: 44px; box-shadow: 0 0 60px rgba(255,77,46,0.4);
}
.boot-label {
  font-family: var(--mono); font-size: 11px; letter-spacing: 0.4em; color: var(--text-3);
}
.boot-spin {
  width: 18px; height: 18px; border: 2px solid var(--border-2); border-top-color: var(--accent);
  border-radius: 50%; animation: spin 0.8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* APP SHELL */
.app { flex: 1; display: flex; flex-direction: column; min-height: 100vh; min-height: 100dvh; }

.tab-bar {
  position: sticky; bottom: 0; left: 0; right: 0; z-index: 100;
  display: flex; overflow-x: auto;
  background: rgba(10,10,12,0.92); backdrop-filter: blur(20px); -webkit-backdrop-filter: blur(20px);
  border-top: 1px solid var(--border);
  padding-bottom: var(--safe-bottom);
  scrollbar-width: none;
}
.tab-bar::-webkit-scrollbar { display: none; }
.tab {
  display: flex; flex-direction: column; align-items: center; gap: 4px;
  padding: 10px 14px calc(10px + var(--safe-bottom)) 14px;
  background: none; border: none; color: var(--text-3);
  font-size: 9px; font-family: var(--mono); letter-spacing: 0.1em; text-transform: uppercase;
  flex-shrink: 0;
}
.tab.on { color: var(--accent); }
.tab svg { width: 20px; height: 20px; }

/* DESKTOP LAYOUT: sidebar nav instead of bottom tab bar */
@media (min-width: 900px) {
  #root { padding: 0; }
  .app { flex-direction: row; min-height: 100vh; }
  .tab-bar {
    position: sticky; top: 0; left: 0; bottom: 0;
    flex-direction: column;
    width: 220px; height: 100vh; flex-shrink: 0;
    border-top: none; border-right: 1px solid var(--border);
    padding: 24px 12px;
    gap: 4px;
    overflow-x: visible;
  }
  .tab {
    flex-direction: row; justify-content: flex-start; gap: 12px;
    padding: 12px 14px; font-size: 11px; letter-spacing: 0.08em;
    border-radius: 10px;
  }
  .tab.on { background: var(--accent-soft); }
  .tab svg { width: 18px; height: 18px; }
  .screen { padding: 32px 48px; max-width: 1100px; }
  .topbar h1 { font-size: 36px; }
}

/* MOBILE RESPONSIVE TWEAKS */
@media (max-width: 899px) {
  .kpi-grid { grid-template-columns: 1fr; }
  .topbar h1 { font-size: 24px; }
  .btn { font-size: 14px; padding: 12px 16px; min-height: 44px; }
  .tab-bar { justify-content: flex-start; }
  .tab { flex: 0 0 auto; min-width: 0; padding: 12px 14px calc(12px + var(--safe-bottom)) 14px; }
}

.screen {
  flex: 1; padding: calc(20px + var(--safe-top)) 18px calc(20px + var(--safe-bottom));
  display: flex; flex-direction: column; gap: 14px;
}

.topbar { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.topbar h1 {
  font-family: var(--display); font-weight: 700; font-size: 28px; line-height: 1.05;
  letter-spacing: -0.02em; margin: 0;
}
.topbar h1 em { font-style: italic; color: var(--accent); font-weight: 500; }
.topbar .date { font-family: var(--mono); font-size: 10px; color: var(--text-3); letter-spacing: 0.14em; text-transform: uppercase; }

.pill {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 5px 10px; border-radius: 999px;
  background: rgba(255,255,255,0.06); border: 1px solid var(--border);
  font-size: 10px; font-family: var(--mono); letter-spacing: 0.04em; color: var(--text-2);
  white-space: nowrap;
}
.pill.accent { background: var(--accent-soft); border-color: var(--accent-border); color: var(--accent); }
.pill.ok { background: rgba(16,185,129,0.12); border-color: rgba(16,185,129,0.3); color: var(--ok); }
.pill.warn { background: rgba(245,158,11,0.12); border-color: rgba(245,158,11,0.3); color: var(--warn); }
.pill.err { background: rgba(239,68,68,0.12); border-color: rgba(239,68,68,0.3); color: var(--err); }
.pill.info { background: rgba(59,130,246,0.12); border-color: rgba(59,130,246,0.3); color: var(--info); }
.dot { width: 6px; height: 6px; border-radius: 50%; background: var(--accent); }
.dot.ok { background: var(--ok); } .dot.warn { background: var(--warn); } .dot.err { background: var(--err); } .dot.info { background: var(--info); }
.dot.live { background: var(--accent); animation: pulse 1.6s ease-in-out infinite; }
@keyframes pulse { 0%,100% { opacity: 1; transform: scale(1);} 50% { opacity: 0.4; transform: scale(0.7);} }

.surface {
  background: var(--surface); border: 1px solid var(--border); border-radius: 18px;
  padding: 14px;
}
.surface-2 {
  background: var(--surface-2); border: 1px solid var(--border); border-radius: 14px;
  padding: 12px;
}
.section-title {
  font-family: var(--display); font-weight: 600; font-size: 16px; letter-spacing: -0.01em;
}
.label-sm { font-family: var(--mono); font-size: 9px; letter-spacing: 0.14em; text-transform: uppercase; color: var(--text-3); }
.mono { font-family: var(--mono); }
.muted { color: var(--text-3); }
.green { color: var(--ok); } .red { color: var(--err); } .amber { color: var(--warn); }

.kpi-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.kpi {
  padding: 14px; background: var(--surface); border: 1px solid var(--border); border-radius: 16px;
}
.kpi .l { font-family: var(--mono); font-size: 9px; color: var(--text-3); letter-spacing: 0.14em; text-transform: uppercase; }
.kpi .v { font-family: var(--display); font-weight: 700; font-size: 24px; letter-spacing: -0.01em; margin-top: 6px; }
.kpi .d { font-size: 10px; margin-top: 2px; font-family: var(--mono); }

.row { display: flex; align-items: center; gap: 10px; }
.row .grow { flex: 1; min-width: 0; }
.row .right { text-align: right; }

.btn {
  padding: 10px 14px; border-radius: 12px; font-family: var(--display); font-weight: 600; font-size: 13px;
  border: 1px solid var(--border); background: var(--surface); color: var(--text);
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  cursor: pointer; transition: background 180ms ease, border-color 180ms ease, color 180ms ease, transform 120ms ease;
}
.btn:hover { background: var(--surface-2); border-color: var(--border-2); }
.btn:active { transform: scale(0.98); }
.btn:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.btn[disabled] { opacity: 0.5; cursor: not-allowed; }
.btn.primary { background: var(--accent); color: white; border-color: var(--accent); }
.btn.primary:hover { background: #ff5d40; border-color: #ff5d40; }
.btn.ghost { background: transparent; }
.btn.ghost:hover { background: var(--surface); }
.btn.danger { background: rgba(239,68,68,0.12); color: var(--err); border-color: rgba(239,68,68,0.3); }
.btn.danger:hover { background: rgba(239,68,68,0.18); }
.btn.small { padding: 7px 10px; font-size: 11px; }
.tab { cursor: pointer; transition: color 180ms ease, background 180ms ease; }
.tab:focus-visible { outline: 2px solid var(--accent); outline-offset: -2px; border-radius: 10px; }
input.field, textarea.field {
  width: 100%; padding: 12px 14px; background: var(--surface); border: 1px solid var(--border);
  border-radius: 14px; color: var(--text); font-size: 14px; outline: none;
  font-family: var(--font);
  transition: border-color 180ms ease;
}
input.field:focus-visible, textarea.field:focus-visible { border-color: var(--accent-border); outline: 2px solid var(--accent); outline-offset: 1px; }
textarea.field { resize: vertical; min-height: 100px; line-height: 1.45; }

.scroll { overflow-y: auto; -webkit-overflow-scrolling: touch; }

.bubble {
  max-width: 85%; padding: 11px 14px; font-size: 14px; line-height: 1.45;
}
.bubble.frank {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: 4px 16px 16px 16px; align-self: flex-start;
}
.bubble.user {
  background: var(--accent); color: white;
  border-radius: 16px 4px 16px 16px; align-self: flex-end;
}
.bubble .meta { display: block; font-family: var(--mono); font-size: 8px; color: var(--text-3); letter-spacing: 0.12em; text-transform: uppercase; margin-top: 4px; }

.spinner { width: 18px; height: 18px; border: 2px solid var(--border-2); border-top-color: var(--accent); border-radius: 50%; animation: spin 0.8s linear infinite; }

.center-empty { padding: 40px 20px; text-align: center; color: var(--text-3); font-size: 13px; }

.toast {
  position: fixed; top: calc(20px + var(--safe-top)); left: 50%; transform: translateX(-50%);
  background: var(--surface-2); border: 1px solid var(--border-2); color: var(--text);
  padding: 10px 16px; border-radius: 12px; font-size: 13px; z-index: 1000;
  box-shadow: 0 12px 32px -8px rgba(0,0,0,0.6); max-width: 90vw;
  animation: slidein 0.3s ease-out;
}
@keyframes slidein { from { opacity: 0; transform: translate(-50%, -10px); } to { opacity: 1; transform: translate(-50%, 0); } }

.offline-banner {
  position: sticky; top: 0; z-index: 50;
  background: var(--err); color: white; padding: 6px 12px;
  text-align: center; font-size: 11px; font-family: var(--mono);
  letter-spacing: 0.1em; text-transform: uppercase;
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}
