:root {
  --bg: #f6f8fb;
  --panel: #ffffff;
  --ink: #17202a;
  --muted: #667085;
  --line: #d8dee8;
  --brand: #176b87;
  --brand-strong: #0f4f66;
  --accent: #d98c25;
  --ok: #1f8a5f;
  --warn: #b7791f;
  --bad: #b42318;
  --shadow: 0 12px 32px rgba(17, 24, 39, 0.08);
  font-family: Inter, Segoe UI, Arial, sans-serif;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  color: var(--ink);
  background: var(--bg);
}

[hidden] {
  display: none !important;
}

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

button {
  cursor: pointer;
}

.auth-screen {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.86), rgba(246, 248, 251, 0.94)),
    #e9f1f4;
}

.login-card {
  width: min(440px, 100%);
  padding: 24px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #ffffff;
  box-shadow: var(--shadow);
  display: grid;
  gap: 16px;
}

.login-brand {
  padding-bottom: 14px;
  border-bottom: 1px solid var(--line);
}

.login-copy {
  color: var(--muted);
  line-height: 1.55;
  margin-bottom: 0;
}

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

.forgot-link {
  justify-self: start;
}

.demo-users {
  display: grid;
  gap: 8px;
  padding-top: 10px;
  border-top: 1px solid var(--line);
}

.demo-user {
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 10px;
  text-align: left;
  background: #fbfcfe;
}

.demo-user strong,
.demo-user span {
  display: block;
}

.demo-user span {
  color: var(--muted);
  font-size: 12px;
  margin-top: 3px;
}

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

.sidebar {
  background: #101820;
  color: #f8fafc;
  padding: 24px 18px;
  display: flex;
  flex-direction: column;
  gap: 24px;
}

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

.brand-mark {
  width: 44px;
  height: 44px;
  display: grid;
  place-items: center;
  border-radius: 8px;
  background: var(--accent);
  color: #111827;
  font-weight: 800;
}

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

.brand span {
  color: #aeb8c4;
  font-size: 13px;
  margin-top: 2px;
}

.nav-list {
  display: grid;
  gap: 6px;
}

.nav-item {
  width: 100%;
  border: 0;
  border-radius: 6px;
  color: #dbe4ef;
  background: transparent;
  text-align: left;
  padding: 11px 12px;
}

.nav-item:hover,
.nav-item.active {
  background: #243241;
  color: #ffffff;
}

.nav-item.locked {
  cursor: not-allowed;
  opacity: 0.58;
}

.nav-item.locked span {
  display: block;
  color: #aeb8c4;
  font-size: 11px;
  font-weight: 700;
  margin-top: 3px;
}

.nav-section-label {
  color: #8d9baa;
  font-size: 11px;
  font-weight: 800;
  margin: 12px 4px 2px;
  text-transform: uppercase;
}

.role-panel {
  margin-top: auto;
  padding: 14px;
  border: 1px solid #344456;
  border-radius: 8px;
  background: #17222e;
}

label {
  display: block;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0;
  margin-bottom: 6px;
}

.role-panel label {
  color: #bac6d3;
}

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

.role-panel p {
  color: #bac6d3;
  font-size: 12px;
  line-height: 1.45;
  margin: 10px 0 0;
}

.user-panel strong,
.user-panel span {
  display: block;
}

.user-panel strong {
  color: #ffffff;
  margin-bottom: 4px;
}

.user-panel span {
  color: #d5dee8;
  font-size: 13px;
  font-weight: 700;
}

.logout-btn {
  width: 100%;
  margin-top: 12px;
}

.main {
  min-width: 0;
  display: flex;
  flex-direction: column;
}

.topbar {
  min-height: 88px;
  padding: 20px 28px;
  background: #ffffff;
  border-bottom: 1px solid var(--line);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
}

.eyebrow {
  margin: 0 0 4px;
  color: var(--brand);
  font-size: 12px;
  font-weight: 800;
  text-transform: uppercase;
}

h1,
h2,
h3,
p {
  margin-top: 0;
}

h1 {
  margin-bottom: 0;
  font-size: 28px;
}

h2 {
  font-size: 18px;
  margin-bottom: 4px;
}

.top-actions,
.dialog-actions {
  display: flex;
  align-items: center;
  gap: 10px;
}

.primary-btn,
.ghost-btn,
.icon-btn {
  border: 1px solid transparent;
  border-radius: 6px;
  min-height: 40px;
  padding: 8px 14px;
  font-weight: 700;
}

.primary-btn {
  background: var(--brand);
  color: #ffffff;
}

.primary-btn:hover {
  background: var(--brand-strong);
}

.ghost-btn {
  background: #ffffff;
  color: var(--brand-strong);
  border-color: var(--line);
}

.icon-btn {
  min-width: 44px;
  background: #eef5f8;
  color: var(--brand-strong);
  border-color: #c8dbe3;
}

.workspace {
  padding: 24px 28px 32px;
  display: grid;
  gap: 18px;
}

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

.filters {
  padding: 14px;
  display: grid;
  grid-template-columns: minmax(220px, 1fr) 180px 220px auto;
  align-items: end;
  gap: 12px;
}

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

.stat-card {
  min-height: 116px;
  padding: 16px;
  background: #ffffff;
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
  display: grid;
  align-content: space-between;
}

.stat-card span {
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
}

.stat-card strong {
  font-size: 30px;
}

.stat-card p {
  color: var(--muted);
  font-size: 13px;
  margin-bottom: 0;
}

.content-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 360px;
  gap: 18px;
  align-items: start;
}

.panel-header {
  padding: 16px;
  border-bottom: 1px solid var(--line);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.panel-header p {
  color: var(--muted);
  font-size: 13px;
  margin-bottom: 0;
}

.table-wrap {
  overflow: auto;
  max-height: calc(100vh - 330px);
}

table {
  width: 100%;
  border-collapse: collapse;
  min-width: 760px;
}

th,
td {
  padding: 12px 14px;
  border-bottom: 1px solid var(--line);
  text-align: left;
  vertical-align: top;
  font-size: 14px;
}

th {
  position: sticky;
  top: 0;
  z-index: 1;
  background: #f8fafc;
  color: #344054;
  font-size: 12px;
  text-transform: uppercase;
}

tr {
  transition: background 120ms ease;
}

tbody tr:hover,
tbody tr.selected {
  background: #eef7f9;
}

.status-pill {
  display: inline-flex;
  min-height: 24px;
  align-items: center;
  border-radius: 6px;
  padding: 3px 8px;
  font-size: 12px;
  font-weight: 800;
  background: #eef2f6;
  color: #344054;
  white-space: nowrap;
}

.status-pill.active,
.status-pill.completed {
  background: #e7f5ee;
  color: var(--ok);
}

.status-pill.due-soon,
.status-pill.pending,
.status-pill.open,
.status-pill.in-review,
.status-pill.placeholder {
  background: #fff3dc;
  color: var(--warn);
}

.status-pill.overdue,
.status-pill.rejected {
  background: #fee4e2;
  color: var(--bad);
}

.detail-panel {
  position: sticky;
  top: 18px;
}

.detail-body {
  padding: 16px;
  display: grid;
  gap: 12px;
}

.detail-hero {
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #f8fafc;
}

.detail-hero h3 {
  margin: 10px 0 5px;
}

.detail-hero p {
  color: var(--muted);
  margin-bottom: 0;
  line-height: 1.45;
}

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

.detail-metrics div {
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #ffffff;
}

.detail-metrics strong,
.detail-metrics span {
  display: block;
}

.detail-metrics strong {
  font-size: 22px;
}

.detail-metrics span {
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}

.detail-kv {
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fbfcfe;
}

.detail-kv span {
  display: block;
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
  margin-bottom: 4px;
}

.empty-state {
  color: var(--muted);
  line-height: 1.55;
  margin: 0;
}

dialog {
  width: min(760px, calc(100vw - 28px));
  border: 0;
  border-radius: 8px;
  padding: 0;
  box-shadow: 0 24px 80px rgba(15, 23, 42, 0.3);
}

dialog::backdrop {
  background: rgba(16, 24, 32, 0.48);
}

.record-form {
  padding: 18px;
}

.dialog-header {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 14px;
}

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

.field-full {
  grid-column: 1 / -1;
}

.dialog-actions {
  justify-content: flex-end;
  margin: 18px 0 0;
  padding: 0;
}

.action-link {
  border: 0;
  background: transparent;
  color: var(--brand);
  font-weight: 800;
  padding: 0 8px 0 0;
}

.danger-link {
  color: var(--bad);
}

@media (max-width: 1120px) {
  .app-shell {
    grid-template-columns: 230px minmax(0, 1fr);
  }

  .filters,
  .content-grid {
    grid-template-columns: 1fr;
  }

  .detail-panel {
    position: static;
  }

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

@media (max-width: 760px) {
  .app-shell {
    display: block;
  }

  .sidebar {
    position: static;
    padding: 16px;
  }

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

  .topbar {
    align-items: flex-start;
    flex-direction: column;
    padding: 18px;
  }

  .top-actions {
    width: 100%;
  }

  .top-actions button {
    flex: 1;
  }

  .workspace {
    padding: 16px;
  }

  .stats-grid,
  .form-grid {
    grid-template-columns: 1fr;
  }

  table {
    min-width: 640px;
  }
}

@media print {
  body {
    background: #ffffff;
  }

  .sidebar,
  .top-actions,
  .filters,
  .detail-panel,
  dialog {
    display: none;
  }

  .app-shell,
  .content-grid {
    display: block;
  }

  .topbar,
  .workspace,
  .panel-header {
    padding: 0 0 12px;
  }

  .panel,
  .stat-card {
    box-shadow: none;
  }

  .table-wrap {
    max-height: none;
    overflow: visible;
  }
}
