/* ============================================================
   Components: shell, tabs, buttons, forms, board, dialogs, account screens, chatbot.
   Structure is carried by rules and spacing. Only things that are genuinely cards (tasks on the board, dialogs) are
   boxed. Labels are sentence case; there are no all-caps eyebrows. Chart/KPI/table styles live in charts.css.
   ============================================================ */

/* ---------- buttons ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: var(--s2);
  min-height: 40px; padding: var(--s2) var(--s4); border: 1px solid transparent; border-radius: var(--r-control);
  background: none; font-size: var(--fs-sm); font-weight: 600; line-height: 1.2; cursor: pointer;
  transition: background-color 0.15s, border-color 0.15s, color 0.15s;
}
.btn:disabled { opacity: 0.6; cursor: progress; }
.btn-primary { background: var(--brand); color: var(--on-brand); }
.btn-primary:hover:not(:disabled) { background: var(--brand-hover); }
.btn-secondary { background: var(--sheet); border-color: var(--rule-strong); color: var(--ink); }
.btn-secondary:hover:not(:disabled) { background: var(--sheet-2); border-color: var(--muted); }
.btn-quiet { color: var(--ink-2); padding-left: var(--s3); padding-right: var(--s3); }
.btn-quiet:hover:not(:disabled) { background: var(--brand-tint); color: var(--link); }
.btn-small { min-height: 32px; padding: 2px var(--s3); font-size: var(--fs-xs); background: var(--sheet); border-color: var(--rule-strong); color: var(--ink); }
.btn-small:hover:not(:disabled) { background: var(--sheet-2); }
.btn-danger { color: var(--st-blocked-ink); }
.link-btn { display: block; margin: var(--s3) auto 0; padding: var(--s2); background: none; border: 0; color: var(--link); text-decoration: underline; cursor: pointer; font-size: var(--fs-sm); }
.icon-btn {
  display: inline-flex; align-items: center; justify-content: center; min-width: 32px; min-height: 32px; padding: 4px;
  border: 1px solid transparent; border-radius: var(--r-control); background: transparent; color: var(--ink-2); cursor: pointer; font-size: 1.125rem; line-height: 1;
  transition: background-color 0.15s, color 0.15s;
}
.icon-btn:hover { background: var(--brand-tint); color: var(--link); }
.icon-btn.del:hover { background: var(--st-blocked-tint); color: var(--st-blocked-ink); }

/* ---------- forms ---------- */
.field label, .filters label, .tbl-tools label { display: block; margin-bottom: var(--s1); font-size: var(--fs-sm); font-weight: 600; }
.field-control {
  width: 100%; min-height: 40px; padding: var(--s2) var(--s3); border: 1px solid var(--rule-strong); border-radius: var(--r-control);
  background: var(--sheet); color: var(--ink);
}
.field-control:hover { border-color: var(--muted); }
.field-control[aria-invalid="true"] { border-color: var(--st-blocked); background: var(--st-blocked-tint); }
textarea.field-control { resize: vertical; min-height: 84px; }
.req { color: var(--st-blocked-ink); }
.field-error, .form-error { margin-top: var(--s1); color: var(--st-blocked-ink); font-size: var(--fs-sm); }
.field-error:empty, .form-error:empty { display: none; }
.form-notice { margin-top: var(--s2); color: var(--st-done-ink); font-size: var(--fs-sm); }
.form-notice:empty { display: none; }
.form-hint, .field-hint { color: var(--ink-2); font-size: var(--fs-sm); }
.field-hint { float: right; font-weight: 400; }
.form-hint { margin: var(--s1) 0 var(--s2); max-width: 60ch; }
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: var(--s3) var(--s4); }
.form-grid .full { grid-column: 1 / -1; }
.form-actions { display: flex; justify-content: flex-end; gap: var(--s3); margin-top: var(--s4); }
fieldset.methods { min-width: 0; margin: 0 0 var(--s2); padding: var(--s2) var(--s3); border: 1px solid var(--rule); border-radius: var(--r-card); }
fieldset.methods legend { padding: 0 var(--s1); font-size: var(--fs-sm); font-weight: 600; }
.radio { display: flex; align-items: flex-start; gap: var(--s2); padding: var(--s2) 0; cursor: pointer; }
.radio input { margin-top: 5px; accent-color: var(--brand); }
.radio small { display: block; color: var(--ink-2); font-size: var(--fs-sm); }
.show-pw { display: block; margin: var(--s1) 0 var(--s2); color: var(--ink-2); font-size: var(--fs-sm); cursor: pointer; }
.show-pw input, input[type="checkbox"] { accent-color: var(--brand); }
input[type="range"].field-control { min-height: 0; padding: 0; border: 0; background: none; accent-color: var(--brand); }
.range-row { display: flex; align-items: center; gap: var(--s3); }
.range-row output { min-width: 3.4em; text-align: right; font-family: var(--serif); font-size: var(--fs-lg); font-weight: 600; font-variant-numeric: tabular-nums; }

/* ---------- sign-in screens ---------- */
.login-view { min-height: 100vh; display: grid; place-items: center; padding: var(--s4); background: var(--paper); }
.login-card { width: 100%; max-width: 420px; padding: var(--s6) var(--s5); background: var(--sheet); border: 1px solid var(--rule); border-top: 4px solid var(--brand); border-radius: var(--r-dialog); box-shadow: var(--shadow-lg); }
.login-card h1 { margin-bottom: var(--s1); font-family: var(--serif); font-size: var(--fs-xl); color: var(--link); letter-spacing: 0.01em; }
.login-card .sub { margin-bottom: var(--s4); color: var(--ink-2); max-width: 40ch; }
.login-card .field { margin-bottom: var(--s3); }
.login-card .btn { width: 100%; margin-top: var(--s3); }

/* ---------- shell: header and tabs ---------- */
.app-header { position: sticky; top: 0; z-index: 20; background: var(--sheet); border-bottom: 1px solid var(--rule); }
.header-inner { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: var(--s3); max-width: var(--page); margin: 0 auto; padding: var(--s3) var(--s5) var(--s1); }
.brand { display: flex; align-items: baseline; gap: var(--s3); }
.wordmark { font-family: var(--serif); font-size: var(--fs-2xl); line-height: 1.15; font-weight: 700; letter-spacing: 0.01em; color: var(--link); }
.brand-sub { color: var(--ink-2); font-size: var(--fs-sm); }
.header-actions { display: flex; flex-wrap: wrap; align-items: center; gap: var(--s3); }
.user-bar { display: flex; flex-wrap: wrap; align-items: center; gap: var(--s1); font-size: var(--fs-sm); }
.user-name { font-weight: 600; margin-right: var(--s1); }
.role-badge { padding: 1px var(--s2); border: 1px solid var(--rule-strong); border-radius: var(--r-chip); color: var(--ink-2); font-size: var(--fs-xs); font-weight: 500; text-transform: capitalize; margin-right: var(--s2); }

.tabs { display: flex; gap: var(--s1); max-width: var(--page); margin: 0 auto; padding: 0 var(--s4); overflow-x: auto; scrollbar-width: none; }
.tabs::-webkit-scrollbar { display: none; }
.tab {
  display: inline-flex; align-items: center; gap: var(--s2); min-height: 44px; padding: var(--s2) var(--s4); white-space: nowrap;
  background: none; border: 0; border-bottom: 3px solid transparent; color: var(--ink-2); font-size: var(--fs-sm); font-weight: 500; cursor: pointer;
  transition: color 0.15s, border-color 0.15s, background-color 0.15s;
}
.tab:hover { color: var(--ink); background: var(--sheet-2); }
.tab[aria-selected="true"] { color: var(--link); border-bottom-color: var(--link); font-weight: 600; }
.tab .icon { width: 1.2em; height: 1.2em; }

.main { max-width: var(--page); margin: 0 auto; padding: var(--s6) var(--s5) var(--s7); }
.page-head { margin-bottom: var(--s5); }
.page-head h2 { font-family: var(--serif); font-size: var(--fs-xl); font-weight: 600; }
.page-head .sub { margin-top: var(--s1); max-width: 70ch; color: var(--ink-2); font-size: var(--fs-sm); }
.app-footer { padding: var(--s4); text-align: center; color: var(--ink-2); font-size: var(--fs-sm); }

/* ---------- board ---------- */
.summary { display: flex; flex-wrap: wrap; gap: var(--s2) var(--s5); margin: 0 0 var(--s4); padding: 0; list-style: none; }
.summary li { display: flex; align-items: baseline; gap: var(--s2); color: var(--ink-2); font-size: var(--fs-sm); }
.summary strong { font-family: var(--serif); font-size: var(--fs-xl); font-weight: 600; color: var(--ink); font-variant-numeric: tabular-nums; }
.summary .stat-overdue, .summary .stat-overdue strong { color: var(--st-blocked-ink); }
.filters { display: flex; flex-wrap: wrap; align-items: flex-end; gap: var(--s4); margin-bottom: var(--s5); padding-bottom: var(--s4); border-bottom: 1px solid var(--rule); }
.filters > div { flex: 1 1 170px; min-width: 150px; }
.filters > div:last-child { flex: 0 0 auto; }

.board { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: var(--s4); align-items: start; }
.column { min-height: 180px; background: var(--sheet-2); border: 1px solid var(--rule); border-top: 3px solid var(--st-backlog); border-radius: var(--r-card); }
.column[data-status="In Progress"] { border-top-color: var(--st-progress); }
.column[data-status="Blocked"] { border-top-color: var(--st-blocked); }
.column[data-status="Done"] { border-top-color: var(--st-done); }
.column.drop-target { background: var(--brand-tint); border-color: var(--focus); border-style: dashed; border-top-style: solid; }
.column-header { display: flex; justify-content: space-between; align-items: baseline; padding: var(--s3) var(--s3) 0; }
.column-title { font-size: var(--fs); font-weight: 600; }
.count-badge { font-family: var(--serif); font-size: var(--fs-xl); font-weight: 600; color: var(--ink-2); font-variant-numeric: tabular-nums; line-height: 1; }
.column-sub { padding: var(--s1) var(--s3) var(--s2); color: var(--ink-2); font-size: var(--fs-sm); }
.card-list { display: flex; flex-direction: column; gap: var(--s3); min-height: 60px; padding: var(--s2) var(--s3) var(--s3); }
.empty-msg { padding: var(--s4) var(--s3); text-align: center; color: var(--ink-2); font-size: var(--fs-sm); }

.card { position: relative; padding: var(--s3); background: var(--sheet); border: 1px solid var(--rule); border-left: 4px solid var(--pr-low); border-radius: var(--r-control); box-shadow: var(--shadow); cursor: grab; }
.card:hover { border-color: var(--rule-strong); }
.card.readonly { cursor: default; }
.card.dragging { opacity: 0.4; }
.card.prio-Critical { border-left-color: var(--pr-critical); }
.card.prio-High { border-left-color: var(--pr-high); }
.card.prio-Medium { border-left-color: var(--pr-medium); }
.card.prio-Low { border-left-color: var(--pr-low); }
.card-top { display: flex; justify-content: space-between; align-items: center; gap: var(--s2); }
.card-top > span:last-child { display: inline-flex; align-items: center; }
.task-id { color: var(--ink-2); font-size: var(--fs-xs); font-weight: 500; font-variant-numeric: tabular-nums; }
.card-title { margin: var(--s1) 0 var(--s2); font-size: var(--fs); font-weight: 600; word-break: break-word; }
.card-meta { margin: 2px 0; color: var(--ink-2); font-size: var(--fs-sm); word-break: break-word; }
.card-badges { display: flex; flex-wrap: wrap; gap: var(--s1); margin: var(--s2) 0; }
.card-progress { display: flex; align-items: center; gap: var(--s2); margin-top: var(--s2); color: var(--ink-2); font-size: var(--fs-xs); font-variant-numeric: tabular-nums; }
.card-progress svg { flex: 1; height: 6px; }
.card-actions { display: flex; justify-content: space-between; align-items: center; gap: var(--s2); margin-top: var(--s3); }

.pill, .tag, .overdue-badge, .chip { display: inline-flex; align-items: center; gap: 5px; padding: 1px 7px; border-radius: var(--r-chip); font-size: var(--fs-xs); font-weight: 500; line-height: 1.55; }
.pill-Critical { background: var(--st-blocked-tint); color: var(--st-blocked-ink); }
.pill-High { background: var(--warn-tint); color: var(--warn-ink); }
.pill-Medium { background: var(--st-progress-tint); color: var(--st-progress-ink); }
.pill-Low { background: var(--st-backlog-tint); color: var(--st-backlog-ink); }
.tag { background: var(--sheet); color: var(--ink-2); border: 1px solid var(--rule); }
.overdue-badge { background: var(--st-blocked-tint); color: var(--st-blocked-ink); font-weight: 600; }
.chip-backlog { background: var(--st-backlog-tint); color: var(--st-backlog-ink); }
.chip-progress { background: var(--st-progress-tint); color: var(--st-progress-ink); }
.chip-blocked { background: var(--st-blocked-tint); color: var(--st-blocked-ink); }
.chip-done { background: var(--st-done-tint); color: var(--st-done-ink); }
.chip-warn { background: var(--warn-tint); color: var(--warn-ink); }
.chip .icon, .overdue-badge .icon { width: 1em; height: 1em; vertical-align: -0.15em; }
.move-select, .role-select { min-height: 32px; max-width: 150px; padding: 2px var(--s2); border: 1px solid var(--rule-strong); border-radius: var(--r-control); background: var(--sheet); font-size: var(--fs-xs); }
.confirm { display: inline-flex; align-items: center; gap: var(--s1); font-size: var(--fs-xs); }
.confirm button { min-height: 28px; padding: 2px var(--s2); border: 1px solid var(--rule-strong); border-radius: var(--r-control); background: var(--sheet); font-size: var(--fs-xs); cursor: pointer; }
.confirm .yes { background: var(--st-blocked); border-color: var(--st-blocked); color: #fff; }

/* ---------- dialogs ---------- */
.overlay { position: fixed; inset: 0; z-index: 40; display: flex; align-items: flex-start; justify-content: center; padding: var(--s5) var(--s3); overflow-y: auto; background: var(--scrim); }
.modal { width: 100%; max-width: 600px; padding: var(--s5); background: var(--sheet); border-top: 4px solid var(--brand); border-radius: var(--r-dialog); box-shadow: var(--shadow-lg); }
.modal.narrow { max-width: 450px; }
.modal-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: var(--s3); }
.modal-head h2 { font-family: var(--serif); font-size: var(--fs-xl); font-weight: 600; }
.history-list { list-style: none; max-height: 60vh; margin: 0; padding: 0; overflow-y: auto; }
.history-list li { margin-bottom: var(--s3); padding: var(--s1) var(--s3); border-left: 3px solid var(--brand); }
.history-list .h-head { font-weight: 600; }
.history-list .h-meta { display: flex; flex-wrap: wrap; color: var(--ink-2); font-size: var(--fs-sm); font-variant-numeric: tabular-nums; }
.history-list .h-meta > span + span { margin-left: var(--s2); padding-left: var(--s2); border-left: 1px solid var(--rule-strong); }
.history-list .h-change { margin-top: 2px; font-size: var(--fs-sm); word-break: break-word; }
.history-list .h-empty { border-left-color: var(--rule); color: var(--ink-2); }
.history-list .h-delete { border-left-color: var(--st-blocked); }

/* ---------- toasts ---------- */
.toast-region { position: fixed; right: var(--s4); bottom: 88px; z-index: 60; display: flex; flex-direction: column; gap: var(--s2); max-width: calc(100vw - 2 * var(--s4)); }
.toast { padding: var(--s3) var(--s4); background: var(--ink); color: var(--sheet); border-left: 4px solid var(--st-done); border-radius: var(--r-control); box-shadow: var(--shadow-lg); font-size: var(--fs-sm); }
.toast.warn { border-left-color: var(--pr-high); }

/* ---------- skip link ---------- */
.sr-only:focus-visible#skip-link {
  position: fixed; top: var(--s2); left: var(--s2); z-index: 100; width: auto; height: auto; margin: 0; padding: var(--s2) var(--s4);
  overflow: visible; clip: auto; background: var(--sheet); color: var(--ink); border-radius: var(--r-control); box-shadow: var(--shadow-lg); font-weight: 600; text-decoration: none;
}

/* ---------- account screens: password strength, users, one-time credentials ---------- */
.pw-meter { display: flex; align-items: center; gap: var(--s2); margin: var(--s1) 0 var(--s2); }
.pw-bar { flex: 1; height: 8px; overflow: hidden; background: var(--sheet-2); border: 1px solid var(--rule); border-radius: var(--r-chip); }
.pw-bar span { display: block; height: 100%; transition: width 0.2s; }
.pw-bar .l0 { width: 8%; background: var(--st-blocked); }
.pw-bar .l1 { width: 40%; background: var(--pr-high); }
.pw-bar .l2 { width: 70%; background: var(--st-progress); }
.pw-bar .l3 { width: 100%; background: var(--st-done); }
.pw-label { min-width: 120px; text-align: right; color: var(--ink-2); font-size: var(--fs-sm); font-weight: 500; }
.pw-checks { margin: 0 0 var(--s2); padding: 0; list-style: none; color: var(--ink-2); font-size: var(--fs-sm); }
.pw-checks li { padding: 1px 0; }
.pw-checks li.ok { color: var(--st-done-ink); }
.pw-checks li.bad { color: var(--st-blocked-ink); }

.users-head { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: flex-end; gap: var(--s3); margin-bottom: var(--s4); }
.users-head h2 { font-family: var(--serif); font-size: var(--fs-xl); font-weight: 600; }
.users-note { margin-bottom: var(--s3); padding: var(--s2) var(--s3); background: var(--warn-tint); border-radius: var(--r-control); color: var(--warn-ink); font-size: var(--fs-sm); }
.users-note:empty { display: none; }
.users-table { width: 100%; border-collapse: collapse; font-size: var(--fs-sm); }
.users-table th, .users-table td { padding: var(--s3); text-align: left; vertical-align: middle; border-bottom: 1px solid var(--rule); }
.users-table thead th { color: var(--ink-2); font-size: var(--fs-sm); font-weight: 600; border-bottom: 2px solid var(--ink); }
.users-table tbody th { font-weight: 600; }
.actions-cell { display: flex; flex-wrap: wrap; align-items: center; gap: var(--s1); }
.role-chip { padding: 1px var(--s2); border: 1px solid var(--rule-strong); border-radius: var(--r-chip); color: var(--ink-2); font-size: var(--fs-xs); font-weight: 500; text-transform: capitalize; }
.status-pill { padding: 1px var(--s2); border-radius: var(--r-chip); font-size: var(--fs-xs); font-weight: 600; }
.status-active { background: var(--st-done-tint); color: var(--st-done-ink); }
.status-invited, .status-temporary { background: var(--st-progress-tint); color: var(--st-progress-ink); }
.status-expired { background: var(--warn-tint); color: var(--warn-ink); }
.status-deactivated { background: var(--st-backlog-tint); color: var(--st-backlog-ink); }
.activity-title { margin: var(--s6) 0 var(--s2); font-family: var(--serif); font-size: var(--fs-lg); font-weight: 600; }
.activity { max-height: 340px; margin: 0; padding: 0; overflow-y: auto; list-style: none; border-top: 2px solid var(--ink); font-size: var(--fs-sm); }
.activity li { padding: var(--s2) var(--s1); border-bottom: 1px solid var(--rule); word-break: break-word; }
.activity time { margin-right: var(--s2); color: var(--ink-2); font-variant-numeric: tabular-nums; }
.cred-box { margin: var(--s3) 0; padding: var(--s3); background: var(--sheet-2); border: 1px solid var(--rule); border-radius: var(--r-card); }
.cred-row { display: flex; flex-direction: column; margin-bottom: var(--s2); }
.cred-label { color: var(--ink-2); font-size: var(--fs-sm); font-weight: 600; }
.cred-box code { font-family: ui-monospace, "Cascadia Mono", "Consolas", monospace; font-size: var(--fs-lg); font-weight: 600; user-select: all; word-break: break-all; }
.cred-copied { margin-left: var(--s2); color: var(--st-done-ink); font-size: var(--fs-sm); }
.cred-warn { color: var(--ink-2); font-size: var(--fs-sm); }
.cred-warn.bad { color: var(--st-blocked-ink); }

/* ---------- IT assistant chatbot ---------- */
.bot { position: fixed; right: var(--s4); bottom: var(--s4); z-index: 50; display: flex; flex-direction: column; align-items: flex-end; gap: var(--s2); }
.bot-fab { display: grid; place-items: center; width: 60px; height: 60px; border: 0; border-radius: 50%; background: var(--st-done); box-shadow: var(--shadow-lg); cursor: pointer; animation: bot-float 3s ease-in-out infinite; }
.bot-fab:hover { filter: brightness(0.92); }
.bot-fab svg { width: 34px; height: 34px; }
.bot.speaking .bot-fab { animation: bot-pulse 0.9s ease-in-out infinite; }
.bot-panel { width: 290px; max-width: calc(100vw - 2 * var(--s4)); overflow: hidden; background: var(--sheet); border: 1px solid var(--rule); border-radius: var(--r-dialog); box-shadow: var(--shadow-lg); }
.bot-head { display: flex; justify-content: space-between; align-items: center; padding: 10px 14px; background: var(--st-done); color: #0b0b0b; font-weight: 600; }
.bot-close { padding: 4px 8px; border: 0; background: none; color: #0b0b0b; font-size: 20px; line-height: 1; cursor: pointer; }
.bot-body { padding: 14px; font-size: var(--fs-sm); }
.bot-msg { margin-bottom: 12px; padding: 10px 12px; background: var(--sheet-2); border-radius: 12px 12px 12px 2px; }
.bot-wa { display: block; padding: 10px; background: var(--st-done); color: #0b0b0b; border-radius: var(--r-control); font-weight: 600; text-align: center; text-decoration: none; }
.bot-wa:hover { filter: brightness(0.92); }
.bot-note { margin-top: 8px; color: var(--ink-2); font-size: var(--fs-xs); }
@keyframes bot-float { 0%, 100% { transform: translateY(0); } 50% { transform: translateY(-6px); } }
@keyframes bot-pulse { 0%, 100% { transform: scale(1); } 50% { transform: scale(1.12); } }

/* ---------- touch screens: 44px targets with room between them ---------- */
@media (pointer: coarse) {
  .btn, .field-control, .tab, .toggle-btn, .move-select, .role-select, .confirm button, .view-toggle button { min-height: 44px; }
  .icon-btn { min-width: 44px; min-height: 44px; }
  .btn-small { min-height: 40px; }
  .card-top { gap: var(--s1); }
  .actions-cell, .tbl-quick, .card-badges { gap: var(--s2); }
}

/* ---------- responsive ---------- */
@media (max-width: 1100px) and (min-width: 769px) {
  .board { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 768px) {
  /* A sticky header would eat a third of a phone screen, so it scrolls away (the tab bar is one swipe back up). */
  .app-header { position: static; }
  .header-inner { padding: var(--s3) var(--s3) var(--s1); }
  .tabs { padding: 0 var(--s2); }
  .main { padding: var(--s4) var(--s3) var(--s6); }
  .board { grid-template-columns: 1fr; }
  .form-grid { grid-template-columns: 1fr; }
  .modal { padding: var(--s4); }
  .pw-label { min-width: 96px; }
  .brand-sub { display: none; }
  .wordmark { font-size: var(--fs-xl); }
}

/* NYP logo: navy and red on transparent. On dark themes it sits on a white plate (--logo-backing). */
.logo { display: block; height: 44px; width: auto; flex: none; padding: var(--logo-pad); background: var(--logo-backing); border-radius: 6px; align-self: center; }
.logo-login { height: 56px; margin-bottom: var(--s3); }
@media (max-width: 768px) { .logo { height: 36px; } .logo-login { height: 48px; } }
