/* ClaimGuard — production styles.
   Extracted from alpha v3 prototype, polished for production.
   Warm earth palette + Fraunces display + mobile-first.
   iPad-tested. Smart-quote-safe (all quotes here are straight ASCII). */

:root {
  --bg: #f5f1ea;
  --bg-warm: #ebe4d6;
  --ink: #0a1628;
  --ink-soft: #2c3e50;
  --ink-muted: #5a6c7d;
  --paper: #fdfbf6;
  --line: #d4c9b5;
  --accent: #c9461f;
  --accent-soft: #e8dcc6;
  --flag: #b8391a;
  --flag-bg: #f5e6dd;
  --ok: #2d5a3d;
  --ok-bg: #dde8de;
  --warn: #a67c00;
  --warn-bg: #f5ecd6;
  --shadow: 0 1px 2px rgba(10,22,40,0.06), 0 4px 16px rgba(10,22,40,0.04);
  --shadow-lg: 0 2px 8px rgba(10,22,40,0.08), 0 24px 48px rgba(10,22,40,0.08);
}

* { margin: 0; padding: 0; box-sizing: border-box; }

html, body { height: 100%; }

body {
  font-family: -apple-system, BlinkMacSystemFont, "Helvetica Neue", Arial, sans-serif;
  background: var(--bg);
  color: var(--ink);
  line-height: 1.5;
  font-size: 15px;
  min-height: 100vh;
  overflow-x: hidden;
  -webkit-text-size-adjust: 100%;
}

body::before {
  content: "";
  position: fixed;
  inset: 0;
  background-image:
    radial-gradient(circle at 20% 30%, rgba(201, 70, 31, 0.04) 0%, transparent 40%),
    radial-gradient(circle at 80% 70%, rgba(10, 22, 40, 0.03) 0%, transparent 40%);
  pointer-events: none;
  z-index: 0;
}

/* ---------- App shell ---------- */

.app {
  position: relative;
  z-index: 1;
  max-width: 1400px;
  margin: 0 auto;
  min-height: 100vh;
  display: grid;
  grid-template-columns: 280px 1fr;
}

.sidebar {
  background: var(--ink);
  color: var(--paper);
  padding: 28px 24px;
  display: flex;
  flex-direction: column;
  gap: 24px;
  min-height: 100vh;
  position: sticky;
  top: 0;
}

.brand {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  padding-bottom: 20px;
  border-bottom: 1px solid rgba(245, 241, 234, 0.1);
}

.brand-mark {
  font-family: "Fraunces", Georgia, serif;
  font-size: 26px;
  font-weight: 500;
  letter-spacing: -0.02em;
}

.brand-mark .accent { color: var(--accent); }

.brand-tag {
  font-size: 9px;
  text-transform: uppercase;
  letter-spacing: 0.15em;
  color: var(--accent);
  padding: 3px 6px;
  border: 1px solid rgba(201, 70, 31, 0.4);
  border-radius: 3px;
}

.nav-section { display: flex; flex-direction: column; gap: 2px; }

.nav-label {
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.15em;
  color: rgba(245, 241, 234, 0.4);
  margin-bottom: 10px;
  padding-left: 12px;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 12px;
  border-radius: 6px;
  font-size: 13px;
  color: rgba(245, 241, 234, 0.75);
  cursor: pointer;
  border: none;
  background: transparent;
  width: 100%;
  text-align: left;
  font-family: inherit;
  text-decoration: none;
}

.nav-item:hover { background: rgba(245, 241, 234, 0.05); color: var(--paper); }
.nav-item.active {
  background: rgba(201, 70, 31, 0.15);
  color: var(--paper);
  border-left: 2px solid var(--accent);
  padding-left: 10px;
}

.nav-item .dot {
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: currentColor;
  opacity: 0.4;
}

.claim-card {
  margin-top: auto;
  padding: 16px;
  background: rgba(245, 241, 234, 0.04);
  border-radius: 8px;
  border: 1px solid rgba(245, 241, 234, 0.08);
  font-size: 12px;
}

.claim-card .label {
  font-size: 9px;
  text-transform: uppercase;
  letter-spacing: 0.15em;
  color: rgba(245, 241, 234, 0.5);
  margin-bottom: 6px;
}

.claim-card .title {
  font-family: "Fraunces", Georgia, serif;
  font-size: 16px;
  font-weight: 500;
  color: var(--paper);
  margin-bottom: 2px;
}

.claim-card .meta {
  color: rgba(245, 241, 234, 0.6);
  font-size: 11px;
}

.reset-link {
  font-size: 10px;
  color: rgba(245, 241, 234, 0.4);
  text-decoration: underline;
  cursor: pointer;
  margin-top: 8px;
  display: inline-block;
  background: none;
  border: none;
  padding: 0;
  font-family: inherit;
}

.reset-link:hover { color: rgba(245, 241, 234, 0.7); }

.main {
  padding: 32px 36px;
  min-height: 100vh;
  max-width: 100%;
  overflow-x: hidden;
}

.view-header {
  margin-bottom: 28px;
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 20px;
}

.view-title {
  font-family: "Fraunces", Georgia, serif;
  font-size: 36px;
  font-weight: 400;
  letter-spacing: -0.02em;
  line-height: 1.05;
}

.view-title em {
  font-style: italic;
  font-weight: 300;
  color: var(--ink-muted);
}

.view-sub {
  color: var(--ink-muted);
  font-size: 14px;
  max-width: 560px;
  margin-top: 6px;
}

/* ---------- Chat ---------- */

.chat-shell {
  display: grid;
  grid-template-columns: 1fr 320px;
  gap: 20px;
  height: calc(100vh - 160px);
  min-height: 560px;
}

.chat-main {
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: 10px;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  box-shadow: var(--shadow);
}

.chat-header {
  padding: 16px 24px;
  border-bottom: 1px solid var(--line);
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.chat-header-left { display: flex; align-items: center; gap: 12px; }

.assistant-avatar {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--ink), var(--ink-soft));
  color: var(--paper);
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: "Fraunces", Georgia, serif;
  font-size: 14px;
  font-weight: 500;
}

.assistant-name {
  font-family: "Fraunces", Georgia, serif;
  font-size: 16px;
  font-weight: 500;
}

.assistant-role {
  font-size: 11px;
  color: var(--ink-muted);
  display: flex;
  align-items: center;
  gap: 6px;
}

.status-live {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--ok);
}

.messages {
  flex: 1;
  overflow-y: auto;
  padding: 24px;
  display: flex;
  flex-direction: column;
  gap: 18px;
  -webkit-overflow-scrolling: touch;
}

.messages::-webkit-scrollbar { width: 6px; }
.messages::-webkit-scrollbar-thumb { background: var(--line); border-radius: 3px; }

.msg {
  max-width: 82%;
  display: flex;
  flex-direction: column;
  gap: 4px;
  animation: msgIn 0.3s ease;
}

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

.msg.user { align-self: flex-end; align-items: flex-end; }

.msg-bubble {
  padding: 12px 16px;
  border-radius: 14px;
  font-size: 14px;
  line-height: 1.55;
  white-space: pre-wrap;
  word-wrap: break-word;
}

.msg-bubble strong { font-weight: 600; }

.msg.assistant .msg-bubble {
  background: var(--bg-warm);
  color: var(--ink);
  border-bottom-left-radius: 4px;
}

.msg.user .msg-bubble {
  background: var(--ink);
  color: var(--paper);
  border-bottom-right-radius: 4px;
}

.msg.system { align-self: center; max-width: 95%; }

.msg.system .msg-bubble {
  background: var(--flag-bg);
  color: var(--flag);
  border: 1px solid rgba(184, 57, 26, 0.2);
  font-size: 11px;
  font-weight: 500;
  border-radius: 6px;
  font-family: "JetBrains Mono", ui-monospace, SFMono-Regular, monospace;
  padding: 8px 12px;
}

.msg.error .msg-bubble {
  background: var(--flag-bg);
  color: var(--flag);
  border: 1px solid rgba(184, 57, 26, 0.2);
  font-size: 13px;
}

.msg-meta {
  font-size: 10px;
  color: var(--ink-muted);
  padding: 0 4px;
  font-family: "JetBrains Mono", ui-monospace, SFMono-Regular, monospace;
}

.input-bar {
  padding: 14px 18px;
  border-top: 1px solid var(--line);
  background: var(--paper);
}

.input-shell {
  display: flex;
  gap: 10px;
  align-items: flex-end;
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 10px 12px;
}

.input-shell:focus-within { border-color: var(--ink-muted); }

.input-field {
  flex: 1;
  border: none;
  background: transparent;
  font-family: inherit;
  font-size: 16px; /* >= 16px on iOS to suppress zoom-on-focus */
  color: var(--ink);
  resize: none;
  outline: none;
  min-height: 22px;
  max-height: 120px;
  line-height: 1.5;
  padding: 3px 0;
}

.send-btn {
  background: var(--ink);
  color: var(--paper);
  padding: 0 16px;
  height: 32px;
  border-radius: 6px;
  border: none;
  cursor: pointer;
  font-family: inherit;
  font-size: 12px;
  font-weight: 500;
}

.send-btn:hover:not(:disabled) { background: var(--ink-soft); }
.send-btn:disabled { opacity: 0.4; cursor: not-allowed; }

.suggested {
  display: flex;
  gap: 6px;
  padding: 10px 18px 0;
  flex-wrap: wrap;
}

.chip {
  padding: 5px 10px;
  border: 1px solid var(--line);
  background: var(--paper);
  border-radius: 16px;
  font-size: 11px;
  color: var(--ink-muted);
  cursor: pointer;
  font-family: inherit;
}

.chip:hover {
  border-color: var(--ink);
  color: var(--ink);
  background: var(--bg-warm);
}

/* ---------- Context panel ---------- */

.context-panel {
  display: flex;
  flex-direction: column;
  gap: 14px;
  overflow-y: auto;
}

.context-card {
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 18px;
  box-shadow: var(--shadow);
}

.context-card h4 {
  font-family: "Fraunces", Georgia, serif;
  font-size: 15px;
  font-weight: 500;
  margin-bottom: 10px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.context-card h4 .count {
  font-family: "JetBrains Mono", ui-monospace, SFMono-Regular, monospace;
  font-size: 10px;
  font-weight: 400;
  color: var(--ink-muted);
  background: var(--bg-warm);
  padding: 2px 6px;
  border-radius: 3px;
}

.flag-card {
  background: var(--flag-bg);
  border-color: rgba(184, 57, 26, 0.25);
  color: var(--ink);
}

.flag-card h4 { color: var(--flag); }

.flag-list {
  display: flex;
  flex-direction: column;
  gap: 6px;
  font-size: 12px;
}

.flag-item {
  display: flex;
  gap: 8px;
  align-items: flex-start;
}

.flag-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--flag);
  margin-top: 6px;
  flex-shrink: 0;
}

.facts-list { display: flex; flex-direction: column; gap: 6px; font-size: 12px; }

.fact-row {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 10px;
  padding: 4px 0;
}

.fact-row .label {
  color: var(--ink-muted);
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

.fact-row .value {
  font-weight: 500;
  text-align: right;
  font-family: "JetBrains Mono", ui-monospace, SFMono-Regular, monospace;
  font-size: 11px;
  word-break: break-word;
}

.fact-row .value.empty { color: var(--ink-muted); font-style: italic; font-weight: 400; }

/* ---------- Typing indicator ---------- */

.typing {
  display: inline-flex;
  gap: 4px;
  padding: 14px 16px;
  background: var(--bg-warm);
  border-radius: 14px;
  border-bottom-left-radius: 4px;
}

.typing-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--ink-muted);
  animation: typing 1.4s infinite;
}

.typing-dot:nth-child(2) { animation-delay: 0.2s; }
.typing-dot:nth-child(3) { animation-delay: 0.4s; }

@keyframes typing {
  0%, 60%, 100% { opacity: 0.3; transform: translateY(0); }
  30% { opacity: 1; transform: translateY(-4px); }
}

/* ---------- Login / EULA ---------- */

.gate-screen {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  background: var(--ink);
  color: var(--paper);
}

.gate-card {
  max-width: 520px;
  width: 100%;
  background: var(--paper);
  color: var(--ink);
  border-radius: 12px;
  padding: 40px;
  box-shadow: var(--shadow-lg);
}

.gate-card h1 {
  font-family: "Fraunces", Georgia, serif;
  font-size: 32px;
  font-weight: 500;
  margin-bottom: 8px;
  letter-spacing: -0.02em;
}

.gate-card .tag-line {
  color: var(--ink-muted);
  margin-bottom: 28px;
  font-size: 14px;
}

.gate-input {
  width: 100%;
  padding: 12px 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--bg);
  font-family: inherit;
  font-size: 16px;
  margin-bottom: 16px;
  outline: none;
}

.gate-input:focus { border-color: var(--ink); }

.gate-error {
  background: var(--flag-bg);
  color: var(--flag);
  padding: 10px 14px;
  border-radius: 6px;
  font-size: 12px;
  margin-bottom: 16px;
  display: none;
}

.gate-error.visible { display: block; }

.gate-ok {
  background: var(--ok-bg);
  color: var(--ok);
  padding: 12px 16px;
  border-radius: 6px;
  font-size: 13px;
  margin-bottom: 16px;
  display: none;
  line-height: 1.5;
}

.gate-ok.visible { display: block; }

.btn-primary {
  background: var(--ink);
  color: var(--paper);
  padding: 12px 20px;
  height: 44px;
  border-radius: 8px;
  border: none;
  cursor: pointer;
  font-family: inherit;
  font-size: 14px;
  font-weight: 500;
  width: 100%;
}

.btn-primary:hover:not(:disabled) { background: var(--ink-soft); }
.btn-primary:disabled { opacity: 0.5; cursor: not-allowed; }

.eula-scroll {
  max-height: 320px;
  overflow-y: auto;
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--bg);
  margin-bottom: 16px;
  font-size: 13px;
  line-height: 1.55;
}

.eula-scroll h1, .eula-scroll h2 { font-family: "Fraunces", Georgia, serif; font-weight: 500; margin: 12px 0 6px; }
.eula-scroll h1 { font-size: 18px; }
.eula-scroll h2 { font-size: 15px; }
.eula-scroll p, .eula-scroll li { margin: 6px 0; }
.eula-scroll strong { font-weight: 600; }

.eula-accept {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  margin-bottom: 16px;
  font-size: 13px;
}

.eula-accept input { margin-top: 3px; }

/* ---------- Admin dashboard ---------- */

.admin-shell {
  max-width: 1400px;
  margin: 0 auto;
  padding: 28px 32px;
}

.admin-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-end;
  margin-bottom: 24px;
  flex-wrap: wrap;
  gap: 16px;
}

.admin-header h1 {
  font-family: "Fraunces", Georgia, serif;
  font-size: 32px;
  font-weight: 500;
  letter-spacing: -0.02em;
}

.admin-filters {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.admin-filters select, .admin-filters input {
  padding: 8px 10px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--paper);
  font-family: inherit;
  font-size: 13px;
  color: var(--ink);
}

.alerts-table {
  width: 100%;
  border-collapse: collapse;
  background: var(--paper);
  border-radius: 10px;
  overflow: hidden;
  box-shadow: var(--shadow);
}

.alerts-table th,
.alerts-table td {
  text-align: left;
  padding: 12px 14px;
  border-bottom: 1px solid var(--line);
  font-size: 13px;
  vertical-align: top;
}

.alerts-table th {
  background: var(--bg-warm);
  font-weight: 500;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--ink-soft);
}

.alerts-table tr.row-click { cursor: pointer; }
.alerts-table tr.row-click:hover { background: var(--bg); }

.badge {
  display: inline-block;
  padding: 2px 8px;
  font-size: 10px;
  font-weight: 600;
  border-radius: 3px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

.badge.new { background: var(--accent); color: var(--paper); }
.badge.contacted { background: var(--warn); color: var(--paper); }
.badge.signed { background: var(--ok); color: var(--paper); }
.badge.no_contact { background: var(--ink-muted); color: var(--paper); }
.badge.false_positive { background: var(--line); color: var(--ink); }

.alert-detail {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 18px;
  margin-top: 18px;
}

.alert-detail .card {
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 20px;
  box-shadow: var(--shadow);
}

.alert-detail h3 {
  font-family: "Fraunces", Georgia, serif;
  font-size: 17px;
  font-weight: 500;
  margin-bottom: 10px;
}

.alert-actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  margin-top: 12px;
}

.alert-actions button {
  padding: 8px 14px;
  border: 1px solid var(--line);
  background: var(--paper);
  border-radius: 6px;
  cursor: pointer;
  font-family: inherit;
  font-size: 12px;
  font-weight: 500;
}

.alert-actions button.primary {
  background: var(--ok);
  color: var(--paper);
  border-color: var(--ok);
}

.alert-actions button.warn {
  background: var(--warn);
  color: var(--paper);
  border-color: var(--warn);
}

.alert-actions button.danger {
  background: var(--flag);
  color: var(--paper);
  border-color: var(--flag);
}

.transcript-scroll {
  max-height: 480px;
  overflow-y: auto;
  font-size: 13px;
  line-height: 1.55;
}

.transcript-msg {
  margin-bottom: 12px;
  padding: 10px 12px;
  border-radius: 6px;
  background: var(--bg);
}

.transcript-msg.user { background: var(--bg-warm); }

.transcript-role {
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  color: var(--ink-muted);
  margin-bottom: 4px;
}

/* ---------- Mobile ---------- */

@media (max-width: 1100px) {
  .app { grid-template-columns: 1fr; }
  .sidebar { position: relative; min-height: auto; flex-direction: row; flex-wrap: wrap; align-items: center; padding: 16px 20px; gap: 14px; }
  .sidebar .nav-section { flex-direction: row; flex: 1; }
  .sidebar .nav-label { display: none; }
  .sidebar .claim-card { display: none; }
  .chat-shell { grid-template-columns: 1fr; height: auto; min-height: 480px; }
  .context-panel { order: -1; }
  .alert-detail { grid-template-columns: 1fr; }
  .main { padding: 20px; }
}

@media (max-width: 640px) {
  .view-title { font-size: 28px; }
  .gate-card { padding: 28px 24px; }
  .messages { padding: 16px; }
  .input-bar { padding: 12px 14px; }
  .main { padding: 16px; }
  .admin-shell { padding: 18px 16px; }
  .alerts-table th, .alerts-table td { padding: 10px 8px; font-size: 12px; }
}
