/* ═══════════════════════════════════════════════════════════
   Kairos Helm — portal / admin / auth shared styles
   Palette: warm off-white, ink-black, rust accent
   ═══════════════════════════════════════════════════════════ */

:root {
  --bg: #F5F1EA;
  --surface: #FFFFFF;
  --ink: #151822;
  --ink-soft: #2A2D38;
  --muted: #6C6A65;
  --dim: #9A978F;
  --line: #EDE6D8;
  --line-strong: #D9D1BF;
  --accent: #C8501F;
  --accent-soft: rgba(200, 80, 31, 0.08);
  --accent-hover: #A53F15;
  --success: #2E7D4A;
  --warn: #B87514;
  --error: #B33A1A;
  --radius: 10px;
  --radius-lg: 14px;
  --shadow: 0 1px 2px rgba(20,24,35,0.04), 0 4px 16px rgba(20,24,35,0.06);
}

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

html { -webkit-text-size-adjust: 100%; }
body {
  font-family: 'Manrope', -apple-system, BlinkMacSystemFont, 'Segoe UI', Helvetica, Arial, sans-serif;
  background: var(--bg);
  color: var(--ink);
  line-height: 1.6;
  font-size: 15px;
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
}

a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }

code { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 0.92em; background: rgba(0,0,0,0.04); padding: 1px 5px; border-radius: 4px; }

/* ─── BRAND ─── */
.brand {
  display: inline-flex; align-items: center; gap: 10px;
  font-weight: 800; letter-spacing: 0.1em; text-transform: uppercase;
  color: var(--ink); text-decoration: none; font-size: 15px;
}
.brand em { font-style: normal; color: var(--accent); }
.brand-lg { font-size: 17px; }
.brand-mark {
  width: 28px; height: 28px; border-radius: 50%;
  background: radial-gradient(circle at 30% 30%, var(--accent) 0%, var(--accent-hover) 70%);
  position: relative; flex-shrink: 0;
}
.brand-mark::before, .brand-mark::after {
  content: ''; position: absolute; inset: 0; border-radius: 50%;
}
.brand-mark::before {
  border: 2px solid rgba(255,255,255,0.7);
  inset: 6px;
}
.brand-mark::after {
  width: 4px; height: 4px; top: 50%; left: 50%;
  transform: translate(-50%,-50%);
  background: #fff; border-radius: 50%;
}

/* ─── APP SHELL ─── */
.app-nav {
  position: sticky; top: 0; z-index: 10;
  background: rgba(245,241,234,0.92); backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--line);
  padding: 14px 28px;
  display: flex; align-items: center; justify-content: space-between;
  gap: 20px;
}
.app-nav-links { display: flex; gap: 22px; }
.app-nav-links a {
  color: var(--ink-soft); font-weight: 600; font-size: 14px;
  padding: 6px 0; border-bottom: 2px solid transparent;
}
.app-nav-links a:hover { color: var(--accent); text-decoration: none; }
.app-nav-links a.active { color: var(--ink); border-bottom-color: var(--accent); }
.app-nav-user { display: flex; align-items: center; gap: 14px; font-size: 13px; }

.app-main {
  max-width: 1100px; margin: 0 auto; padding: 36px 28px 80px;
}
.app-footer {
  max-width: 1100px; margin: 0 auto; padding: 24px 28px;
  display: flex; justify-content: space-between; gap: 16px;
  color: var(--dim); font-size: 12px;
  border-top: 1px solid var(--line);
}

.back-link {
  display: inline-block; margin-bottom: 16px;
  color: var(--muted); font-size: 13px; font-weight: 500;
}

.page-hd { margin-bottom: 28px; }
.page-hd h1 { font-size: 28px; font-weight: 800; letter-spacing: -0.01em; line-height: 1.2; margin: 6px 0; }
.page-hd p { color: var(--muted); font-size: 14px; max-width: 62ch; }

.eyebrow {
  display: inline-block; font-size: 11px; letter-spacing: 0.16em;
  text-transform: uppercase; color: var(--accent); font-weight: 700;
}

.meta-row { display: flex; gap: 14px; flex-wrap: wrap; align-items: center; margin-top: 10px; }
.sub-hd { font-size: 14px; font-weight: 700; color: var(--ink); margin-bottom: 10px; }

/* ─── CARDS / PANELS ─── */
.panel {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  padding: 24px;
  margin-bottom: 20px;
  box-shadow: var(--shadow);
}
.panel-hd {
  display: flex; justify-content: space-between; align-items: center;
  margin-bottom: 16px; gap: 12px;
}
.panel-hd h2 { font-size: 16px; font-weight: 700; }

/* ─── STATS ─── */
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; }
.grid-3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 20px; }
.grid-4 { display: grid; grid-template-columns: repeat(4, 1fr); gap: 16px; }
@media (max-width: 780px) {
  .grid-2, .grid-3, .grid-4 { grid-template-columns: 1fr; }
}

.stat-row { margin-bottom: 24px; }
.stat {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  padding: 18px 20px;
  display: flex; flex-direction: column; gap: 4px;
}
.stat-label { font-size: 12px; color: var(--muted); text-transform: uppercase; letter-spacing: 0.08em; font-weight: 600; }
.stat-value { font-size: 28px; font-weight: 800; color: var(--ink); }

/* ─── LIST ROWS ─── */
.list { list-style: none; }
.list-row {
  display: flex; justify-content: space-between; align-items: center; gap: 16px;
  padding: 14px 0; border-bottom: 1px solid var(--line);
}
.list-row:last-child { border-bottom: none; }
.link-strong { font-weight: 700; color: var(--ink); }
.link-strong:hover { color: var(--accent); text-decoration: underline; }
.link-sm { font-size: 13px; font-weight: 600; }
.link-danger { color: var(--error); background: none; border: none; cursor: pointer; font-weight: 600; font-size: 13px; padding: 0; }

.data-table { width: 100%; border-collapse: collapse; font-size: 14px; }
.data-table th, .data-table td {
  text-align: left; padding: 10px 12px; border-bottom: 1px solid var(--line);
  vertical-align: top;
}
.data-table th { font-size: 11px; text-transform: uppercase; letter-spacing: 0.08em; color: var(--muted); font-weight: 700; }

/* ─── BADGES ─── */
.badge {
  display: inline-flex; align-items: center;
  font-size: 11px; font-weight: 700;
  text-transform: uppercase; letter-spacing: 0.06em;
  padding: 3px 9px; border-radius: 999px;
  background: var(--line); color: var(--ink-soft);
}
.badge-active, .badge-complete, .badge-paid { background: rgba(46,125,74,0.12); color: var(--success); }
.badge-in_progress, .badge-sent, .badge-contacted { background: rgba(184,117,20,0.15); color: var(--warn); }
.badge-draft, .badge-pending, .badge-new { background: rgba(108,106,101,0.15); color: var(--ink-soft); }
.badge-on_hold, .badge-archived { background: rgba(179,58,26,0.12); color: var(--error); }
.badge-void, .badge-past_due, .badge-canceled, .badge-refunded { background: rgba(179,58,26,0.12); color: var(--error); }
.badge-converted, .badge-qualified { background: rgba(200,80,31,0.12); color: var(--accent); }

/* ─── FORMS ─── */
.form { display: flex; flex-direction: column; gap: 14px; }
.form .field { display: flex; flex-direction: column; gap: 6px; }
.form .field > span {
  font-size: 12px; font-weight: 700; color: var(--muted);
  text-transform: uppercase; letter-spacing: 0.05em;
}
.form input, .form select, .form textarea {
  font-family: inherit; font-size: 15px;
  background: #fff; color: var(--ink);
  border: 1px solid var(--line-strong); border-radius: 8px;
  padding: 10px 12px; outline: none;
  transition: border-color 0.15s, box-shadow 0.15s;
  width: 100%;
}
.form textarea { resize: vertical; min-height: 80px; }
.form input:focus, .form select:focus, .form textarea:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(200,80,31,0.15);
}
.inline-form { display: inline-flex; }
.inline-form select {
  font-size: 12px; padding: 4px 8px; border-radius: 6px;
  border: 1px solid var(--line-strong); background: #fff;
}

.fieldset { border: none; padding: 0; margin: 0 0 22px; }
.fieldset legend {
  font-size: 12px; font-weight: 800; color: var(--accent);
  text-transform: uppercase; letter-spacing: 0.12em; margin-bottom: 14px;
  display: block; border-bottom: 1px solid var(--line); padding-bottom: 8px; width: 100%;
}

/* ─── BUTTONS ─── */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  font-family: inherit; font-weight: 700;
  padding: 10px 18px; border-radius: 8px;
  border: 1px solid transparent; cursor: pointer;
  font-size: 14px; line-height: 1.2;
  transition: all 0.15s; text-decoration: none;
}
.btn:hover { text-decoration: none; }
.btn-primary {
  background: var(--accent); color: #fff;
}
.btn-primary:hover { background: var(--accent-hover); }
.btn-ghost {
  background: transparent; color: var(--ink-soft); border-color: var(--line-strong);
}
.btn-ghost:hover { border-color: var(--accent); color: var(--accent); }
.btn-sm { padding: 6px 12px; font-size: 13px; }
.btn-lg { padding: 14px 24px; font-size: 15px; }
.btn-block { width: 100%; }

/* ─── FLASH ─── */
.flash {
  padding: 12px 16px; border-radius: 8px; font-size: 14px;
  margin-bottom: 14px;
}
.flash-success { background: rgba(46,125,74,0.1); color: var(--success); border: 1px solid rgba(46,125,74,0.2); }
.flash-error { background: rgba(179,58,26,0.1); color: var(--error); border: 1px solid rgba(179,58,26,0.2); }
.flash-warn { background: rgba(184,117,20,0.1); color: var(--warn); border: 1px solid rgba(184,117,20,0.2); }
.flash-info { background: var(--accent-soft); color: var(--accent); border: 1px solid rgba(200,80,31,0.2); }

/* ─── AUTH / INTAKE SHELL ─── */
.auth-page { background: var(--bg); }
.auth-shell {
  max-width: 440px; margin: 60px auto; padding: 0 24px;
  display: flex; flex-direction: column; align-items: center; gap: 28px;
}
.intake-shell {
  max-width: 720px; margin: 60px auto; padding: 0 24px;
  display: flex; flex-direction: column; align-items: center; gap: 28px;
}
.card {
  width: 100%;
  background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--radius-lg); padding: 32px;
  box-shadow: var(--shadow);
}
.card h1 { font-size: 22px; font-weight: 800; margin-bottom: 6px; }
.card p { font-size: 14px; }
.intake-hd { margin-bottom: 24px; border-bottom: 1px solid var(--line); padding-bottom: 16px; }
.intake-hd h1 { font-size: 26px; margin: 8px 0 4px; }
.intake-submit { display: flex; align-items: center; gap: 18px; margin-top: 8px; }

/* ─── TIMELINE (milestones) ─── */
.timeline { list-style: none; margin-left: 8px; }
.timeline-item {
  display: grid; grid-template-columns: 24px 1fr; gap: 14px;
  padding: 14px 0; border-left: 2px solid var(--line); padding-left: 18px; margin-left: 4px;
  position: relative;
}
.t-dot {
  width: 12px; height: 12px; border-radius: 50%;
  background: var(--surface); border: 2px solid var(--line-strong);
  position: absolute; left: -7px; top: 18px;
}
.timeline-item.t-in_progress .t-dot { border-color: var(--warn); background: rgba(184,117,20,0.2); }
.timeline-item.t-complete .t-dot { border-color: var(--success); background: var(--success); }
.t-body { grid-column: 2; }
.t-row { display: flex; justify-content: space-between; align-items: center; gap: 10px; }

/* ─── MESSAGES ─── */
.messages { list-style: none; display: flex; flex-direction: column; gap: 12px; }
.messages-preview .msg { max-width: 100%; }
.msg {
  background: #fff; border: 1px solid var(--line); border-radius: 12px;
  padding: 14px 16px; max-width: 86%;
}
.msg.msg-admin { background: var(--accent-soft); border-color: rgba(200,80,31,0.18); }
.msg.msg-client { align-self: flex-end; background: #fff; }
.msg-meta { display: flex; justify-content: space-between; align-items: baseline; margin-bottom: 4px; }
.msg-meta strong { font-size: 13px; }
.msg p { white-space: pre-wrap; font-size: 14px; color: var(--ink); }

/* ─── KEY-VALUE ─── */
.kv { display: grid; grid-template-columns: 140px 1fr; gap: 8px 16px; font-size: 14px; }
.kv dt { color: var(--muted); font-size: 12px; text-transform: uppercase; letter-spacing: 0.06em; font-weight: 700; padding-top: 3px; }
.kv dd { color: var(--ink); }

.muted { color: var(--muted); }
.small { font-size: 13px; }
.xs { font-size: 12px; }
.wrap { white-space: pre-wrap; }

/* ─── RESPONSIVE ─── */
@media (max-width: 640px) {
  .app-nav { flex-direction: column; align-items: stretch; gap: 10px; padding: 12px 18px; }
  .app-nav-links { overflow-x: auto; flex-wrap: nowrap; }
  .app-main { padding: 24px 18px 60px; }
  .card { padding: 22px; }
}
