:root {
  color-scheme: light;
  --ink: #102526;
  --muted: #667475;
  --line: #d9e3e2;
  --paper: #ffffff;
  --bg: #edf4f2;
  --brand: #153b3c;
  --brand-soft: #dcebea;
  --ok: #0f7a4f;
  --ok-bg: #e3f4ea;
  --warning: #996b00;
  --warning-bg: #fff3cf;
  --danger: #b3261e;
  --danger-bg: #ffe8e5;
  --shadow: 0 12px 30px rgba(15, 48, 49, 0.12);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
  color: var(--ink);
  font-family: Arial, Helvetica, sans-serif;
}

body:not(.is-authenticated):not(.is-demo) .app-shell {
  display: none;
}

body.is-authenticated .auth-gate,
body.is-demo .auth-gate {
  display: none;
}

button,
input,
select {
  font: inherit;
}

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

.auth-gate {
  display: grid;
  min-height: 100vh;
  place-items: center;
  padding: 18px;
}

.auth-card {
  display: grid;
  width: min(100%, 420px);
  gap: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--paper);
  padding: 22px;
  box-shadow: var(--shadow);
}

.auth-card h1 {
  margin: 4px 0 2px;
  font-size: 28px;
  letter-spacing: 0;
}

.auth-brand {
  margin-bottom: 4px;
  color: var(--ink);
}

.auth-brand span {
  color: var(--muted);
}

.sidebar {
  background: var(--brand);
  color: #fff;
  padding: 20px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  min-height: 56px;
  margin-bottom: 24px;
}

.brand-mark {
  display: grid;
  place-items: center;
  width: 44px;
  height: 44px;
  border-radius: 8px;
  background: #f0c85a;
  color: #172526;
  font-weight: 800;
}

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

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

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

.nav-item {
  min-height: 46px;
  border: 1px solid rgba(255, 255, 255, 0.14);
  border-radius: 8px;
  background: transparent;
  color: #fff;
  text-align: left;
  padding: 0 14px;
  cursor: pointer;
}

.nav-item.is-active,
.nav-item:hover {
  background: rgba(255, 255, 255, 0.14);
}

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

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

.topbar h1 {
  margin: 2px 0 0;
  font-size: 28px;
  letter-spacing: 0;
}

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

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

.icon-button {
  display: none;
  min-width: 44px;
  height: 44px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--paper);
  color: var(--ink);
}

select,
input {
  width: 100%;
  min-height: 44px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  color: var(--ink);
  padding: 0 12px;
}

.status-pill {
  display: inline-flex;
  align-items: center;
  min-height: 34px;
  border-radius: 999px;
  background: var(--ok-bg);
  color: var(--ok);
  padding: 0 12px;
  font-weight: 700;
  white-space: nowrap;
}

.neutral-pill {
  background: #eef1f1;
  color: var(--ink);
}

.warning-pill {
  background: var(--warning-bg);
  color: var(--warning);
}

.view {
  display: none;
}

.view.is-visible {
  display: block;
}

.alert-row {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 14px;
  margin-bottom: 18px;
}

.alert-card {
  min-height: 78px;
  border-radius: 8px;
  padding: 14px;
  border: 1px solid var(--line);
}

.alert-card strong,
.alert-card span {
  display: block;
}

.alert-card span {
  margin-top: 6px;
  color: var(--muted);
}

.alert-card.ok {
  background: var(--ok-bg);
  border-color: #acd9c2;
}

.alert-card.warning {
  background: var(--warning-bg);
  border-color: #ecd88a;
}

.alert-card.danger {
  background: var(--danger-bg);
  border-color: #f0b4ae;
}

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

.action-tile {
  min-height: 112px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--paper);
  padding: 16px;
  color: var(--ink);
  text-align: left;
  cursor: pointer;
  box-shadow: var(--shadow);
}

.action-tile span,
.action-tile strong {
  display: block;
}

.action-tile span {
  color: var(--muted);
  margin-bottom: 12px;
}

.action-tile strong {
  font-size: 20px;
}

.panel-grid,
.split-layout {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 16px;
}

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

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

.panel h2 {
  margin: 0;
  font-size: 18px;
  letter-spacing: 0;
}

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

.metric {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 12px;
  background: #f8fbfa;
}

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

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

.metric strong {
  margin-top: 8px;
  font-size: 22px;
}

.metric.big strong {
  font-size: 32px;
}

.risk-list,
.simple-list {
  display: grid;
  gap: 10px;
}

.risk-list {
  list-style: none;
  margin: 0;
  padding: 0;
}

.risk-list li {
  display: flex;
  align-items: center;
  min-height: 38px;
  gap: 10px;
}

.dot {
  width: 12px;
  height: 12px;
  border-radius: 50%;
}

.ok-dot {
  background: var(--ok);
}

.warning-dot {
  background: #d69a00;
}

.danger-dot {
  background: var(--danger);
}

.form-panel {
  display: grid;
  gap: 12px;
  align-content: start;
}

label {
  display: grid;
  gap: 7px;
  color: var(--muted);
  font-weight: 700;
}

.primary-button,
.secondary-button,
.text-button {
  min-height: 48px;
  border-radius: 8px;
  border: 1px solid transparent;
  padding: 0 16px;
  font-weight: 800;
  cursor: pointer;
}

.primary-button {
  background: var(--brand);
  color: #fff;
}

.secondary-button {
  background: #fff;
  color: var(--brand);
  border-color: var(--line);
}

.text-button {
  background: transparent;
  color: var(--brand);
}

.small-button {
  min-height: 36px;
  padding: 0 12px;
}

.form-message {
  min-height: 20px;
  margin: 0;
  color: var(--muted);
  line-height: 1.4;
}

.search-input {
  max-width: 220px;
}

.list-item {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #f8fbfa;
  padding: 12px;
}

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

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

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

.cash-summary div {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #f8fbfa;
  padding: 12px;
}

.cash-summary span,
.cash-summary strong {
  display: block;
}

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

.cash-summary strong {
  margin-top: 8px;
  font-size: 22px;
}

.wide-label {
  max-width: 360px;
  margin-bottom: 12px;
}

.helper-text {
  margin: 0 0 8px;
  color: var(--muted);
  line-height: 1.45;
}

body.menu-open .sidebar {
  transform: translateX(0);
}

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

  .sidebar {
    position: fixed;
    inset: 0 auto 0 0;
    z-index: 10;
    width: 280px;
    transform: translateX(-100%);
    transition: transform 160ms ease;
  }

  .icon-button {
    display: inline-grid;
    place-items: center;
  }

  .main {
    padding: 16px;
  }

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

  .top-actions {
    flex-wrap: wrap;
    justify-content: flex-end;
  }

  .alert-row,
  .quick-grid,
  .panel-grid,
  .split-layout,
  .metric-grid,
  .cash-summary {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 560px) {
  .topbar h1 {
    font-size: 24px;
  }

  .topbar {
    display: grid;
    grid-template-columns: auto 1fr;
  }

  .top-actions {
    grid-column: 1 / -1;
    justify-content: stretch;
  }

  .top-actions > * {
    flex: 1;
  }
}
