:root {
  --navy: #0f172a;
  --bg: #f0f2f5;
  --panel: #ffffff;
  --border: #d1d5db;
  --text: #0f172a;
  --muted: #64748b;
  --red: #dc2626;
  --amber: #b45309;
  --accent: #2563eb;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; height: 100%; }
body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
  font-size: 14px;
}

.hidden { display: none !important; }
.view { min-height: 100vh; }

/* Login */
#login-view { display: flex; align-items: center; justify-content: center; background: var(--navy); }
.login-card { text-align: center; color: #e2e8f0; padding: 32px; width: min(360px, 90vw); }
.login-logo { font-size: 48px; }
.login-card h1 { margin: 8px 0 0; letter-spacing: 2px; }
.login-sub { color: #94a3b8; font-size: 11px; text-transform: uppercase; letter-spacing: 2px; margin: 4px 0 24px; }
.login-card input {
  width: 100%; padding: 12px; border-radius: 8px; border: 1px solid #334155;
  background: #1e293b; color: #e2e8f0; font-size: 16px; margin-bottom: 12px;
}
.login-card button {
  width: 100%; padding: 12px; border-radius: 8px; border: none;
  background: var(--accent); color: white; font-size: 15px; font-weight: 600; cursor: pointer;
}
.error { color: #f87171; font-size: 12px; }

/* Header + nav */
header {
  background: var(--navy); color: #e2e8f0; padding: 14px 16px;
  padding-top: max(14px, env(safe-area-inset-top));
  display: flex; justify-content: space-between; align-items: center;
}
.header-title { font-size: 16px; }
.header-meta { font-size: 11px; color: #94a3b8; }
nav { display: flex; background: var(--panel); border-bottom: 1px solid var(--border); position: sticky; top: 0; z-index: 5; }
.tab {
  flex: 1; padding: 12px 4px; border: none; background: none; cursor: pointer;
  font-size: 12px; text-transform: uppercase; letter-spacing: 0.5px; color: var(--muted);
  border-bottom: 2px solid transparent;
}
.tab.active { color: var(--text); border-bottom-color: var(--accent); font-weight: 600; }
.badge {
  background: var(--red); color: white; border-radius: 9px; font-size: 10px;
  padding: 1px 6px; margin-left: 4px;
}

main { padding: 12px; max-width: 860px; margin: 0 auto; }
.panel { background: var(--panel); border: 1px solid var(--border); border-radius: 10px; padding: 16px; margin-bottom: 12px; }
.placeholder { color: var(--muted); font-size: 13px; }
.spend { font-size: 12px; color: var(--muted); margin-bottom: 12px; }

button.secondary {
  display: block; width: 100%; margin-bottom: 8px; padding: 10px; border-radius: 8px;
  border: 1px solid var(--border); background: var(--bg); color: var(--text); cursor: pointer; font-size: 13px;
}

/* Chat */
#tab-chat { display: flex; flex-direction: column; height: calc(100vh - 160px); }
#tab-chat.hidden { display: none; }
#chat-messages { flex: 1; overflow-y: auto; padding: 4px 2px; }
.msg { max-width: 85%; margin: 6px 0; padding: 10px 14px; border-radius: 14px; white-space: pre-wrap; line-height: 1.45; }
.msg.user { background: var(--accent); color: white; margin-left: auto; border-bottom-right-radius: 4px; }
.msg.jarvis { background: var(--panel); border: 1px solid var(--border); border-bottom-left-radius: 4px; }
.msg.thinking { color: var(--muted); font-style: italic; background: none; border: none; }
#chat-form { display: flex; gap: 8px; padding: 8px 0; padding-bottom: max(8px, env(safe-area-inset-bottom)); }
#chat-input {
  flex: 1; resize: none; padding: 12px; border-radius: 10px; border: 1px solid var(--border);
  font-family: inherit; font-size: 16px;
}
#chat-send {
  padding: 0 18px; border-radius: 10px; border: none; background: var(--navy);
  color: white; font-weight: 600; cursor: pointer;
}
#chat-send:disabled { opacity: 0.5; }

/* Activity table */
.activity-row { border-bottom: 1px solid var(--bg); padding: 8px 0; font-size: 12px; }
.activity-row .ev { font-weight: 600; }
.activity-row .ts { color: var(--muted); font-size: 11px; }
.activity-row .detail { color: var(--muted); word-break: break-all; }
