/* ═══════════════════════════════════════════════════════════════
   ChangeFlow — Mobile-First Stylesheet
   Design: Clean professional · touch-friendly · dark nav
═══════════════════════════════════════════════════════════════ */

/* ── Variables ─────────────────────────────────────────────── */
:root {
  --ink:        #0f1117;
  --ink-2:      #2a2d3a;
  --ink-3:      #4a4f66;
  --ink-4:      #7a7f96;
  --ink-5:      #a8adc4;
  --bg:         #f5f4f0;
  --bg-2:       #eceae4;
  --bg-3:       #e2dfd7;
  --white:      #ffffff;
  --surface:    #fdfcfa;

  --accent:       #2563eb;
  --accent-dark:  #1d4ed8;
  --accent-light: #dbeafe;

  --green:        #16a34a;
  --green-light:  #dcfce7;
  --red:          #dc2626;
  --red-light:    #fee2e2;
  --amber:        #d97706;
  --amber-light:  #fef3c7;
  --orange:       #ea580c;
  --orange-light: #ffedd5;
  --purple:       #7c3aed;
  --purple-light: #ede9fe;

  --radius:    8px;
  --radius-lg: 12px;
  --radius-xl: 16px;
  --shadow:    0 1px 3px rgba(0,0,0,.08), 0 1px 2px rgba(0,0,0,.04);
  --shadow-md: 0 4px 16px rgba(0,0,0,.08), 0 2px 4px rgba(0,0,0,.04);

  --font-display: 'DM Serif Display', Georgia, serif;
  --font-body:    'DM Sans', system-ui, sans-serif;
  --nav-h: 56px;

  /* Touch target minimum */
  --touch: 44px;
}

/* ── Reset ──────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { font-size: 16px; -webkit-text-size-adjust: 100%; scroll-behavior: smooth; }
body {
  font-family: var(--font-body);
  background: var(--bg);
  color: var(--ink);
  line-height: 1.6;
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  /* Prevent horizontal overflow on mobile */
  overflow-x: hidden;
}
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
img { max-width: 100%; }
input, textarea, select, button { font-family: inherit; font-size: 16px; /* prevent iOS zoom */ }

/* ── Navbar ─────────────────────────────────────────────────── */
.navbar {
  height: var(--nav-h);
  background: var(--ink);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 16px;
  position: sticky;
  top: 0;
  z-index: 200;
  box-shadow: 0 2px 8px rgba(0,0,0,.3);
}
.nav-brand { display: flex; align-items: center; gap: 10px; min-width: 0; }
.nav-logo {
  width: 32px; height: 32px; flex-shrink: 0;
  background: var(--accent);
  border-radius: 7px;
  display: flex; align-items: center; justify-content: center;
  font-size: 16px;
}
.nav-text { display: flex; flex-direction: column; min-width: 0; }
.nav-title {
  font-family: var(--font-display);
  font-size: 16px; color: var(--white);
  line-height: 1; white-space: nowrap;
}
.nav-sub { font-size: 10px; color: var(--ink-5); letter-spacing: .04em; display: none; }
.nav-links { display: flex; align-items: center; gap: 6px; flex-shrink: 0; }
.nav-link {
  color: var(--ink-5); font-size: 13px;
  padding: 8px 12px;
  border-radius: var(--radius);
  transition: all .15s; white-space: nowrap;
  min-height: var(--touch);
  display: flex; align-items: center;
}
.nav-link:hover { color: var(--white); background: rgba(255,255,255,.08); text-decoration: none; }
.nav-cta {
  background: var(--accent); color: var(--white) !important;
  font-weight: 600; font-size: 13px;
}
.nav-cta:hover { background: var(--accent-dark) !important; }

/* ── Main ───────────────────────────────────────────────────── */
.main-content {
  flex: 1;
  width: 100%;
  max-width: 1280px;
  margin: 0 auto;
  padding: 20px 16px 80px;
}

/* ── Buttons ────────────────────────────────────────────────── */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  padding: 0 18px;
  height: var(--touch);
  border-radius: var(--radius);
  font-size: 14px; font-weight: 600;
  border: none; cursor: pointer;
  transition: all .15s;
  text-decoration: none; white-space: nowrap;
  -webkit-tap-highlight-color: transparent;
}
.btn:hover { text-decoration: none; }
.btn-primary  { background: var(--accent); color: #fff; }
.btn-primary:hover  { background: var(--accent-dark); color: #fff; }
.btn-secondary { background: var(--bg-3); color: var(--ink-2); }
.btn-secondary:hover { background: var(--bg-2); }
.btn-ghost { background: transparent; color: var(--ink-3); border: 1.5px solid var(--bg-3); }
.btn-ghost:hover { background: var(--bg-2); }
.btn-submit { background: var(--ink); color: #fff; font-size: 15px; height: 48px; }
.btn-submit:hover { background: var(--ink-2); }
.btn-submit:disabled { opacity: .4; cursor: not-allowed; }
.btn-sm { height: 34px; padding: 0 12px; font-size: 13px; }
.btn-approve { background: var(--green); color: #fff; }
.btn-approve:hover { background: #15803d; color: #fff; }
.btn-reject { background: var(--red); color: #fff; }
.btn-reject:hover { background: #b91c1c; color: #fff; }
.btn-full { width: 100%; }

/* ── Page Header ────────────────────────────────────────────── */
.page-header {
  display: flex; flex-direction: column; gap: 12px;
  margin-bottom: 20px;
}
.page-title {
  font-family: var(--font-display);
  font-size: clamp(24px, 6vw, 40px);
  color: var(--ink); line-height: 1.1; font-style: italic;
}
.page-subtitle { color: var(--ink-4); font-size: 14px; margin-top: 4px; }
.header-actions { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }

/* ── Stats Grid ─────────────────────────────────────────────── */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
  margin-bottom: 20px;
}
.stat-card {
  background: var(--white);
  border-radius: var(--radius-lg);
  padding: 14px 12px;
  box-shadow: var(--shadow);
  border-left: 3px solid var(--bg-3);
}
.stat-value {
  font-family: var(--font-display);
  font-size: 28px; line-height: 1;
}
.stat-label { font-size: 10px; color: var(--ink-4); margin-top: 3px; font-weight: 600; text-transform: uppercase; letter-spacing: .04em; }
.stat-submitted { border-left-color: var(--accent); }
.stat-submitted .stat-value { color: var(--accent); }
.stat-review { border-left-color: var(--amber); }
.stat-review .stat-value { color: var(--amber); }
.stat-quoted { border-left-color: var(--purple); }
.stat-quoted .stat-value { color: var(--purple); }
.stat-approved { border-left-color: var(--green); }
.stat-approved .stat-value { color: var(--green); }
.stat-critical { border-left-color: var(--red); }
.stat-critical .stat-value { color: var(--red); }

/* ── Filter Bar ─────────────────────────────────────────────── */
.filter-bar { margin-bottom: 16px; }
.filter-form {
  display: flex; flex-direction: column; gap: 10px;
  background: var(--white);
  padding: 12px;
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow);
}
.filter-row { display: flex; gap: 8px; flex-wrap: wrap; }
.search-wrap { position: relative; width: 100%; }
.search-icon {
  position: absolute; left: 11px; top: 50%; transform: translateY(-50%);
  width: 16px; height: 16px; color: var(--ink-5); pointer-events: none;
}
.search-input {
  width: 100%;
  padding: 10px 12px 10px 36px;
  border: 1.5px solid var(--bg-3); border-radius: var(--radius);
  font-size: 16px; color: var(--ink); background: var(--bg);
  height: var(--touch);
}
.search-input:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-light); }
.filter-select {
  flex: 1; min-width: 120px;
  padding: 0 32px 0 12px;
  height: var(--touch);
  border: 1.5px solid var(--bg-3); border-radius: var(--radius);
  font-size: 14px; color: var(--ink); background: var(--bg);
  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='%237a7f96' stroke-width='2'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 10px center;
  cursor: pointer;
}
.filter-select:focus { outline: none; border-color: var(--accent); }

/* ── Table / Card List ──────────────────────────────────────── */
.table-wrap {
  background: var(--white);
  border-radius: var(--radius-xl);
  box-shadow: var(--shadow-md);
  overflow: hidden;
}

/* Mobile: card list */
.requests-table { display: none; }

.card-list { display: flex; flex-direction: column; }
.cr-card {
  padding: 16px;
  border-bottom: 1px solid var(--bg-2);
  cursor: pointer;
  transition: background .1s;
  -webkit-tap-highlight-color: transparent;
  display: block; text-decoration: none; color: inherit;
}
.cr-card:last-child { border-bottom: none; }
.cr-card:active { background: var(--bg); }
.cr-card-top { display: flex; align-items: flex-start; justify-content: space-between; gap: 8px; margin-bottom: 6px; }
.cr-card-title { font-size: 15px; font-weight: 600; color: var(--ink); line-height: 1.3; }
.cr-card-id { font-size: 12px; color: var(--ink-5); white-space: nowrap; }
.cr-card-meta { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; margin-bottom: 6px; }
.cr-card-bottom { display: flex; align-items: center; justify-content: space-between; }
.cr-card-dept { font-size: 12px; color: var(--ink-4); }
.cr-card-date { font-size: 11px; color: var(--ink-5); }

/* ── Badges ─────────────────────────────────────────────────── */
.badge {
  display: inline-block; padding: 3px 9px;
  border-radius: 100px; font-size: 11px; font-weight: 600;
  white-space: nowrap;
}
.badge-category { background: var(--bg-2); color: var(--ink-3); }
.status-draft       { background: var(--bg-3);        color: var(--ink-3); }
.status-submitted   { background: var(--accent-light); color: var(--accent-dark); }
.status-review      { background: var(--amber-light);  color: #92400e; }
.status-quoted      { background: var(--purple-light); color: #5b21b6; }
.status-approved    { background: var(--green-light);  color: #14532d; }
.status-rejected    { background: var(--red-light);    color: #7f1d1d; }
.status-implemented { background: var(--ink);          color: var(--white); }
.priority-low      { background: var(--green-light);  color: #14532d; }
.priority-medium   { background: var(--amber-light);  color: #78350f; }
.priority-high     { background: var(--orange-light); color: #7c2d12; }
.priority-critical { background: var(--red-light);    color: #7f1d1d; font-weight: 700; }

/* ── Empty State ────────────────────────────────────────────── */
.empty-state { padding: 60px 24px; text-align: center; }
.empty-icon { font-size: 40px; margin-bottom: 12px; }
.empty-state h3 { font-family: var(--font-display); font-size: 22px; margin-bottom: 8px; }
.empty-state p { color: var(--ink-4); margin-bottom: 20px; font-size: 14px; }

/* ── Form Layout ────────────────────────────────────────────── */
.form-layout { max-width: 760px; margin: 0 auto; }

.form-progress {
  display: flex; align-items: center;
  overflow-x: auto; -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
  margin-bottom: 20px;
  background: var(--white);
  padding: 16px 12px;
  border-radius: var(--radius-xl);
  box-shadow: var(--shadow);
  gap: 0;
}
.form-progress::-webkit-scrollbar { display: none; }
.progress-step {
  display: flex; flex-direction: column; align-items: center; gap: 4px;
  flex-shrink: 0; cursor: default;
}
.step-num {
  width: 30px; height: 30px; border-radius: 50%;
  background: var(--bg-3); color: var(--ink-4);
  display: flex; align-items: center; justify-content: center;
  font-size: 13px; font-weight: 700; transition: all .2s;
}
.step-label { font-size: 10px; color: var(--ink-5); white-space: nowrap; letter-spacing: .02em; }
.progress-step.active .step-num { background: var(--accent); color: #fff; }
.progress-step.active .step-label { color: var(--accent); font-weight: 700; }
.progress-step.done .step-num { background: var(--green); color: #fff; }
.progress-step.done .step-label { color: var(--green); }
.progress-line { flex: 1; min-width: 12px; height: 2px; background: var(--bg-3); margin-bottom: 14px; }

/* ── Form Sections ──────────────────────────────────────────── */
.form-section {
  display: none;
  background: var(--white);
  border-radius: var(--radius-xl);
  box-shadow: var(--shadow-md);
  overflow: hidden;
  animation: fadeIn .2s ease;
}
.form-section.active { display: block; }
@keyframes fadeIn { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }

.section-header {
  display: flex; align-items: flex-start; gap: 12px;
  padding: 20px 16px 16px;
  border-bottom: 1px solid var(--bg-2);
}
.section-num {
  font-family: var(--font-display);
  font-size: 36px; line-height: 1; color: var(--bg-3); font-style: italic; flex-shrink: 0;
}
.section-title { font-family: var(--font-display); font-size: 20px; margin-bottom: 2px; }
.section-desc { color: var(--ink-4); font-size: 13px; }

/* Mobile-first: single column grid */
.form-grid {
  display: flex; flex-direction: column; gap: 16px;
  padding: 20px 16px;
}
.form-group { display: flex; flex-direction: column; gap: 6px; }
/* span-2 / span-4 are no-ops on mobile — override on desktop */
.span-2, .span-4 { width: 100%; }
.form-row { display: flex; gap: 12px; }
.form-row .form-group { flex: 1; }

.form-label { font-size: 13px; font-weight: 700; color: var(--ink-2); }
.form-label.required::after { content: " *"; color: var(--red); }
.form-hint { font-size: 12px; color: var(--ink-5); }
.form-error { font-size: 12px; color: var(--red); display: none; }
.form-group.has-error .form-error { display: block; }
.char-count { font-size: 11px; color: var(--ink-5); text-align: right; }

.form-input, .form-select, .form-textarea {
  padding: 10px 14px;
  border: 1.5px solid var(--bg-3); border-radius: var(--radius);
  font-size: 16px; /* prevents iOS zoom */ color: var(--ink);
  background: var(--surface); width: 100%;
  min-height: var(--touch);
  transition: border-color .15s, box-shadow .15s;
  -webkit-appearance: none; appearance: none;
}
.form-input:focus, .form-select:focus, .form-textarea:focus {
  outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-light);
}
.form-input.error, .form-select.error, .form-textarea.error {
  border-color: var(--red); box-shadow: 0 0 0 3px var(--red-light);
}
.form-textarea { min-height: 100px; resize: vertical; font-size: 15px; }
.form-select {
  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='%237a7f96' stroke-width='2'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 14px center;
  padding-right: 40px; cursor: pointer;
}

/* ── Benefits Builder ───────────────────────────────────────── */
.benefits-builder { display: flex; flex-direction: column; gap: 8px; margin-bottom: 8px; }
.benefit-item { display: flex; align-items: center; gap: 8px; }
.benefit-input { flex: 1; }

/* ── Signature Pad ──────────────────────────────────────────── */
.sig-container {
  border: 2px dashed var(--bg-3);
  border-radius: var(--radius-lg);
  overflow: hidden;
  background: #fafaf9;
  position: relative;
}
.sig-container.has-sig { border-color: var(--accent); border-style: solid; }
.sig-canvas {
  display: block;
  width: 100%;
  height: 160px;
  touch-action: none; /* critical: prevents scroll while signing */
  cursor: crosshair;
}
.sig-placeholder {
  position: absolute; inset: 0;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 6px; color: var(--ink-5); pointer-events: none;
  transition: opacity .2s;
}
.sig-placeholder svg { width: 28px; height: 28px; opacity: .4; }
.sig-placeholder span { font-size: 13px; }
.sig-toolbar {
  display: flex; align-items: center; justify-content: space-between;
  padding: 8px 12px;
  background: var(--bg); border-top: 1px solid var(--bg-2);
}
.sig-toolbar-left { display: flex; align-items: center; gap: 6px; }
.sig-color-btn {
  width: 22px; height: 22px; border-radius: 50%; border: 2px solid transparent;
  cursor: pointer; transition: transform .15s;
  -webkit-tap-highlight-color: transparent;
}
.sig-color-btn:hover, .sig-color-btn.active { transform: scale(1.2); border-color: var(--ink); }
.sig-size-label { font-size: 11px; color: var(--ink-5); }
.sig-size { width: 70px; accent-color: var(--accent); }
.sig-clear { font-size: 12px; color: var(--ink-4); background: none; border: none; cursor: pointer; padding: 4px 8px; border-radius: var(--radius); }
.sig-clear:hover { background: var(--bg-3); }
.sig-note { font-size: 11px; color: var(--ink-5); margin-top: 6px; text-align: center; }

/* ── Review Panel ───────────────────────────────────────────── */
.review-panel {
  margin: 0 16px 16px;
  background: var(--bg); border-radius: var(--radius-lg);
  padding: 16px; border: 1px solid var(--bg-3);
}
.review-group { margin-bottom: 14px; }
.review-label { font-size: 10px; font-weight: 700; color: var(--ink-5); text-transform: uppercase; letter-spacing: .06em; margin-bottom: 2px; }
.review-value { font-size: 14px; color: var(--ink-2); }
.review-sig { margin-top: 12px; border-top: 1px solid var(--bg-3); padding-top: 12px; }
.review-sig img { max-height: 80px; border: 1px solid var(--bg-2); border-radius: var(--radius); background: white; }

.submit-declaration {
  padding: 0 16px 16px;
}
.checkbox-label {
  display: flex; align-items: flex-start; gap: 10px;
  font-size: 13px; color: var(--ink-3); cursor: pointer;
}
.checkbox-label input { margin-top: 3px; flex-shrink: 0; width: 18px; height: 18px; }

.form-nav {
  display: flex; justify-content: space-between; align-items: center;
  padding: 16px;
  border-top: 1px solid var(--bg-2);
  background: var(--bg);
  gap: 8px;
}

/* ── Detail Layout (mobile: single col) ─────────────────────── */
.detail-layout {
  display: flex; flex-direction: column; gap: 16px;
}
.detail-main { display: flex; flex-direction: column; gap: 16px; }
.detail-sidebar { display: flex; flex-direction: column; gap: 12px; }

/* Detail header */
.breadcrumb { font-size: 12px; color: var(--ink-5); margin-bottom: 6px; }
.breadcrumb a { color: var(--ink-4); }
.detail-title { font-size: clamp(20px, 5vw, 30px) !important; }
.request-meta { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; margin-top: 8px; }
.meta-text { font-size: 12px; color: var(--ink-5); }
.status-form { display: flex; gap: 6px; align-items: center; flex-wrap: wrap; }

/* ── Cards ──────────────────────────────────────────────────── */
.detail-card {
  background: var(--white); border-radius: var(--radius-xl); box-shadow: var(--shadow); overflow: hidden;
}
.card-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 14px 16px 12px; border-bottom: 1px solid var(--bg-2);
}
.card-header.clickable { cursor: pointer; user-select: none; -webkit-tap-highlight-color: transparent; }
.card-header.clickable:active { background: var(--bg); }
.card-title { font-family: var(--font-display); font-size: 16px; }
.toggle-icon { font-size: 12px; color: var(--ink-5); }
.comment-count { font-size: 11px; color: var(--ink-5); background: var(--bg-2); padding: 2px 8px; border-radius: 100px; }

.info-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; padding: 14px 16px; }
.info-item { display: flex; flex-direction: column; gap: 3px; }
.info-label { font-size: 10px; font-weight: 700; color: var(--ink-5); text-transform: uppercase; letter-spacing: .05em; }
.info-value { font-size: 14px; color: var(--ink); }
.deadline { color: var(--amber); font-weight: 600; }

.prose-content {
  padding: 14px 16px;
  font-size: 14px; color: var(--ink-2); line-height: 1.7;
  white-space: pre-wrap; word-break: break-word;
}

/* Signature display */
.sig-display { padding: 14px 16px; }
.sig-display img {
  max-width: 100%; max-height: 120px;
  border: 1px solid var(--bg-2); border-radius: var(--radius);
  background: white; display: block;
}
.sig-display .sig-name { font-size: 12px; color: var(--ink-5); margin-top: 6px; }

/* Benefits */
.benefits-list { padding: 10px 16px; }
.benefit-row { display: flex; gap: 10px; padding: 8px 0; border-bottom: 1px solid var(--bg-2); align-items: flex-start; }
.benefit-row:last-child { border-bottom: none; }
.benefit-check {
  width: 20px; height: 20px; background: var(--green-light); color: var(--green);
  border-radius: 50%; display: flex; align-items: center; justify-content: center;
  font-size: 10px; font-weight: 700; flex-shrink: 0; margin-top: 1px;
}
.benefit-text { font-size: 14px; color: var(--ink-2); line-height: 1.5; }

/* Impact badge */
.impact-badge { display: inline-block; padding: 3px 9px; border-radius: 100px; font-size: 11px; font-weight: 700; }
.impact-High   { background: var(--red-light);   color: #7f1d1d; }
.impact-Medium { background: var(--amber-light); color: #78350f; }
.impact-Low    { background: var(--green-light); color: #14532d; }

/* ── Analyst Card ───────────────────────────────────────────── */
.analyst-card { border: 2px solid var(--purple-light); }
.analyst-by { font-size: 11px; color: var(--ink-5); }

.quote-summary {
  display: grid; grid-template-columns: 1fr 1fr;
  gap: 1px; background: var(--bg-2);
}
.quote-metric { background: var(--white); padding: 14px 12px; text-align: center; }
.quote-metric-value { font-family: var(--font-display); font-size: 18px; color: var(--ink); word-break: break-word; }
.quote-metric-label { font-size: 10px; color: var(--ink-5); margin-top: 3px; text-transform: uppercase; letter-spacing: .04em; }
.recommend-approve .quote-metric-value { color: var(--green); }
.recommend-reject  .quote-metric-value { color: var(--red); }
.recommend-neutral .quote-metric-value { color: var(--amber); }

.analyst-details { padding: 14px 16px; }
.analyst-section { margin-bottom: 14px; }
.analyst-section:last-child { margin-bottom: 0; }
.analyst-section-title { font-size: 11px; font-weight: 700; color: var(--ink-4); text-transform: uppercase; letter-spacing: .05em; margin-bottom: 5px; }
.quote-validity { font-size: 13px; color: var(--ink-4); font-style: italic; }
.analyst-actions { padding: 12px 16px; border-top: 1px solid var(--bg-2); display: flex; gap: 8px; flex-wrap: wrap; }

.analyst-form-card { border: 2px dashed var(--bg-3); }
.analyst-form-card.collapsed { border-style: solid; }
.analyst-note { margin: 12px 16px 0; padding: 10px 14px; background: var(--amber-light); border-radius: var(--radius); font-size: 13px; color: #78350f; border-left: 3px solid var(--amber); }

/* Recommendation buttons */
.recommendation-buttons { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.rec-btn {
  padding: 10px; border-radius: var(--radius); font-size: 13px; font-weight: 600;
  border: 2px solid var(--bg-3); background: var(--bg); cursor: pointer;
  transition: all .15s; color: var(--ink-3); text-align: center;
  min-height: var(--touch);
  -webkit-tap-highlight-color: transparent;
}
.rec-approve:active, .rec-approve.rec-selected { background: var(--green-light); border-color: var(--green); color: var(--green); }
.rec-defer:active,   .rec-defer.rec-selected   { background: var(--amber-light); border-color: var(--amber); color: var(--amber); }
.rec-revise:active,  .rec-revise.rec-selected  { background: var(--accent-light); border-color: var(--accent); color: var(--accent); }
.rec-reject:active,  .rec-reject.rec-selected  { background: var(--red-light); border-color: var(--red); color: var(--red); }

/* ── Comments ───────────────────────────────────────────────── */
.comments-list { padding: 6px 16px; }
.comment { padding: 14px 0; border-bottom: 1px solid var(--bg-2); }
.comment:last-child { border-bottom: none; }
.comment-header { display: flex; align-items: center; gap: 8px; margin-bottom: 6px; }
.comment-avatar {
  width: 30px; height: 30px; background: var(--ink-2); color: #fff;
  border-radius: 50%; display: flex; align-items: center; justify-content: center;
  font-size: 13px; font-weight: 700; flex-shrink: 0;
}
.comment-author { font-size: 14px; font-weight: 600; }
.comment-role { font-weight: 400; color: var(--ink-5); font-size: 12px; }
.comment-date { font-size: 11px; color: var(--ink-5); }
.comment-body { font-size: 14px; color: var(--ink-2); line-height: 1.6; }
.no-comments { padding: 20px 0; text-align: center; font-size: 13px; color: var(--ink-5); }

.comment-form { padding: 14px 16px; border-top: 1px solid var(--bg-2); display: flex; flex-direction: column; gap: 10px; }
.comment-inputs { display: flex; flex-direction: column; gap: 10px; }

/* ── Sidebar cards ──────────────────────────────────────────── */
.sidebar-card { background: var(--white); border-radius: var(--radius-xl); box-shadow: var(--shadow); padding: 16px; }
.sidebar-title { font-size: 11px; font-weight: 700; color: var(--ink-5); text-transform: uppercase; letter-spacing: .06em; margin-bottom: 12px; }
.sidebar-items { display: flex; flex-direction: column; gap: 10px; }
.sidebar-item { display: flex; justify-content: space-between; align-items: center; }
.sidebar-label { font-size: 12px; color: var(--ink-5); }
.sidebar-value { font-size: 13px; color: var(--ink-2); text-align: right; }

.quote-sidebar { border-top: 3px solid var(--purple); }
.quote-total { font-family: var(--font-display); font-size: 28px; color: var(--ink); margin-bottom: 3px; }
.quote-hours { font-size: 13px; color: var(--ink-4); margin-bottom: 3px; }
.quote-analyst { font-size: 12px; color: var(--ink-5); }
.quote-expiry { font-size: 11px; color: var(--amber); margin-top: 6px; font-style: italic; }

/* ── Timeline ───────────────────────────────────────────────── */
.timeline { display: flex; flex-direction: column; }
.timeline-item { display: flex; align-items: flex-start; gap: 10px; padding: 7px 0; position: relative; }
.timeline-item:not(:last-child)::before {
  content: ''; position: absolute; left: 6px; top: 22px;
  width: 2px; height: calc(100% - 8px); background: var(--bg-3);
}
.timeline-dot {
  width: 14px; height: 14px; border-radius: 50%;
  border: 2px solid var(--bg-3); background: var(--white);
  flex-shrink: 0; margin-top: 3px;
}
.timeline-item.done     .timeline-dot { background: var(--green); border-color: var(--green); }
.timeline-item.rejected .timeline-dot { background: var(--red);   border-color: var(--red); }
.timeline-label { font-size: 13px; font-weight: 500; color: var(--ink-4); }
.timeline-item.done .timeline-label { color: var(--ink); }
.timeline-date { font-size: 11px; color: var(--ink-5); margin-top: 1px; }

/* ── Footer ─────────────────────────────────────────────────── */
.footer { background: var(--ink-2); color: var(--ink-5); font-size: 11px; text-align: center; padding: 14px; }

/* ══════════════════════════════════════════════════════════════
   TABLET  ≥ 640px
══════════════════════════════════════════════════════════════ */
@media (min-width: 640px) {
  .main-content { padding: 24px 20px 80px; }
  .navbar { padding: 0 24px; }
  .nav-sub { display: block; }
  .nav-title { font-size: 18px; }

  .stats-grid { grid-template-columns: repeat(6, 1fr); }
  .stat-card { padding: 16px; }
  .stat-value { font-size: 32px; }

  .filter-form { flex-direction: row; flex-wrap: wrap; align-items: center; }
  .search-wrap { flex: 1; min-width: 200px; }
  .filter-row { flex: 1; display: contents; }

  .form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 18px; padding: 24px 24px; }
  .span-2 { grid-column: span 1; }
  .span-4 { grid-column: span 2; }
  .form-row { display: contents; }

  .section-header { padding: 24px 24px 18px; gap: 16px; }
  .section-num { font-size: 42px; }
  .section-title { font-size: 22px; }
  .form-nav { padding: 16px 24px; }
  .review-panel { margin: 0 24px 20px; }
  .submit-declaration { padding: 0 24px 20px; }

  .card-header { padding: 16px 20px 14px; }
  .prose-content { padding: 16px 20px; }
  .info-grid { grid-template-columns: repeat(3, 1fr); padding: 16px 20px; }
  .comment-inputs { flex-direction: row; }
  .comment-form { padding: 16px 20px; }
  .comments-list { padding: 6px 20px; }
  .analyst-details { padding: 16px 20px; }
  .analyst-actions { padding: 14px 20px; }
  .analyst-note { margin: 14px 20px 0; }
  .benefits-list { padding: 12px 20px; }
  .sig-display { padding: 16px 20px; }

  .quote-summary { grid-template-columns: repeat(4, 1fr); }

  .recommendation-buttons { grid-template-columns: repeat(4, 1fr); }

  /* Show table, hide card list */
  .requests-table { display: table; width: 100%; border-collapse: collapse; }
  .card-list { display: none; }
  .requests-table thead { background: var(--ink); }
  .requests-table th { padding: 12px 14px; text-align: left; font-size: 11px; font-weight: 700; color: var(--ink-5); letter-spacing: .06em; text-transform: uppercase; }
  .table-row { border-bottom: 1px solid var(--bg-2); cursor: pointer; transition: background .1s; }
  .table-row:hover { background: var(--bg); }
  .table-row:last-child { border-bottom: none; }
  .requests-table td { padding: 12px 14px; font-size: 14px; vertical-align: middle; }
  .td-id { font-family: var(--font-display); font-size: 15px; color: var(--ink-4); }
  .td-title .title-cell { font-weight: 600; }
  .td-title .dept-cell { font-size: 11px; color: var(--ink-5); margin-top: 1px; }
  .requester-name { font-weight: 500; }
  .requester-email { font-size: 11px; color: var(--ink-5); }
  .td-date { font-size: 11px; color: var(--ink-4); white-space: nowrap; }
  .action-link { color: var(--accent); font-size: 12px; font-weight: 600; }

  .sig-canvas { height: 180px; }
}

/* ══════════════════════════════════════════════════════════════
   DESKTOP  ≥ 1024px
══════════════════════════════════════════════════════════════ */
@media (min-width: 1024px) {
  .main-content { padding: 32px 24px 80px; }
  .navbar { padding: 0 32px; height: 64px; }
  .nav-link { font-size: 14px; }

  .page-header {
    flex-direction: row; align-items: flex-start;
    justify-content: space-between; margin-bottom: 28px;
  }

  .detail-layout {
    display: grid; grid-template-columns: 1fr 280px;
    align-items: start; gap: 24px;
  }
  .detail-sidebar { position: sticky; top: calc(64px + 20px); }

  .form-grid { grid-template-columns: repeat(4, 1fr); gap: 20px; padding: 28px 28px; }
  .span-2 { grid-column: span 2; }
  .span-4 { grid-column: span 4; }

  .sig-canvas { height: 200px; }
}

/* ── Role indicators ────────────────────────────────────────── */
.role-badge { display: flex; align-items: center; }

.analyst-banner {
  background: linear-gradient(135deg, #ede9fe, #dbeafe);
  border: 1px solid #c4b5fd;
  border-radius: var(--radius-lg);
  padding: 10px 16px;
  display: flex; align-items: center; gap: 10px;
  margin-bottom: 16px;
  font-size: 13px; color: #5b21b6;
}
.analyst-banner strong { font-weight: 700; }

.locked-notice {
  background: var(--bg);
  border: 1.5px dashed var(--bg-3);
  border-radius: var(--radius-lg);
  padding: 24px;
  text-align: center;
  color: var(--ink-5);
}
.locked-notice .lock-icon { font-size: 28px; margin-bottom: 8px; }
.locked-notice p { font-size: 14px; line-height: 1.6; }

/* ═══════════════════════════════════════════════════════════════
   AUTH & USER SYSTEM STYLES
═══════════════════════════════════════════════════════════════ */

/* ── Login page ────────────────────────────────────────────── */
.login-body {
  background: var(--ink);
  display: flex; flex-direction: column;
  align-items: center; justify-content: center;
  min-height: 100dvh; padding: 24px 16px;
}
.login-wrap { width: 100%; max-width: 400px; }
.login-card {
  background: var(--white);
  border-radius: var(--radius-xl);
  padding: 36px 28px;
  box-shadow: 0 20px 60px rgba(0,0,0,.4);
}
.login-brand { text-align: center; margin-bottom: 28px; }
.login-logo {
  width: 52px; height: 52px; margin: 0 auto 12px;
  background: var(--accent); border-radius: 12px;
  display: flex; align-items: center; justify-content: center;
  font-size: 26px; color: white;
}
.login-title {
  font-family: var(--font-display);
  font-size: 28px; font-style: italic; color: var(--ink);
  margin-bottom: 4px;
}
.login-sub { font-size: 13px; color: var(--ink-5); }
.login-form { display: flex; flex-direction: column; gap: 16px; }
.login-footer { text-align: center; margin-top: 20px; font-size: 12px; color: var(--ink-5); }

/* Password toggle */
.pw-wrap { position: relative; }
.pw-toggle {
  position: absolute; right: 12px; top: 50%; transform: translateY(-50%);
  background: none; border: none; cursor: pointer; color: var(--ink-5);
  padding: 4px;
}
.pw-toggle:hover { color: var(--ink-3); }

/* ── Alerts ────────────────────────────────────────────────── */
.alert {
  padding: 12px 16px; border-radius: var(--radius);
  font-size: 14px; display: flex; align-items: flex-start; gap: 8px;
}
.alert-error   { background: var(--red-light);   color: #7f1d1d; border-left: 3px solid var(--red); }
.alert-success { background: var(--green-light);  color: #14532d; border-left: 3px solid var(--green); }
.alert-info    { background: var(--accent-light); color: var(--accent-dark); border-left: 3px solid var(--accent); }

/* ── Flash message (top of page) ───────────────────────────── */
.flash-msg {
  background: var(--green);
  color: white;
  padding: 12px 20px;
  display: flex; align-items: center; justify-content: space-between;
  font-size: 14px; font-weight: 500;
  animation: slideDown .3s ease;
}
@keyframes slideDown { from { transform: translateY(-100%); opacity: 0; } to { transform: none; opacity: 1; } }
.flash-close {
  background: none; border: none; color: rgba(255,255,255,.7);
  font-size: 18px; cursor: pointer; line-height: 1; padding: 0 4px;
}
.flash-close:hover { color: white; }

/* ── Nav user menu & dropdown ──────────────────────────────── */
.nav-user-menu { position: relative; }
.nav-user-btn {
  display: flex; align-items: center; gap: 6px;
  background: rgba(255,255,255,.08);
  border: 1px solid rgba(255,255,255,.12);
  border-radius: var(--radius);
  padding: 6px 10px;
  cursor: pointer; color: var(--white);
  min-height: var(--touch);
  -webkit-tap-highlight-color: transparent;
}
.nav-user-btn:hover { background: rgba(255,255,255,.14); }
.nav-avatar {
  width: 26px; height: 26px;
  background: var(--accent); color: white;
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-size: 12px; font-weight: 700; flex-shrink: 0;
}
.nav-username { font-size: 13px; max-width: 120px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.nav-role-chip {
  font-size: 10px; font-weight: 700;
  background: rgba(255,255,255,.15);
  border-radius: 4px; padding: 2px 6px;
  text-transform: uppercase; letter-spacing: .04em;
  display: none;
}
.nav-dropdown {
  position: absolute; right: 0; top: calc(100% + 6px);
  background: var(--white);
  border: 1px solid var(--bg-3);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  min-width: 200px; z-index: 300;
  display: none; overflow: hidden;
}
.nav-dropdown.open { display: block; animation: fadeIn .15s ease; }
.nav-drop-item {
  display: block; padding: 11px 16px;
  font-size: 14px; color: var(--ink-2);
  transition: background .1s;
  text-decoration: none;
}
.nav-drop-item:hover { background: var(--bg); text-decoration: none; }
.nav-drop-sep { height: 1px; background: var(--bg-2); margin: 4px 0; }
.nav-drop-danger { color: var(--red); }
.nav-drop-danger:hover { background: var(--red-light); }

/* ── Profile layout ────────────────────────────────────────── */
.profile-layout {
  display: flex; flex-direction: column; gap: 20px;
}

/* ── Admin users table ─────────────────────────────────────── */
.users-table { width: 100%; border-collapse: collapse; }
.users-table th {
  padding: 10px 14px; text-align: left;
  font-size: 11px; font-weight: 700; color: var(--ink-5);
  text-transform: uppercase; letter-spacing: .05em;
  background: var(--ink); white-space: nowrap;
}
.users-table td { padding: 12px 14px; font-size: 14px; vertical-align: middle; border-bottom: 1px solid var(--bg-2); }
.users-table tr:last-child td { border-bottom: none; }
.users-table tr:hover td { background: var(--bg); }

/* Role badge colors */
.role-user     { background: var(--accent-light); color: var(--accent-dark); }
.role-analyst  { background: var(--purple-light); color: #5b21b6; }
.role-sysadmin { background: var(--amber-light);  color: #78350f; }
.role-admin    { background: var(--red-light);    color: #7f1d1d; }

/* Approver / requester flags */
.flag-yes { color: var(--green); font-weight: 700; }
.flag-no  { color: var(--ink-5); }

/* ── Approver sidebar card ─────────────────────────────────── */
.approver-actions { display: flex; gap: 6px; flex-wrap: wrap; }

/* ── Responsive additions ──────────────────────────────────── */
@media (min-width: 640px) {
  .nav-role-chip { display: inline-block; }
  .profile-layout { display: grid; grid-template-columns: 1fr 320px; gap: 24px; align-items: start; }
}

@media (min-width: 1024px) {
  .nav-username { max-width: 160px; }
}

/* ── Signature display on detail page ───────────────────────── */
.sig-display {
  padding: 14px 16px;
  border-top: 1px solid var(--bg-2);
}

.sig-image-wrap {
  background: #fff;
  border: 1.5px solid var(--bg-3);
  border-radius: var(--radius);
  padding: 10px 14px;
  display: inline-block;
  max-width: 100%;
  margin-bottom: 8px;
}

.sig-image {
  display: block;
  max-height: 100px;
  max-width: 100%;
  object-fit: contain;
}

.sig-name {
  font-size: 12px;
  color: var(--green);
  display: flex;
  align-items: center;
  gap: 4px;
}

.sig-missing {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  color: var(--amber);
  padding: 8px 12px;
  background: var(--amber-light);
  border-radius: var(--radius);
}
.sig-missing-icon { font-size: 16px; }

@media (min-width: 640px) {
  .sig-display { padding: 16px 20px; }
}

/* ═══════════════════════════════════════════════════════════════
   PRINT STYLES
   Everything tagged .no-print is hidden.
   .print-only elements are shown only when printing.
═══════════════════════════════════════════════════════════════ */

/* ── Print button (screen only) ─────────────────────────────── */
.btn-print {
  background: var(--ink);
  color: #fff;
  display: inline-flex;
  align-items: center;
  gap: 6px;
}
.btn-print:hover { background: var(--ink-2); color: #fff; }
.btn-print svg { width: 15px; height: 15px; }

/* ── Print-only elements (hidden on screen) ─────────────────── */
.print-only { display: none !important; }

/* ── Print media query ───────────────────────────────────────── */
@media print {
  /* Reset page */
  * { -webkit-print-color-adjust: exact !important; print-color-adjust: exact !important; }

  html, body {
    background: #fff !important;
    font-size: 11pt;
    color: #000;
  }

  /* Hide everything interactive / navigational */
  .navbar,
  .footer,
  .no-print,
  .btn,
  .btn-print,
  .btn-approve,
  .btn-reject,
  .btn-ghost,
  .btn-secondary,
  .btn-submit,
  .header-actions,
  .status-form,
  .approver-actions,
  .analyst-form-card,
  .comment-form,
  .flash-msg,
  .nav-dropdown,
  .detail-sidebar,
  .analyst-actions,
  .toggle-icon,
  form[action$="/status"],
  form[action$="/comment"] {
    display: none !important;
  }

  /* Full-width main content — no sidebar */
  .main-content {
    max-width: 100% !important;
    padding: 0 !important;
    margin: 0 !important;
  }

  .detail-layout {
    display: block !important;
  }

  .detail-main {
    display: block !important;
  }

  /* Page header: keep title and badges, hide action buttons */
  .page-header {
    display: block !important;
    margin-bottom: 18pt !important;
    border-bottom: 2pt solid #0f1117;
    padding-bottom: 10pt;
  }

  .page-title { font-size: 18pt !important; font-style: italic; }
  .breadcrumb { font-size: 9pt; color: #666; margin-bottom: 4pt; }
  .request-meta { display: flex !important; gap: 6pt; flex-wrap: wrap; margin-top: 6pt; }

  /* Cards: clean bordered boxes */
  .detail-card {
    box-shadow: none !important;
    border: 1pt solid #ddd !important;
    border-radius: 4pt !important;
    margin-bottom: 10pt !important;
    break-inside: avoid;
    page-break-inside: avoid;
  }

  .card-header {
    background: #f5f5f5 !important;
    padding: 6pt 10pt !important;
    border-bottom: 1pt solid #ddd !important;
  }

  .card-title { font-size: 11pt !important; }

  .prose-content {
    padding: 8pt 10pt !important;
    font-size: 10pt !important;
    line-height: 1.5 !important;
  }

  .info-grid {
    padding: 8pt 10pt !important;
    grid-template-columns: repeat(3, 1fr) !important;
  }

  .info-label { font-size: 8pt !important; }
  .info-value { font-size: 10pt !important; }

  /* Signature */
  .sig-display {
    padding: 8pt 10pt !important;
    border-top: 1pt solid #ddd !important;
  }

  .sig-image { max-height: 70pt !important; }

  /* Benefits list */
  .benefits-list { padding: 6pt 10pt !important; }
  .benefit-row { padding: 4pt 0 !important; }
  .benefit-text { font-size: 10pt !important; }

  /* Analyst quote summary */
  .quote-summary {
    grid-template-columns: repeat(4, 1fr) !important;
    border: 1pt solid #ddd;
  }
  .quote-metric { padding: 8pt !important; }
  .quote-metric-value { font-size: 13pt !important; }
  .quote-metric-label { font-size: 8pt !important; }
  .analyst-details { padding: 8pt 10pt !important; }
  .analyst-section { margin-bottom: 8pt !important; }
  .analyst-section-title { font-size: 8pt !important; }

  /* Comments — print them */
  .comments-list { padding: 4pt 10pt !important; }
  .comment { padding: 6pt 0 !important; border-bottom: 0.5pt solid #eee !important; }
  .comment-author { font-size: 10pt !important; }
  .comment-body { font-size: 10pt !important; }
  .comment-date { font-size: 8pt !important; }

  /* Badges */
  .badge {
    border: 0.5pt solid #ccc !important;
    background: #f5f5f5 !important;
    color: #000 !important;
    font-size: 8pt !important;
  }

  /* Print header (shown only when printing) */
  .print-only {
    display: block !important;
    font-size: 8pt;
    color: #666;
    margin-bottom: 4pt;
  }

  .print-header {
    display: flex !important;
    justify-content: space-between;
    align-items: flex-start;
    margin-bottom: 12pt;
    padding-bottom: 8pt;
    border-bottom: 2pt solid #0f1117;
  }

  .print-header-logo {
    font-size: 16pt;
    font-weight: bold;
    font-style: italic;
    color: #0f1117;
    font-family: Georgia, serif;
  }

  .print-header-meta {
    text-align: right;
    font-size: 8pt;
    color: #444;
    line-height: 1.6;
  }

  /* Don't break analyst card across pages */
  .analyst-card { page-break-before: auto; break-before: auto; }

  /* Signature block gets its own line */
  .sig-display { display: block !important; }
  .sig-image-wrap { display: inline-block !important; }
}
