:root {
  --bg: #f8f9fa;
  --surface: #ffffff;
  --surface-strong: #f8f9fa;
  --ink: #343a40;
  --muted: #657179;
  --line: #dfe5e8;
  --accent: #008080;
  --accent-strong: #006f6f;
  --peach: #f8cd98;
  --lime: #d7f29b;
  --charcoal: #343a40;
  --blue: #2563eb;
  --amber: #b45309;
  --red: #b42318;
  --green: #15803d;
  --shadow: 0 18px 42px rgba(52, 58, 64, 0.12);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  color: var(--ink);
  background:
    linear-gradient(90deg, rgba(248, 205, 152, 0.28), transparent 34%),
    var(--bg);
  font-family: Poppins, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

.login-screen {
  position: fixed;
  inset: 0;
  z-index: 20;
  display: grid;
  place-items: center;
  padding: 20px;
  background: var(--bg);
}

.login-screen[hidden] {
  display: none;
}

.login-card {
  width: min(430px, 100%);
  margin: 0;
  padding: 24px;
  border: 1px solid var(--line);
  border-radius: 22px;
  background: var(--surface);
  box-shadow: var(--shadow);
}

.login-card .brand-mark {
  margin-bottom: 16px;
}

.login-note {
  color: var(--muted);
  font-size: 13px;
}

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

button {
  cursor: pointer;
}

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

.sidebar {
  position: sticky;
  top: 0;
  height: 100vh;
  display: flex;
  flex-direction: column;
  gap: 24px;
  padding: 24px 18px;
  color: #f8f9fa;
  background: var(--charcoal);
}

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

.brand strong {
  font-family: Georgia, "Times New Roman", serif;
  font-size: 31px;
  font-weight: 800;
  line-height: 0.9;
}

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

.brand span:not(.brand-mark) {
  margin-top: 4px;
  color: #f8cd98;
  font-size: 13px;
}

.brand-mark {
  position: relative;
  display: grid;
  width: 42px;
  height: 42px;
  place-items: center;
  border-radius: 50%;
  color: var(--charcoal);
  background: var(--lime);
  font-family: Georgia, "Times New Roman", serif;
  font-size: 34px;
  font-weight: 900;
  line-height: 1;
}

.brand-mark::after {
  position: absolute;
  right: -5px;
  bottom: 5px;
  width: 18px;
  height: 5px;
  border-radius: 999px;
  background: var(--accent);
  content: "";
}

.role-list,
.module-list {
  display: grid;
  gap: 8px;
}

.module-list {
  padding-top: 18px;
  border-top: 1px solid rgba(248, 249, 250, 0.14);
}

.role-button,
.module-button {
  display: grid;
  grid-template-columns: 34px 1fr auto;
  gap: 10px;
  align-items: center;
  width: 100%;
  padding: 10px;
  border: 1px solid transparent;
  border-radius: 18px;
  color: #dbe7e3;
  background: transparent;
  text-align: left;
}

.role-button:hover,
.role-button.active,
.module-button:hover,
.module-button.active {
  color: #ffffff;
  background: rgba(0, 128, 128, 0.35);
  border-color: rgba(255, 255, 255, 0.12);
}

.module-button {
  color: #d7dde1;
}

.module-icon {
  display: grid;
  width: 34px;
  height: 34px;
  place-items: center;
  border-radius: 12px;
  background: rgba(248, 249, 250, 0.08);
  font-size: 17px;
}

.avatar {
  display: grid;
  width: 34px;
  height: 34px;
  place-items: center;
  border-radius: 50%;
  color: var(--charcoal);
  background: var(--lime);
  font-size: 12px;
  font-weight: 800;
}

.role-meta {
  display: block;
  color: #9fb1ab;
  font-size: 12px;
}

.sidebar-panel {
  margin-top: auto;
  padding: 16px;
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 8px;
  background: rgba(248, 205, 152, 0.11);
}

.panel-label,
.eyebrow {
  color: var(--accent);
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 0;
  text-transform: uppercase;
}

.sidebar-panel .panel-label {
  color: #9ee8dc;
}

.sidebar-panel strong {
  display: block;
  margin-top: 8px;
}

.sidebar-panel p {
  color: #c3d1cd;
  font-size: 13px;
  line-height: 1.5;
}

.workspace {
  min-width: 0;
  padding: 28px;
}

.topbar,
.section-heading {
  display: flex;
  gap: 16px;
  align-items: center;
  justify-content: space-between;
}

.topbar {
  margin-bottom: 24px;
}

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

h1 {
  margin-top: 5px;
  font-size: 34px;
  font-family: Georgia, "Times New Roman", serif;
  line-height: 1.1;
}

h2 {
  margin-top: 5px;
  font-size: 18px;
  font-family: Georgia, "Times New Roman", serif;
}

h3 {
  font-size: 16px;
}

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

.top-badges {
  display: flex;
  gap: 8px;
}

.badge-button {
  display: inline-flex;
  min-height: 42px;
  align-items: center;
  gap: 7px;
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 0 11px;
  color: var(--charcoal);
  background: #ffffff;
  font-weight: 800;
}

.badge-button span {
  min-width: 24px;
  border-radius: 999px;
  padding: 3px 7px;
  color: #ffffff;
  background: var(--accent);
  font-size: 12px;
}

#mobile-role {
  display: none;
}

.primary-action,
.ghost-button,
.icon-button {
  min-height: 42px;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: var(--surface-strong);
}

.primary-action {
  padding: 0 16px;
  border-color: var(--accent);
  color: #f8f9fa;
  background: var(--accent);
  font-weight: 800;
}

.primary-action:hover {
  background: var(--accent-strong);
}

.ghost-button {
  padding: 0 13px;
  color: var(--ink);
  font-weight: 700;
}

.icon-button {
  width: 42px;
  font-size: 20px;
}

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

.metric-card,
.workflow-card,
.evidence-card,
.section-block {
  border: 1px solid var(--line);
  border-radius: 22px;
  background: var(--surface);
  box-shadow: 0 1px 0 rgba(23, 32, 29, 0.03);
}

.metric-card {
  padding: 16px;
}

.metric-card strong {
  display: block;
  margin-top: 8px;
  font-size: 28px;
}

.metric-card span:last-child {
  display: block;
  margin-top: 5px;
  color: var(--muted);
  font-size: 13px;
}

.content-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.4fr) minmax(330px, 0.6fr);
  gap: 20px;
  align-items: start;
}

.main-column,
.side-column {
  display: grid;
  gap: 20px;
}

.section-block {
  padding: 18px;
}

.module-workspace {
  margin-bottom: 20px;
}

.module-toolbar {
  display: flex;
  gap: 12px;
  align-items: end;
  flex-wrap: wrap;
  margin-top: 16px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 18px;
  background: #ffffff;
}

.module-toolbar label {
  min-width: 180px;
  flex: 1;
}

.admin-tile-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
  gap: 12px;
  margin-top: 16px;
}

.dashboard-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 16px;
  margin-top: 16px;
}

.dashboard-card {
  min-height: 260px;
  border: 1px solid var(--line);
  border-radius: 18px;
  padding: 18px;
  background: #ffffff;
}

.dashboard-card h3 {
  font-family: Poppins, ui-sans-serif, system-ui, sans-serif;
  font-size: 16px;
  font-weight: 900;
  text-align: center;
  text-transform: uppercase;
}

.dashboard-card .empty-state {
  margin-top: 28px;
  color: var(--ink);
  font-size: 18px;
  line-height: 1.45;
}

.bar-chart {
  display: grid;
  gap: 10px;
  margin-top: 24px;
}

.bar-row {
  display: grid;
  grid-template-columns: 76px 1fr 24px;
  gap: 8px;
  align-items: center;
  font-size: 12px;
}

.bar-track {
  height: 19px;
  overflow: hidden;
  border-radius: 999px;
  background: #eef2f4;
}

.bar-fill {
  height: 100%;
  border-radius: inherit;
}

.pie-wrap {
  display: grid;
  justify-items: center;
  gap: 14px;
  margin-top: 26px;
}

.pie {
  width: 146px;
  height: 146px;
  border-radius: 50%;
  background: conic-gradient(var(--green) 0 62%, #ef756f 62% 100%);
}

.pie.target {
  background: conic-gradient(var(--green) 0 50%, #eda85c 50% 72%, #ef756f 72% 100%);
}

.pie.otj {
  background: conic-gradient(#ef756f 0 64%, #ffd34f 64% 86%, var(--green) 86% 100%);
}

.pie.completion {
  box-shadow: 0 0 0 10px rgba(239, 117, 111, 0.22);
  background: #ff8580;
}

.legend {
  display: grid;
  gap: 5px;
  font-size: 12px;
  font-weight: 800;
}

.legend span {
  display: flex;
  gap: 7px;
  align-items: center;
}

.legend i {
  width: 11px;
  height: 11px;
  border-radius: 50%;
}

.dashboard-section-title {
  margin-top: 24px;
}

.admin-tile {
  display: grid;
  min-height: 132px;
  align-content: center;
  justify-items: center;
  gap: 10px;
  border: 1px solid var(--line);
  border-radius: 18px;
  padding: 14px;
  color: var(--accent-strong);
  background: #ffffff;
  text-align: center;
  font-weight: 800;
}

.admin-tile:hover,
.admin-tile.highlight {
  border-color: var(--accent);
  background: var(--lime);
  color: var(--charcoal);
}

.admin-tile-icon {
  font-size: 34px;
}

.data-table-wrap {
  overflow: auto;
  margin-top: 16px;
  border: 1px solid var(--line);
  border-radius: 18px;
  background: #ffffff;
}

.data-table {
  width: 100%;
  min-width: 720px;
  border-collapse: collapse;
}

.data-table th,
.data-table td {
  border-bottom: 1px solid var(--line);
  padding: 12px;
  text-align: left;
}

.data-table th {
  color: #ffffff;
  background: var(--charcoal);
}

.message-subject {
  color: var(--accent);
  font-weight: 800;
}

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

.workflow-card {
  padding: 14px;
  background: linear-gradient(135deg, #ffffff 0%, rgba(215, 242, 155, 0.18) 100%);
}

.workflow-card p,
.evidence-card p,
.compact-item p,
.role-intro {
  margin-top: 8px;
  color: var(--muted);
  line-height: 1.45;
}

.status-row {
  display: flex;
  gap: 8px;
  align-items: center;
  flex-wrap: wrap;
  margin-top: 12px;
}

.tag {
  display: inline-flex;
  min-height: 26px;
  align-items: center;
  border-radius: 999px;
  padding: 0 9px;
  color: #2d3935;
  background: #edf6f6;
  font-size: 12px;
  font-weight: 800;
}

.tag.green {
  color: #0f4a26;
  background: #eafbd0;
}

.tag.amber {
  color: #78350f;
  background: #f8cd98;
}

.tag.red {
  color: #7f1d1d;
  background: #fee2e2;
}

.tag.blue {
  color: #005b5b;
  background: #d9f3f3;
}

.ksb-list,
.evidence-list,
.compact-list {
  display: grid;
  gap: 10px;
  margin-top: 14px;
}

.ksb-item {
  display: grid;
  grid-template-columns: 44px 1fr 92px;
  gap: 12px;
  align-items: center;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 18px;
  background: #ffffff;
}

.ksb-code {
  display: grid;
  width: 44px;
  height: 44px;
  place-items: center;
  border-radius: 50%;
  color: var(--charcoal);
  background: var(--lime);
  font-weight: 900;
}

.progress-track {
  height: 9px;
  overflow: hidden;
  border-radius: 999px;
  background: #e4ecef;
}

.progress-fill {
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, var(--accent), var(--lime));
}

.ksb-percent {
  text-align: right;
  font-weight: 900;
}

.evidence-card {
  display: grid;
  gap: 10px;
  padding: 14px;
  background: #ffffff;
}

.evidence-card header,
.compact-item header {
  display: flex;
  gap: 12px;
  align-items: flex-start;
  justify-content: space-between;
}

.compact-item {
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 18px;
  background: #ffffff;
}

form {
  display: grid;
  gap: 13px;
  margin-top: 14px;
}

.setup-form {
  padding-bottom: 16px;
  border-bottom: 1px solid var(--line);
}

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

.setup-results {
  margin-top: 16px;
}

.user-admin {
  padding-top: 16px;
  border-top: 1px solid var(--line);
}

.csv-import-form {
  margin-top: 18px;
  padding-top: 14px;
  border-top: 1px dashed var(--line);
}

.form-hint {
  margin: 0;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.5;
}

label,
legend {
  color: #31403b;
  font-size: 13px;
  font-weight: 800;
}

input,
select,
textarea {
  width: 100%;
  margin-top: 6px;
  border: 1px solid #cfc8bc;
  border-radius: 16px;
  padding: 10px 11px;
  color: var(--ink);
  background: #ffffff;
}

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

fieldset {
  min-width: 0;
  margin: 0;
  border: 1px solid var(--line);
  border-radius: 18px;
  padding: 12px;
}

.checkbox-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
  margin-top: 10px;
}

.checkbox-grid label {
  display: flex;
  gap: 8px;
  align-items: center;
  min-height: 36px;
  padding: 7px;
  border-radius: 16px;
  background: #f8f9fa;
}

.checkbox-grid input {
  width: auto;
  margin: 0;
}

.full-width {
  width: 100%;
}

.toast {
  position: fixed;
  right: 20px;
  bottom: 20px;
  z-index: 5;
  max-width: min(360px, calc(100vw - 40px));
  padding: 13px 15px;
  border-radius: 18px;
  color: #f8f9fa;
  background: var(--charcoal);
  box-shadow: var(--shadow);
  opacity: 0;
  transform: translateY(12px);
  transition: 180ms ease;
  pointer-events: none;
}

.toast.visible {
  opacity: 1;
  transform: translateY(0);
}

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

  .sidebar {
    display: none;
  }

  .workspace {
    padding: 20px;
  }

  #mobile-role {
    display: block;
    width: auto;
    min-width: 180px;
    margin: 0;
  }
}

@media (max-width: 860px) {
  .metrics-grid,
  .content-grid,
  .workflow-grid,
  .dashboard-grid,
  .form-grid,
  .setup-results {
    grid-template-columns: 1fr;
  }

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

  .top-actions {
    width: 100%;
  }

  #mobile-role,
  .primary-action {
    flex: 1;
    min-width: 0;
  }
}

@media (max-width: 560px) {
  .workspace {
    padding: 14px;
  }

  h1 {
    font-size: 27px;
  }

  .top-actions {
    flex-wrap: wrap;
  }

  .icon-button {
    flex: 0 0 42px;
  }

  .ksb-item {
    grid-template-columns: 40px 1fr;
  }

  .ksb-percent {
    grid-column: 2;
    text-align: left;
  }

  .checkbox-grid {
    grid-template-columns: 1fr;
  }
}
