/* ==========================================================================
   AMAG Engineering Portal — shared design system
   One token set, reused by every page (auth, wiki/dashboard, quote builder).
   Colors below are verified against WCAG 2.1 AA (4.5:1 body text minimum).
   ========================================================================== */

:root {
  /* Brand */
  --navy: #0f2438;
  --navy-2: #16324a;
  --navy-3: #1c3f5c;
  --accent: #c8372e;
  --accent-dark: #a52a22;
  --accent-soft: #fbeceb;

  /* Neutrals */
  --paper: #f5f6f8;
  --card: #ffffff;
  --line: #e1e5ea;
  --ink: #1b2530;
  --ink-soft: #5b6b7a;   /* 5.5:1 on white/paper — safe for body-weight text */

  /* Semantic status (each paired with an icon + text in markup, never color alone) */
  --good: #1c7a4d;
  --good-soft: #e8f5ee;
  --warn: #8a5a00;       /* darkened from sample's #a06a00 for a safer AA margin */
  --warn-soft: #fff4e0;
  --info: #1a56db;
  --info-soft: #e8eefc;

  /* Geometry */
  --radius: 8px;
  --radius-sm: 6px;
  --sidebar-w: 260px;

  /* Type */
  --font-sans: -apple-system, "Segoe UI", Helvetica, Arial, sans-serif;
  --mono: "SF Mono", "Consolas", "Menlo", monospace;

  /* Elevation */
  --shadow-card: 0 1px 2px rgba(15, 36, 56, 0.06);
  --shadow-modal: 0 20px 60px rgba(0, 0, 0, 0.25);
}

/* ---------- Reset / base ---------- */
*, *::before, *::after { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font-family: var(--font-sans);
  background: var(--paper);
  color: var(--ink);
  font-size: 15px;
  line-height: 1.55;
}
h1, h2, h3, h4 { line-height: 1.25; margin: 0; }
p { margin: 0 0 12px; }
img { max-width: 100%; display: block; }
a { color: var(--accent); }
a:hover { color: var(--accent-dark); }

/* ---------- Accessibility primitives ---------- */
.skip-link {
  position: absolute;
  left: 12px;
  top: -60px;
  background: var(--navy);
  color: #fff;
  padding: 10px 16px;
  border-radius: var(--radius-sm);
  font-weight: 700;
  font-size: 13.5px;
  z-index: 2000;
  transition: top .15s ease;
}
.skip-link:focus { top: 12px; }

.sr-only {
  position: absolute;
  width: 1px; height: 1px;
  padding: 0; margin: -1px;
  overflow: hidden;
  clip: rect(0,0,0,0);
  white-space: nowrap;
  border: 0;
}

/* Never remove a focus indicator without replacing it. */
:focus-visible {
  outline: 3px solid var(--accent);
  outline-offset: 2px;
  border-radius: 4px;
}
input:focus-visible, select:focus-visible, textarea:focus-visible {
  outline: 3px solid var(--accent);
  outline-offset: 0;
}

/* ---------- App shell (dashboard + quote builder) ---------- */
.app-shell {
  display: grid;
  grid-template-columns: var(--sidebar-w) 1fr;
  min-height: 100vh;
}

.sidebar {
  background: linear-gradient(180deg, var(--navy), var(--navy-2) 60%, var(--navy-3));
  color: #dce7ef;
  padding: 18px 0;
  position: sticky;
  top: 0;
  height: 100vh;
  overflow-y: auto;
}
.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 0 18px 16px;
  border-bottom: 1px solid rgba(255,255,255,0.12);
  margin-bottom: 10px;
}
.brand-mark {
  width: 34px;
  height: 34px;
  border-radius: 8px;
  background: var(--accent);
  color: #fff;
  font-weight: 800;
  font-size: 13px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}
.brand-text .name { font-weight: 700; font-size: 15px; color: #fff; }
.brand-text .tag { font-size: 11px; color: #93a9ba; font-family: var(--mono); }

.nav-group-label {
  font-size: 10.5px;
  text-transform: uppercase;
  letter-spacing: .08em;
  color: #7d93a3;
  padding: 16px 18px 6px;
}
.nav-list { list-style: none; margin: 0; padding: 0; }
.nav-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}
.nav-link {
  flex: 1;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 18px;
  color: #c7d6e1;
  text-decoration: none;
  font-size: 13.5px;
  border-left: 3px solid transparent;
}
.nav-link:hover { background: rgba(255,255,255,0.08); color: #fff; }
.nav-link[aria-current="page"] {
  background: rgba(255,255,255,0.10);
  color: #fff;
  border-left-color: var(--accent);
  font-weight: 600;
}
.nav-link.is-disabled {
  color: #6f8695;
  cursor: default;
  pointer-events: none;
}
.nav-icon { width: 16px; text-align: center; flex-shrink: 0; }
.nav-soon {
  font-size: 9.5px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .04em;
  color: #93a9ba;
  border: 1px solid rgba(255,255,255,0.18);
  border-radius: 20px;
  padding: 2px 7px;
  margin-right: 14px;
  flex-shrink: 0;
}

.sidebar-toggle {
  display: none;
  position: fixed;
  top: 12px;
  left: 12px;
  z-index: 1500;
  background: var(--navy);
  color: #fff;
  border: none;
  border-radius: var(--radius-sm);
  width: 40px;
  height: 40px;
  font-size: 18px;
  cursor: pointer;
}

.main { min-width: 0; }
.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  background: var(--card);
  border-bottom: 1px solid var(--line);
  padding: 12px 24px;
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
}
.topbar h1 { font-size: 16px; font-weight: 700; margin-right: auto; }
.topbar-crumb { font-size: 12px; color: var(--ink-soft); margin-right: auto; }
.topbar-crumb strong { color: var(--ink); }

.user-chip {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  font-weight: 600;
  color: var(--ink);
  padding: 6px 10px 6px 6px;
  border-radius: 20px;
  border: 1px solid var(--line);
}
.user-avatar {
  width: 26px; height: 26px;
  border-radius: 50%;
  background: var(--navy-2);
  color: #fff;
  font-size: 11px;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
}

.content { padding: 24px 28px; max-width: 1180px; }

/* ---------- Buttons ---------- */
.btn {
  border: 1px solid var(--line);
  background: #fff;
  color: var(--ink);
  padding: 8px 14px;
  border-radius: var(--radius);
  font-size: 13px;
  font-weight: 600;
  font-family: inherit;
  cursor: pointer;
  white-space: nowrap;
}
.btn:hover { border-color: #c3cbd3; background: #fafbfc; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn.primary:hover { background: var(--accent-dark); }
.btn.info { background: var(--info); border-color: var(--info); color: #fff; }
.btn.ghost { background: transparent; }
.btn.small { padding: 6px 11px; font-size: 12px; }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn-block { width: 100%; }

/* ---------- Cards & headings ---------- */
.page-head { margin-bottom: 20px; }
.page-head h2 { font-size: 22px; font-weight: 700; margin-bottom: 4px; }
.page-head p { color: var(--ink-soft); font-size: 14px; max-width: 760px; margin: 0; }

.card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 20px 22px;
  margin-bottom: 16px;
  box-shadow: var(--shadow-card);
}
.card h3 {
  font-size: 12.5px;
  text-transform: uppercase;
  letter-spacing: .05em;
  color: var(--ink-soft);
  margin-bottom: 14px;
}

.grid { display: grid; gap: 14px; }
.grid.cols-2 { grid-template-columns: 1fr 1fr; }
.grid.cols-3 { grid-template-columns: 1fr 1fr 1fr; }
@media (max-width: 860px) {
  .grid.cols-2, .grid.cols-3 { grid-template-columns: 1fr; }
}

/* ---------- Forms ---------- */
.field { margin-bottom: 16px; }
.field label {
  display: block;
  font-size: 12.5px;
  font-weight: 600;
  color: var(--ink-soft);
  margin-bottom: 5px;
}
.field .req-star { color: var(--accent-dark); }
.field input, .field select, .field textarea {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  font-size: 14px;
  font-family: inherit;
  color: var(--ink);
  background: #fff;
}
.field .hint { font-size: 12px; color: var(--ink-soft); margin-top: 4px; }
.field.has-error input { border-color: var(--accent-dark); }
.field.has-error label { color: var(--accent-dark); }
.field-error {
  display: flex;
  align-items: flex-start;
  gap: 6px;
  font-size: 12.5px;
  color: var(--accent-dark);
  margin-top: 5px;
}

.password-field { position: relative; }
.password-field input { padding-right: 44px; }
.password-toggle {
  position: absolute;
  right: 6px;
  top: 6px;
  bottom: 6px;
  width: 34px;
  border: none;
  background: transparent;
  color: var(--ink-soft);
  cursor: pointer;
  border-radius: var(--radius-sm);
  font-size: 13px;
}
.password-toggle:hover { background: var(--paper); color: var(--ink); }

/* ---------- Status: icon + text, never color alone ---------- */
.status-banner {
  display: flex;
  gap: 10px;
  align-items: flex-start;
  padding: 12px 14px;
  border-radius: var(--radius-sm);
  font-size: 13.5px;
  border: 1px solid transparent;
  margin-bottom: 16px;
}
.status-banner.error { background: var(--accent-soft); border-color: #eec6c3; color: var(--accent-dark); }
.status-banner.warn { background: var(--warn-soft); border-color: #edd6a3; color: var(--warn); }
.status-banner.good { background: var(--good-soft); border-color: #bfe3d0; color: var(--good); }
.status-banner .icon { flex-shrink: 0; margin-top: 1px; }
.status-banner strong { font-weight: 700; }

.badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 3px 9px;
  border-radius: 20px;
  font-size: 11px;
  font-weight: 700;
}
.badge.draft { background: #eef0f2; color: #5b6673; }
.badge.pending { background: var(--warn-soft); color: var(--warn); }
.badge.approved { background: var(--good-soft); color: var(--good); }
.badge.sent { background: var(--info-soft); color: var(--info); }

/* ---------- Data table (quote builder) ---------- */
table.data-table { width: 100%; border-collapse: collapse; font-size: 13px; }
table.data-table th {
  text-align: left;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: .04em;
  color: var(--ink-soft);
  border-bottom: 1px solid var(--line);
  padding: 8px;
  white-space: nowrap;
  position: sticky;
  top: 0;
  background: #fff;
}
table.data-table td { padding: 8px; border-bottom: 1px solid #eef0f3; vertical-align: middle; }
table.data-table td.num, table.data-table th.num { text-align: right; font-family: var(--mono); }
table.data-table tr.subtotal-row td { font-weight: 700; border-top: 2px solid var(--navy); background: #fbfbfc; }

.totals-bar {
  display: flex;
  gap: 24px;
  flex-wrap: wrap;
  align-items: baseline;
  padding: 16px 20px;
  background: var(--navy);
  color: #fff;
  border-radius: var(--radius);
}
.totals-bar .tb-item .l { font-size: 11px; color: #9db2c1; text-transform: uppercase; letter-spacing: .05em; }
.totals-bar .tb-item .v { font-size: 20px; font-weight: 800; font-family: var(--mono); }
.totals-bar .tb-item.grand .v { color: #ffd8d5; }

/* ---------- Wizard / step indicator ---------- */
.steps {
  display: flex;
  gap: 6px;
  list-style: none;
  margin: 0 0 20px;
  padding: 0;
}
.steps li {
  flex: 1;
  text-align: center;
  font-size: 12px;
  font-weight: 600;
  color: var(--ink-soft);
  padding: 8px 6px;
  border-bottom: 3px solid var(--line);
}
.steps li.is-current { color: var(--navy); border-bottom-color: var(--accent); }
.steps li.is-done { color: var(--good); }

/* ---------- Auth page ---------- */
.auth-shell {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: radial-gradient(circle at top, var(--navy-3), var(--navy) 65%);
  padding: 24px;
}
.auth-card {
  width: 100%;
  max-width: 400px;
  background: var(--card);
  border-radius: 12px;
  padding: 34px 32px 28px;
  box-shadow: var(--shadow-modal);
}
.auth-brand {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 22px;
}
.auth-brand .brand-text .name { color: var(--navy); }
.auth-brand .brand-text .tag { color: var(--ink-soft); }
.auth-card h2 { font-size: 19px; margin-bottom: 4px; }
.auth-card > p.lead { color: var(--ink-soft); font-size: 13.5px; margin-bottom: 22px; }
.auth-footnote {
  text-align: center;
  font-size: 12px;
  color: var(--ink-soft);
  margin-top: 18px;
}
.auth-footer {
  text-align: center;
  font-size: 11.5px;
  color: rgba(255,255,255,0.65);
  margin-top: 20px;
}

/* ---------- Wiki cards ---------- */
.wiki-list { list-style: none; margin: 0; padding: 0; }
.wiki-list li + li { border-top: 1px solid var(--line); }
.wiki-row {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 12px 2px;
  text-decoration: none;
  color: inherit;
}
.wiki-row:hover .wiki-title { color: var(--accent); }
.wiki-row .wiki-icon {
  width: 34px; height: 34px;
  border-radius: 8px;
  background: var(--paper);
  color: var(--navy);
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
  font-weight: 700;
  font-size: 12px;
}
.wiki-title { font-weight: 600; font-size: 14px; color: var(--ink); }
.wiki-meta { font-size: 12px; color: var(--ink-soft); }

.tool-card {
  display: flex;
  flex-direction: column;
  gap: 10px;
  text-decoration: none;
  color: inherit;
}
.tool-card .tool-icon {
  width: 38px; height: 38px;
  border-radius: 9px;
  background: var(--accent-soft);
  color: var(--accent-dark);
  display: flex; align-items: center; justify-content: center;
  font-weight: 800;
}
.tool-card h4 { font-size: 15px; color: var(--ink); }
.tool-card p { font-size: 13px; color: var(--ink-soft); margin: 0; }

/* ---------- Print (quote builder) ---------- */
@media print {
  .sidebar, .topbar, .no-print { display: none !important; }
  .app-shell { display: block; }
  .content { padding: 0; max-width: 100%; }
}

/* ---------- Responsive ---------- */
@media (max-width: 900px) {
  .app-shell { grid-template-columns: 1fr; }
  .sidebar {
    position: fixed;
    left: -280px;
    width: 260px;
    z-index: 1400;
    transition: left .18s ease;
    box-shadow: var(--shadow-modal);
  }
  .sidebar.is-open { left: 0; }
  .sidebar-toggle { display: block; }
  .topbar { padding-left: 60px; }
}
