:root {
  --navy: #0b2146;
  --ink: #172033;
  --muted: #6b7280;
  --teal: #13b9a8;
  --blue: #2d5f9f;
  --orange: #f59e0b;
  --bg: #f6f8fb;
  --panel: #ffffff;
  --line: #dde5ef;
  --shadow: 0 14px 34px rgba(15, 23, 42, 0.08);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  color: var(--ink);
  background: var(--bg);
}

[hidden] {
  display: none !important;
}

button,
input,
select {
  font: inherit;
}

.app-shell {
  min-height: 100vh;
  display: grid;
  grid-template-columns: 280px minmax(0, 1fr);
}

.sidebar {
  position: sticky;
  top: 0;
  height: 100vh;
  background: #fff;
  border-right: 1px solid var(--line);
  padding: 22px;
  display: flex;
  flex-direction: column;
  gap: 22px;
}

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

.brand img {
  width: 44px;
  height: 44px;
  object-fit: cover;
  border-radius: 10px;
  box-shadow: 0 8px 18px rgba(15, 23, 42, 0.14);
}

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

.login-card {
  width: min(400px, 100%);
  display: grid;
  gap: 18px;
  padding: 28px;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
}

.compact-login-card {
  margin-top: 14px;
}

.compact-login-card h2 {
  margin: 0;
}

.login-logo {
  display: block;
  width: 52px !important;
  height: 52px !important;
  max-width: 52px;
  max-height: 52px;
  aspect-ratio: 1;
  object-fit: cover;
  border-radius: 12px;
  box-shadow: 0 8px 18px rgba(15, 23, 42, 0.14);
}

.login-heading {
  display: grid;
  gap: 5px;
}

.login-heading h1 {
  font-size: 1.55rem;
}

.login-heading > p:last-child {
  color: var(--muted);
}

.field {
  display: grid;
  gap: 7px;
}

.field label {
  color: var(--ink);
  font-size: 0.84rem;
  font-weight: 750;
}

.login-submit {
  width: 100%;
}

.login-error {
  min-height: 18px;
  color: #b91c1c !important;
  font-size: 0.85rem;
  font-weight: 700;
}

.brand strong,
.brand span {
  display: block;
}

.brand span,
.eyebrow,
.small,
.admin-contact span {
  color: var(--muted);
  font-size: 0.82rem;
}

nav {
  display: grid;
  gap: 6px;
}

.nav-item,
.icon-button,
.primary,
.danger-button,
.secondary-button {
  border: 0;
  cursor: pointer;
}

.nav-item {
  text-align: left;
  padding: 10px 12px;
  border-radius: 8px;
  background: transparent;
  color: var(--muted);
  font-weight: 700;
}

.nav-item.active,
.nav-item:hover {
  background: rgba(19, 185, 168, 0.12);
  color: var(--navy);
}

.nav-badge {
  align-items: center;
  background: #dc2626;
  border-radius: 999px;
  color: white;
  display: inline-flex;
  font-size: 11px;
  font-weight: 900;
  height: 20px;
  justify-content: center;
  margin-left: auto;
  min-width: 20px;
  padding: 0 6px;
}

.admin-contact {
  margin-top: auto;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  display: grid;
  gap: 4px;
}

a {
  color: var(--blue);
  font-weight: 700;
  text-decoration: none;
}

.main {
  min-width: 0;
  padding: 26px;
}

.topbar {
  display: flex;
  justify-content: space-between;
  gap: 18px;
  align-items: center;
  margin-bottom: 22px;
}

h1,
h2,
p {
  margin: 0;
}

h1 {
  font-size: 1.8rem;
}

h2 {
  font-size: 1rem;
}

.toolbar {
  display: flex;
  gap: 10px;
}

input,
select {
  min-height: 42px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 9px 11px;
  background: #fff;
  color: var(--ink);
}

#global-search {
  width: min(360px, 42vw);
}

.primary,
.icon-button,
.danger-button,
.secondary-button {
  min-height: 40px;
  border-radius: 8px;
  padding: 0 14px;
  color: #fff;
  background: var(--navy);
  font-weight: 800;
}

.icon-button {
  background: var(--teal);
}

.danger-button {
  background: #b91c1c;
}

.secondary-button {
  color: var(--navy);
  background: #fff;
  border: 1px solid var(--line);
}

button:disabled,
input:disabled,
select:disabled {
  cursor: not-allowed;
  opacity: 0.62;
}

.section {
  display: none;
}

.section.active {
  display: grid;
  gap: 18px;
}

.metrics {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 14px;
}

.metric,
.panel,
.record-form,
.table {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
}

.metric {
  padding: 16px;
  display: grid;
  gap: 4px;
  width: 100%;
  text-align: left;
  color: inherit;
  font: inherit;
  cursor: pointer;
  transition: transform 160ms ease, border-color 160ms ease, box-shadow 160ms ease;
}

.metric:hover,
.metric:focus-visible {
  transform: translateY(-2px);
  border-color: rgba(19, 185, 168, 0.55);
  box-shadow: 0 12px 28px rgba(21, 43, 63, 0.12);
}

.metric.attention strong {
  color: var(--orange);
}

.metric span,
.metric em {
  color: var(--muted);
  font-style: normal;
  font-size: 0.82rem;
}

.metric strong {
  font-size: 1.9rem;
}

.panel-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 16px;
}

.block-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 16px;
}

.block-card {
  display: grid;
  gap: 16px;
  padding: 18px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
}

.block-card-heading {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
}

.block-card h3 {
  margin: 3px 0 0;
}

.block-details {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
  margin: 0;
}

.block-details div {
  min-width: 0;
}

.block-details .block-reference {
  grid-column: 1 / -1;
}

.block-details dt {
  color: var(--muted);
  font-size: 0.75rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.block-details dd {
  margin: 4px 0 0;
  overflow-wrap: anywhere;
}

.panel {
  padding: 18px;
  display: grid;
  gap: 14px;
}

.section-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
}

.record-form,
.stacked-form {
  display: grid;
  gap: 10px;
}

.record-form {
  grid-template-columns: repeat(3, minmax(0, 1fr)) auto;
  padding: 14px;
}

.stacked-form {
  max-width: 560px;
}

.table,
.list {
  overflow: hidden;
}

.row,
.list-item {
  display: grid;
  grid-template-columns: 1.3fr 1fr 1fr auto;
  gap: 12px;
  align-items: center;
  padding: 12px 14px;
  border-bottom: 1px solid var(--line);
}

.review-item {
  grid-template-columns: 1fr 1.8fr auto auto;
}

.list-actions {
  display: flex;
  gap: 8px;
  justify-content: flex-end;
  flex-wrap: wrap;
}

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

.row small,
.list-item small {
  color: var(--muted);
}

.list-item.actionable {
  width: 100%;
  border: 0;
  background: transparent;
  color: inherit;
  font: inherit;
  text-align: left;
  cursor: pointer;
}

.list-item.actionable:hover,
.list-item.actionable:focus-visible {
  background: rgba(19, 185, 168, 0.08);
}

.status {
  width: max-content;
  padding: 4px 8px;
  border-radius: 999px;
  background: rgba(19, 185, 168, 0.12);
  color: var(--navy);
  font-size: 0.78rem;
  font-weight: 800;
}

.warning {
  background: rgba(245, 158, 11, 0.16);
}

.notice {
  min-height: 28px;
  color: var(--blue);
  font-weight: 800;
}

.toast {
  min-height: 0;
  margin: -8px 0 14px;
}

.notice.error {
  color: #b91c1c;
}

.checklist {
  display: grid;
  gap: 10px;
  padding-left: 0;
  list-style: none;
}

.settings-grid {
  display: grid;
  gap: 12px;
  max-width: 760px;
}

.settings-grid label {
  align-items: center;
  background: var(--soft);
  border: 1px solid var(--line);
  border-radius: 8px;
  display: flex;
  gap: 10px;
  padding: 12px;
}

.settings-grid input[type="checkbox"] {
  accent-color: var(--teal);
  height: 18px;
  width: 18px;
}

.admin-permission-row {
  align-items: center;
  display: grid;
  gap: 10px;
  grid-template-columns: 1fr minmax(120px, 160px) auto;
}

.permission-pill {
  background: var(--soft);
  border-radius: 999px;
  color: var(--blue);
  display: inline-flex;
  font-size: 12px;
  font-weight: 800;
  padding: 4px 8px;
}

.director-only[hidden] {
  display: none !important;
}

.legal-page {
  max-width: 920px;
  margin: 0 auto;
}

.legal-page .panel {
  gap: 16px;
  line-height: 1.55;
}

@media (max-width: 920px) {
  .app-shell {
    grid-template-columns: 1fr;
  }

  .sidebar {
    position: static;
    height: auto;
  }

  nav {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .topbar,
  .toolbar,
  .section-head {
    align-items: stretch;
    flex-direction: column;
  }

  #global-search,
  .toolbar button {
    width: 100%;
  }

  .metrics,
  .panel-grid,
  .block-grid,
  .record-form {
    grid-template-columns: 1fr;
  }

  .block-details {
    grid-template-columns: 1fr;
  }

  .row,
  .list-item {
    grid-template-columns: 1fr;
  }

  .list-actions {
    justify-content: flex-start;
  }
}
