:root {
  --bg: #EEF3F8;
  --surface: #FFFFFF;
  --ink: #14243A;
  --ink-soft: #4A5568;
  --ink-faint: #8A93A3;
  --line: #DCE3EE;

  --brand-blue: #0F7BC4;
  --brand-blue-dark: #0A4F7A;
  --brand-gold: #E9AF1D;
  --brand-gold-soft: #FBF1D3;
  --brand-teal: #1B7F8C;
  --brand-teal-soft: #E2F3F5;
  --stamp: #A33D2E;
  --stamp-soft: #F6E7E4;
  --warn-bg: #FBF1DE;
  --warn-ink: #93650E;
  --overdue-bg: #FCE8E6;
  --overdue-ink: #A33D2E;

  --radius: 10px;
  --font-ui: 'IBM Plex Sans', system-ui, sans-serif;
  --font-mono: 'IBM Plex Mono', ui-monospace, monospace;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--font-ui);
  font-size: 14px;
  line-height: 1.5;
}

.mono { font-family: var(--font-mono); }

/* ---------- topbar ---------- */
.topbar {
  background: linear-gradient(135deg, var(--brand-blue-dark), var(--brand-blue) 70%);
  color: #fff;
  border-bottom: 4px solid var(--brand-gold);
}
.topbar-inner {
  max-width: 1320px;
  margin: 0 auto;
  padding: 16px 28px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  flex-wrap: wrap;
}
.brand { display: flex; align-items: center; gap: 14px; text-decoration: none; color: inherit; }
.brand-seal {
  width: 56px; height: 56px;
  border-radius: 50%;
  object-fit: cover;
  background: #fff;
  border: 2px solid rgba(255,255,255,0.7);
  flex-shrink: 0;
}
.brand-eyebrow { display: block; font-size: 11px; letter-spacing: 0.05em; color: #CDE6F5; font-weight: 500; margin-bottom: 2px; }
.brand-text h1 { margin: 0; font-size: 17px; font-weight: 700; letter-spacing: 0.1px; }
.subtitle { margin: 3px 0 0; font-size: 12px; color: #CDE6F5; }

.topnav { display: flex; align-items: center; gap: 14px; flex-wrap: wrap; }
.nav-link { color: #fff; text-decoration: none; font-size: 13px; font-weight: 600; padding: 8px 12px; border-radius: 7px; border: 1px solid rgba(255,255,255,0.35); }
.nav-link:hover { background: rgba(255,255,255,0.12); }
.nav-cta { background: var(--brand-gold); border-color: var(--brand-gold); color: var(--brand-blue-dark); }
.nav-cta:hover { background: #cf9a15; }
.nav-logout { border-color: rgba(255,255,255,0.2); opacity: 0.85; }
.nav-user { font-size: 12.5px; color: #E7F2FB; }
.role-pill { font-family: var(--font-mono); font-size: 9.5px; text-transform: uppercase; letter-spacing: 0.05em; padding: 2px 6px; border-radius: 4px; margin-left: 4px; }
.role-admin { background: var(--brand-gold); color: var(--brand-blue-dark); }
.role-editor { background: rgba(255,255,255,0.2); color: #fff; }

/* ---------- layout ---------- */
.wrap { max-width: 1320px; margin: 0 auto; padding: 24px 28px 60px; }
.wrap-narrow { max-width: 880px; }

/* ---------- summary cards ---------- */
.cards { display: grid; grid-template-columns: repeat(4, 1fr); gap: 16px; margin-bottom: 20px; }
.card { background: var(--surface); border: 1px solid var(--line); border-left: 4px solid var(--brand-teal); border-radius: var(--radius); padding: 16px 18px; display: flex; flex-direction: column; gap: 6px; }
.card-label { font-size: 11.5px; text-transform: uppercase; letter-spacing: 0.06em; color: var(--ink-faint); font-weight: 600; }
.card-value { font-size: 24px; font-weight: 600; }

/* ---------- filters ---------- */
.filters { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px 18px; display: flex; align-items: flex-end; gap: 16px; flex-wrap: wrap; margin-bottom: 20px; }
.filter-group { display: flex; flex-direction: column; gap: 5px; }
.filter-group label { font-size: 11px; text-transform: uppercase; letter-spacing: 0.05em; color: var(--ink-faint); font-weight: 600; }
.filter-group select, .filter-group input { font-family: var(--font-ui); font-size: 13px; padding: 8px 10px; border: 1px solid var(--line); border-radius: 7px; background: #fff; min-width: 150px; }
.filter-grow { flex: 1; min-width: 200px; }
.filter-grow input { width: 100%; }

/* ---------- charts ---------- */
.charts { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; margin-bottom: 26px; }
.chart-panel { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 18px; }
.chart-panel.span-2 { grid-column: 1 / -1; }
.chart-panel h2 { margin: 0 0 12px; font-size: 13px; font-weight: 600; color: var(--ink-soft); text-transform: uppercase; letter-spacing: 0.05em; }
.chart-panel canvas { max-height: 260px; }

/* ---------- register / table ---------- */
.register { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 18px; }
.register-head { display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; gap: 12px; margin-bottom: 14px; }
.register-head h2 { margin: 0; font-size: 15px; font-weight: 600; }
.hint { font-size: 12px; font-weight: 400; color: var(--ink-faint); margin-left: 6px; }
.register-actions { display: flex; gap: 10px; }
#search-box, #f-search { font-family: var(--font-ui); padding: 8px 12px; border: 1px solid var(--line); border-radius: 7px; font-size: 13px; min-width: 220px; }

.btn { font-family: var(--font-ui); font-size: 13px; font-weight: 600; padding: 8px 14px; border-radius: 7px; border: 1px solid var(--line); background: var(--surface); color: var(--ink); cursor: pointer; text-decoration: none; display: inline-block; }
.btn:hover { background: var(--bg); }
.btn-primary { background: var(--brand-teal); border-color: var(--brand-teal); color: #fff; }
.btn-primary:hover { background: #166b76; }
.btn-block { width: 100%; padding: 10px; }
.btn-tiny { font-size: 11.5px; padding: 4px 8px; }

.table-scroll { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 12.5px; }
thead th { text-align: left; font-size: 10.5px; text-transform: uppercase; letter-spacing: 0.05em; color: var(--ink-faint); font-weight: 600; padding: 8px 10px; border-bottom: 2px solid var(--line); white-space: nowrap; }
tbody td { padding: 7px 10px; border-bottom: 1px solid var(--line); white-space: nowrap; }
tbody tr:hover { background: var(--bg); }
.col-name { min-width: 200px; white-space: normal; }
td.col-name { white-space: normal; font-weight: 500; }
.row-actions { display: flex; gap: 8px; align-items: center; }

.status-badge { display: inline-block; font-size: 11px; font-weight: 600; padding: 3px 9px; border-radius: 20px; white-space: nowrap; }
.status-badge.implemented { background: var(--brand-teal-soft); color: var(--brand-teal); }
.status-badge.partial { background: var(--warn-bg); color: var(--warn-ink); }
.status-badge.not-implemented { background: var(--overdue-bg); color: var(--overdue-ink); }

.priority-badge { display: inline-block; font-size: 10.5px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.03em; padding: 2px 8px; border-radius: 4px; }
.priority-high { background: var(--overdue-bg); color: var(--overdue-ink); }
.priority-medium { background: var(--warn-bg); color: var(--warn-ink); }
.priority-low { background: var(--brand-teal-soft); color: var(--brand-teal); }

.overdue-flag { color: var(--stamp); font-weight: 700; font-size: 11px; margin-left: 6px; }

.progress-cell { display: flex; align-items: center; gap: 8px; min-width: 90px; }
.progress-track { flex: 1; height: 7px; background: var(--line); border-radius: 4px; overflow: hidden; }
.progress-fill { height: 100%; background: var(--brand-teal); }
.progress-label { font-family: var(--font-mono); font-size: 11.5px; color: var(--ink-soft); width: 34px; text-align: right; }

.row-delete { color: var(--ink-faint); background: none; border: none; cursor: pointer; font-size: 15px; }
.row-delete:hover { color: var(--stamp); }

/* ---------- pagination ---------- */
.pagination { display: flex; align-items: center; justify-content: center; gap: 6px; margin-top: 16px; flex-wrap: wrap; }
.pagination button { font-family: var(--font-ui); font-size: 12.5px; font-weight: 600; padding: 6px 11px; border-radius: 6px; border: 1px solid var(--line); background: #fff; color: var(--ink); cursor: pointer; }
.pagination button:hover:not(:disabled) { background: var(--bg); }
.pagination button.active { background: var(--brand-teal); border-color: var(--brand-teal); color: #fff; }
.pagination button:disabled { opacity: 0.4; cursor: default; }

/* ---------- alerts ---------- */
.alert { padding: 10px 14px; border-radius: 7px; font-size: 13px; margin-bottom: 4px; }
.alert-error { background: var(--stamp-soft); color: var(--stamp); }

/* ---------- modal ---------- */
.modal-backdrop { display: none; position: fixed; inset: 0; background: rgba(20,36,58,0.45); align-items: center; justify-content: center; z-index: 50; }
.modal-backdrop.open { display: flex; }
.modal { background: #fff; border-radius: var(--radius); padding: 22px; width: 320px; display: flex; flex-direction: column; gap: 12px; }
.modal h3 { margin: 0 0 4px; font-size: 15px; }
.modal label { font-size: 12.5px; color: var(--ink-soft); display: flex; flex-direction: column; gap: 4px; }
.modal input, .modal select { font-family: var(--font-ui); padding: 8px 10px; border: 1px solid var(--line); border-radius: 6px; font-size: 13px; }
.modal-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 6px; }

/* ---------- record form (add/edit recommendation) ---------- */
.back-link { display: inline-block; margin-top: 18px; font-size: 12.5px; color: var(--brand-blue); text-decoration: none; }
.back-link:hover { text-decoration: underline; }
.back-link-inline { margin: 0 0 16px; }

.record-form fieldset {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 18px 20px;
  margin-bottom: 16px;
}
.record-form legend { font-size: 13px; font-weight: 700; color: var(--brand-blue-dark); padding: 0 6px; text-transform: uppercase; letter-spacing: 0.04em; }
.record-form legend .hint { text-transform: none; letter-spacing: normal; font-weight: 400; }
.form-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 14px; margin-bottom: 14px; }
.record-form label { display: flex; flex-direction: column; gap: 5px; font-size: 12.5px; color: var(--ink-soft); font-weight: 600; margin-bottom: 4px; }
.record-form label.full { margin-bottom: 14px; }
.record-form input, .record-form select, .record-form textarea {
  font-family: var(--font-ui); font-size: 13.5px; padding: 9px 11px; border: 1px solid var(--line);
  border-radius: 7px; background: #fff; color: var(--ink); font-weight: 400;
}
.record-form textarea { resize: vertical; }
.req { color: var(--stamp); }
.form-actions { display: flex; justify-content: flex-end; gap: 10px; margin-top: 10px; padding-bottom: 20px; }

/* ---------- login page ---------- */
.login-body { min-height: 100vh; display: flex; align-items: center; justify-content: center; background: radial-gradient(circle at 30% 20%, #1E7BB5, var(--brand-blue-dark) 70%); padding: 20px; }
.login-card { background: #fff; border-radius: 14px; padding: 36px 32px; width: 100%; max-width: 360px; text-align: center; box-shadow: 0 20px 50px rgba(0,0,0,0.25); }
.login-seal { width: 88px; height: 88px; border-radius: 50%; margin-bottom: 14px; }
.login-card h1 { margin: 0 0 4px; font-size: 19px; }
.login-org { margin: 0 0 20px; font-size: 12.5px; color: var(--ink-faint); }
.login-form { display: flex; flex-direction: column; gap: 14px; text-align: left; }
.login-form label { font-size: 12.5px; color: var(--ink-soft); font-weight: 600; display: flex; flex-direction: column; gap: 5px; }
.login-form input { font-family: var(--font-ui); padding: 10px 12px; border: 1px solid var(--line); border-radius: 7px; font-size: 13.5px; }

/* ---------- footer ---------- */
.page-footer { text-align: center; padding: 24px; color: var(--ink-faint); font-size: 12px; }

@media (max-width: 900px) {
  .cards { grid-template-columns: repeat(2, 1fr); }
  .charts { grid-template-columns: 1fr; }
  .form-grid { grid-template-columns: 1fr; }
  .brand-text h1 { font-size: 14.5px; }
  .subtitle { display: none; }
}
