/* ============================================================
   Cold Mail Ops — Design tokens
   Palette: deep ink (#14181F) / paper (#F7F6F3) / signal amber (#E8964D)
            / wire green (#3F8F6F) / alert red (#C0503E) / steel (#6B7280)
   Type: "Fraunces" (display, used sparingly) + "Inter" (body/UI) + "JetBrains Mono" (data/numbers)
   Signature: status is shown as a colored "wire" — a 2px left-border accent
   on every card/row that encodes state at a glance, like a patch panel.
   ============================================================ */

@import url('https://fonts.googleapis.com/css2?family=Fraunces:opsz,wght@9..144,500;9..144,600&family=Inter:wght@400;500;600;700&family=JetBrains+Mono:wght@400;500&display=swap');

:root {
  --ink: #14181F;
  --ink-soft: #2A2F3A;
  --paper: #F7F6F3;
  --paper-raised: #FFFFFF;
  --line: #E4E1D9;
  --steel: #6B7280;
  --steel-light: #9CA3AF;

  --amber: #E8964D;
  --amber-soft: #FBE8D4;
  --green: #3F8F6F;
  --green-soft: #DEEFE7;
  --red: #C0503E;
  --red-soft: #F6E0DC;
  --blue: #3F6FA8;
  --blue-soft: #DCE6F0;

  --radius: 6px;
  --shadow-card: 0 1px 2px rgba(20,24,31,0.06), 0 1px 1px rgba(20,24,31,0.04);

  font-size: 15px;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--paper);
  color: var(--ink);
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
  line-height: 1.5;
}

h1, h2, h3 {
  font-family: 'Fraunces', Georgia, serif;
  font-weight: 600;
  letter-spacing: -0.01em;
  margin: 0 0 0.4em 0;
  color: var(--ink);
}

h1 { font-size: 1.65rem; }
h2 { font-size: 1.3rem; }
h3 { font-size: 1.05rem; }

a { color: var(--ink); text-decoration: none; }
a.link { color: var(--blue); text-decoration: underline; text-decoration-color: rgba(63,111,168,0.3); }
a.link:hover { text-decoration-color: var(--blue); }

.mono { font-family: 'JetBrains Mono', monospace; font-size: 0.9em; }

/* ---------- Layout ---------- */
.app-shell { display: flex; min-height: 100vh; }

.sidebar {
  width: 220px;
  background: var(--ink);
  color: #D8D5CC;
  padding: 24px 16px;
  flex-shrink: 0;
  display: flex;
  flex-direction: column;
}

.sidebar .brand {
  font-family: 'Fraunces', serif;
  font-size: 1.15rem;
  font-weight: 600;
  color: #fff;
  margin-bottom: 28px;
  display: flex;
  align-items: baseline;
  gap: 6px;
}
.sidebar .brand .dot { color: var(--amber); font-size: 1.4em; line-height: 0; }

.sidebar nav { display: flex; flex-direction: column; gap: 2px; flex: 1; }
.sidebar nav a {
  color: #B8B5AC;
  padding: 9px 12px;
  border-radius: var(--radius);
  font-size: 0.92rem;
  font-weight: 500;
  transition: background 0.12s, color 0.12s;
}
.sidebar nav a:hover { background: rgba(255,255,255,0.06); color: #fff; }
.sidebar nav a.active { background: rgba(232,150,77,0.16); color: var(--amber); }

.sidebar .user-block {
  border-top: 1px solid rgba(255,255,255,0.1);
  padding-top: 14px;
  margin-top: 14px;
  font-size: 0.85rem;
}
.sidebar .user-block .uname { color: #fff; font-weight: 500; }
.sidebar .user-block .urole { color: var(--steel-light); text-transform: uppercase; font-size: 0.7rem; letter-spacing: 0.05em; }
.sidebar .user-block a { display: block; margin-top: 8px; color: var(--steel-light); font-size: 0.82rem; }
.sidebar .user-block a:hover { color: #fff; }

.main {
  flex: 1;
  padding: 32px 40px;
  max-width: 1180px;
}

.topbar { display: flex; justify-content: space-between; align-items: flex-start; margin-bottom: 28px; }
.topbar .subtitle { color: var(--steel); font-size: 0.95rem; margin-top: 2px; }

/* ---------- Cards & wire-accent (signature element) ---------- */
.card {
  background: var(--paper-raised);
  border: 1px solid var(--line);
  border-left: 3px solid var(--line);
  border-radius: var(--radius);
  padding: 18px 20px;
  box-shadow: var(--shadow-card);
  margin-bottom: 16px;
}
.card.wire-green { border-left-color: var(--green); }
.card.wire-amber { border-left-color: var(--amber); }
.card.wire-red { border-left-color: var(--red); }
.card.wire-blue { border-left-color: var(--blue); }
.card.wire-steel { border-left-color: var(--steel-light); }

.card-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 14px; }

.stat-card .stat-value { font-family: 'JetBrains Mono', monospace; font-size: 1.9rem; font-weight: 500; line-height: 1; }
.stat-card .stat-label { color: var(--steel); font-size: 0.82rem; text-transform: uppercase; letter-spacing: 0.04em; margin-top: 6px; }

/* ---------- Tables ---------- */
table { width: 100%; border-collapse: collapse; font-size: 0.9rem; }
th { text-align: left; color: var(--steel); font-weight: 600; font-size: 0.78rem; text-transform: uppercase; letter-spacing: 0.04em; padding: 8px 12px; border-bottom: 1px solid var(--line); }
td { padding: 10px 12px; border-bottom: 1px solid var(--line); vertical-align: middle; }
tr:last-child td { border-bottom: none; }
tr:hover td { background: rgba(20,24,31,0.015); }

/* ---------- Badges (status pills) ---------- */
.badge {
  display: inline-flex; align-items: center; gap: 5px;
  padding: 3px 9px; border-radius: 100px;
  font-size: 0.76rem; font-weight: 600; text-transform: uppercase; letter-spacing: 0.03em;
}
.badge::before { content: ''; width: 6px; height: 6px; border-radius: 50%; }
.badge-green { background: var(--green-soft); color: #2A6B50; } .badge-green::before { background: var(--green); }
.badge-amber { background: var(--amber-soft); color: #9C5E1F; } .badge-amber::before { background: var(--amber); }
.badge-red { background: var(--red-soft); color: #8E3527; } .badge-red::before { background: var(--red); }
.badge-blue { background: var(--blue-soft); color: #2A4E76; } .badge-blue::before { background: var(--blue); }
.badge-steel { background: #ECEAE4; color: var(--steel); } .badge-steel::before { background: var(--steel-light); }

/* ---------- Forms ---------- */
label { display: block; font-size: 0.85rem; font-weight: 600; margin-bottom: 5px; color: var(--ink-soft); }
.field { margin-bottom: 18px; }
.field-hint { font-size: 0.8rem; color: var(--steel); margin-top: 4px; }
.field-row { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }

input[type=text], input[type=email], input[type=password], input[type=number], select, textarea {
  width: 100%;
  padding: 9px 11px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  font-size: 0.92rem;
  font-family: inherit;
  background: var(--paper-raised);
  color: var(--ink);
  transition: border-color 0.12s, box-shadow 0.12s;
}
input:focus, select:focus, textarea:focus {
  outline: none;
  border-color: var(--blue);
  box-shadow: 0 0 0 3px rgba(63,111,168,0.12);
}
textarea { resize: vertical; min-height: 90px; }
textarea.code { font-family: 'JetBrains Mono', monospace; font-size: 0.85rem; min-height: 220px; }

.checkbox-row { display: flex; align-items: center; gap: 8px; }
.checkbox-row input[type=checkbox] { width: 16px; height: 16px; }
.checkbox-row label { margin: 0; font-weight: 500; }

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 9px 16px;
  border-radius: var(--radius);
  font-size: 0.88rem; font-weight: 600;
  border: 1px solid transparent;
  cursor: pointer;
  transition: opacity 0.12s, background 0.12s;
  text-decoration: none;
}
.btn-primary { background: var(--ink); color: #fff; }
.btn-primary:hover { background: var(--ink-soft); }
.btn-amber { background: var(--amber); color: #fff; }
.btn-amber:hover { opacity: 0.88; }
.btn-outline { background: transparent; border-color: var(--line); color: var(--ink); }
.btn-outline:hover { background: rgba(20,24,31,0.04); }
.btn-danger { background: transparent; border-color: var(--red); color: var(--red); }
.btn-danger:hover { background: var(--red-soft); }
.btn-sm { padding: 5px 11px; font-size: 0.8rem; }
.btn[disabled] { opacity: 0.45; cursor: not-allowed; }

.btn-row { display: flex; gap: 10px; margin-top: 22px; }

/* ---------- Flash messages ---------- */
.flash { padding: 11px 16px; border-radius: var(--radius); margin-bottom: 16px; font-size: 0.9rem; border-left: 3px solid; }
.flash-success { background: var(--green-soft); border-color: var(--green); color: #2A6B50; }
.flash-danger { background: var(--red-soft); border-color: var(--red); color: #8E3527; }
.flash-warning { background: var(--amber-soft); border-color: var(--amber); color: #9C5E1F; }

/* ---------- Misc ---------- */
.empty-state { text-align: center; padding: 48px 20px; color: var(--steel); }
.empty-state h3 { color: var(--ink-soft); margin-bottom: 6px; }
.section-divider { border: none; border-top: 1px solid var(--line); margin: 28px 0; }
.muted { color: var(--steel); }
.progress-bar-track { background: var(--line); border-radius: 100px; height: 8px; overflow: hidden; }
.progress-bar-fill { background: var(--amber); height: 100%; border-radius: 100px; }

/* ---------- Rich text editor ---------- */
.editor-toolbar {
  display: flex; gap: 4px; padding: 6px;
  border: 1px solid var(--line); border-bottom: none;
  border-radius: var(--radius) var(--radius) 0 0;
  background: #F0EEE8; flex-wrap: wrap;
}
.editor-toolbar button {
  background: transparent; border: 1px solid transparent; border-radius: 4px;
  width: 30px; height: 30px; font-size: 0.88rem; font-weight: 600; cursor: pointer;
  color: var(--ink-soft); display: flex; align-items: center; justify-content: center;
}
.editor-toolbar button:hover { background: rgba(20,24,31,0.07); border-color: var(--line); }
.editor-toolbar button.active { background: rgba(232,150,77,0.18); color: var(--amber); }
.editor-toolbar .divider { width: 1px; background: var(--line); margin: 4px 3px; }
.editor-toolbar .mode-toggle { margin-left: auto; }
.editor-toolbar .mode-toggle button { width: auto; padding: 0 10px; font-size: 0.78rem; font-weight: 600; text-transform: uppercase; letter-spacing: 0.03em; }

.editor-surface {
  border: 1px solid var(--line); border-radius: 0 0 var(--radius) var(--radius);
  min-height: 220px; max-height: 420px; overflow-y: auto;
  padding: 14px 16px; font-size: 0.92rem; line-height: 1.6;
  background: var(--paper-raised);
}
.editor-surface:focus { outline: none; border-color: var(--blue); box-shadow: 0 0 0 3px rgba(63,111,168,0.12); }
.editor-surface a { color: var(--blue); text-decoration: underline; }
.editor-surface p { margin: 0 0 0.8em 0; }

.editor-source {
  border: 1px solid var(--line); border-radius: 0 0 var(--radius) var(--radius);
  min-height: 220px; max-height: 420px;
  font-family: 'JetBrains Mono', monospace; font-size: 0.84rem;
  padding: 14px 16px; width: 100%; resize: vertical;
}

.followup-row { border: 1px solid var(--line); border-radius: var(--radius); padding: 14px; margin-bottom: 10px; background: rgba(20,24,31,0.015); }
.followup-row .followup-num { font-family: 'JetBrains Mono', monospace; font-weight: 600; color: var(--amber); }

.preview-pane { border: 1px solid var(--line); border-radius: var(--radius); padding: 18px; background: #fff; max-height: 420px; overflow-y: auto; }
.preview-pane .preview-subject { font-weight: 600; padding-bottom: 10px; margin-bottom: 12px; border-bottom: 1px solid var(--line); }

@media (max-width: 860px) {
  .app-shell { flex-direction: column; }
  .sidebar { width: 100%; flex-direction: row; align-items: center; padding: 14px 18px; }
  .sidebar nav { flex-direction: row; flex-wrap: wrap; }
  .sidebar .user-block { display: none; }
  .main { padding: 20px; }
  .field-row { grid-template-columns: 1fr; }
}
