/* ── Design tokens ─────────────────────────────────────────── */
:root {
  --bg: #FAFAF8;
  --surface: #FFFFFF;
  --surface2: #F4F2EC;
  --border: #E5E3DC;
  --border2: #D1CFC6;
  --text: #1A1916;
  --text2: #6B6861;
  --text3: #9B9890;
  --blue: #185FA5;
  --blue-bg: #E6F1FB;
  --green: #1D9E75;
  --green-bg: #EAF3DE;
  --amber: #EF9F27;
  --amber-bg: #FAEEDA;
  --red: #E24B4A;
  --red-bg: #FCEBEB;
  --radius-sm: 6px;
  --radius-md: 8px;
  --radius-lg: 12px;
  --shadow: 0 1px 3px rgba(0,0,0,.07), 0 1px 2px rgba(0,0,0,.04);
  --shadow-lg: 0 4px 12px rgba(0,0,0,.10);
}

/* ── Base ───────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { font-size: 15px; }
body { font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', system-ui, sans-serif; background: var(--bg); color: var(--text); line-height: 1.5; -webkit-font-smoothing: antialiased; }
a { color: inherit; text-decoration: none; }
button { font-family: inherit; cursor: pointer; }
input, textarea, select { font-family: inherit; }

/* ── Login ──────────────────────────────────────────────────── */
.login-page { min-height: 100vh; display: flex; align-items: center; justify-content: center; background: var(--bg); }
.login-box { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-lg); padding: 2.5rem 2rem; width: 100%; max-width: 380px; box-shadow: var(--shadow-lg); }
.login-logo { display: flex; align-items: center; gap: 10px; margin-bottom: 1.75rem; }
.login-logo svg { color: var(--blue); }
.login-title { font-size: 18px; font-weight: 600; color: var(--text); }
.login-subtitle { font-size: 13px; color: var(--text2); margin-top: 2px; }
.form-group { margin-bottom: 1rem; }
.form-label { display: block; font-size: 12px; font-weight: 500; color: var(--text2); margin-bottom: 6px; text-transform: uppercase; letter-spacing: .04em; }
.form-input { width: 100%; padding: 8px 12px; border: 1px solid var(--border); border-radius: var(--radius-md); font-size: 14px; color: var(--text); background: var(--surface); transition: border-color .15s; }
.form-input:focus { outline: none; border-color: var(--blue); box-shadow: 0 0 0 3px var(--blue-bg); }
.form-error { font-size: 12px; color: var(--red); margin-top: 0.5rem; }
.btn-primary { width: 100%; padding: 9px; background: var(--blue); color: #fff; border: none; border-radius: var(--radius-md); font-size: 14px; font-weight: 500; transition: opacity .15s; margin-top: .5rem; }
.btn-primary:hover { opacity: .88; }
.btn-primary:disabled { opacity: .5; cursor: not-allowed; }

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

/* ── Sidebar ────────────────────────────────────────────────── */
.sidebar { width: 220px; flex-shrink: 0; background: var(--surface); border-right: 1px solid var(--border); display: flex; flex-direction: column; position: fixed; top: 0; left: 0; height: 100vh; z-index: 100; }
.sidebar-logo { padding: 1.25rem 1rem 1rem; display: flex; align-items: center; gap: 8px; border-bottom: 1px solid var(--border); }
.sidebar-logo-text { font-size: 14px; font-weight: 600; color: var(--text); }
.sidebar-logo-sub { font-size: 11px; color: var(--text2); }
.sidebar-nav { flex: 1; padding: .75rem .5rem; overflow-y: auto; }
.nav-item { display: flex; align-items: center; gap: 9px; padding: 7px 10px; border-radius: var(--radius-md); font-size: 13.5px; color: var(--text2); cursor: pointer; transition: background .12s, color .12s; margin-bottom: 2px; border: none; background: none; width: 100%; text-align: left; }
.nav-item:hover { background: var(--surface2); color: var(--text); }
.nav-item.active { background: var(--blue-bg); color: var(--blue); font-weight: 500; }
.nav-item svg { flex-shrink: 0; }
.sidebar-footer { padding: .75rem .5rem 1rem; border-top: 1px solid var(--border); }
.user-row { display: flex; align-items: center; gap: 8px; padding: 8px 10px; border-radius: var(--radius-md); cursor: pointer; transition: background .12s; }
.user-row:hover { background: var(--surface2); }
.user-avatar { width: 28px; height: 28px; border-radius: 50%; background: var(--blue-bg); color: var(--blue); font-size: 12px; font-weight: 600; display: flex; align-items: center; justify-content: center; flex-shrink: 0; }
.user-name { font-size: 13px; font-weight: 500; color: var(--text); }
.user-role { font-size: 11px; color: var(--text2); }

/* ── Main content ───────────────────────────────────────────── */
.main { margin-left: 220px; flex: 1; min-height: 100vh; }
.page-header { padding: 1.5rem 2rem 0; border-bottom: 1px solid var(--border); background: var(--surface); position: sticky; top: 0; z-index: 50; }
.page-title { font-size: 18px; font-weight: 600; color: var(--text); margin-bottom: 1rem; }
.page-content { padding: 1.5rem 2rem; max-width: 1100px; }

/* ── Tab content ────────────────────────────────────────────── */
.tab-panel { display: none; }
.tab-panel.active { display: block; }

/* ── Metrics ────────────────────────────────────────────────── */
.metrics-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); gap: 12px; margin-bottom: 1.75rem; }
.metric-card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-lg); padding: 1rem 1.25rem; }
.metric-label { font-size: 11px; color: var(--text2); text-transform: uppercase; letter-spacing: .04em; margin-bottom: 6px; }
.metric-value { font-size: 26px; font-weight: 600; color: var(--text); line-height: 1; }
.metric-value.danger { color: var(--red); }
.metric-sub { font-size: 11px; color: var(--text3); margin-top: 4px; }

/* ── Cards ──────────────────────────────────────────────────── */
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-lg); padding: 1.25rem 1.5rem; margin-bottom: 1rem; }
.card.warn { border-color: #f7c1c1; background: #fff9f9; }
.card-title { font-size: 14px; font-weight: 600; color: var(--text); margin-bottom: 1rem; }

/* ── Timeline ───────────────────────────────────────────────── */
.timeline { list-style: none; }
.tl-item { display: flex; gap: 12px; padding: 10px 0; border-bottom: 1px solid var(--border); align-items: flex-start; }
.tl-item:last-child { border-bottom: none; }
.tl-dot { width: 10px; height: 10px; border-radius: 50%; margin-top: 5px; flex-shrink: 0; }
.tl-dot.done { background: var(--green); }
.tl-dot.next { background: var(--blue); }
.tl-dot.pending { background: var(--amber); }
.tl-dot.blocked { background: var(--red); }
.tl-body { flex: 1; }
.tl-title { font-size: 13px; font-weight: 500; color: var(--text); }
.tl-desc { font-size: 12px; color: var(--text2); margin-top: 2px; }
.tl-date { font-size: 11px; color: var(--text3); margin-top: 3px; }
.tl-actions { display: flex; gap: 6px; align-items: center; flex-shrink: 0; }

/* ── Badges ─────────────────────────────────────────────────── */
.badge { display: inline-block; font-size: 11px; font-weight: 500; padding: 2px 8px; border-radius: 20px; white-space: nowrap; }
.badge-green { background: var(--green-bg); color: #2d6b14; }
.badge-amber { background: var(--amber-bg); color: #854F0B; }
.badge-red { background: var(--red-bg); color: #A32D2D; }
.badge-blue { background: var(--blue-bg); color: var(--blue); }
.badge-gray { background: var(--surface2); color: var(--text2); }

/* ── Providers ──────────────────────────────────────────────── */
.providers-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(290px, 1fr)); gap: 14px; margin-bottom: 1.5rem; }
.pcard { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-lg); padding: 1.25rem; position: relative; }
.pcard.featured { border-color: var(--blue); border-width: 2px; }
.pcard-header { display: flex; justify-content: space-between; align-items: flex-start; margin-bottom: .75rem; }
.pcard-name { font-size: 15px; font-weight: 600; color: var(--text); }
.pcard-partner { font-size: 12px; color: var(--text2); margin-top: 2px; }
.progress-bar { height: 4px; background: var(--border); border-radius: 2px; margin: .75rem 0; overflow: hidden; }
.progress-fill { height: 100%; border-radius: 2px; transition: width .3s; }
.pcard-meta { font-size: 12px; color: var(--text2); margin-bottom: 8px; }
.pcard-meta span { display: inline-flex; align-items: center; gap: 4px; margin-right: 10px; }
.pcard-desc { font-size: 12px; color: var(--text2); margin-bottom: .75rem; line-height: 1.5; }
.badges-row { display: flex; flex-wrap: wrap; gap: 5px; }
.pcard-footer { margin-top: .75rem; padding-top: .75rem; border-top: 1px solid var(--border); display: flex; gap: 8px; }

/* ── Meetings section ───────────────────────────────────────── */
.meetings-section { margin-top: .5rem; }
.meeting-item { background: var(--surface2); border-radius: var(--radius-md); padding: .75rem 1rem; margin-bottom: 8px; }
.meeting-header { display: flex; justify-content: space-between; align-items: flex-start; gap: 8px; }
.meeting-title { font-size: 13px; font-weight: 500; color: var(--text); }
.meeting-date { font-size: 11px; color: var(--text3); }
.meeting-body { font-size: 12px; color: var(--text2); margin-top: 4px; white-space: pre-line; }
.meeting-meta { font-size: 11px; color: var(--text3); margin-top: 4px; }

/* ── Requirements matrix ────────────────────────────────────── */
.matrix-wrap { overflow-x: auto; border: 1px solid var(--border); border-radius: var(--radius-lg); }
.matrix-table { width: 100%; border-collapse: collapse; font-size: 12px; min-width: 600px; }
.matrix-table th { padding: 9px 12px; font-size: 11px; font-weight: 500; color: var(--text2); text-transform: uppercase; letter-spacing: .04em; border-bottom: 1px solid var(--border); background: var(--surface2); text-align: left; white-space: nowrap; }
.matrix-table td { padding: 9px 12px; border-bottom: 1px solid var(--border); color: var(--text); vertical-align: middle; }
.matrix-table tr:last-child td { border-bottom: none; }
.matrix-table tr:hover td { background: #fafaf9; }
.cov-badge { display: inline-flex; align-items: center; gap: 4px; font-size: 11px; padding: 2px 8px; border-radius: 12px; white-space: nowrap; cursor: pointer; transition: opacity .12s; }
.cov-badge:hover { opacity: .75; }
.cov-full { background: var(--green-bg); color: #2d6b14; }
.cov-partial { background: var(--amber-bg); color: #854F0B; }
.cov-dev { background: var(--blue-bg); color: var(--blue); }
.cov-no { background: var(--red-bg); color: #A32D2D; }
.cov-pending { background: var(--surface2); color: var(--text2); }

/* ── Scoring ────────────────────────────────────────────────── */
.scoring-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: 14px; margin-bottom: 1.5rem; }
.score-card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-lg); padding: 1.25rem; }
.score-card-name { font-size: 14px; font-weight: 600; color: var(--text); margin-bottom: .75rem; }
.score-row { display: flex; align-items: center; gap: 8px; margin-bottom: 6px; }
.score-lbl { font-size: 11px; color: var(--text2); width: 130px; flex-shrink: 0; line-height: 1.3; }
.score-track { flex: 1; height: 6px; background: var(--border); border-radius: 3px; overflow: hidden; }
.score-fill { height: 100%; border-radius: 3px; transition: width .3s; }
.score-num { font-size: 11px; font-weight: 500; color: var(--text2); width: 26px; text-align: right; cursor: pointer; }
.score-num:hover { color: var(--blue); text-decoration: underline; }
.score-total { font-size: 20px; font-weight: 600; margin-top: .75rem; padding-top: .75rem; border-top: 1px solid var(--border); }
.weight-tag { font-size: 10px; color: var(--text3); margin-left: 3px; }

/* ── Actions ────────────────────────────────────────────────── */
.action-list { list-style: none; }
.action-item { display: flex; gap: 12px; align-items: flex-start; padding: .875rem 0; border-bottom: 1px solid var(--border); }
.action-item:last-child { border-bottom: none; }
.action-stripe { width: 4px; min-height: 44px; border-radius: 2px; flex-shrink: 0; }
.action-body { flex: 1; }
.action-title { font-size: 13px; font-weight: 500; color: var(--text); }
.action-desc { font-size: 12px; color: var(--text2); margin-top: 3px; line-height: 1.45; }
.action-owner { display: inline-block; font-size: 11px; background: var(--surface2); padding: 2px 7px; border-radius: 10px; color: var(--text2); margin-top: 5px; }
.action-done { opacity: .45; }
.action-done .action-title { text-decoration: line-through; }

.risk-item { display: flex; gap: 10px; align-items: flex-start; padding: .75rem 0; border-bottom: 1px solid var(--border); }
.risk-item:last-child { border-bottom: none; }
.risk-dot { width: 10px; height: 10px; border-radius: 50%; margin-top: 4px; flex-shrink: 0; }
.risk-body { flex: 1; }
.risk-title { font-size: 13px; font-weight: 500; color: var(--text); }
.risk-desc { font-size: 12px; color: var(--text2); margin-top: 2px; line-height: 1.45; }

/* ── Buttons ────────────────────────────────────────────────── */
.btn { display: inline-flex; align-items: center; gap: 6px; padding: 6px 13px; font-size: 13px; border-radius: var(--radius-md); border: 1px solid var(--border); background: var(--surface); color: var(--text2); cursor: pointer; transition: background .12s, color .12s, border-color .12s; }
.btn:hover { background: var(--surface2); color: var(--text); border-color: var(--border2); }
.btn-sm { padding: 4px 9px; font-size: 12px; }
.btn-blue { background: var(--blue); color: #fff; border-color: var(--blue); }
.btn-blue:hover { background: #1455a0; border-color: #1455a0; color: #fff; }
.btn-ghost { background: transparent; border-color: transparent; padding: 4px 6px; color: var(--text3); }
.btn-ghost:hover { background: var(--surface2); color: var(--text2); border-color: transparent; }
.btn-danger { color: var(--red); }
.btn-danger:hover { background: var(--red-bg); border-color: var(--red-bg); color: var(--red); }
.add-row-btn { width: 100%; padding: 8px; font-size: 13px; background: var(--surface2); border: 1px dashed var(--border2); border-radius: var(--radius-md); color: var(--text2); cursor: pointer; margin-top: .75rem; transition: background .12s; }
.add-row-btn:hover { background: var(--border); }

/* ── Modal ──────────────────────────────────────────────────── */
.modal-overlay { position: fixed; inset: 0; background: rgba(0,0,0,.35); z-index: 200; display: flex; align-items: center; justify-content: center; padding: 1rem; opacity: 0; pointer-events: none; transition: opacity .18s; }
.modal-overlay.open { opacity: 1; pointer-events: all; }
.modal { background: var(--surface); border-radius: var(--radius-lg); padding: 1.5rem; width: 100%; max-width: 520px; max-height: 90vh; overflow-y: auto; box-shadow: var(--shadow-lg); transform: translateY(12px); transition: transform .18s; }
.modal-overlay.open .modal { transform: translateY(0); }
.modal-title { font-size: 16px; font-weight: 600; color: var(--text); margin-bottom: 1.25rem; }
.modal-footer { display: flex; gap: 8px; justify-content: flex-end; margin-top: 1.25rem; }
.field-row { margin-bottom: .875rem; }
.field-label { font-size: 12px; font-weight: 500; color: var(--text2); margin-bottom: 5px; display: block; }
.field-input { width: 100%; padding: 7px 10px; border: 1px solid var(--border); border-radius: var(--radius-md); font-size: 13px; color: var(--text); background: var(--surface); }
.field-input:focus { outline: none; border-color: var(--blue); box-shadow: 0 0 0 2px var(--blue-bg); }
.field-textarea { resize: vertical; min-height: 80px; line-height: 1.5; }
.field-select { appearance: none; background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%236B6861' stroke-width='2'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E"); background-repeat: no-repeat; background-position: right 10px center; padding-right: 28px; }

/* ── Toast ──────────────────────────────────────────────────── */
.toast-container { position: fixed; bottom: 1.5rem; right: 1.5rem; z-index: 300; display: flex; flex-direction: column; gap: 8px; }
.toast { background: var(--text); color: #fff; font-size: 13px; padding: 10px 16px; border-radius: var(--radius-md); box-shadow: var(--shadow-lg); animation: toastIn .2s ease; }
.toast.success { background: var(--green); }
.toast.error { background: var(--red); }
@keyframes toastIn { from { transform: translateY(10px); opacity: 0; } to { transform: translateY(0); opacity: 1; } }

/* ── Context menu ────────────────────────────────────────────── */
.ctx-menu { position: fixed; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-md); box-shadow: var(--shadow-lg); z-index: 400; min-width: 150px; padding: 4px; }
.ctx-item { display: block; width: 100%; text-align: left; padding: 7px 12px; font-size: 13px; color: var(--text); background: none; border: none; border-radius: var(--radius-sm); cursor: pointer; }
.ctx-item:hover { background: var(--surface2); }
.ctx-item.danger { color: var(--red); }

/* ── Misc ────────────────────────────────────────────────────── */
.section-title { font-size: 14px; font-weight: 600; color: var(--text); margin-bottom: .875rem; margin-top: 1.5rem; }
.section-title:first-child { margin-top: 0; }
.legend { display: flex; flex-wrap: wrap; gap: 8px; margin-top: .875rem; }
.divider { height: 1px; background: var(--border); margin: 1rem 0; }
.empty-state { text-align: center; padding: 2.5rem 1rem; color: var(--text2); font-size: 13px; }
.empty-state svg { display: block; margin: 0 auto .75rem; opacity: .35; }
.spinner { width: 20px; height: 20px; border: 2px solid var(--border); border-top-color: var(--blue); border-radius: 50%; animation: spin .6s linear infinite; margin: 2rem auto; }
@keyframes spin { to { transform: rotate(360deg); } }
.inline-edit { background: none; border: none; border-bottom: 1px dashed transparent; padding: 0; font-size: inherit; color: inherit; font-weight: inherit; width: 100%; cursor: text; }
.inline-edit:hover { border-bottom-color: var(--border2); }
.inline-edit:focus { outline: none; border-bottom-color: var(--blue); }
.tag-list { display: flex; flex-wrap: wrap; gap: 5px; }

/* ── Mobile header ───────────────────────────────────────────── */
.mobile-header { display: none; }

/* ── Sidebar backdrop ────────────────────────────────────────── */
.sidebar-backdrop { display: none; position: fixed; inset: 0; background: rgba(0,0,0,.4); z-index: 99; opacity: 0; transition: opacity .2s; pointer-events: none; }
.sidebar-backdrop.open { opacity: 1; pointer-events: all; }

/* ── Responsive ──────────────────────────────────────────────── */
@media (max-width: 768px) {
  /* Show mobile header */
  .mobile-header {
    display: flex; align-items: center; gap: 12px;
    position: fixed; top: 0; left: 0; right: 0; height: 52px;
    background: var(--surface); border-bottom: 1px solid var(--border);
    padding: 0 1rem; z-index: 150;
  }
  .mobile-header-title { font-size: 15px; font-weight: 600; color: var(--text); }

  /* Hamburger button */
  .hamburger { display: flex; flex-direction: column; justify-content: center; gap: 5px; width: 36px; height: 36px; padding: 6px; background: none; border: none; cursor: pointer; border-radius: var(--radius-md); flex-shrink: 0; }
  .hamburger span { display: block; height: 2px; background: var(--text); border-radius: 2px; transition: transform .2s, opacity .2s; }
  .hamburger.open span:nth-child(1) { transform: translateY(7px) rotate(45deg); }
  .hamburger.open span:nth-child(2) { opacity: 0; }
  .hamburger.open span:nth-child(3) { transform: translateY(-7px) rotate(-45deg); }

  /* Show backdrop */
  .sidebar-backdrop { display: block; }

  /* Sidebar slides in over content */
  .sidebar { transform: translateX(-100%); transition: transform .22s ease; z-index: 100; }
  .sidebar.open { transform: translateX(0); box-shadow: 4px 0 20px rgba(0,0,0,.15); }

  /* Main shifts down for header, no left margin */
  .main { margin-left: 0; padding-top: 52px; }
  .page-content { padding: 1rem; }

  /* Single column grids */
  .scoring-grid { grid-template-columns: 1fr; }
  .providers-grid { grid-template-columns: 1fr; }

  /* Modal full-width on small screens */
  .modal { max-width: 100%; margin: 0; border-radius: var(--radius-lg) var(--radius-lg) 0 0; position: fixed; bottom: 0; left: 0; right: 0; max-height: 92vh; }
  .modal-overlay { align-items: flex-end; padding: 0; }

  /* Toast above potential bottom bar */
  .toast-container { bottom: 1rem; right: 1rem; left: 1rem; }
  .toast { text-align: center; }
}
