/* =====================================================================
   SAM1 Monitoring System - Shared Stylesheet
   Single source of truth for all pages (BC, PBM, Admin, Auth).
   Edit here once, applies everywhere.
   ===================================================================== */

/* ---------- Reset / base ---------- */
*,*::before,*::after { box-sizing: border-box; }
html, body {
  margin: 0; padding: 0;
  background: #FAFAFA; color: #171717;
  font-family: "Segoe UI", Tahoma, Geneva, Verdana, sans-serif;
  font-size: 14px; line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}
a { color: #006FA8; text-decoration: none; }
a:hover { text-decoration: underline; }
button { font-family: inherit; font-size: 0.875rem; cursor: pointer; }
hr { border: none; border-top: 1px solid #EAEAEA; margin: 16px 0; }

/* ---------- Top utility bar ---------- */
.topbar {
  background: #171717; color: #D4D4D4;
  font-size: 0.75rem; padding: 6px 24px;
  display: flex; justify-content: space-between; align-items: center;
  letter-spacing: 0.02em;
  gap: 12px;
}
.topbar .org { font-weight: 600; color: #FAFAFA; }
.topbar .period { color: #BDBDBD; }
.topbar .right { display: flex; align-items: center; gap: 14px; }

/* ---------- Language switcher ---------- */
.lang-switcher {
  display: inline-flex; align-items: center; gap: 1px;
  background: rgba(255,255,255,0.06);
  border: 1px solid rgba(255,255,255,0.12);
  padding: 1px;
}
.lang-switcher button {
  background: transparent; border: none;
  padding: 3px 9px; font-size: 0.72rem;
  font-weight: 700; letter-spacing: 0.05em;
  color: #BDBDBD; cursor: pointer;
  font-family: inherit;
  transition: background-color 0.12s, color 0.12s;
}
.lang-switcher button:hover { color: #FFFFFF; background: rgba(255,255,255,0.08); }
.lang-switcher button.active { background: #009CDE; color: #FFFFFF; }

/* ---------- Cycle picker ---------- */
.cycle-picker select {
  background: rgba(255,255,255,0.06);
  color: #FAFAFA;
  border: 1px solid rgba(255,255,255,0.18);
  padding: 3px 24px 3px 9px;
  font-size: 0.72rem;
  font-weight: 600;
  letter-spacing: 0.02em;
  font-family: inherit;
  cursor: pointer;
  appearance: none;
  -webkit-appearance: none;
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 8 6' fill='%23BDBDBD'><path d='M0 0l4 6 4-6z'/></svg>");
  background-repeat: no-repeat;
  background-position: right 8px center;
  background-size: 7px 5px;
  width: auto;
  min-width: 0;
}
.cycle-picker select:hover { background-color: rgba(255,255,255,0.12); }
.cycle-picker select:focus {
  outline: none;
  border-color: #009CDE;
  box-shadow: 0 0 0 2px rgba(0,156,222,0.25);
}
.cycle-picker option { background: #171717; color: #FAFAFA; }

/* ---------- Comparison view (SAM1 ↔ SAM2) ---------- */
.compare-grid {
  display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin-bottom: 18px;
}
.compare-cell {
  border: 1px solid #D4D4D4; background: #FFFFFF; padding: 14px 16px;
}
.compare-cell .label {
  font-size: 0.7rem; text-transform: uppercase; letter-spacing: 0.06em;
  color: #737373; font-weight: 600;
}
.compare-cell .value {
  font-size: 1.4rem; font-weight: 700; color: #171717;
  font-variant-numeric: tabular-nums; margin-top: 4px;
}
.compare-cell .delta {
  font-size: 0.78rem; font-weight: 700; margin-top: 4px;
  display: inline-flex; align-items: center; gap: 4px;
}
.compare-cell .delta.up   { color: #1F5C22; }
.compare-cell .delta.down { color: #8A1A1A; }
.compare-cell .delta.flat { color: #737373; }
.delta-cell { font-variant-numeric: tabular-nums; font-weight: 700; }
.delta-cell.up   { color: #1F5C22; }
.delta-cell.down { color: #8A1A1A; }
.delta-cell.flat { color: #737373; }

/* ---------- Attachments ---------- */
.attachments {
  margin-top: 12px;
  border: 1px dashed #BDBDBD;
  background: #FAFAFA;
  padding: 12px 14px;
}
.attachments.dragover { border-color: #009CDE; background: #F0F7FB; }
.attachments .head {
  display: flex; justify-content: space-between; align-items: center;
  font-size: 0.7rem; text-transform: uppercase; letter-spacing: 0.06em;
  color: #737373; font-weight: 700;
  padding-bottom: 8px;
}
.attachments .head .right { font-weight: 600; color: #525252; }
.att-dropzone {
  text-align: center; padding: 16px 8px;
  font-size: 0.82rem; color: #737373;
  cursor: pointer;
}
.att-dropzone strong { color: #006FA8; }
.att-list {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
  gap: 8px;
  margin-top: 8px;
}
.att-item {
  border: 1px solid #D4D4D4; background: #FFFFFF;
  padding: 8px 10px;
  display: flex; align-items: center; gap: 8px;
  font-size: 0.78rem;
  position: relative;
}
.att-item .ext {
  width: 32px; height: 32px;
  background: #006FA8; color: #FFFFFF;
  display: flex; align-items: center; justify-content: center;
  font-size: 0.65rem; font-weight: 700; letter-spacing: 0.04em;
  flex-shrink: 0;
}
.att-item .ext.pdf  { background: #C62828; }
.att-item .ext.doc  { background: #2A6FDB; }
.att-item .ext.xls  { background: #2E7D32; }
.att-item .ext.img  { background: #8E44AD; }
.att-item .info { flex: 1; min-width: 0; }
.att-item .name {
  font-weight: 600; color: #171717;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.att-item .meta { font-size: 0.7rem; color: #737373; }
.att-item .rm {
  background: none; border: none; color: #737373;
  cursor: pointer; padding: 0 4px; font-size: 1.1rem; line-height: 1;
}
.att-item .rm:hover { color: #C62828; }
.att-item.readonly .rm { display: none; }

/* ---------- Header ---------- */
.header {
  background: #FFFFFF; border-bottom: 1px solid #D4D4D4;
  padding: 14px 24px; display: flex; align-items: center; gap: 20px;
}
.logo-mark {
  width: 44px; height: 44px; background: #009CDE; color: #FFFFFF;
  display: flex; align-items: center; justify-content: center;
  font-weight: 700; font-size: 0.75rem; letter-spacing: 0.05em; flex-shrink: 0;
}
.header-title { flex: 1; }
.header-title .system {
  font-size: 1.05rem; font-weight: 700; color: #171717; letter-spacing: -0.005em;
}
.header-title .sub { font-size: 0.78rem; color: #525252; margin-top: 2px; }
.header-user {
  text-align: right; font-size: 0.78rem; color: #404040; line-height: 1.4;
  border-left: 1px solid #D4D4D4; padding-left: 20px;
  display: flex; align-items: center; gap: 14px;
}
.header-user .user-info { text-align: right; }
.header-user .name { font-weight: 600; color: #171717; font-size: 0.85rem; }
.header-user .role { color: #737373; }
.header-user .signout {
  display: inline-block; margin-top: 4px; font-size: 0.72rem;
  color: #006FA8; cursor: pointer; background: none; border: none; padding: 0;
}
.header-user .signout:hover { text-decoration: underline; }

/* ---------- Notifications bell ---------- */
.header-user .bell {
  position: relative;
  width: 36px; height: 36px;
  display: flex; align-items: center; justify-content: center;
  color: #525252;
  border: 1px solid #D4D4D4;
  background: #FFFFFF;
  transition: background-color 0.12s, color 0.12s, border-color 0.12s;
}
.header-user .bell:hover {
  background: #F5F5F5; color: #006FA8; border-color: #006FA8;
  text-decoration: none;
}
.header-user .bell-badge {
  position: absolute; top: -6px; right: -6px;
  background: #C62828; color: #FFFFFF;
  font-size: 0.62rem; font-weight: 700;
  padding: 2px 5px; min-width: 18px; height: 18px;
  display: flex; align-items: center; justify-content: center;
  border: 2px solid #FFFFFF;
  line-height: 1;
}

/* ---------- Notification list (for notifications.html) ---------- */
.notif-list { display: flex; flex-direction: column; }
.notif {
  display: grid; grid-template-columns: 36px 1fr 130px 100px;
  gap: 14px; padding: 14px 18px;
  border-bottom: 1px solid #EAEAEA;
  align-items: center;
  background: #FFFFFF;
  transition: background-color 0.1s;
}
.notif:hover { background: #FAFAFA; }
.notif.unread { background: #F0F7FB; border-left: 3px solid #009CDE; padding-left: 15px; }
.notif:last-child { border-bottom: none; }
.notif .icon {
  width: 36px; height: 36px;
  display: flex; align-items: center; justify-content: center;
  background: #F5F5F5; color: #525252;
  border: 1px solid #EAEAEA;
  font-weight: 700; font-size: 0.78rem;
}
.notif.kind-warning .icon { background: #FDF1E0; border-color: #F0CB8E; color: #8A4810; }
.notif.kind-comment .icon { background: #E3F1F9; border-color: #A6D4EC; color: #00547F; }
.notif.kind-inbox   .icon { background: #FDF1E0; border-color: #F0CB8E; color: #8A4810; }
.notif.kind-forward .icon { background: #E8F3E9; border-color: #B6D7B7; color: #1F5C22; }
.notif.kind-approve .icon { background: #E8F3E9; border-color: #B6D7B7; color: #1F5C22; }
.notif.kind-user    .icon { background: #F0F0F0; }
.notif .body .title { font-weight: 600; font-size: 0.88rem; color: #171717; }
.notif .body .msg   { font-size: 0.78rem; color: #525252; margin-top: 2px; }
.notif .when { font-size: 0.75rem; color: #737373; text-align: right; }
.notif .action { text-align: right; }

@media (max-width: 768px) {
  .notif { grid-template-columns: 28px 1fr; }
  .notif .when, .notif .action { grid-column: 2; text-align: left; }
}

/* ---------- Primary navigation ---------- */
.nav {
  background: #FFFFFF; border-bottom: 1px solid #D4D4D4;
  padding: 0 24px; display: flex; gap: 4px; overflow-x: auto;
}
.nav a, .nav button {
  background: transparent; border: none; border-bottom: 3px solid transparent;
  padding: 12px 18px; font-size: 0.82rem; font-weight: 600;
  color: #525252; letter-spacing: 0.02em; cursor: pointer; white-space: nowrap;
  text-decoration: none; display: inline-block;
  transition: background-color 0.12s, color 0.12s, border-color 0.12s;
}
.nav a:hover, .nav button:hover { background: #F5F5F5; color: #171717; text-decoration: none; }
.nav a.active, .nav button.active { color: #006FA8; border-bottom-color: #009CDE; }

/* ---------- Page container ---------- */
main { max-width: 1400px; margin: 0 auto; padding: 24px; }
main.narrow { max-width: 960px; }
main.wide { max-width: 1600px; }

/* ---------- Breadcrumb ---------- */
.breadcrumb {
  font-size: 0.78rem; color: #737373; margin-bottom: 16px; letter-spacing: 0.01em;
}
.breadcrumb a { color: #006FA8; cursor: pointer; }
.breadcrumb .sep { margin: 0 8px; color: #BDBDBD; }

/* ---------- Page header card ---------- */
.page-header {
  background: #FFFFFF; border: 1px solid #D4D4D4;
  padding: 20px 24px; margin-bottom: 20px;
}
.page-header h1 {
  margin: 0 0 6px 0; font-size: 1.5rem; font-weight: 700;
  color: #171717; letter-spacing: -0.01em;
}
.page-header .lede { font-size: 0.9rem; color: #525252; margin: 0; }
.page-header .meta {
  display: flex; flex-wrap: wrap; gap: 24px;
  font-size: 0.8rem; color: #525252;
  margin-top: 12px; padding-top: 12px; border-top: 1px solid #EAEAEA;
}
.page-header .meta .item { display: flex; flex-direction: column; gap: 2px; }
.page-header .meta .label {
  text-transform: uppercase; font-size: 0.68rem; color: #737373;
  font-weight: 600; letter-spacing: 0.06em;
}
.page-header .meta .value { color: #171717; font-weight: 600; font-size: 0.85rem; }
.page-header .actions { margin-top: 14px; display: flex; gap: 8px; flex-wrap: wrap; }

/* ---------- Summary cards grid ---------- */
.summary-grid {
  display: grid; grid-template-columns: repeat(4, 1fr);
  gap: 12px; margin-bottom: 20px;
}
.summary-grid.cols-3 { grid-template-columns: repeat(3, 1fr); }
.summary-box {
  background: #FFFFFF; border: 1px solid #D4D4D4; padding: 16px 18px;
}
.summary-box .label {
  font-size: 0.7rem; text-transform: uppercase; letter-spacing: 0.06em;
  color: #737373; font-weight: 600;
}
.summary-box .value {
  margin-top: 6px; font-size: 1.75rem; font-weight: 700; color: #171717; line-height: 1;
  font-variant-numeric: tabular-nums;
}
.summary-box .hint { font-size: 0.72rem; color: #737373; margin-top: 6px; }
.summary-box .accent-bar { height: 3px; margin-top: 12px; background: #009CDE; }
.summary-box.green .accent-bar { background: #2E7D32; }
.summary-box.yellow .accent-bar { background: #F57C00; }
.summary-box.red .accent-bar { background: #C62828; }
.summary-box.grey .accent-bar { background: #9E9E9E; }

/* ---------- Action bar / filters ---------- */
.action-bar {
  background: #FFFFFF; border: 1px solid #D4D4D4;
  padding: 12px 18px; margin-bottom: 16px;
  display: flex; justify-content: space-between; align-items: center;
  gap: 12px; flex-wrap: wrap;
}
.action-bar .group { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.action-bar .info { font-size: 0.78rem; color: #525252; }

.filter-bar {
  background: #FFFFFF; border: 1px solid #D4D4D4;
  padding: 12px 18px; margin-bottom: 16px;
  display: flex; gap: 12px; align-items: flex-end; flex-wrap: wrap;
}
.filter-bar .field { display: flex; flex-direction: column; gap: 4px; min-width: 160px; }
.filter-bar .field.grow { flex: 1; min-width: 220px; }
.filter-bar label {
  text-transform: uppercase; font-size: 0.65rem; font-weight: 700;
  letter-spacing: 0.06em; color: #737373;
}

/* ---------- Buttons ---------- */
.btn {
  background: #FFFFFF; color: #171717; border: 1px solid #BDBDBD;
  padding: 8px 16px; font-size: 0.82rem; font-weight: 600;
  letter-spacing: 0.01em; cursor: pointer; text-decoration: none;
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  transition: background-color 0.12s, border-color 0.12s, color 0.12s;
}
.btn:hover { background: #F5F5F5; border-color: #737373; text-decoration: none; }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }
.btn-primary { background: #009CDE; color: #FFFFFF; border-color: #009CDE; }
.btn-primary:hover { background: #006FA8; border-color: #006FA8; color: #FFFFFF; }
.btn-success { background: #2E7D32; color: #FFFFFF; border-color: #2E7D32; }
.btn-success:hover { background: #1F5C22; border-color: #1F5C22; color: #FFFFFF; }
.btn-warning { background: #F57C00; color: #FFFFFF; border-color: #F57C00; }
.btn-warning:hover { background: #C76700; border-color: #C76700; color: #FFFFFF; }
.btn-danger { background: #C62828; color: #FFFFFF; border-color: #C62828; }
.btn-danger:hover { background: #8A1A1A; border-color: #8A1A1A; color: #FFFFFF; }
.btn-sm { padding: 5px 10px; font-size: 0.75rem; }
.btn-lg { padding: 12px 22px; font-size: 0.92rem; }
.btn-block { display: flex; width: 100%; }

/* ---------- Tables ---------- */
.table-wrap {
  background: #FFFFFF; border: 1px solid #D4D4D4; overflow-x: auto;
}
.table-title {
  padding: 12px 18px; border-bottom: 1px solid #D4D4D4;
  font-size: 0.78rem; font-weight: 700; text-transform: uppercase;
  letter-spacing: 0.08em; color: #404040; background: #FAFAFA;
  display: flex; justify-content: space-between; align-items: center;
}
.table-title .count { font-weight: 600; color: #737373; letter-spacing: 0.03em; }
table { width: 100%; border-collapse: collapse; font-size: 0.85rem; }
thead th {
  background: #F5F5F5; text-align: left; padding: 10px 14px;
  font-size: 0.7rem; font-weight: 700; text-transform: uppercase;
  letter-spacing: 0.06em; color: #404040;
  border-bottom: 1px solid #D4D4D4; white-space: nowrap;
}
thead th.num { text-align: right; }
tbody td {
  padding: 12px 14px; border-bottom: 1px solid #EAEAEA;
  vertical-align: middle; color: #171717;
}
tbody td.num { text-align: right; font-variant-numeric: tabular-nums; }
tbody tr { transition: background-color 0.1s; }
tbody tr.clickable { cursor: pointer; }
tbody tr.clickable:hover { background: #F5F5F5; }
tbody tr:last-child td { border-bottom: none; }
tbody td.code {
  font-weight: 600; color: #006FA8;
  font-variant-numeric: tabular-nums; white-space: nowrap;
}
tbody td.title { max-width: 360px; }
tbody td.title .ttext {
  font-weight: 600; color: #171717;
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden;
}
tbody td.title .sub { font-size: 0.72rem; color: #737373; margin-top: 2px; }
tbody td.actions { white-space: nowrap; }
tbody td.actions .btn { margin-right: 6px; }
tbody td.actions .btn:last-child { margin-right: 0; }

/* ---------- Status indicators ---------- */
.status {
  display: inline-flex; align-items: center; gap: 8px;
  font-size: 0.8rem; color: #171717; white-space: nowrap;
}
.dot {
  width: 12px; height: 12px; border-radius: 50%;
  flex-shrink: 0; display: inline-block;
}
.dot.green { background: #2E7D32; }
.dot.yellow { background: #F57C00; }
.dot.red { background: #C62828; }
.dot.grey { background: #9E9E9E; }
.dot.blue { background: #009CDE; }

.badge {
  display: inline-flex; align-items: center; gap: 8px;
  padding: 4px 10px; font-size: 0.72rem; font-weight: 700;
  text-transform: uppercase; letter-spacing: 0.06em;
  border: 1px solid #D4D4D4; background: #FAFAFA; color: #404040;
  white-space: nowrap;
}
.badge.green { background: #E8F3E9; border-color: #B6D7B7; color: #1F5C22; }
.badge.yellow { background: #FDF1E0; border-color: #F0CB8E; color: #8A4810; }
.badge.red { background: #FBE7E7; border-color: #E0B0B0; color: #8A1A1A; }
.badge.grey { background: #F0F0F0; border-color: #D4D4D4; color: #525252; }
.badge.blue { background: #E3F1F9; border-color: #A6D4EC; color: #00547F; }

/* ---------- Progress bar ---------- */
.progress {
  background: #EAEAEA; height: 8px; width: 100%;
  position: relative; overflow: hidden;
}
.progress .bar { background: #009CDE; height: 100%; transition: width 0.3s; }
.progress.green .bar { background: #2E7D32; }
.progress.yellow .bar { background: #F57C00; }
.progress.red .bar { background: #C62828; }
.progress.grey .bar { background: #9E9E9E; }
.progress-row {
  display: flex; align-items: center; gap: 10px; min-width: 140px;
}
.progress-row .progress { flex: 1; }
.progress-row .pct {
  font-size: 0.78rem; font-weight: 600; color: #404040;
  font-variant-numeric: tabular-nums; min-width: 36px; text-align: right;
}
.progress-tall { height: 12px; }

/* ---------- Tabs ---------- */
.tabs {
  display: flex; background: #F5F5F5;
  border: 1px solid #D4D4D4; border-bottom: none; overflow-x: auto;
}
.tabs button {
  background: transparent; border: none;
  border-right: 1px solid #D4D4D4;
  padding: 12px 22px; font-size: 0.82rem; font-weight: 600;
  color: #525252; letter-spacing: 0.02em; cursor: pointer;
  border-bottom: 3px solid transparent; white-space: nowrap;
  transition: background-color 0.12s, color 0.12s;
}
.tabs button:last-child { border-right: none; }
.tabs button:hover { background: #EAEAEA; color: #171717; }
.tabs button.active {
  background: #FFFFFF; color: #006FA8; border-bottom-color: #009CDE;
}
.tab-panel {
  background: #FFFFFF; border: 1px solid #D4D4D4; padding: 24px;
}

/* ---------- Section heading ---------- */
.section-h {
  text-transform: uppercase; font-size: 0.72rem; font-weight: 700;
  letter-spacing: 0.08em; color: #404040;
  margin: 0 0 12px 0; padding-bottom: 6px; border-bottom: 1px solid #EAEAEA;
  display: flex; justify-content: space-between; align-items: center;
}
.section-h .right { font-weight: 600; }

/* ---------- Budget cells ---------- */
.budget-grid {
  display: grid; grid-template-columns: repeat(3, 1fr);
  gap: 12px; margin-bottom: 20px;
}
.budget-cell {
  border: 1px solid #D4D4D4; padding: 14px 16px; background: #FAFAFA;
}
.budget-cell .label {
  font-size: 0.7rem; text-transform: uppercase; letter-spacing: 0.06em;
  color: #737373; font-weight: 600;
}
.budget-cell .value {
  margin-top: 4px; font-size: 1.4rem; font-weight: 700;
  color: #171717; font-variant-numeric: tabular-nums;
}
.budget-cell .sub { font-size: 0.72rem; color: #737373; margin-top: 2px; }

/* ---------- KPI card ---------- */
.kpi { border: 1px solid #D4D4D4; background: #FFFFFF; margin-bottom: 14px; }
.kpi-head {
  padding: 14px 18px; border-bottom: 1px solid #EAEAEA; background: #FAFAFA;
  display: flex; justify-content: space-between; align-items: flex-start; gap: 12px;
}
.kpi-head .code-title { flex: 1; }
.kpi-head .code {
  font-size: 0.72rem; color: #006FA8; font-weight: 700;
  letter-spacing: 0.04em; font-variant-numeric: tabular-nums;
}
.kpi-head .title {
  font-size: 0.95rem; font-weight: 600; color: #171717; margin-top: 2px;
}
.kpi-body { padding: 16px 18px; }
.kpi-metrics {
  display: grid; grid-template-columns: repeat(5, 1fr); gap: 14px; margin-bottom: 14px;
}
.kpi-metric .label {
  font-size: 0.65rem; text-transform: uppercase; letter-spacing: 0.06em;
  color: #737373; font-weight: 600;
}
.kpi-metric .value {
  font-size: 1rem; font-weight: 700; color: #171717;
  margin-top: 3px; font-variant-numeric: tabular-nums;
}
.kpi-notes {
  margin-top: 12px; padding-top: 12px; border-top: 1px solid #EAEAEA;
  font-size: 0.82rem; color: #404040; line-height: 1.55;
}
.kpi-notes .lbl {
  text-transform: uppercase; font-size: 0.65rem; letter-spacing: 0.06em;
  color: #737373; font-weight: 700; display: block; margin-bottom: 4px;
}
.kpi-actions {
  margin-top: 14px; padding-top: 12px; border-top: 1px solid #EAEAEA;
  display: flex; justify-content: flex-end; gap: 8px;
}

/* ---------- Narrative ---------- */
.narr-section + .narr-section { margin-top: 22px; }
.narr-section label.h {
  display: block; text-transform: uppercase; font-size: 0.72rem;
  font-weight: 700; letter-spacing: 0.06em; color: #404040; margin-bottom: 8px;
}
.narr-section .hint { font-size: 0.75rem; color: #737373; margin-bottom: 8px; }
.narr-section .readonly-text {
  border: 1px solid #EAEAEA; background: #FAFAFA;
  padding: 12px 14px; font-size: 0.85rem; color: #171717;
  line-height: 1.6; white-space: pre-wrap; min-height: 60px;
}
.narr-section .readonly-text.empty { color: #9E9E9E; font-style: italic; }

/* ---------- Forms ---------- */
textarea, input[type="text"], input[type="email"], input[type="password"],
input[type="number"], input[type="search"], input[type="date"], select {
  width: 100%; border: 1px solid #BDBDBD; background: #FFFFFF;
  padding: 9px 12px; font-family: inherit; font-size: 0.85rem;
  color: #171717; transition: border-color 0.12s, box-shadow 0.12s;
}
textarea { min-height: 110px; line-height: 1.55; resize: vertical; }
textarea:focus, input:focus, select:focus {
  outline: none; border-color: #009CDE;
  box-shadow: 0 0 0 2px rgba(0,156,222,0.15);
}
.form-label {
  display: block; text-transform: uppercase; font-size: 0.68rem;
  font-weight: 700; letter-spacing: 0.06em; color: #404040; margin-bottom: 5px;
}
.form-label .req { color: #C62828; margin-left: 3px; }
.form-field + .form-field { margin-top: 14px; }
.form-grid {
  display: grid; grid-template-columns: 1fr 1fr; gap: 14px;
}
.form-grid .full { grid-column: 1 / -1; }
.form-hint { font-size: 0.72rem; color: #737373; margin-top: 4px; }
.char-count { font-size: 0.7rem; color: #737373; margin-top: 4px; text-align: right; }
.checkbox-row {
  display: flex; align-items: center; gap: 8px;
  padding: 6px 0; font-size: 0.85rem; cursor: pointer;
}
.checkbox-row input { margin: 0; width: 16px; height: 16px; cursor: pointer; }
.radio-row { display: flex; gap: 16px; flex-wrap: wrap; }
.radio-row label {
  display: flex; align-items: center; gap: 6px; cursor: pointer; font-size: 0.85rem;
}
.radio-row label input { width: 14px; height: 14px; margin: 0; }

/* ---------- Scorecard ---------- */
.score-grid {
  display: grid; grid-template-columns: repeat(2, 1fr); gap: 14px;
}
.score-cell {
  border: 1px solid #D4D4D4; padding: 16px 18px; background: #FFFFFF;
}
.score-cell h3 {
  margin: 0; font-size: 0.92rem; font-weight: 700;
  color: #171717; letter-spacing: -0.005em;
}
.score-cell .desc {
  font-size: 0.75rem; color: #737373;
  margin-top: 3px; margin-bottom: 12px; line-height: 1.5;
}
.rating-row {
  display: grid; grid-template-columns: repeat(4, 1fr);
  gap: 6px; margin-bottom: 12px;
}
.rating-btn {
  border: 1px solid #BDBDBD; background: #FFFFFF;
  padding: 8px 6px; font-size: 0.72rem; font-weight: 600; color: #404040;
  display: flex; flex-direction: column; align-items: center; gap: 5px;
  cursor: pointer; transition: background-color 0.12s, border-color 0.12s;
}
.rating-btn:hover { background: #F5F5F5; }
.rating-btn .dot { width: 14px; height: 14px; }
.rating-btn.selected.green { background: #E8F3E9; border-color: #2E7D32; color: #1F5C22; }
.rating-btn.selected.yellow { background: #FDF1E0; border-color: #F57C00; color: #8A4810; }
.rating-btn.selected.red { background: #FBE7E7; border-color: #C62828; color: #8A1A1A; }
.rating-btn.selected.grey { background: #F0F0F0; border-color: #737373; color: #404040; }
.score-cell .evidence-label {
  display: block; text-transform: uppercase; font-size: 0.65rem;
  font-weight: 700; letter-spacing: 0.06em; color: #737373; margin-bottom: 5px;
}
.score-cell .evidence-label .req { color: #C62828; margin-left: 3px; }
.score-cell textarea { min-height: 70px; font-size: 0.82rem; }
.score-cell .readonly-text {
  border: 1px solid #EAEAEA; background: #FAFAFA;
  padding: 10px 12px; font-size: 0.82rem; color: #404040; line-height: 1.5;
}

/* ---------- Page footer (action zone) ---------- */
.page-footer {
  margin-top: 22px; padding: 16px 18px;
  background: #FFFFFF; border: 1px solid #D4D4D4;
  display: flex; justify-content: space-between; align-items: center;
  gap: 12px; flex-wrap: wrap;
}
.page-footer .group { display: flex; gap: 8px; flex-wrap: wrap; }

/* ---------- Site footer ---------- */
.site-footer {
  border-top: 1px solid #D4D4D4; background: #FFFFFF;
  padding: 18px 24px; font-size: 0.72rem; color: #737373;
  display: flex; justify-content: space-between; align-items: center;
  margin-top: 32px; flex-wrap: wrap; gap: 8px;
}

/* ---------- Toast ---------- */
.toast {
  position: fixed; bottom: 24px; right: 24px;
  background: #171717; color: #FAFAFA;
  padding: 12px 18px; font-size: 0.82rem;
  border-left: 3px solid #009CDE;
  box-shadow: 0 2px 6px rgba(0,0,0,0.2);
  opacity: 0; pointer-events: none;
  transition: opacity 0.2s, transform 0.2s;
  transform: translateY(8px); z-index: 1000;
  max-width: 360px;
}
.toast.show { opacity: 1; transform: translateY(0); }
.toast.toast-error { border-left-color: #C62828; }
.toast.toast-success { border-left-color: #2E7D32; }

/* ---------- Modal ---------- */
.modal-overlay {
  position: fixed; inset: 0;
  background: rgba(23,23,23,0.55);
  display: flex; align-items: center; justify-content: center;
  z-index: 900; padding: 24px;
  opacity: 0; pointer-events: none;
  transition: opacity 0.15s;
}
.modal-overlay.show { opacity: 1; pointer-events: auto; }
.modal {
  background: #FFFFFF; border: 1px solid #D4D4D4;
  box-shadow: 0 10px 30px rgba(0,0,0,0.25);
  max-width: 560px; width: 100%;
  max-height: calc(100vh - 48px);
  display: flex; flex-direction: column;
  transform: translateY(8px); transition: transform 0.15s;
}
.modal-overlay.show .modal { transform: translateY(0); }
.modal.modal-lg { max-width: 720px; }
.modal.modal-xl { max-width: min(1280px, calc(100vw - 48px)); }
.modal.modal-sm { max-width: 420px; }

/* ---------- WYSIWYG (light) ---------- */
.wysiwyg {
  border: 1px solid #BDBDBD; background: #FFFFFF;
}
.wysiwyg:focus-within {
  border-color: #009CDE;
  box-shadow: 0 0 0 2px rgba(0,156,222,0.15);
}
.wysiwyg-toolbar {
  display: flex; flex-wrap: wrap; gap: 2px;
  padding: 6px 8px;
  background: #FAFAFA;
  border-bottom: 1px solid #EAEAEA;
}
.wysiwyg-btn {
  background: transparent; border: 1px solid transparent;
  padding: 5px 9px; font-size: 0.82rem;
  font-weight: 600; color: #404040;
  font-family: inherit; cursor: pointer;
  transition: background-color 0.1s, border-color 0.1s;
  min-width: 28px; text-align: center;
}
.wysiwyg-btn:hover { background: #EAEAEA; border-color: #D4D4D4; }
.wysiwyg-btn.active { background: #E3F1F9; border-color: #A6D4EC; color: #00547F; }
.wysiwyg-btn .ic-b { font-weight: 700; }
.wysiwyg-btn .ic-i { font-style: italic; }
.wysiwyg-btn .ic-u { text-decoration: underline; }
.wysiwyg-sep {
  width: 1px; background: #D4D4D4; margin: 4px 4px;
}
.wysiwyg-editor {
  min-height: 130px;
  padding: 10px 12px;
  font-family: inherit; font-size: 0.85rem;
  color: #171717; line-height: 1.55;
  outline: none;
  overflow-y: auto;
  max-height: 360px;
}
.wysiwyg-editor[contenteditable=true]:empty::before {
  content: attr(data-placeholder);
  color: #9E9E9E; pointer-events: none;
}
.wysiwyg-editor p { margin: 0 0 8px 0; }
.wysiwyg-editor p:last-child { margin-bottom: 0; }
.wysiwyg-editor ul, .wysiwyg-editor ol { margin: 0 0 8px 22px; padding: 0; }
.wysiwyg-editor li { margin-bottom: 3px; }
.wysiwyg-editor h3 { margin: 6px 0 6px 0; font-size: 0.95rem; font-weight: 700; color: #171717; }
.wysiwyg-editor a { color: #006FA8; }

/* ---------- Revision banner ---------- */
.revision-banner {
  background: #FBE7E7; border: 1px solid #E0B0B0; color: #8A1A1A;
  padding: 14px 18px; margin-bottom: 18px;
  display: flex; justify-content: space-between; align-items: center;
  gap: 14px; flex-wrap: wrap;
}
.revision-banner .title { font-weight: 700; font-size: 0.92rem; }
.revision-banner .sub { font-size: 0.82rem; margin-top: 2px; }

/* ---------- Comment thread ---------- */
.comment.is-addressed { background: #FAFCFA; border-left: 3px solid #2E7D32; padding-left: 13px; }
.comment.is-accepted  { background: #F0F7F0; opacity: 0.85; border-left: 3px solid #2E7D32; padding-left: 13px; }
.comment .status-row {
  display: flex; justify-content: space-between; align-items: center;
  gap: 8px; margin-top: 8px; flex-wrap: wrap;
}
.comment .actions-row {
  display: flex; gap: 6px; flex-wrap: wrap; margin-top: 8px;
}
.comment .response {
  margin-top: 10px; padding: 10px 12px;
  background: #FFFFFF; border: 1px solid #D4D4D4;
  border-left: 3px solid #009CDE;
  font-size: 0.82rem; line-height: 1.55;
}
.comment .response .who {
  font-size: 0.7rem; font-weight: 700; color: #006FA8;
  text-transform: uppercase; letter-spacing: 0.05em;
  display: flex; justify-content: space-between; gap: 8px;
  margin-bottom: 4px;
}
.comment .response .who .when { color: #737373; font-weight: 600; letter-spacing: 0; text-transform: none; }
.comment .response-form {
  margin-top: 8px; display: flex; flex-direction: column; gap: 6px;
}
.comment .response-form textarea { min-height: 70px; font-size: 0.82rem; }
.comment .response-form .form-actions { display: flex; gap: 6px; justify-content: flex-end; }
.modal-head {
  padding: 14px 20px; border-bottom: 1px solid #D4D4D4;
  display: flex; justify-content: space-between; align-items: center;
  background: #FAFAFA;
}
.modal-head h2 {
  margin: 0; font-size: 1rem; font-weight: 700; color: #171717;
}
.modal-head .close {
  background: none; border: none; cursor: pointer;
  font-size: 1.4rem; line-height: 1; color: #737373; padding: 0 4px;
}
.modal-head .close:hover { color: #171717; }
.modal-body {
  padding: 20px; overflow-y: auto; flex: 1;
}
.modal-foot {
  padding: 14px 20px; border-top: 1px solid #D4D4D4;
  background: #FAFAFA;
  display: flex; justify-content: flex-end; gap: 8px; flex-wrap: wrap;
}
.modal-foot.between { justify-content: space-between; }

/* ---------- Login screen ---------- */
.login-shell {
  min-height: 100vh; background: #FAFAFA;
  display: flex; align-items: center; justify-content: center;
  padding: 32px 16px;
}
.login-card {
  background: #FFFFFF; border: 1px solid #D4D4D4;
  max-width: 420px; width: 100%; padding: 32px;
}
.login-card .brand {
  display: flex; align-items: center; gap: 14px;
  padding-bottom: 18px; margin-bottom: 22px;
  border-bottom: 1px solid #EAEAEA;
}
.login-card .brand .logo-mark { width: 52px; height: 52px; font-size: 0.85rem; }
.login-card .brand .text .org {
  font-size: 0.72rem; text-transform: uppercase; letter-spacing: 0.08em; color: #737373;
}
.login-card .brand .text .sys {
  font-size: 1.05rem; font-weight: 700; color: #171717; margin-top: 2px;
}
.login-card h1 {
  margin: 0 0 6px 0; font-size: 1.3rem; font-weight: 700; color: #171717;
}
.login-card .lede {
  font-size: 0.85rem; color: #525252; margin: 0 0 22px 0; line-height: 1.55;
}
.login-card .help {
  margin-top: 20px; padding-top: 18px; border-top: 1px solid #EAEAEA;
  font-size: 0.78rem; color: #737373; line-height: 1.6;
}
.notice {
  background: #F0F7FB; border-left: 3px solid #009CDE;
  padding: 14px 16px; font-size: 0.85rem; color: #00547F;
  margin-bottom: 18px;
}
.notice.warning { background: #FDF1E0; border-left-color: #F57C00; color: #8A4810; }
.notice.success { background: #E8F3E9; border-left-color: #2E7D32; color: #1F5C22; }
.notice.danger  { background: #FBE7E7; border-left-color: #C62828; color: #8A1A1A; }
.notice .title { font-weight: 700; margin-bottom: 4px; }

/* ---------- Two-pane layout (review, assignments) ---------- */
.two-pane {
  display: grid; grid-template-columns: 1fr 360px; gap: 16px;
}
.two-pane > .main-pane { min-width: 0; }
.two-pane > .side-pane { min-width: 0; }
.side-card {
  background: #FFFFFF; border: 1px solid #D4D4D4; margin-bottom: 14px;
}
.side-card .head {
  padding: 12px 16px; border-bottom: 1px solid #EAEAEA;
  font-size: 0.72rem; text-transform: uppercase; letter-spacing: 0.08em;
  font-weight: 700; color: #404040; background: #FAFAFA;
  display: flex; justify-content: space-between; align-items: center;
}
.side-card .body { padding: 14px 16px; }

/* ---------- Comment list ---------- */
.comment-list { display: flex; flex-direction: column; }
.comment {
  padding: 12px 16px; border-bottom: 1px solid #EAEAEA;
  font-size: 0.82rem; line-height: 1.5;
}
.comment:last-child { border-bottom: none; }
.comment .meta {
  display: flex; justify-content: space-between; align-items: center;
  font-size: 0.7rem; color: #737373; margin-bottom: 4px;
}
.comment .section-tag {
  display: inline-block; font-size: 0.66rem; font-weight: 700;
  text-transform: uppercase; letter-spacing: 0.06em;
  color: #006FA8; margin-bottom: 4px;
}
.comment .text { color: #171717; }
.comment .commenter { font-weight: 600; color: #404040; }

/* ---------- Analytics / charts ---------- */
.chart-card {
  background: #FFFFFF; border: 1px solid #D4D4D4;
  margin-bottom: 16px;
}
.chart-card .head {
  padding: 12px 18px; border-bottom: 1px solid #EAEAEA;
  background: #FAFAFA;
  font-size: 0.78rem; text-transform: uppercase; font-weight: 700;
  letter-spacing: 0.08em; color: #404040;
  display: flex; justify-content: space-between; align-items: center;
}
.chart-card .body { padding: 18px; }

.bar-chart { display: flex; flex-direction: column; gap: 10px; }
.bar-row {
  display: grid; grid-template-columns: 160px 1fr 60px;
  align-items: center; gap: 12px; font-size: 0.8rem;
}
.bar-row .lbl { font-weight: 600; color: #404040; }
.bar-row .track {
  background: #EAEAEA; height: 18px; position: relative; overflow: hidden;
}
.bar-row .fill { background: #009CDE; height: 100%; transition: width 0.4s; }
.bar-row .fill.green { background: #2E7D32; }
.bar-row .fill.yellow { background: #F57C00; }
.bar-row .fill.red { background: #C62828; }
.bar-row .fill.grey { background: #9E9E9E; }
.bar-row .val {
  text-align: right; font-weight: 700; font-variant-numeric: tabular-nums; color: #171717;
}

.vbar-chart {
  display: flex; align-items: flex-end; gap: 18px;
  height: 220px; padding: 12px 4px 0 4px;
  border-bottom: 1px solid #D4D4D4;
}
.vbar-col {
  flex: 1; display: flex; flex-direction: column; align-items: center; gap: 6px;
}
.vbar-col .vbar {
  width: 70%; min-width: 32px; background: #009CDE; position: relative;
  display: flex; justify-content: center; align-items: flex-start; padding-top: 4px;
  color: #FFFFFF; font-weight: 700; font-size: 0.75rem;
}
.vbar-col .vbar.green { background: #2E7D32; }
.vbar-col .vbar.yellow { background: #F57C00; }
.vbar-col .vbar.red { background: #C62828; }
.vbar-col .vbar.grey { background: #9E9E9E; }
.vbar-col .vbar-lbl {
  font-size: 0.72rem; color: #525252; text-align: center;
  text-transform: uppercase; letter-spacing: 0.04em;
}

/* ---------- Two-column transfer (assignments) ---------- */
.transfer {
  display: grid; grid-template-columns: 1fr 1fr; gap: 16px;
}
.transfer-col {
  background: #FFFFFF; border: 1px solid #D4D4D4;
  display: flex; flex-direction: column; max-height: 600px;
}
.transfer-col .head {
  padding: 12px 16px; border-bottom: 1px solid #EAEAEA;
  background: #FAFAFA;
  font-size: 0.78rem; text-transform: uppercase; font-weight: 700;
  letter-spacing: 0.08em; color: #404040;
}
.transfer-col .filter { padding: 10px 14px; border-bottom: 1px solid #EAEAEA; }
.transfer-col .list { overflow-y: auto; flex: 1; }
.transfer-item {
  padding: 10px 14px; border-bottom: 1px solid #EAEAEA;
  display: flex; align-items: center; gap: 10px; cursor: pointer;
  transition: background-color 0.1s;
}
.transfer-item:hover { background: #F5F5F5; }
.transfer-item:last-child { border-bottom: none; }
.transfer-item input[type=checkbox] { width: 16px; height: 16px; margin: 0; }
.transfer-item .code-title { flex: 1; min-width: 0; }
.transfer-item .code {
  font-weight: 600; font-size: 0.78rem; color: #006FA8;
  font-variant-numeric: tabular-nums;
}
.transfer-item .ttext {
  font-size: 0.82rem; color: #171717; margin-top: 2px;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.transfer-item .tag {
  font-size: 0.65rem; color: #737373;
  text-transform: uppercase; letter-spacing: 0.05em; margin-top: 2px;
}

/* ---------- Activity feed (admin) ---------- */
.activity-list { display: flex; flex-direction: column; }
.activity-row {
  display: grid; grid-template-columns: 130px 1fr 120px;
  gap: 12px; padding: 10px 14px;
  border-bottom: 1px solid #EAEAEA;
  font-size: 0.82rem;
}
.activity-row:last-child { border-bottom: none; }
.activity-row .when { color: #737373; font-variant-numeric: tabular-nums; }
.activity-row .who { color: #404040; font-weight: 600; }
.activity-row .what { color: #171717; }

/* ---------- Audit logs ---------- */
.log-row td { font-family: "SFMono-Regular", Consolas, monospace; font-size: 0.78rem; }
.log-row .details {
  background: #FAFAFA; padding: 10px 14px; font-size: 0.75rem;
  color: #525252; border-left: 3px solid #009CDE;
}

/* ---------- Role landing cards ---------- */
.role-grid {
  display: grid; grid-template-columns: repeat(3, 1fr); gap: 16px;
  margin-top: 22px;
}
.role-card {
  background: #FFFFFF; border: 1px solid #D4D4D4;
  padding: 22px; text-decoration: none; color: inherit;
  transition: border-color 0.15s, background-color 0.15s;
  display: flex; flex-direction: column;
}
.role-card:hover {
  border-color: #009CDE; background: #FCFEFF; text-decoration: none;
}
.role-card .tag {
  font-size: 0.7rem; text-transform: uppercase;
  letter-spacing: 0.08em; font-weight: 700; color: #009CDE;
}
.role-card h3 {
  margin: 4px 0 6px 0; font-size: 1.05rem; font-weight: 700; color: #171717;
}
.role-card p { margin: 0 0 14px 0; font-size: 0.82rem; color: #525252; line-height: 1.55; }
.role-card .links { margin-top: auto; }
.role-card .links a {
  display: block; padding: 6px 0;
  font-size: 0.82rem; color: #006FA8; border-top: 1px solid #EAEAEA;
}
.role-card .links a:first-child { border-top: none; }

/* ---------- Responsive ---------- */
@media (max-width: 1200px) {
  .summary-grid { grid-template-columns: repeat(2, 1fr); }
  .summary-grid.cols-3 { grid-template-columns: 1fr; }
  .kpi-metrics { grid-template-columns: repeat(3, 1fr); }
  .score-grid { grid-template-columns: 1fr; }
  .two-pane { grid-template-columns: 1fr; }
  .role-grid { grid-template-columns: 1fr 1fr; }
}
@media (max-width: 768px) {
  main { padding: 14px; }
  .topbar { padding: 6px 14px; flex-direction: column; gap: 2px; text-align: center; }
  .header { padding: 12px 14px; flex-wrap: wrap; }
  .header-user { padding-left: 0; border-left: none; border-top: 1px solid #D4D4D4; padding-top: 8px; margin-top: 4px; text-align: left; width: 100%; }
  .nav { padding: 0 8px; }
  .nav a, .nav button { padding: 12px 12px; }
  .summary-grid, .summary-grid.cols-3 { grid-template-columns: 1fr 1fr; }
  .budget-grid { grid-template-columns: 1fr; }
  .kpi-metrics { grid-template-columns: 1fr 1fr; }
  .tabs button { padding: 12px 14px; }
  .rating-row { grid-template-columns: 1fr 1fr; }
  .page-header h1 { font-size: 1.2rem; }
  table { font-size: 0.78rem; }
  tbody td.title { max-width: 200px; }
  .form-grid { grid-template-columns: 1fr; }
  .transfer { grid-template-columns: 1fr; }
  .role-grid { grid-template-columns: 1fr; }
  .activity-row { grid-template-columns: 1fr; gap: 2px; }
}

@media print {
  .topbar, .nav, .action-bar, .filter-bar, .page-footer, .tabs, .toast,
  .modal-overlay, .side-pane { display: none !important; }
  body { background: #FFFFFF; }
  .page-header, .summary-box, .table-wrap, .tab-panel, .kpi, .score-cell,
  .chart-card { box-shadow: none; border: 1px solid #999; }
}
