:root {
  color-scheme: light;
  --bg: #f5f7f6;
  --panel: #ffffff;
  --panel-soft: #eef3f0;
  --ink: #1d2528;
  --muted: #64706c;
  --line: #dce4df;
  --teal: #0f8b8d;
  --teal-dark: #09696b;
  --amber: #d4932f;
  --blue: #356c95;
  --red: #c8524e;
  --green: #3f8f5b;
  --shadow: 0 18px 55px rgba(29, 37, 40, 0.12);
  --radius: 8px;
  font-family:
    Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI",
    sans-serif;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background:
    linear-gradient(180deg, rgba(15, 139, 141, 0.06), transparent 260px),
    var(--bg);
  color: var(--ink);
}

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

button {
  cursor: pointer;
}

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

.sidebar {
  position: sticky;
  top: 0;
  height: 100vh;
  display: flex;
  flex-direction: column;
  gap: 24px;
  padding: 22px;
  background: #182023;
  color: #f7fbfa;
  border-right: 1px solid rgba(255, 255, 255, 0.08);
}

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

.brand-mark {
  display: grid;
  place-items: center;
  width: 44px;
  height: 44px;
  border-radius: var(--radius);
  background: var(--teal);
  color: #fff;
  font-weight: 800;
  letter-spacing: 0;
}

.brand-copy {
  display: grid;
  gap: 2px;
}

.brand-copy strong {
  font-size: 15px;
  letter-spacing: 0;
}

.brand-copy span {
  color: rgba(255, 255, 255, 0.68);
  font-size: 13px;
}

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

.nav-item,
.btn,
.icon-btn,
.segmented button {
  border: 0;
  border-radius: var(--radius);
  min-height: 40px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 9px;
  transition:
    transform 0.16s ease,
    background 0.16s ease,
    color 0.16s ease,
    border-color 0.16s ease;
}

.nav-item {
  justify-content: flex-start;
  width: 100%;
  padding: 12px 12px;
  color: rgba(255, 255, 255, 0.74);
  background: transparent;
}

.nav-item:hover,
.nav-item.active {
  background: rgba(255, 255, 255, 0.11);
  color: #fff;
}

.nav-item.active {
  box-shadow: inset 3px 0 0 var(--amber);
}

.sidebar-footer {
  margin-top: auto;
  display: flex;
  align-items: center;
  gap: 8px;
  color: rgba(255, 255, 255, 0.72);
  font-size: 13px;
}

.status-dot {
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: #5bd38a;
  box-shadow: 0 0 0 4px rgba(91, 211, 138, 0.12);
}

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

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

.eyebrow {
  margin: 0 0 4px;
  color: var(--muted);
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

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

h1 {
  margin-bottom: 0;
  font-size: 30px;
  line-height: 1.15;
  letter-spacing: 0;
}

h2 {
  font-size: 21px;
  letter-spacing: 0;
}

h3 {
  font-size: 15px;
  letter-spacing: 0;
}

.quick-actions,
.toolbar,
.table-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px;
}

.btn {
  padding: 0 14px;
  min-width: 42px;
  color: var(--ink);
  background: var(--panel);
  border: 1px solid var(--line);
  box-shadow: 0 1px 1px rgba(29, 37, 40, 0.04);
  white-space: nowrap;
}

.btn:hover,
.icon-btn:hover,
.segmented button:hover {
  transform: translateY(-1px);
}

.btn.primary {
  color: #fff;
  background: var(--teal);
  border-color: var(--teal);
}

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

.btn.dark {
  color: #fff;
  background: #1d2528;
  border-color: #1d2528;
}

.btn.ghost {
  background: transparent;
}

.btn.warning {
  color: #fff;
  background: var(--amber);
  border-color: var(--amber);
}

.btn.danger {
  color: #fff;
  background: var(--red);
  border-color: var(--red);
}

.icon-btn {
  width: 38px;
  height: 38px;
  padding: 0;
  background: var(--panel-soft);
  color: var(--ink);
}

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

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

.stat-card,
.panel,
.data-table-wrap,
.mini-card {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: 0 1px 2px rgba(29, 37, 40, 0.04);
}

.stat-card {
  min-height: 126px;
  padding: 16px;
  display: grid;
  align-content: space-between;
  gap: 12px;
}

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

.stat-card .value {
  font-size: 25px;
  font-weight: 800;
  line-height: 1.15;
}

.stat-card .meta {
  color: var(--muted);
  font-size: 12px;
}

.stat-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.stat-icon {
  display: grid;
  place-items: center;
  width: 38px;
  height: 38px;
  border-radius: var(--radius);
  color: #fff;
}

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

.stat-icon.amber {
  background: var(--amber);
}

.stat-icon.blue {
  background: var(--blue);
}

.stat-icon.red {
  background: var(--red);
}

.stat-icon.green {
  background: var(--green);
}

.content-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.45fr) minmax(320px, 0.75fr);
  gap: 18px;
}

.panel {
  padding: 16px;
  min-width: 0;
}

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

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

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

.canvas-wrap {
  width: 100%;
  height: 284px;
}

canvas {
  width: 100%;
  height: 100%;
  display: block;
}

.mini-list {
  display: grid;
  gap: 10px;
}

.mini-card {
  padding: 12px;
  display: grid;
  gap: 8px;
}

.mini-card strong {
  overflow-wrap: anywhere;
}

.mini-row,
.record-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
}

.badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 24px;
  padding: 0 9px;
  border-radius: 999px;
  color: var(--teal-dark);
  background: rgba(15, 139, 141, 0.1);
  font-size: 12px;
  font-weight: 700;
  white-space: nowrap;
}

.badge.warning {
  color: #805300;
  background: rgba(212, 147, 47, 0.17);
}

.badge.red {
  color: #9a2f2d;
  background: rgba(200, 82, 78, 0.14);
}

.progress-line {
  position: relative;
  height: 8px;
  overflow: hidden;
  border-radius: 999px;
  background: #e7ece9;
}

.progress-line span {
  position: absolute;
  inset: 0 auto 0 0;
  min-width: 0;
  border-radius: inherit;
  background: linear-gradient(90deg, var(--teal), var(--green));
}

.toolbar {
  justify-content: space-between;
  padding: 12px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
}

.searchbox,
.field input,
.field select,
.field textarea {
  width: 100%;
  min-height: 40px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #fff;
  color: var(--ink);
  padding: 9px 11px;
  outline: none;
}

.searchbox {
  max-width: 360px;
}

.searchbox:focus,
.field input:focus,
.field select:focus,
.field textarea:focus {
  border-color: var(--teal);
  box-shadow: 0 0 0 3px rgba(15, 139, 141, 0.12);
}

.data-table-wrap {
  overflow: auto;
}

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

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

.data-table th {
  position: sticky;
  top: 0;
  z-index: 1;
  background: #f9fbfa;
  color: var(--muted);
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.data-table tr:hover td {
  background: rgba(15, 139, 141, 0.04);
}

.amount {
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.amount.positive {
  color: var(--green);
}

.amount.negative {
  color: var(--red);
}

.empty-state {
  display: grid;
  place-items: center;
  min-height: 220px;
  padding: 18px;
  color: var(--muted);
  border: 1px dashed var(--line);
  border-radius: var(--radius);
  background: rgba(255, 255, 255, 0.65);
}

.segmented {
  display: inline-flex;
  gap: 4px;
  padding: 4px;
  background: var(--panel-soft);
  border-radius: var(--radius);
}

.segmented button {
  min-height: 34px;
  padding: 0 11px;
  background: transparent;
  color: var(--muted);
}

.segmented button.active {
  background: #fff;
  color: var(--ink);
  box-shadow: 0 1px 2px rgba(29, 37, 40, 0.08);
}

.modal {
  position: fixed;
  inset: 0;
  z-index: 20;
  display: grid;
  place-items: center;
  padding: 22px;
}

.modal.is-hidden {
  display: none;
}

.modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(20, 26, 28, 0.42);
}

.modal-panel {
  position: relative;
  width: min(920px, 100%);
  max-height: min(92vh, 820px);
  overflow: auto;
  background: var(--panel);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

.modal-header {
  position: sticky;
  top: 0;
  z-index: 2;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 16px;
  border-bottom: 1px solid var(--line);
  background: var(--panel);
}

.modal-header h2 {
  margin: 0;
}

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

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

.field label {
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
}

.field textarea {
  min-height: 88px;
  resize: vertical;
}

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

.form-actions {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  padding-top: 4px;
}

.toast {
  position: fixed;
  right: 18px;
  bottom: 18px;
  z-index: 30;
  max-width: min(420px, calc(100vw - 36px));
  padding: 12px 14px;
  border-radius: var(--radius);
  color: #fff;
  background: #1d2528;
  box-shadow: var(--shadow);
  transform: translateY(18px);
  opacity: 0;
  pointer-events: none;
  transition:
    opacity 0.2s ease,
    transform 0.2s ease;
}

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

svg.icon {
  width: 18px;
  height: 18px;
  stroke-width: 2;
  flex: 0 0 auto;
}

@media (max-width: 1120px) {
  .stat-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

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

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

  .sidebar {
    position: static;
    height: auto;
    padding: 14px;
    gap: 14px;
  }

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

  .nav-item {
    justify-content: center;
    min-height: 48px;
    padding: 8px;
  }

  .nav-item span:last-child {
    display: none;
  }

  .main {
    padding: 16px;
  }

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

  .quick-actions {
    width: 100%;
  }

  .quick-actions .btn {
    flex: 1 1 132px;
  }

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

  h1 {
    font-size: 25px;
  }
}
