:root {
  color-scheme: light;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  color: #151b2a;
  background: #f4f6f8;
  --red: #e60005;
  --red-dark: #b70004;
  --border: #d9dee5;
  --muted: #667085;
  --surface: #ffffff;
}

* { box-sizing: border-box; }
body { margin: 0; min-height: 100vh; background: #f4f6f8; }
button, input, select { font: inherit; }
button, .button {
  border: 1px solid var(--red);
  border-radius: 10px;
  padding: .72rem 1rem;
  color: #fff;
  background: var(--red);
  font-weight: 750;
  cursor: pointer;
  text-decoration: none;
}
button:hover, .button:hover { background: var(--red-dark); }
button:disabled { cursor: wait; opacity: .6; }
.secondary { color: var(--red); background: #fff; }
.secondary:hover { color: #fff; }
.danger { border-color: #7a171a; background: #7a171a; }
.danger:hover { border-color: #5e1114; background: #5e1114; }
input, select {
  width: 100%;
  border: 1px solid #cbd2dc;
  border-radius: 10px;
  padding: .72rem .8rem;
  background: #fff;
  color: #151b2a;
}
input:focus, select:focus, button:focus-visible, a:focus-visible {
  outline: 3px solid rgba(230, 0, 5, .2);
  outline-offset: 2px;
}
label { color: #344054; font-weight: 700; }
h1, h2, p { margin-top: 0; }

.auth-page { display: grid; place-items: center; padding: 1.5rem; }
.login-shell { width: min(100%, 520px); }
.login-card {
  display: grid;
  gap: 1.35rem;
  padding: clamp(1.5rem, 5vw, 2.6rem);
  border-top: 8px solid var(--red);
  border-radius: 18px;
  background: var(--surface);
  box-shadow: 0 18px 50px rgba(17, 24, 39, .12);
}
.auth-logo { width: min(100%, 270px); max-height: 110px; object-fit: contain; object-position: left center; }
.auth-eyebrow { margin-bottom: .3rem; color: var(--red); font-size: .78rem; font-weight: 850; letter-spacing: .08em; text-transform: uppercase; }
.login-card h1 { margin-bottom: .5rem; font-size: clamp(1.7rem, 6vw, 2.35rem); }
.auth-intro { margin: 0; color: var(--muted); }
.auth-form { display: grid; gap: .65rem; }
.auth-form button { margin-top: .55rem; }
#hiorgLoginTitle, #adminLoginTitle { margin: 0; font-size: 1.25rem; }
.hiorg-login-panel {
  padding: clamp(.7rem, 3vw, 1rem);
  border: 1px solid var(--border);
  border-radius: 12px;
  background: #f4f6f8;
}
.hiorg-login-header {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: start;
  gap: .6rem;
}
.hiorg-login-logo {
  display: block;
  width: clamp(3rem, 14vw, 4rem);
  height: auto;
  padding: .28rem;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--surface);
}
.hiorg-login-heading, .local-login-heading { display: grid; gap: .3rem; }
.hiorg-login-heading { overflow-wrap: anywhere; }
.hiorg-external-badge {
  justify-self: start;
  padding: .18rem .55rem;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--surface);
  color: #344054;
  font-size: .75rem;
  font-weight: 750;
}
.login-method-hint { margin: 0; color: #475467; font-size: .9rem; line-height: 1.45; }
.login-method-hint strong { display: inline-block; max-width: 100%; color: #151b2a; overflow-wrap: anywhere; }
.login-method-hint a { color: var(--red-dark); text-underline-offset: .12em; }
#hiorgLoginButton {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: .45rem;
  min-height: 44px;
  margin-top: .15rem;
}
.local-login-button {
  min-height: 44px;
  border-color: #cbd2dc;
  color: #151b2a;
  background: var(--surface);
}
.local-login-button:hover:not(:disabled) { background: #f4f6f8; }
@media (max-width: 420px) {
  .login-page { padding: 1rem; }
  .login-page .login-card { padding: 1.15rem; }
  #hiorgLoginButton { padding-inline: .65rem; }
}
#hiorgLoginMessage:empty { min-height: 0; margin: 0; }
.form-message { min-height: 1.35rem; margin: .35rem 0 0; color: #a20b10; font-weight: 700; }
.test-notice { margin: 0; padding: .85rem 1rem; border: 1px solid #f4c7c8; border-radius: 10px; color: #7b2225; background: #fff7f7; font-size: .9rem; line-height: 1.45; }
.setup-notice { margin: 0; padding: .85rem 1rem; border: 1px solid #f6d776; border-radius: 10px; color: #6c4a04; background: #fffbea; font-size: .9rem; font-weight: 700; line-height: 1.45; }
.mfa-section { display: grid; gap: 1rem; }
.mfa-section[hidden] { display: none; }
.mfa-section > p { margin-bottom: 0; color: var(--muted); line-height: 1.5; }
.mfa-setup-code { display: grid; grid-template-columns: minmax(150px, 220px) 1fr; align-items: center; gap: 1rem; }
.mfa-setup-code img { width: 100%; border: 1px solid var(--border); border-radius: 10px; }
.mfa-setup-code code { display: block; margin-top: .4rem; overflow-wrap: anywhere; color: #344054; font-size: 1rem; font-weight: 800; letter-spacing: .08em; }
.field-label { color: #344054; font-weight: 700; }
.recovery-section h2 { margin-bottom: 0; }
.recovery-section pre { margin: 0; padding: 1rem; border: 1px solid var(--border); border-radius: 10px; background: #f8fafc; font: 750 1rem/1.7 ui-monospace, SFMono-Regular, Menlo, monospace; user-select: all; }
.confirmation-check { display: grid; grid-template-columns: 1.2rem 1fr; align-items: start; gap: .65rem; }
.confirmation-check input { width: 1.2rem; height: 1.2rem; margin: .1rem 0 0; }

.admin-main { display: grid; grid-template-columns: minmax(0, 1fr); gap: 1.5rem; width: min(1480px, calc(100% - 2rem)); margin: 2rem auto; }
.admin-card { padding: clamp(1rem, 3vw, 1.8rem); border-radius: 16px; background: #fff; box-shadow: 0 8px 28px rgba(17, 24, 39, .08); }
.section-heading { display: flex; align-items: end; justify-content: space-between; gap: 1rem; margin-bottom: 1.25rem; }
.section-heading h1, .section-heading h2 { margin-bottom: 0; }
.section-heading > p { margin-bottom: 0; color: var(--muted); }
.user-create-grid { display: grid; grid-template-columns: repeat(5, minmax(140px, 1fr)) auto; align-items: end; gap: .85rem; }
.user-create-grid label { display: grid; gap: .4rem; }
.admin-create-grid { grid-template-columns: repeat(2, minmax(9rem, 1fr)) minmax(12rem, 1.25fr) auto auto; }
.admin-create-grid > button { white-space: nowrap; }
.admin-create-hint { grid-column: 1 / -1; color: var(--muted); line-height: 1.35; }
.incident-toolbar { display: flex; align-items: end; justify-content: flex-end; gap: .65rem; flex-wrap: wrap; }
.incident-toolbar label { display: grid; gap: .3rem; }
.incident-toolbar select { min-width: 190px; }
.table-scroll { overflow-x: auto; }
.admin-table { width: 100%; border-collapse: collapse; }
.admin-table th, .admin-table td { padding: .75rem; border-bottom: 1px solid #e4e7ec; text-align: left; vertical-align: middle; }
.admin-table th { color: var(--muted); font-size: .78rem; text-transform: uppercase; }
.admin-table input[type="checkbox"] { width: 1.2rem; height: 1.2rem; }
.inactive-user { opacity: .58; }
.archived-incident { background: #f8fafc; color: #526071; }
.incident-title { display: grid; gap: .2rem; min-width: 190px; }
.incident-title strong { color: #151b2a; }
.incident-title small, .incident-meta { color: var(--muted); }
.status-badge { display: inline-block; border-radius: 999px; padding: .3rem .55rem; font-size: .8rem; font-weight: 800; white-space: nowrap; }
.status-running { color: #126b38; background: #e8f7ee; }
.status-ended { color: #475467; background: #eef1f4; }
.status-archived { color: #7a4e00; background: #fff1c7; }
.row-actions { display: flex; gap: .45rem; flex-wrap: wrap; }
.row-actions button:disabled { cursor: not-allowed; }
.compact { padding: .55rem .7rem; white-space: nowrap; }
.role-note { margin: 1rem 0 0; color: var(--muted); line-height: 1.5; }
.password-dialog { width: min(92vw, 500px); border: 0; border-top: 7px solid var(--red); border-radius: 14px; padding: 1.4rem; box-shadow: 0 20px 70px rgba(0, 0, 0, .3); }
.password-dialog::backdrop { background: rgba(15, 23, 42, .58); }
.password-dialog form { display: grid; gap: .65rem; }
.dialog-actions { display: flex; justify-content: flex-end; gap: .65rem; margin-top: .65rem; }
.delete-warning { padding: .75rem; border: 1px solid #f4c7c8; border-radius: 10px; color: #7b2225; background: #fff7f7; font-weight: 700; }

@media (max-width: 1000px) {
  .user-create-grid { grid-template-columns: repeat(2, minmax(180px, 1fr)); }
  .admin-create-grid > button[type="submit"] { grid-column: 1 / -1; justify-self: end; }
}

@media (max-width: 700px) {
  .mfa-setup-code { grid-template-columns: 1fr; }
  .mfa-setup-code img { width: min(100%, 240px); justify-self: center; }
  .section-heading { align-items: flex-start; flex-direction: column; }
  .user-create-grid { grid-template-columns: 1fr; }
  .admin-create-grid > button[type="submit"] { justify-self: stretch; }
  .admin-table thead { display: none; }
  .admin-table, .admin-table tbody, .admin-table tr, .admin-table td { display: block; width: 100%; }
  .admin-table tr { margin-bottom: 1rem; padding: .7rem; border: 1px solid var(--border); border-radius: 12px; }
  .admin-table td { display: grid; grid-template-columns: 105px 1fr; gap: .6rem; padding: .55rem; border: 0; }
  .admin-table td::before { content: attr(data-label); color: var(--muted); font-size: .8rem; font-weight: 800; }
  .row-actions { display: flex !important; }
}
