:root {
  --bg: #f6f7f3;
  --surface: #ffffff;
  --surface-2: #eef2ef;
  --ink: #17211f;
  --muted: #61706b;
  --line: #d9e0dc;
  --brand: #126b68;
  --brand-2: #d97941;
  --accent: #395f9f;
  --danger: #b42318;
  --warning: #b7791f;
  --success: #18794e;
  --shadow: 0 16px 38px rgba(23, 33, 31, 0.13);
  --radius: 8px;
  color-scheme: light;
  font-family:
    Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI",
    sans-serif;
}

* {
  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);
}

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

.sidebar {
  background: #17211f;
  color: #f8faf8;
  padding: 20px 16px;
  position: sticky;
  top: 0;
  height: 100vh;
  overflow: auto;
}

.brand {
  display: grid;
  gap: 6px;
  margin-bottom: 22px;
}

.brand strong {
  font-size: 18px;
}

.brand span {
  color: #b9c7c2;
  font-size: 13px;
  line-height: 1.4;
}

.nav-section {
  display: grid;
  gap: 6px;
  margin-bottom: 18px;
}

.nav-label {
  display: flex;
  align-items: center;
  gap: 8px;
  min-height: 28px;
  color: #f3faf6;
  font-family:
    "Segoe UI Semibold", Inter, ui-sans-serif, system-ui, -apple-system,
    BlinkMacSystemFont, "Segoe UI", sans-serif;
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 0;
  text-transform: uppercase;
  margin: 18px 4px 8px;
  padding: 7px 9px;
  border-left: 3px solid var(--brand-2);
  border-radius: 6px;
  background: rgba(255, 255, 255, 0.06);
}

.nav-label::after {
  content: "";
  height: 1px;
  flex: 1;
  background: rgba(255, 255, 255, 0.16);
}

.nav-link {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  min-height: 38px;
  padding: 9px 10px;
  border-radius: var(--radius);
  color: #e8eeeb;
  text-decoration: none;
}

.nav-link:hover,
.nav-link.active {
  background: rgba(255, 255, 255, 0.11);
}

.nav-link small {
  color: #b9c7c2;
}

.content {
  min-width: 0;
}

.main {
  padding: 24px;
  display: grid;
  gap: 18px;
  align-content: start;
}

.topbar {
  min-height: 72px;
  background: rgba(255, 255, 255, 0.86);
  backdrop-filter: blur(14px);
  border-bottom: 1px solid var(--line);
  position: sticky;
  top: 0;
  z-index: 10;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  padding: 14px 24px;
}

.topbar h1 {
  font-size: 20px;
  margin: 0;
}

.topbar p {
  margin: 4px 0 0;
  color: var(--muted);
  font-size: 13px;
}

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

.topbar-user {
  color: var(--muted);
  font-size: 13px;
}

.system-clock {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 7px 8px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #fbfcfb;
}

.system-clock div {
  display: grid;
  gap: 2px;
  min-width: 132px;
}

.system-clock strong {
  font-size: 14px;
  line-height: 1;
}

.system-clock span {
  color: var(--muted);
  font-size: 12px;
}

.system-clock select {
  min-height: 32px;
  max-width: 160px;
}

.metric-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(150px, 1fr));
  gap: 12px;
}

.metric-grid article,
.metric-card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 16px;
  min-height: 108px;
  display: grid;
  align-content: space-between;
  gap: 12px;
}

.metric-card {
  color: inherit;
  cursor: pointer;
}

.metric-card:hover,
.metric-card:focus-visible {
  border-color: #6c8f82;
  box-shadow: 0 8px 20px rgba(45, 74, 66, 0.12);
  outline: none;
}

.metric-grid span {
  color: var(--muted);
  font-size: 13px;
}

.metric-grid strong {
  font-size: 30px;
  line-height: 1;
}

.chart-section {
  display: grid;
  gap: 12px;
  font-family:
    Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI",
    sans-serif;
}

.chart-section-header h3 {
  margin: 0;
  font-size: 16px;
}

.chart-section-header p {
  margin: 4px 0 0;
  color: #61706b;
  font-size: 13px;
}

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

.chart-card {
  min-height: 240px;
  height: 240px;
  border: 1px solid #d9e0dc;
  border-radius: var(--radius);
  background: #ffffff;
  padding: 14px;
  display: grid;
  align-content: start;
  gap: 12px;
  overflow: hidden;
}

.chart-card h3 {
  margin: 0;
  font-size: 15px;
}

.donut-wrap {
  display: grid;
  grid-template-columns: 132px minmax(0, 1fr);
  align-items: center;
  gap: 14px;
}

.donut {
  width: 132px;
  aspect-ratio: 1;
  border-radius: 50%;
  display: grid;
  place-items: center;
  position: relative;
}

.donut::after {
  content: "";
  position: absolute;
  inset: 24px;
  border-radius: 50%;
  background: #ffffff;
}

.donut span {
  position: relative;
  z-index: 1;
  font-weight: 800;
  font-size: 24px;
}

.chart-legend {
  display: grid;
  gap: 7px;
  color: #61706b;
  font-size: 13px;
}

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

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

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

.chart-scroll {
  max-height: 172px;
  overflow-y: auto;
  padding-right: 6px;
}

.bar-row {
  display: grid;
  grid-template-columns: minmax(96px, 1.1fr) minmax(120px, 2fr) 34px;
  align-items: center;
  gap: 8px;
  font-size: 13px;
}

.bar-row span {
  color: #61706b;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.bar-row strong {
  text-align: right;
}

.bar-track,
.stacked-track {
  min-height: 12px;
  border-radius: 999px;
  background: #e9efec;
  overflow: hidden;
}

.bar-fill {
  min-height: 12px;
  border-radius: inherit;
}

.stacked-row {
  display: grid;
  gap: 6px;
}

.stacked-label {
  display: flex;
  justify-content: space-between;
  gap: 8px;
  color: #61706b;
  font-size: 13px;
}

.stacked-track {
  display: flex;
}

.stacked-closed {
  background: #2e7d4f;
}

.stacked-open {
  background: #c8d3cf;
}

.empty {
  color: #61706b;
  border: 1px dashed #d9e0dc;
  border-radius: var(--radius);
  padding: 14px;
  background: var(--surface-2);
}

.chart-panel {
  padding: 0;
  overflow: hidden;
  background: var(--surface);
  border: 1px solid #d9e0dc;
  border-radius: var(--radius);
  font-family:
    Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI",
    sans-serif;
}

.chart-panel .panel-header {
  margin-bottom: 0;
  padding: 14px 16px;
  border-bottom: 1px solid #d9e0dc;
  background: #fbfcfb;
}

.chart-panel .panel-header h2,
.chart-panel .panel-header h3 {
  margin: 0;
  font-size: 16px;
}

.chart-panel .panel-header p {
  margin: 4px 0 0;
  color: #61706b;
  font-size: 13px;
}

.chart-panel .panel-body {
  padding: 16px;
}

.chart-panel .stack {
  display: grid;
  gap: 12px;
}

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

.chart-panel {
  overflow: hidden;
}

.panel > h3 {
  margin: 0;
  padding: 14px 16px;
  border-bottom: 1px solid var(--line);
  background: #fbfcfb;
  font-size: 16px;
}

.panel-header,
.action-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  flex-wrap: wrap;
}

.panel-header {
  margin-bottom: 0;
  padding: 14px 16px;
  border-bottom: 1px solid var(--line);
  background: #fbfcfb;
}

.panel-header h2,
.panel-header h3,
.panel-header p {
  margin: 0;
}

.panel-header h2,
.panel-header h3 {
  font-size: 16px;
}

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

.panel > :not(.panel-header):not(h3):not(table):not(.panel-body),
.panel > h3 + :not(table):not(.panel-body) {
  margin: 16px;
}

.panel > table {
  margin: 0;
}

.panel-body {
  padding: 16px;
}

.muted {
  color: var(--muted);
}

table {
  width: 100%;
  border-collapse: separate;
  border-spacing: 0;
  background: #fff;
  min-width: 760px;
}

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

th {
  position: sticky;
  top: 0;
  z-index: 1;
  background: #f3f6f4;
  color: #40514c;
  font-weight: 650;
}

tr:hover td {
  background: #fbfcfb;
}

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

button {
  border: 0;
}

a {
  color: inherit;
  text-decoration: none;
}

.button,
.danger,
button:not(.link-danger):not(.link-button):not(.ghost):not(.danger) {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  min-height: 34px;
  border: 0;
  background: var(--brand);
  color: #fff;
  border-radius: 6px;
  padding: 8px 12px;
  text-decoration: none;
  cursor: pointer;
  white-space: nowrap;
}

.button:hover,
button:not(.link-danger):not(.link-button):not(.ghost):not(.danger):hover {
  background: #0e5d5a;
}

.button.secondary,
.ghost {
  min-height: 34px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 8px 12px;
  border-radius: 6px;
  cursor: pointer;
  white-space: nowrap;
  background: var(--surface-2);
  color: var(--ink);
  border: 1px solid var(--line);
}

.button.secondary:hover,
.ghost:hover {
  background: #e5ece8;
}

.danger,
button.danger {
  color: #ffffff;
  background: var(--danger);
  border-color: var(--danger);
}

.link-danger {
  border: 0;
  background: transparent;
  color: var(--danger);
  padding: 0;
  min-height: 0;
}

.link-button {
  border: 0;
  background: transparent;
  color: var(--brand);
  padding: 0;
  min-height: 0;
}

.auth-panel {
  max-width: 460px;
}

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

.form-panel {
  max-width: 780px;
}

.wide-form {
  max-width: 1100px;
}

.field {
  display: grid;
  gap: 6px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 650;
}

.field small {
  color: var(--muted);
  font-weight: 400;
}

.error {
  color: var(--danger);
}

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

.form-control {
  display: block;
}

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

select[multiple] {
  min-height: 130px;
}

input[type="checkbox"],
input[type="radio"] {
  width: auto;
  min-height: auto;
  padding: 0;
}

.messages {
  display: grid;
  gap: 8px;
}

.message {
  background: #e8f5ee;
  border: 1px solid #b9dfca;
  color: #174d36;
  border-radius: 8px;
  padding: 10px 12px;
}

.message.error {
  background: #fff1f0;
  border-color: #ffc9c2;
  color: #8a241d;
}

.badge {
  display: inline-flex;
  align-items: center;
  min-height: 24px;
  padding: 4px 8px;
  border-radius: 999px;
  font-size: 12px;
  color: var(--ink);
  background: var(--surface-2);
  border: 1px solid var(--line);
}

.badge.success {
  color: var(--success);
  background: #e7f5ef;
  border-color: #bee3d0;
}

.badge.warning {
  color: var(--warning);
  background: #fff4da;
  border-color: #f7d99a;
}

.badge.danger {
  color: var(--danger);
  background: #feeceb;
  border-color: #f5b7b1;
}

.badge.info {
  color: var(--accent);
  background: #edf3ff;
  border-color: #c6d8fb;
}

.rag-pill {
  display: inline-flex;
  align-items: center;
  min-height: 24px;
  padding: 4px 8px;
  border: 1px solid var(--line);
  border-radius: 999px;
  font-size: 12px;
  font-weight: 700;
}

.rag-green {
  color: var(--success);
  background: #e7f5ef;
  border-color: #bee3d0;
}

.rag-amber {
  color: var(--warning);
  background: #fff4da;
  border-color: #f7d99a;
}

.rag-red {
  color: var(--danger);
  background: #feeceb;
  border-color: #f5b7b1;
}

.rag-row-green > td {
  background: #f2fbf7;
}

.rag-row-amber > td {
  background: #fff9ea;
}

.rag-row-red > td {
  background: #fff3f1;
}

.rag-card.rag-green,
.rag-card.rag-amber,
.rag-card.rag-red {
  border-color: currentColor;
}

.field-grid .field > .rag-field.rag-green,
.field-grid .field > .rag-field.rag-amber,
.field-grid .field > .rag-field.rag-red {
  border-color: currentColor;
  font-weight: 700;
}

.summary-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(140px, 1fr));
  gap: 12px;
}

.summary-grid div {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 12px;
  display: grid;
  gap: 6px;
}

.summary-grid span {
  color: var(--muted);
  font-size: 13px;
}

.summary-grid strong {
  font-size: 14px;
  line-height: 1.4;
}

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

.package-summary-split .panel {
  min-width: 0;
}

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

.field-grid.three {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

.field-grid .field,
.full-field {
  display: grid;
  gap: 6px;
}

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

.field-grid .field > label {
  color: var(--muted);
  font-size: 12px;
  font-weight: 650;
}

.field-grid .field > div {
  min-height: 38px;
  display: flex;
  align-items: center;
  padding: 8px 10px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #ffffff;
  color: var(--ink);
  font-size: 13px;
  line-height: 1.35;
}

.audit {
  display: grid;
  gap: 8px;
}

.audit-item {
  padding: 10px 0;
  border-bottom: 1px solid var(--line);
}

.audit-item strong {
  display: block;
  font-size: 13px;
}

.audit-item span {
  color: var(--muted);
  font-size: 12px;
}

.compact-actions {
  justify-content: flex-start;
  gap: 8px;
}

.inline-edit {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(130px, 1fr));
  gap: 8px;
  align-items: end;
}

.inline-edit label {
  display: grid;
  gap: 4px;
  font-size: 12px;
  color: var(--muted);
}

.inline-edit .wide {
  grid-column: span 2;
}

.inline-edit textarea {
  min-height: 42px;
  resize: vertical;
}

.folder-grid {
  display: grid;
  gap: 14px;
}

.folder-card {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 14px;
  background: var(--surface-2);
}

.folder-card h4 {
  margin: 0;
}

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

.upload-row input[type="file"] {
  max-width: 100%;
  border: 1px solid var(--line);
  background: #fff;
  border-radius: 6px;
  padding: 8px;
}

.comment-box {
  margin-top: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface-2);
  padding: 12px;
  line-height: 1.5;
}

.rich-body-source {
  display: none;
}

.rich-editor-shell {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  overflow: hidden;
}

.rich-toolbar {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
  padding: 8px;
  border-bottom: 1px solid var(--line);
  background: var(--surface-2);
}

.rich-toolbar button {
  min-width: 36px;
  background: #fff;
  color: var(--ink);
}

.rich-toolbar input[type="color"] {
  width: 38px;
  height: 36px;
  padding: 3px;
  border: 1px solid var(--line);
  border-radius: 6px;
}

.rich-editor {
  min-height: 360px;
  padding: 18px;
  line-height: 1.55;
  outline: none;
}

.rich-content {
  min-height: 180px;
  line-height: 1.6;
}

.rich-content table,
.rich-editor table {
  margin: 12px 0;
}

.rich-content td,
.rich-editor td {
  border: 1px solid var(--line);
  min-width: 90px;
  padding: 8px;
}

.attachment-list {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  align-items: center;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface-2);
}

.template-actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  margin-bottom: 12px;
}

.package-tabs {
  display: grid;
  gap: 0;
}

.package-tab-list {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
  padding: 8px;
  margin: 16px;
  background: var(--surface-2);
  border: 1px solid var(--line);
  border-radius: var(--radius);
}

.package-tab-button {
  min-height: 34px;
  padding: 8px 11px;
  border-radius: 6px;
  background: transparent;
  color: var(--muted);
  font-size: 13px;
}

.package-tab-button.active {
  background: var(--surface);
  color: var(--ink);
  box-shadow: 0 1px 2px rgba(23, 33, 31, 0.08);
}

.package-tab-panels {
  min-width: 0;
  overflow: auto;
  padding: 0 16px 16px;
}

.panel > .package-tab-panels {
  margin: 0;
}

.package-tab-panel {
  display: none;
  min-width: 0;
}

.package-tab-panel.active {
  display: grid;
  gap: 12px;
}

.package-tab-panel[hidden] {
  display: none;
}

.filter-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(180px, 1fr));
  gap: 12px;
  align-items: end;
}

.tracker-filter-form {
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #fbfcfb;
}

.tracker-filter-grid {
  grid-template-columns: repeat(6, minmax(150px, 1fr));
}

.request-filter-grid {
  grid-template-columns: repeat(7, minmax(150px, 1fr));
  padding: 16px;
}

.inline-create {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #ffffff;
}

.inline-create summary {
  min-height: 40px;
  display: flex;
  align-items: center;
  padding: 9px 12px;
  color: var(--brand);
  font-weight: 700;
  cursor: pointer;
}

.inline-create[open] summary {
  border-bottom: 1px solid var(--line);
  background: #fbfcfb;
}

.compact-create-grid {
  grid-template-columns: repeat(4, minmax(160px, 1fr));
  padding: 12px;
}

.compact-create-grid .field:has(textarea),
.compact-create-grid .action-row {
  grid-column: 1 / -1;
}

.filter-grid label {
  display: grid;
  gap: 6px;
  color: var(--muted);
  font-size: 13px;
}

.checkbox-row {
  align-items: center;
  grid-template-columns: auto 1fr;
  min-height: 38px;
}

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

.modal-overlay {
  position: fixed;
  inset: 0;
  z-index: 20;
  display: none;
  align-items: center;
  justify-content: center;
  padding: 24px;
  background: rgba(22, 33, 31, 0.46);
}

.modal-overlay:target {
  display: flex;
}

.modal-card {
  width: min(1120px, 100%);
  max-height: 88vh;
  overflow: auto;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 16px;
  box-shadow: 0 24px 70px rgba(22, 33, 31, 0.28);
}

@media (max-width: 900px) {
  .shell,
  .metric-grid,
  .summary-grid,
  .split,
  .field-grid,
  .field-grid.three,
  .chart-grid {
    grid-template-columns: 1fr;
  }

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

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

  .user-tools,
  .system-clock {
    width: 100%;
  }

  .system-clock {
    align-items: stretch;
    flex-direction: column;
  }

  .system-clock select {
    max-width: none;
  }

  .donut-wrap {
    grid-template-columns: 1fr;
    justify-items: start;
  }

  .inline-edit {
    grid-template-columns: 1fr;
  }

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

  .tracker-filter-grid {
    grid-template-columns: 1fr;
  }

  .request-filter-grid {
    grid-template-columns: 1fr;
  }

  .compact-create-grid {
    grid-template-columns: 1fr;
  }

  .inline-edit .wide {
    grid-column: auto;
  }
}
