:root {
  color-scheme: light;
  --bg: #f6f8f8;
  --surface: #ffffff;
  --surface-2: #eef3f2;
  --text: #17211f;
  --muted: #687672;
  --line: #dce5e2;
  --teal: #0f766e;
  --teal-dark: #115e59;
  --blue: #2563eb;
  --amber: #b45309;
  --red: #b91c1c;
  --green: #15803d;
  --ink: #111827;
  --shadow: 0 10px 30px rgba(15, 23, 42, 0.08);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
}

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

button {
  cursor: pointer;
}

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

.sidebar {
  background: #10201d;
  color: #effaf7;
  padding: 18px;
  position: sticky;
  top: 0;
  height: 100vh;
  overflow: auto;
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 8px 8px 18px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.12);
  margin-bottom: 12px;
}

.brand-mark {
  width: 42px;
  height: 42px;
  border-radius: 8px;
  display: grid;
  place-items: center;
  background: #e6fffb;
  color: #0f766e;
  font-weight: 800;
}

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

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

.module-nav {
  display: grid;
  gap: 5px;
}

.nav-item {
  width: 100%;
  border: 0;
  color: #d7e9e5;
  background: transparent;
  display: grid;
  grid-template-columns: 34px 1fr;
  align-items: center;
  gap: 10px;
  padding: 9px 8px;
  border-radius: 8px;
  text-align: left;
}

.nav-item span {
  width: 30px;
  height: 30px;
  display: grid;
  place-items: center;
  border: 1px solid rgba(255, 255, 255, 0.16);
  border-radius: 6px;
  font-size: 11px;
  color: #cfe7e1;
}

.nav-item strong {
  font-size: 14px;
  font-weight: 650;
}

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

.nav-item.active span {
  background: #0f766e;
  border-color: #0f766e;
  color: #ffffff;
}

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

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

.eyebrow {
  color: var(--muted);
  text-transform: uppercase;
  font-size: 11px;
  letter-spacing: 0;
  font-weight: 760;
  margin: 0 0 5px;
}

h1,
h2 {
  margin: 0;
  letter-spacing: 0;
}

h1 {
  font-size: 26px;
  line-height: 1.15;
}

h2 {
  font-size: 18px;
  line-height: 1.25;
}

.topbar-actions,
.module-actions {
  display: flex;
  align-items: end;
  gap: 10px;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.global-search,
.role-switcher,
.module-search,
.form-grid label {
  display: grid;
  gap: 5px;
}

.global-search span,
.role-switcher span,
.module-search span,
.form-grid span {
  color: var(--muted);
  font-size: 12px;
  font-weight: 650;
}

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

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

.global-search input {
  min-width: min(340px, 70vw);
}

.role-switcher select {
  min-width: 180px;
}

.content {
  display: grid;
  gap: 18px;
}

.kpi-grid {
  display: grid;
  grid-template-columns: repeat(7, minmax(120px, 1fr));
  gap: 10px;
}

.kpi {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 13px;
  box-shadow: 0 1px 0 rgba(15, 23, 42, 0.02);
  min-height: 82px;
}

.kpi span {
  display: block;
  color: var(--muted);
  font-size: 12px;
  font-weight: 650;
  margin-bottom: 10px;
}

.kpi strong {
  font-size: clamp(18px, 2vw, 28px);
  line-height: 1;
}

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

.panel {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 15px;
  min-width: 0;
}

.panel.wide {
  grid-column: 1 / -1;
}

.panel-header,
.module-toolbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  margin-bottom: 12px;
}

.module-toolbar {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 15px;
}

.button,
.table-action,
.icon-button {
  border: 1px solid transparent;
  border-radius: 8px;
  min-height: 40px;
  padding: 9px 13px;
  font-weight: 720;
}

.button.primary {
  background: var(--teal);
  color: #ffffff;
}

.button.primary:hover {
  background: var(--teal-dark);
}

.button.secondary,
.table-action,
.icon-button {
  background: var(--surface-2);
  color: var(--ink);
  border-color: var(--line);
}

.module-search input {
  min-width: min(380px, 70vw);
}

.table-wrap {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
  overflow: auto;
}

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

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

th {
  color: var(--muted);
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0;
  background: #f9fbfa;
}

tr:last-child td {
  border-bottom: 0;
}

.pill {
  display: inline-flex;
  align-items: center;
  min-height: 24px;
  padding: 4px 8px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 760;
  white-space: nowrap;
}

.pill.success {
  color: #166534;
  background: #dcfce7;
}

.pill.warning {
  color: #92400e;
  background: #fef3c7;
}

.pill.danger {
  color: #991b1b;
  background: #fee2e2;
}

.pill.neutral {
  color: #334155;
  background: #e2e8f0;
}

.bar-list {
  display: grid;
  gap: 14px;
}

.bar-label {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  font-size: 13px;
  margin-bottom: 6px;
}

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

.bar-track span {
  display: block;
  height: 100%;
  background: linear-gradient(90deg, var(--teal), var(--blue));
}

.compact-table,
.action-list,
.result-list {
  display: grid;
  gap: 8px;
}

.compact-row {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(90px, 1fr));
  gap: 8px;
  align-items: center;
  padding: 10px;
  background: #f9fbfa;
  border: 1px solid var(--line);
  border-radius: 8px;
  font-size: 13px;
}

.action-list div {
  padding: 11px;
  background: #f9fbfa;
  border: 1px solid var(--line);
  border-radius: 8px;
}

.empty,
.empty-state {
  color: var(--muted);
  padding: 18px;
}

.danger-text {
  color: var(--red);
}

.search-results {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 14px;
  margin-bottom: 16px;
}

.search-results.is-hidden {
  display: none;
}

.result-list {
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
}

.result-list button {
  text-align: left;
  border: 1px solid var(--line);
  background: #f9fbfa;
  border-radius: 8px;
  padding: 11px;
}

.result-list strong,
.result-list span {
  display: block;
}

.result-list span {
  color: var(--muted);
  font-size: 12px;
  margin-top: 4px;
}

.record-dialog {
  width: min(760px, calc(100vw - 24px));
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 0;
  box-shadow: var(--shadow);
}

.record-dialog::backdrop {
  background: rgba(15, 23, 42, 0.35);
}

.record-dialog form {
  display: grid;
  gap: 16px;
  padding: 18px;
}

.record-dialog header,
.record-dialog footer {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
}

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

.form-grid label:has(textarea) {
  grid-column: 1 / -1;
}

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

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

  .module-nav {
    grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  }

  .kpi-grid {
    grid-template-columns: repeat(3, minmax(120px, 1fr));
  }
}

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

  .topbar,
  .module-toolbar,
  .panel-header {
    align-items: stretch;
    flex-direction: column;
  }

  .topbar-actions,
  .module-actions {
    width: 100%;
    justify-content: stretch;
  }

  .global-search,
  .role-switcher,
  .module-search {
    width: 100%;
  }

  .global-search input,
  .role-switcher select,
  .module-search input {
    min-width: 0;
  }

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

  .sidebar {
    padding: 12px;
  }

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

  .nav-item {
    grid-template-columns: 30px 1fr;
    padding: 8px;
  }
}
