/* ============================================================
   Ayotta ISMS & QMS Hub — v2 (platform-aligned)
   Matches the ayotta-platform-* family visual language:
   orange accent + deep navy + warm surfaces + Geist + pill buttons.
   Loaded AFTER styles.css + register.css; overrides legacy v1.
   ============================================================ */

/* ---- Body / page chrome ---- */
body {
  background: var(--warm);
  color: var(--text);
  line-height: 1.5;
}

/* ---- Top utility bar (warm-paper, matches ayotta-tech.com utility row) ---- */
.top-bar {
  min-height: 56px;
  padding: 10px 28px;
  background: var(--warm);
  color: var(--text);
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: 1px solid var(--line);
  font-family: var(--font-mono);
  font-size: 11px;
  letter-spacing: 0.06em;
  gap: 14px;
  flex-wrap: nowrap;
  box-shadow: none;
}
.top-bar .brand {
  font-family: var(--font);
  font-size: 14px;
  font-weight: 700;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--text);
}
.top-bar .brand-sub {
  font-family: var(--font-mono);
  font-size: 10.5px;
  color: var(--text-faint);
  letter-spacing: 0.14em;
  text-transform: uppercase;
  margin-top: 2px;
  font-weight: 500;
}
.top-right { gap: 14px; font-size: 12px; color: var(--text-dim); }
.top-right a, .top-right button { color: var(--text); }
.hub-mobile-btn {
  background: transparent;
  border: 1px solid var(--line);
  border-radius: var(--r-pill);
  padding: 4px 12px;
  color: var(--text);
}
.hub-mobile-btn:hover { border-color: var(--text); }

/* ---- Sidebar — matches admin.ayotta-tech.com style ---- */
.hub-sidebar {
  /* layout — js-injected CSS handles the visual style */
  width: 240px;
  flex-shrink: 0;
  position: sticky;
  top: 0;
  height: 100vh;
  overflow-y: auto;
  scrollbar-width: thin;
  scrollbar-color: rgba(120,110,90,0.25) transparent;
}
.hub-sidebar::-webkit-scrollbar { width: 7px; }
.hub-sidebar::-webkit-scrollbar-thumb { background: rgba(120,110,90,0.25); border-radius: 4px; }
.hub-sidebar::-webkit-scrollbar-track { background: transparent; }
.sb-section { margin: 0; }

/* ---- Main content ---- */
.hub-main { background: var(--warm); }
.wrap { max-width: 1280px; padding: 28px 32px; }

/* ---- Cards (more rounded, lighter borders, soft shadow) ---- */
.card {
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: var(--r-lg);
  box-shadow: var(--shadow-xs);
  padding: 26px 30px;
  margin-bottom: 16px;
}
.card h2 {
  color: var(--text);
  font-size: 24px;
  font-weight: 600;
  letter-spacing: -0.02em;
  margin-bottom: 6px;
}
.card h3 {
  color: var(--text);
  font-size: 14px;
  font-weight: 600;
  margin: 14px 0 6px;
  letter-spacing: -0.005em;
}
.muted { color: var(--text-dim); font-size: 14px; }

/* ---- Buttons — pills ---- */
.btn-primary, .btn-secondary, .btn-ghost, .btn-link {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-family: var(--font);
  font-weight: 600;
  border: 2px solid transparent;
  cursor: pointer;
  transition: all 0.18s ease;
  border-radius: var(--r-pill);
  letter-spacing: -0.005em;
  white-space: nowrap;
}
.btn-primary {
  background: var(--orange);
  color: var(--paper);
  border-color: var(--orange);
  padding: 11px 22px;
  font-size: 14px;
  width: auto;
  margin-bottom: 0;
  box-shadow: var(--shadow-xs);
}
.btn-primary:hover { background: var(--orange-dark); border-color: var(--orange-dark); transform: translateY(-1px); }
.btn-secondary {
  background: var(--navy);
  color: var(--paper);
  border-color: var(--navy);
  padding: 11px 22px;
  font-size: 14px;
}
.btn-secondary:hover { background: var(--navy-soft); border-color: var(--navy-soft); transform: translateY(-1px); }
.btn-ghost {
  background: transparent;
  border-color: var(--line);
  color: var(--text);
  padding: 8px 16px;
  font-size: 13px;
}
.btn-ghost:hover { border-color: var(--text); background: var(--paper); }
.btn-link {
  background: rgba(255,255,255,0.08);
  border-color: rgba(255,255,255,0.20);
  color: white;
  padding: 5px 12px;
  font-size: 11.5px;
  font-weight: 500;
}
.btn-link:hover { background: rgba(255,255,255,0.16); }

/* ---- Form fields ---- */
.field label {
  font-family: var(--font-mono);
  font-size: 10.5px;
  font-weight: 500;
  letter-spacing: 0.12em;
  color: var(--text-dim);
  text-transform: uppercase;
}
.field input, .field select, input[type="text"], input[type="date"], input[type="datetime-local"], select, textarea {
  border: 1px solid var(--line);
  border-radius: var(--r-sm);
  padding: 10px 14px;
  font-size: 14px;
  background: var(--paper);
  color: var(--text);
  font-family: var(--font);
}
.field input:focus, .field select:focus, input:focus, select:focus, textarea:focus {
  outline: none;
  border-color: var(--orange);
  box-shadow: 0 0 0 3px var(--orange-soft);
}

/* ---- Auth / sign-in box (legacy state) ---- */
.auth-box {
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: var(--r-xl);
  box-shadow: var(--shadow-lg);
  padding: 40px 44px;
}
.auth-box .logo {
  font-family: var(--font);
  color: var(--text);
  font-size: 22px;
  font-weight: 800;
  letter-spacing: 0.04em;
}
.auth-box .logo-sub {
  font-family: var(--font-mono);
  color: var(--orange);
  font-size: 10.5px;
  letter-spacing: 0.18em;
  font-weight: 500;
  text-transform: uppercase;
  margin: 4px 0 24px;
}

/* ---- Tables (dense, modern, mono headers) ---- */
.reg-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13.5px;
}
.reg-table thead th {
  background: var(--warm-2);
  color: var(--text-dim);
  font-family: var(--font-mono);
  font-weight: 500;
  font-size: 10.5px;
  text-transform: uppercase;
  letter-spacing: 0.10em;
  padding: 10px 12px;
  text-align: left;
  border-bottom: 1px solid var(--line);
}
.reg-table tbody td {
  padding: 11px 12px;
  border-bottom: 1px solid var(--line-soft);
  color: var(--text);
  vertical-align: top;
}
.reg-table tbody tr:hover { background: var(--warm); }
.reg-table tbody tr.row-overdue { background: var(--status-red-50); }
.reg-table tbody tr.row-overdue:hover { background: #FBDCD6; }

/* ---- KPIs + metric tiles ---- */
/* .kpis is the grid container used by actions/intern-dashboard/soa etc;
   unified here so those pages are styled even without page-local CSS. */
.kpi-row, .metric-row, .kpis {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: 12px;
  margin-bottom: 16px;
}
.kpi, .metric-tile, .stat, .kpi-card {
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: var(--r-md);
  box-shadow: var(--shadow-xs);
  padding: 16px 18px;
  border-left: 3px solid var(--orange);
}
/* Clickable KPI affordance — pages add class "clickable" + a JS onclick. */
.kpi.clickable, .metric-tile.clickable, .stat.clickable, .kpi-card.clickable { cursor: pointer; transition: transform .1s, box-shadow .1s, border-color .1s; }
.kpi.clickable:hover, .metric-tile.clickable:hover, .stat.clickable:hover, .kpi-card.clickable:hover { transform: translateY(-2px); box-shadow: 0 8px 22px -10px rgba(0,0,0,.25); border-left-color: var(--navy, #0E1B33); }
.kpi.active, .metric-tile.active, .stat.active, .kpi-card.active { border-color: var(--orange); border-left-color: var(--orange); box-shadow: inset 0 0 0 1px var(--orange); }
/* Child label/value — cover every naming convention used across pages so
   none render as unstyled stacked text. */
.kpi .lbl, .kpi .kpi-label, .kpis .kpi .lbl, .kpi-card .kpi-label {
  font-size: 10.5px; color: var(--muted, #6b7280); text-transform: uppercase; letter-spacing: .06em; font-weight: 600;
}
.kpi .val, .kpi .kpi-val, .kpi-card .kpi-val, .kpi-card .kpi-value {
  font-size: 26px; font-weight: 800; color: var(--navy, #0E1B33); letter-spacing: -0.02em; margin-top: 4px; line-height: 1;
}
.kpi.warn .val, .kpi.warn .kpi-val { color: var(--status-amber, #d97706); }
.kpi.danger .val, .kpi.danger .kpi-val { color: var(--status-red, #dc2626); }
.kpi.good .val, .kpi.good .kpi-val { color: var(--status-green, #16a34a); }
.kpi.good, .metric-tile.good, .stat.good { border-left-color: var(--status-green); }
.kpi.warn, .metric-tile.warn, .stat.warn { border-left-color: var(--status-amber); }
.kpi.danger, .metric-tile.danger, .stat.danger { border-left-color: var(--status-red); }
.metric-tile .lab, .stat-label {
  font-family: var(--font-mono);
  color: var(--text-faint);
  font-size: 10.5px;
  letter-spacing: 0.10em;
  font-weight: 500;
  text-transform: uppercase;
}
.metric-tile .val, .stat-value {
  color: var(--text);
  font-size: 26px;
  font-weight: 700;
  letter-spacing: -0.02em;
  margin-top: 4px;
}
.metric-tile.danger .val, .stat.danger .stat-value { color: var(--status-red); }
.metric-tile.good .val, .stat.good .stat-value { color: var(--status-green); }

/* ---- Pills / status badges (full-round) ---- */
.pill-status, .sop-pill {
  font-family: var(--font-mono);
  font-size: 10.5px;
  font-weight: 500;
  letter-spacing: 0.08em;
  padding: 3px 10px;
  border-radius: var(--r-pill);
  display: inline-block;
  text-transform: uppercase;
}
.pill-status.open      { background: var(--status-amber-50); color: var(--status-amber); }
.pill-status.done      { background: var(--status-green-50); color: var(--status-green); }
.pill-status.slipped   { background: var(--status-red-50);   color: var(--status-red); }
.pill-status.cancelled { background: var(--line-soft); color: var(--text-faint); }
.sop-pill              { background: var(--warm-2); color: var(--text); }
.sop-pill.cadence      { background: var(--orange-soft); color: var(--orange-dark); }
.sop-pill.docid        { background: var(--status-green-50); color: var(--status-green); font-weight: 600; }

/* ---- Footer ---- */
.footer {
  background: var(--paper);
  border-top: 1px solid var(--line);
  color: var(--text-faint);
  font-family: var(--font-mono);
  font-size: 10.5px;
  padding: 16px 28px;
  letter-spacing: 0.10em;
  text-transform: uppercase;
}

/* ---- Module cards (dashboard grid) ---- */
.module-card {
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: var(--r-lg);
  box-shadow: var(--shadow-xs);
  padding: 22px 24px;
  transition: transform 0.15s ease, box-shadow 0.15s ease, border-color 0.15s ease;
  text-decoration: none;
  border-left: 3px solid var(--orange);
  display: block;
}
.module-card.accent-amber { border-left-color: var(--orange); }
.module-card.accent-green { border-left-color: var(--status-green); }
.module-card.accent-navy  { border-left-color: var(--navy); }
.module-card:hover { transform: translateY(-2px); box-shadow: var(--shadow-md); border-color: var(--orange); background: var(--orange-soft); }
.module-card.planned { opacity: 0.5; cursor: default; }
.module-card.planned:hover { transform: none; background: var(--paper); border-color: var(--line); }
.module-card .mc-section {
  font-family: var(--font-mono);
  font-size: 10.5px;
  font-weight: 500;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--text-faint);
  margin-bottom: 8px;
}
.module-card .mc-title, .module-card h3 {
  color: var(--text);
  font-size: 16px;
  font-weight: 600;
  margin-bottom: 6px;
  letter-spacing: -0.01em;
}
.module-card .mc-desc, .module-card p {
  color: var(--text-dim);
  font-size: 13px;
  line-height: 1.5;
  margin-bottom: 10px;
}
.module-card .mc-meta {
  font-family: var(--font-mono);
  color: var(--text-faint);
  font-size: 10.5px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

/* ---- SOPs module overrides ---- */
.sop-card {
  background: var(--paper);
  border: 1px solid var(--line);
  border-left: 3px solid var(--orange);
  border-radius: var(--r-md);
  box-shadow: var(--shadow-xs);
  padding: 18px 22px;
}
.sop-card:hover { box-shadow: var(--shadow-md); border-color: var(--orange); }
.sop-section h3 {
  font-family: var(--font-mono);
  font-size: 11px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--text-faint);
  border-bottom-color: var(--line);
}
.sop-procedure { background: var(--warm); border-radius: var(--r-md); }
.sop-key-procedure { border-left-color: var(--orange); background: var(--orange-soft); }
.sop-escalation { background: var(--status-red-50); border-left-color: var(--status-red); }
.sop-doc-meta { background: var(--warm); border-radius: var(--r-md); }

/* ---- Performance ring ---- */
.perf-ring .pct .num { color: var(--text); }
.perf-ring .pct .lab { color: var(--text-faint); font-family: var(--font-mono); letter-spacing: 0.10em; }
.perf-meta h2 { color: var(--text); font-weight: 600; }
.perf-meta .cadence-pill {
  font-family: var(--font-mono);
  background: var(--orange-soft);
  color: var(--orange-dark);
  font-weight: 500;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  border-radius: var(--r-pill);
}

/* ---- Links ---- */
a { color: var(--orange); }
a:hover { color: var(--orange-dark); }

/* ---- Reg toolbar (filters) ---- */
.reg-toolbar select, .reg-toolbar input {
  border: 1px solid var(--line);
  border-radius: var(--r-sm);
  padding: 8px 12px;
  font-size: 13px;
  background: var(--paper);
  color: var(--text);
}

/* ---- Mobile sidebar ---- */
@media (max-width: 840px) {
  .hub-sidebar { box-shadow: 4px 0 20px rgba(0,0,0,0.15); }
}

/* ============================================================
   Welcome screen (unauthenticated landing) — platform-aligned
   ============================================================ */
body.is-welcome .hub-sidebar { display: none; }
body.is-welcome .hub-main { background: var(--warm); }

.welcome-shell {
  flex: 1;
  display: flex;
  justify-content: center;
  padding: 64px 24px 48px;
}
.welcome-inner { width: 100%; max-width: 1120px; }
.welcome-hero {
  text-align: center;
  margin-bottom: 64px;
}
.welcome-logo {
  font-family: var(--font);
  font-size: 14px;
  font-weight: 800;
  letter-spacing: 0.28em;
  color: var(--text);
  margin-bottom: 4px;
}
.welcome-logo-sub {
  font-family: var(--font-mono);
  font-size: 11px;
  font-weight: 500;
  letter-spacing: 0.18em;
  color: var(--orange);
  text-transform: uppercase;
  margin-bottom: 32px;
}
.welcome-headline {
  font-size: 56px;
  line-height: 0.96;
  letter-spacing: -0.035em;
  font-weight: 700;
  color: var(--text);
  margin: 0 auto 20px;
  max-width: 800px;
}
.welcome-headline .accent { color: var(--orange); }
.welcome-sub {
  color: var(--text-dim);
  font-size: 18px;
  line-height: 1.55;
  max-width: 640px;
  margin: 0 auto 36px;
}
.welcome-cta { display: flex; flex-direction: column; align-items: center; }
.welcome-signin {
  font-size: 15px;
  padding: 14px 28px;
  font-weight: 600;
  background: var(--orange);
  border-color: var(--orange);
  border-radius: var(--r-pill);
  box-shadow: var(--shadow-sm);
}
.welcome-signin:hover { background: var(--orange-dark); border-color: var(--orange-dark); transform: translateY(-1px); }
.welcome-restriction {
  font-family: var(--font-mono);
  margin-top: 16px;
  color: var(--text-faint);
  font-size: 11px;
  letter-spacing: 0.10em;
  text-transform: uppercase;
}
.welcome-restriction strong { color: var(--text); font-weight: 600; }

.welcome-modules { margin-top: 16px; }
.welcome-section-title {
  font-family: var(--font-mono);
  font-size: 11px;
  font-weight: 500;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--text-faint);
  text-align: center;
  margin-bottom: 24px;
}
.welcome-tile-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
  gap: 16px;
}
.welcome-tile {
  background: var(--paper);
  border: 1px solid var(--line);
  border-left: 3px solid var(--orange);
  border-radius: var(--r-lg);
  padding: 24px 26px;
  text-decoration: none;
  color: inherit;
  box-shadow: var(--shadow-xs);
  display: block;
  transition: transform 0.15s ease, box-shadow 0.15s ease, border-color 0.15s ease, background 0.15s ease;
}
.welcome-tile:nth-child(2) { border-left-color: var(--orange-bright); }
.welcome-tile:nth-child(3) { border-left-color: var(--status-green); }
.welcome-tile.welcome-tile-external { border-left-color: var(--navy); }
.welcome-tile:hover { transform: translateY(-2px); box-shadow: var(--shadow-md); border-color: var(--orange); background: var(--orange-soft); }
.welcome-tile-tag {
  font-family: var(--font-mono);
  font-size: 10.5px;
  font-weight: 500;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--text-faint);
  margin-bottom: 10px;
}
.welcome-tile h3 {
  font-size: 17px;
  font-weight: 600;
  color: var(--text);
  margin: 0 0 8px;
  letter-spacing: -0.01em;
}
.welcome-tile p {
  font-size: 13px;
  line-height: 1.55;
  color: var(--text-dim);
  margin: 0;
}

.welcome-foot {
  margin-top: 56px;
  text-align: center;
  font-family: var(--font-mono);
  font-size: 11px;
  letter-spacing: 0.10em;
  color: var(--text-faint);
  text-transform: uppercase;
}
.welcome-foot-sep { margin: 0 12px; opacity: 0.5; }

@media (max-width: 640px) {
  .welcome-shell { padding: 36px 18px 28px; }
  .welcome-headline { font-size: 36px; }
  .welcome-sub { font-size: 15px; }
  .welcome-hero { margin-bottom: 36px; }
}

/* ── QA pass: accessibility + contrast ── */
/* Keyboard focus indicator — was missing app-wide (WCAG 2.4.7) */
a:focus-visible, button:focus-visible, select:focus-visible, input:focus-visible,
textarea:focus-visible, [tabindex]:focus-visible, .sb-link:focus-visible,
.q-opt:focus-visible, .module-card:focus-visible, .kb-tab:focus-visible,
.act-trigger:focus-visible, .modal-close:focus-visible {
  outline: 2px solid var(--orange, #E0612A);
  outline-offset: 2px;
  border-radius: 4px;
}
/* Lift faint/de-emphasised text off the WCAG floor (was rgba .40 ≈ 2.5:1) */
:root { --text-faint: rgba(14, 27, 51, 0.60); }
.pill-status.open { color: #8A5A0B; }
