/* LOOP Design System
 * Imported by every wireframe HTML file in this directory.
 * Tokens, typography, and shared components.
 * Source of truth: PRODUCT_DESIGN.md and CLAUDE.md
 */

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

/* ============================================================
   COLOR + GEOMETRY TOKENS
   ============================================================ */
:root {
  /* Surfaces */
  --bg: #FAFAF7;
  --surface: #FFFFFF;
  --surface-2: #F4F2EC;

  /* Ink */
  --ink: #0F0F0E;
  --ink-2: #26241F;
  --muted: #6E6B66;
  --muted-2: #A09C94;

  /* Borders */
  --border: #E8E5DD;
  --border-strong: #D4D0C5;

  /* Forest green accent */
  --accent: #1F3D2C;
  --accent-ink: #FAFAF7;
  --accent-soft: #E8EFE9;

  /* Status / confidence tiers */
  --tier-green: #2D7A4A;
  --tier-amber: #B8810D;
  --tier-gray: #9A958C;
  --tier-red: #B33A3A;
  --tier-purple: #6B5BB8;

  /* Functional */
  --good: #2D7A4A;
  --warn: #B8810D;
  --error: #B33A3A;

  /* Document viewer special surfaces */
  --doc-tab-bar: #2A2824;
  --doc-viewport: #B8B4AC;
  --doc-paper: #FCFAF4;

  /* Geometry */
  --radius: 14px;
  --radius-sm: 8px;

  /* Shadow scale */
  --shadow-sm: 0 1px 2px rgba(15,15,14,0.05);
  --shadow-md: 0 4px 12px rgba(15,15,14,0.08);
  --shadow-lg: 0 12px 32px rgba(15,15,14,0.14);
  --shadow-paper: 0 1px 2px rgba(15,15,14,0.06), 0 6px 18px rgba(15,15,14,0.08);
}

/* ============================================================
   RESET + BASE
   ============================================================ */
*, *::before, *::after { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font-family: 'DM Sans', system-ui, -apple-system, sans-serif;
  font-size: 14px;
  line-height: 1.5;
  color: var(--ink);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}
button { font: inherit; cursor: pointer; border: 0; background: none; padding: 0; color: inherit; }
a { color: inherit; text-decoration: none; }
input, textarea, select { font: inherit; color: inherit; }

/* Typography helpers */
.font-display { font-family: 'Fraunces', Georgia, serif; font-optical-sizing: auto; letter-spacing: -0.01em; }
.font-mono { font-family: 'DM Mono', ui-monospace, monospace; }
.font-ui { font-family: 'DM Sans', system-ui, sans-serif; }

/* ============================================================
   APP SHELL  (224px sidebar + 1040px main = 1264px min)
   ============================================================ */
.app {
  display: grid;
  grid-template-columns: 224px 1fr;
  min-height: 100vh;
  min-width: 1264px;
}

/* ============================================================
   SIDEBAR
   ============================================================ */
.sidebar {
  background: var(--accent);
  color: var(--accent-ink);
  display: flex;
  flex-direction: column;
  padding: 18px 14px 14px;
  position: sticky;
  top: 0;
  height: 100vh;
}
.sidebar__brand {
  font-family: 'Fraunces', Georgia, serif;
  font-size: 28px;
  font-weight: 600;
  letter-spacing: -0.02em;
  padding: 4px 6px 22px;
  display: flex;
  align-items: center;
  gap: 10px;
}
.sidebar__brand-mark {
  width: 28px; height: 28px;
  border-radius: 7px;
  background: var(--accent-ink);
  flex-shrink: 0;
  display: grid;
  place-items: center;
}
.sidebar__brand-mark::after {
  content: '';
  width: 22px; height: 22px;
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 100 100' fill='none'><circle cx='50' cy='50' r='32' stroke='%231F3D2C' stroke-width='6'/><circle cx='50' cy='50' r='13' stroke='%231F3D2C' stroke-width='4'/></svg>");
  background-size: contain;
  background-repeat: no-repeat;
  background-position: center;
}
.sidebar__nav {
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.sidebar__nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 10px;
  border-radius: 8px;
  font-size: 13.5px;
  color: rgba(250, 250, 247, 0.75);
  cursor: pointer;
  transition: background 0.12s ease;
}
.sidebar__nav-item:hover { background: rgba(255,255,255,0.06); color: var(--accent-ink); }
.sidebar__nav-item.is-active {
  background: rgba(255,255,255,0.10);
  color: var(--accent-ink);
  font-weight: 500;
}
.sidebar__nav-item.is-disabled {
  color: rgba(250, 250, 247, 0.30);
  cursor: not-allowed;
}
.sidebar__nav-item.is-disabled:hover { background: transparent; color: rgba(250, 250, 247, 0.30); }
.sidebar__nav-icon {
  width: 16px; height: 16px;
  opacity: 0.85;
  flex-shrink: 0;
}
.sidebar__group-label {
  font-size: 10.5px;
  font-family: 'DM Mono', monospace;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: rgba(250, 250, 247, 0.40);
  padding: 22px 10px 8px;
}
.sidebar__sub-item {
  padding-left: 32px;
  font-size: 13px;
}
.sidebar__spacer { flex: 1 1 auto; }
.sidebar__sparkline {
  margin: 14px 6px;
  padding: 12px 10px;
  background: rgba(255,255,255,0.04);
  border-radius: 10px;
  font-family: 'DM Mono', monospace;
}
.sidebar__sparkline-label {
  font-size: 9.5px;
  letter-spacing: 0.1em;
  color: rgba(250, 250, 247, 0.50);
  text-transform: uppercase;
}
.sidebar__sparkline-row {
  display: flex; align-items: end; justify-content: space-between;
  margin-top: 6px; gap: 6px;
}
.sidebar__sparkline-num {
  font-size: 14px;
  color: var(--accent-ink);
  font-weight: 500;
}
.sidebar__sparkline-bars {
  display: flex; align-items: end; gap: 2px; flex: 1;
  height: 22px;
}
.sidebar__sparkline-bars span {
  flex: 1;
  background: rgba(45, 122, 74, 0.6);
  border-radius: 1px;
  min-height: 3px;
}
.sidebar__user {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px;
  border-top: 1px solid rgba(255,255,255,0.10);
  margin-top: 8px;
}
.sidebar__avatar {
  width: 30px; height: 30px;
  border-radius: 999px;
  background: rgba(255,255,255,0.18);
  display: flex; align-items: center; justify-content: center;
  font-size: 12px; font-weight: 500;
  color: var(--accent-ink);
}
.sidebar__user-meta { line-height: 1.25; min-width: 0; }
.sidebar__user-name { font-size: 13px; color: var(--accent-ink); }
.sidebar__user-role { font-size: 11px; color: rgba(250, 250, 247, 0.55); }

/* ============================================================
   MAIN PANEL (everything to the right of the sidebar)
   ============================================================ */
.main {
  display: flex;
  flex-direction: column;
  background: var(--bg);
  min-width: 1040px;
}

/* ============================================================
   TOPBAR
   ============================================================ */
.topbar {
  height: 54px;
  display: flex;
  align-items: center;
  padding: 0 22px;
  background: var(--bg);
  border-bottom: 1px solid var(--border);
  gap: 14px;
  flex-shrink: 0;
}
.topbar__breadcrumb {
  font-family: 'Fraunces', Georgia, serif;
  font-size: 16px;
  display: flex;
  align-items: center;
  gap: 8px;
}
.topbar__breadcrumb-link { color: var(--muted); cursor: pointer; }
.topbar__breadcrumb-link:hover { color: var(--ink); }
.topbar__breadcrumb-sep { color: var(--muted-2); }
.topbar__breadcrumb-current { color: var(--ink); }

/* ============================================================
   COMMON COMPONENTS — buttons
   ============================================================ */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 7px 14px;
  font-size: 13px;
  font-weight: 500;
  border-radius: 8px;
  border: 1px solid transparent;
  cursor: pointer;
  transition: background 0.12s ease, border-color 0.12s ease, color 0.12s ease;
  white-space: nowrap;
}
.btn--primary { background: var(--accent); color: var(--accent-ink); }
.btn--primary:hover { background: #2a4d3a; }
.btn--primary:disabled { background: var(--surface-2); color: var(--muted-2); cursor: not-allowed; border-color: var(--border); }
.btn--ghost { background: var(--surface); color: var(--ink-2); border-color: var(--border-strong); }
.btn--ghost:hover { border-color: var(--ink); background: var(--surface-2); }
.btn--accent-outline { background: var(--surface); color: var(--accent); border-color: var(--accent); }
.btn--accent-outline:hover { background: var(--accent-soft); }
.btn--amber-outline { background: var(--surface); color: var(--tier-amber); border-color: var(--tier-amber); }
.btn--amber-outline:hover { background: rgba(184, 129, 13, 0.08); }
.btn--text { background: transparent; color: var(--muted); padding: 6px 8px; }
.btn--text:hover { color: var(--ink); }
.btn--sm { padding: 4px 10px; font-size: 12px; }

/* ============================================================
   COMMON COMPONENTS — pills, badges, dots
   ============================================================ */
.pill {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 3px 9px;
  font-size: 11.5px;
  font-weight: 500;
  border-radius: 999px;
  background: var(--surface-2);
  color: var(--ink-2);
  white-space: nowrap;
  border: 1px solid var(--border);
}
.pill--debt { background: var(--accent-soft); color: var(--tier-green); border-color: rgba(45, 122, 74, 0.25); }
.pill--equity { background: rgba(184, 129, 13, 0.12); color: var(--tier-amber); border-color: rgba(184, 129, 13, 0.28); }
.pill--amber { background: rgba(184, 129, 13, 0.12); color: var(--tier-amber); border-color: rgba(184, 129, 13, 0.28); }
.pill--green { background: var(--accent-soft); color: var(--tier-green); border-color: rgba(45, 122, 74, 0.25); }
.pill--gray { background: var(--surface-2); color: var(--muted); border-color: var(--border); }
.pill--red { background: rgba(179, 58, 58, 0.10); color: var(--tier-red); border-color: rgba(179, 58, 58, 0.28); }
.pill--purple { background: rgba(107, 91, 184, 0.12); color: var(--tier-purple); border-color: rgba(107, 91, 184, 0.28); }
.pill--clickable { cursor: pointer; }
.pill--clickable:hover { filter: brightness(0.97); }

.badge {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 4px 10px;
  font-size: 12px;
  font-weight: 500;
  border-radius: 999px;
}
.badge--new { background: var(--surface-2); color: var(--muted); border: 1px solid var(--border); }
.badge--extracting { background: rgba(107, 91, 184, 0.12); color: var(--tier-purple); border: 1px solid rgba(107, 91, 184, 0.28); }
.badge--in-review { background: rgba(184, 129, 13, 0.12); color: var(--tier-amber); border: 1px solid rgba(184, 129, 13, 0.28); }
.badge--complete { background: var(--accent-soft); color: var(--tier-green); border: 1px solid rgba(45, 122, 74, 0.25); }
.badge--error { background: rgba(179, 58, 58, 0.10); color: var(--tier-red); border: 1px solid rgba(179, 58, 58, 0.28); }
.badge--upload { background: rgba(45, 122, 74, 0.10); color: var(--tier-green); border: 1px solid rgba(45, 122, 74, 0.20); }

/* Pulsing dot for "Extracting" status */
.dot {
  display: inline-block;
  width: 6px; height: 6px;
  border-radius: 999px;
  background: currentColor;
  flex-shrink: 0;
}
.dot--pulse { animation: dot-pulse 1.2s ease-in-out infinite; }
@keyframes dot-pulse {
  0%, 100% { opacity: 0.4; }
  50% { opacity: 1; }
}

.confidence-dot {
  width: 8px; height: 8px;
  border-radius: 999px;
  flex-shrink: 0;
  display: inline-block;
}
.confidence-dot--green { background: var(--tier-green); }
.confidence-dot--amber { background: var(--tier-amber); }
.confidence-dot--red { background: var(--tier-red); }
.confidence-dot--gray { background: var(--tier-gray); }

/* ============================================================
   COMMON COMPONENTS — inputs
   ============================================================ */
.input {
  width: 100%;
  padding: 9px 12px;
  font-size: 13px;
  border: 1px solid var(--border-strong);
  border-radius: 8px;
  background: var(--surface);
  color: var(--ink);
  transition: border-color 0.12s ease;
}
.input:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px rgba(31, 61, 44, 0.10); }
.input--mono { font-family: 'DM Mono', monospace; }

.input-search {
  position: relative;
}
.input-search input {
  padding-left: 34px;
}
.input-search::before {
  content: '⌕';
  position: absolute;
  left: 11px; top: 50%;
  transform: translateY(-50%);
  font-size: 14px;
  color: var(--muted);
  pointer-events: none;
}

/* ============================================================
   PROGRESS TRACK
   ============================================================ */
.progress {
  width: 100%;
  height: 4px;
  background: var(--surface-2);
  border-radius: 999px;
  overflow: hidden;
}
.progress__fill {
  height: 100%;
  background: var(--accent);
  border-radius: 999px;
  transition: width 0.3s ease;
}
.progress__fill--amber { background: var(--tier-amber); }

/* ============================================================
   TOAST
   ============================================================ */
.toast {
  position: fixed;
  bottom: 24px; right: 24px;
  background: var(--ink);
  color: var(--accent-ink);
  border-radius: 10px;
  padding: 12px 16px;
  display: flex; align-items: center; gap: 10px;
  font-size: 13px;
  box-shadow: var(--shadow-lg);
  border-left: 3px solid var(--tier-green);
  z-index: 100;
}
.toast--warn { border-left-color: var(--tier-amber); }
.toast--error { border-left-color: var(--tier-red); }

/* ============================================================
   UTILITY
   ============================================================ */
.muted { color: var(--muted); }
.muted-2 { color: var(--muted-2); }
.mono { font-family: 'DM Mono', monospace; }
.flex { display: flex; }
.row { display: flex; align-items: center; }
.col { display: flex; flex-direction: column; }
.gap-4 { gap: 4px; } .gap-6 { gap: 6px; } .gap-8 { gap: 8px; } .gap-12 { gap: 12px; } .gap-16 { gap: 16px; } .gap-24 { gap: 24px; }
.spacer { flex: 1; }
.text-xs { font-size: 11px; } .text-sm { font-size: 12.5px; } .text-md { font-size: 13.5px; } .text-lg { font-size: 16px; } .text-xl { font-size: 22px; }
