:root {
  color-scheme: light;
  --bg: #f5f7f8;
  --surface: #ffffff;
  --surface-alt: #eef3f2;
  --sidebar: #e9eeee;
  --field: #ffffff;
  --raised: #fbfcfc;
  --ink: #172126;
  --muted: #617078;
  --line: #d9e0e3;
  --accent: #e94f1d;
  --accent-strong: #c93418;
  --accent-soft: #fff0ea;
  --gold: #8d6412;
  --red: #a43e3e;
  --blue: #275f9f;
  --green: #23724d;
  --shadow: 0 18px 45px rgba(28, 39, 46, 0.1);
}

[data-theme="dark"] {
  color-scheme: dark;
  --bg: #0f1519;
  --surface: #172126;
  --surface-alt: #1f2d33;
  --sidebar: #121b20;
  --field: #10191e;
  --raised: #141f24;
  --ink: #ecf3f4;
  --muted: #a7b6bc;
  --line: #2d3d44;
  --accent: #ff6a32;
  --accent-strong: #ff7b4a;
  --accent-soft: rgba(255, 106, 50, 0.16);
  --gold: #f0bd58;
  --red: #ff9b9b;
  --blue: #9cc7ff;
  --green: #87d5a9;
  --shadow: 0 18px 45px rgba(0, 0, 0, 0.36);
}

* { box-sizing: border-box; }

body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
  color: var(--ink);
  font-family: "Avenir Next", "Segoe UI", Arial, sans-serif;
}

button, input, select, textarea {
  font: inherit;
}

a { color: var(--accent); }

[hidden] { display: none !important; }

.portal-shell {
  min-height: 100vh;
}

.login-view {
  display: grid;
  min-height: 100vh;
  place-items: center;
  padding: 24px;
}

.login-panel {
  width: min(440px, 100%);
  padding: 30px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  padding: 10px 16px;
  background: var(--surface);
  border-bottom: 1px solid var(--line);
}

.topbar h1,
.login-panel h1,
.board-header h2,
.detail-header h3 {
  margin: 0;
  line-height: 1.15;
  letter-spacing: 0;
}

.topbar h1 { font-size: 1.28rem; }
.login-panel h1 { font-size: 1.8rem; margin-bottom: 20px; }
.board-header h2 { font-size: 1.28rem; }
.detail-header h3 { font-size: 1.25rem; }

.brand-lockup {
  display: flex;
  align-items: center;
  gap: 10px;
}

.brand-lockup img {
  width: 34px;
  height: 34px;
  object-fit: contain;
  flex: 0 0 auto;
}

.brand-lockup.large {
  align-items: center;
  margin-bottom: 20px;
}

.brand-lockup.large img {
  width: 48px;
  height: 48px;
}

.brand-lockup.large h1 {
  margin-bottom: 0;
}

.eyebrow,
.section-label {
  margin: 0 0 3px;
  color: var(--muted);
  font-size: 0.74rem;
  font-weight: 800;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.workspace {
  display: grid;
  grid-template-columns: minmax(240px, 285px) minmax(0, 1fr);
  min-height: calc(100vh - 55px);
}

.sidebar {
  padding: 12px;
  background: var(--sidebar);
  border-right: 1px solid var(--line);
}

.sidebar-block + .sidebar-block { margin-top: 18px; }

.review-board {
  padding: 10px 12px 12px;
}

.board-header,
.profile-strip,
.detail-header,
.status-row,
.form-pair {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
}

.board-header {
  display: grid;
  grid-template-columns: minmax(150px, max-content) minmax(0, 1fr) auto;
  gap: 8px;
  align-items: center;
  margin-bottom: 8px;
}

.board-header h2 {
  white-space: nowrap;
}

.profile-strip {
  justify-content: flex-end;
  color: var(--muted);
  font-weight: 700;
}

.profile-button {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-height: 34px;
  padding: 0 10px;
  border: 1px solid transparent;
  border-radius: 999px;
  background: transparent;
  color: var(--ink);
  cursor: pointer;
  font-weight: 800;
}

.profile-button:hover,
.profile-button:focus {
  border-color: var(--accent);
  background: var(--accent-soft);
}

.profile-avatar {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: var(--accent);
  color: #fff;
  font-size: 0.76rem;
  font-weight: 900;
  object-fit: cover;
}

.profile-avatar.large {
  width: 46px;
  height: 46px;
  font-size: 1rem;
}

.button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 34px;
  padding: 0 11px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--surface);
  color: var(--ink);
  cursor: pointer;
  text-decoration: none;
  font-weight: 750;
}

.button:hover { border-color: var(--accent); }
.button.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.button.primary:hover { background: var(--accent-strong); }
.button.small { min-height: 32px; padding: 0 10px; font-size: 0.88rem; }
.sso-button { margin-top: 12px; width: 100%; }

.form-stack,
.decision-form {
  display: grid;
  gap: 12px;
}

label {
  display: grid;
  gap: 6px;
  color: var(--muted);
  font-size: 0.88rem;
  font-weight: 700;
}

input,
select,
textarea {
  width: 100%;
  min-height: 40px;
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 9px 10px;
  color: var(--ink);
  background: var(--field);
}

.owner-picker {
  position: relative;
}

.owner-search {
  background-image: linear-gradient(45deg, transparent 50%, var(--muted) 50%), linear-gradient(135deg, var(--muted) 50%, transparent 50%);
  background-position: calc(100% - 18px) 17px, calc(100% - 13px) 17px;
  background-size: 5px 5px, 5px 5px;
  background-repeat: no-repeat;
  padding-right: 34px;
}

.owner-options {
  position: absolute;
  z-index: 20;
  top: calc(100% + 4px);
  left: 0;
  right: 0;
  max-height: 220px;
  overflow: auto;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 6px;
  box-shadow: var(--shadow);
}

.owner-option {
  display: grid;
  width: 100%;
  gap: 2px;
  padding: 9px 10px;
  border: 0;
  border-bottom: 1px solid var(--line);
  background: transparent;
  color: var(--ink);
  cursor: pointer;
  text-align: left;
}

.owner-option:last-child {
  border-bottom: 0;
}

.owner-option:hover,
.owner-option:focus {
  background: var(--accent-soft);
}

.owner-option strong {
  font-size: 0.88rem;
}

.owner-option small {
  color: var(--muted);
  font-size: 0.78rem;
}

.owner-option.empty {
  color: var(--muted);
  cursor: default;
}

textarea {
  min-height: 110px;
  resize: vertical;
}

.form-error {
  min-height: 20px;
  margin: 0;
  color: var(--red);
  font-size: 0.9rem;
}

.queue-nav,
.item-list,
.detail-pane {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
}

.queue-nav {
  display: grid;
  gap: 0;
  overflow: hidden;
}

.queue-button,
.item-row {
  display: grid;
  width: 100%;
  grid-template-columns: auto minmax(0, 1fr) auto;
  gap: 12px;
  align-items: center;
  border: 0;
  border-bottom: 1px solid var(--line);
  background: transparent;
  color: var(--ink);
  cursor: pointer;
  text-align: left;
}

.queue-button {
  grid-template-columns: auto minmax(0, 1fr) auto;
  min-height: 66px;
  padding: 10px 12px;
}

.item-row {
  grid-template-columns: minmax(0, 1fr) auto;
}

.queue-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  border-radius: 8px;
  background: var(--surface-alt);
  font-size: 1.1rem;
}

.queue-button:last-child,
.item-row:last-child { border-bottom: 0; }

.queue-button.active,
.item-row.active {
  background: var(--accent-soft);
  box-shadow: inset 4px 0 0 var(--accent);
}

.queue-button strong,
.item-row strong {
  display: block;
  margin-bottom: 5px;
}

.queue-button small,
.item-row small {
  display: block;
  color: var(--muted);
  line-height: 1.35;
}

.status-row {
  justify-content: flex-end;
  flex-wrap: nowrap;
  margin: 0;
  min-width: 0;
  overflow-x: auto;
  scrollbar-width: thin;
}

.metric-button {
  display: grid;
  min-width: max-content;
  grid-template-columns: auto auto;
  gap: 4px;
  align-items: baseline;
  padding: 5px 7px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 6px;
  color: var(--ink);
  cursor: pointer;
  text-align: left;
}

.metric-button:hover,
.metric-button.active {
  border-color: var(--accent);
  background: var(--accent-soft);
}

.metric-button span {
  font-size: 0.9rem;
  font-weight: 850;
  line-height: 1;
  white-space: nowrap;
}

.metric-button small {
  color: var(--muted);
  display: block;
  font-size: 0.66rem;
  font-weight: 800;
  line-height: 1;
  text-transform: uppercase;
  white-space: nowrap;
}

.status-row div {
  min-width: 0;
  padding: 8px 10px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 6px;
}

.status-row span {
  display: block;
  margin-bottom: 2px;
  font-size: 1rem;
  font-weight: 850;
  line-height: 1.05;
  white-space: nowrap;
}

.status-row small {
  color: var(--muted);
  display: block;
  font-size: 0.68rem;
  line-height: 1.15;
  white-space: nowrap;
}

.board-grid {
  display: grid;
  grid-template-columns: minmax(250px, 0.78fr) minmax(390px, 1.22fr);
  gap: 10px;
  align-items: start;
}

.item-list,
.detail-pane {
  overflow: hidden;
  min-width: 0;
}

.list-header {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 12px;
  padding: 9px 12px;
  background: var(--surface-alt);
  color: var(--muted);
  font-size: 0.76rem;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

.item-row {
  min-height: 64px;
  padding: 10px 12px;
}

.detail-pane {
  min-height: 430px;
  padding: 12px;
}

.metadata {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
  margin: 14px 0 10px;
}

.metadata div,
.score-strip div,
.evidence-block,
.decision-strip {
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--raised);
}

.metadata dt {
  margin-bottom: 4px;
  color: var(--muted);
  font-size: 0.75rem;
  font-weight: 800;
  text-transform: uppercase;
}

.metadata dd {
  margin: 0;
  overflow-wrap: anywhere;
}

.score-strip {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
  margin: 0 0 12px;
}

.score-strip span {
  display: block;
  margin-bottom: 4px;
  color: var(--ink);
  font-size: 1.15rem;
  font-weight: 850;
  line-height: 1.1;
  text-transform: capitalize;
}

.score-strip small {
  display: block;
  color: var(--muted);
  font-size: 0.75rem;
  font-weight: 800;
  text-transform: uppercase;
}

.evidence-block {
  margin-bottom: 14px;
}

.evidence-block ul {
  margin: 0;
  padding-left: 18px;
  color: var(--muted);
  line-height: 1.5;
}

.decision-strip {
  display: grid;
  gap: 4px;
  margin-bottom: 14px;
  color: var(--muted);
}

.decision-strip strong { color: var(--ink); }

.detail-actions {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 10px;
  flex-wrap: wrap;
}

.empty-state {
  padding: 28px;
  color: var(--muted);
  text-align: center;
}

.badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 26px;
  padding: 0 9px;
  border-radius: 999px;
  background: #eef1f2;
  color: #485961;
  font-size: 0.72rem;
  font-weight: 850;
  text-transform: uppercase;
  white-space: nowrap;
}

.badge.high,
.badge.rejected { background: #f7e9e9; color: var(--red); }
.badge.medium,
.badge.snoozed { background: #fbf1db; color: var(--gold); }
.badge.open { background: #e8eef5; color: var(--blue); }
.badge.approved,
.badge.password,
.badge.entra { background: #e4f2ea; color: var(--green); }
.badge.blocked { background: #ede9f7; color: #5a4a8d; }

[data-theme="dark"] .badge { background: #25343b; color: var(--muted); }
[data-theme="dark"] .badge.high,
[data-theme="dark"] .badge.rejected { background: rgba(255, 155, 155, 0.15); color: var(--red); }
[data-theme="dark"] .badge.medium,
[data-theme="dark"] .badge.snoozed { background: rgba(240, 189, 88, 0.15); color: var(--gold); }
[data-theme="dark"] .badge.open { background: rgba(156, 199, 255, 0.15); color: var(--blue); }
[data-theme="dark"] .badge.approved,
[data-theme="dark"] .badge.password,
[data-theme="dark"] .badge.entra { background: rgba(135, 213, 169, 0.15); color: var(--green); }
[data-theme="dark"] .badge.blocked { background: rgba(166, 146, 255, 0.15); color: #c2b6ff; }

.settings-view {
  position: fixed;
  inset: 0;
  z-index: 50;
  display: grid;
  place-items: center;
  padding: 18px;
  background: rgba(9, 14, 17, 0.55);
}

.settings-panel {
  width: min(520px, 100%);
  padding: 18px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--surface);
  box-shadow: var(--shadow);
}

.settings-header,
.profile-card {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
}

.settings-header {
  margin-bottom: 16px;
}

.settings-header h2 {
  margin: 0;
}

.profile-card {
  justify-content: flex-start;
  margin-bottom: 16px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--raised);
}

.profile-card div {
  display: grid;
  gap: 4px;
}

.profile-card small {
  color: var(--muted);
}

.settings-form {
  display: grid;
  gap: 12px;
}

@media (max-width: 1000px) {
  .board-grid {
    grid-template-columns: 1fr;
  }

  .board-header {
    grid-template-columns: 1fr auto;
  }

  .board-header .status-row {
    grid-column: 1 / -1;
    grid-row: 2;
    justify-content: flex-start;
    flex-wrap: wrap;
  }

  .metadata,
  .score-strip,
  .form-pair {
    grid-template-columns: 1fr;
    display: grid;
  }
}

@media (min-width: 1001px) and (max-width: 1180px) {
  .workspace {
    grid-template-columns: minmax(220px, 260px) minmax(0, 1fr);
  }

  .queue-button {
    min-height: 54px;
    padding: 8px 10px;
  }

  .queue-button small {
    display: none;
  }

  .board-grid {
    grid-template-columns: minmax(230px, 0.72fr) minmax(360px, 1.28fr);
  }
}

@media (max-width: 680px) {
  .topbar,
  .board-header,
  .detail-header {
    align-items: flex-start;
  }

  .board-header {
    grid-template-columns: 1fr;
  }

  .board-header .status-row {
    grid-column: auto;
    grid-row: auto;
  }

  .topbar h1 {
    font-size: 1.25rem;
  }

  .review-board,
  .sidebar {
    padding: 12px;
  }
}

@media (max-width: 820px) {
  .workspace {
    grid-template-columns: 66px minmax(0, 1fr);
  }

  .sidebar {
    padding: 8px;
  }

  .sidebar .section-label,
  .queue-copy {
    position: absolute;
    width: 1px;
    height: 1px;
    overflow: hidden;
    clip: rect(0 0 0 0);
    white-space: nowrap;
  }

  .queue-button {
    grid-template-columns: 1fr;
    justify-items: center;
    gap: 6px;
    min-height: 58px;
    padding: 8px 4px;
  }

  .queue-button.active,
  .item-row.active {
    box-shadow: inset 3px 0 0 var(--accent);
  }

  .queue-icon {
    width: 34px;
    height: 34px;
  }

  .queue-count-label {
    min-height: 18px;
    padding: 0 5px;
    font-size: 0.62rem;
  }
}
