:root {
  color-scheme: dark;
  --bg: #101514;
  --panel: #17201f;
  --panel-2: #1d2826;
  --line: #31413d;
  --text: #f1f5ef;
  --muted: #aebbb5;
  --accent: #38d39f;
  --accent-2: #f4b942;
  --danger: #ff6b6b;
  --shadow: 0 18px 50px rgba(0, 0, 0, 0.28);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  overflow-x: hidden;
  background:
    linear-gradient(120deg, rgba(56, 211, 159, 0.12), transparent 38%),
    linear-gradient(220deg, rgba(244, 185, 66, 0.10), transparent 32%),
    var(--bg);
  color: var(--text);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

.auth-screen {
  display: none;
  min-height: 100vh;
  padding: 24px;
  place-items: center;
}

.auth-card {
  width: min(430px, 100%);
  display: grid;
  gap: 16px;
  padding: 24px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(23, 32, 31, 0.96);
  box-shadow: var(--shadow);
}

.auth-card h1 {
  font-size: 2rem;
}

body.auth-pending .app-shell,
body.auth-required .app-shell,
body.setup-required .app-shell {
  display: none;
}

body.auth-pending .auth-screen,
body.auth-required #authScreen,
body.setup-required #setupScreen {
  display: grid;
}

body.auth-pending #loginForm {
  opacity: 0.7;
}

body.auth-required #setupScreen,
body.setup-required #authScreen {
  display: none;
}

.setup-card {
  width: min(540px, 100%);
}

button,
input,
select {
  font: inherit;
}

button {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #22302d;
  color: var(--text);
  min-height: 38px;
  padding: 0 12px;
  cursor: pointer;
}

button:hover,
.icon-button:hover {
  border-color: var(--accent);
}

.app-shell {
  width: min(1440px, 100%);
  margin: 0 auto;
  padding: 24px;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  padding: 10px 0 24px;
}

.eyebrow {
  margin: 0 0 6px;
  color: var(--accent);
  font-size: 0.78rem;
  font-weight: 800;
  text-transform: uppercase;
}

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

h1 {
  font-size: clamp(1.8rem, 4vw, 3.5rem);
}

h2 {
  font-size: 1rem;
}

.toolbar {
  display: flex;
  gap: 8px;
}

.tabs {
  display: flex;
  gap: 8px;
  overflow-x: auto;
  padding: 0 0 14px;
  margin-bottom: 14px;
}

.tab {
  flex: 0 0 auto;
  background: rgba(23, 32, 31, 0.78);
  color: var(--muted);
}

.tab.active {
  border-color: rgba(56, 211, 159, 0.72);
  background: rgba(56, 211, 159, 0.14);
  color: var(--text);
}

.tab-panel {
  display: none;
}

.tab-panel.active {
  display: block;
  min-width: 0;
}

.icon-button {
  display: inline-grid;
  place-items: center;
  width: 42px;
  height: 42px;
  padding: 0;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  color: var(--text);
}

.file-button input {
  inline-size: 0;
  block-size: 0;
  opacity: 0;
  position: absolute;
}

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

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

.metric,
.panel {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(23, 32, 31, 0.92);
  box-shadow: var(--shadow);
}

.metric {
  min-height: 132px;
  padding: 18px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
}

.metric span,
.metric small,
.insight-grid span,
.bars span {
  color: var(--muted);
}

.metric strong {
  font-size: clamp(1.35rem, 3vw, 2.1rem);
}

.metric.primary {
  border-color: rgba(56, 211, 159, 0.58);
  background: linear-gradient(145deg, rgba(56, 211, 159, 0.18), rgba(23, 32, 31, 0.95));
}

.workspace {
  display: grid;
  grid-template-columns: 310px minmax(0, 1fr);
  gap: 14px;
  align-items: start;
  min-width: 0;
}

.workspace.two {
  grid-template-columns: 320px minmax(0, 1fr);
}

.main-grid {
  display: grid;
  gap: 14px;
  min-width: 0;
}

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

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

.assumptions {
  position: sticky;
  top: 16px;
  display: grid;
  gap: 14px;
}

label {
  display: grid;
  gap: 7px;
  color: var(--muted);
  font-size: 0.9rem;
}

.label-with-info {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-width: 0;
}

.info-dot {
  position: relative;
  display: inline-grid;
  place-items: center;
  width: 18px;
  height: 18px;
  min-height: 18px;
  padding: 0;
  border-radius: 50%;
  border-color: rgba(174, 187, 181, 0.65);
  background: #101817;
  color: var(--muted);
  flex: 0 0 auto;
}

.info-dot::before {
  content: "i";
  font-size: 0.72rem;
  font-weight: 800;
  line-height: 1;
}

.info-dot::after {
  content: attr(data-tip);
  position: absolute;
  left: 50%;
  bottom: calc(100% + 10px);
  z-index: 5;
  width: min(280px, 72vw);
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #0d1312;
  box-shadow: var(--shadow);
  color: var(--text);
  font-size: 0.82rem;
  font-weight: 500;
  line-height: 1.4;
  text-align: left;
  transform: translateX(-50%) translateY(4px);
  opacity: 0;
  pointer-events: none;
  transition: opacity 140ms ease, transform 140ms ease;
}

.info-dot:hover::after,
.info-dot:focus-visible::after {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

.inline-inputs {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  gap: 8px;
}

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

input[type="checkbox"] {
  width: 18px;
  min-height: 18px;
  accent-color: var(--accent);
}

.toggle {
  grid-template-columns: auto minmax(0, 1fr);
  align-items: center;
}

input:focus,
select:focus,
button:focus-visible {
  outline: 2px solid rgba(56, 211, 159, 0.65);
  outline-offset: 2px;
}

.table-wrap {
  overflow-x: auto;
  overflow-y: hidden;
  max-width: 100%;
  min-width: 0;
  overscroll-behavior-x: contain;
}

.beginner-panel {
  margin-bottom: 14px;
}

.quick-booking {
  display: grid;
  grid-template-columns: 1.4fr 160px 1.2fr auto;
  gap: 10px;
  align-items: end;
}

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

th,
td {
  padding: 9px 8px;
  border-bottom: 1px solid rgba(49, 65, 61, 0.78);
  text-align: left;
}

th {
  color: var(--muted);
  font-size: 0.82rem;
  font-weight: 700;
}

td:nth-child(2),
td:nth-child(3),
td:nth-child(4),
td:nth-child(5) {
  width: 128px;
}

td:last-child {
  width: 52px;
}

.row-result {
  font-weight: 800;
  white-space: nowrap;
}

.remove-row {
  width: 34px;
  min-height: 34px;
  padding: 0;
  color: var(--danger);
}

.file-upload {
  display: inline-grid;
  place-items: center;
  min-width: 86px;
  min-height: 38px;
  padding: 0 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #101817;
  color: var(--text);
  cursor: pointer;
}

.file-upload input {
  inline-size: 0;
  block-size: 0;
  opacity: 0;
  position: absolute;
}

.closed-row {
  opacity: 0.68;
}

.closed-row input,
.closed-row select,
.closed-row button {
  cursor: not-allowed;
}

.insights {
  display: grid;
  gap: 16px;
}

.explain {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
}

.explain p {
  margin: 10px 0 0;
  color: var(--muted);
  line-height: 1.55;
}

.bars {
  display: grid;
  gap: 10px;
}

.bars > div {
  display: grid;
  grid-template-columns: 110px minmax(0, 1fr);
  align-items: center;
  gap: 10px;
}

meter {
  width: 100%;
  height: 16px;
}

meter::-webkit-meter-bar {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #101817;
}

meter::-webkit-meter-optimum-value {
  border-radius: 8px;
  background: linear-gradient(90deg, var(--accent), var(--accent-2));
}

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

.insight-grid > div {
  min-height: 84px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel-2);
  display: grid;
  gap: 6px;
}

.insight-grid strong {
  font-size: 1.15rem;
}

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

.forecast-card,
.tax-item,
.health-card,
.stripe-grid > div,
.ops-grid > div {
  min-height: 88px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel-2);
  display: grid;
  gap: 6px;
}

.forecast-card span,
.forecast-card small,
.tax-item span,
.health-card span,
.health-card small,
.stripe-grid span,
.ops-grid span,
.ops-grid small {
  color: var(--muted);
}

.forecast-card strong,
.tax-item strong,
.health-card strong,
.stripe-grid strong,
.ops-grid strong {
  font-size: 1.18rem;
}

.tax-grid,
.health-grid,
.stripe-grid,
.ops-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
}

.status-pill {
  display: inline-flex;
  align-items: center;
  min-height: 28px;
  padding: 4px 10px;
  border: 1px solid rgba(244, 185, 66, 0.65);
  border-radius: 999px;
  color: var(--accent-2);
  font-size: 0.82rem;
  font-weight: 800;
}

.status-pill.closed {
  border-color: rgba(56, 211, 159, 0.58);
  color: var(--accent);
}

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

.accounting-card {
  min-height: 78px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel-2);
  display: grid;
  gap: 6px;
}

.accounting-card span {
  color: var(--muted);
}

.accounting-card small {
  color: var(--muted);
  line-height: 1.45;
}

.accounting-card strong {
  font-size: 1.1rem;
}

.accounting-card.good {
  border-color: rgba(56, 211, 159, 0.42);
}

.accounting-card.warn {
  border-color: rgba(244, 185, 66, 0.62);
}

.accounting-card.danger {
  border-color: rgba(255, 107, 107, 0.72);
}

.accounting-card.wide {
  grid-column: 1 / -1;
}

.stripe-status {
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #101817;
  color: var(--muted);
  line-height: 1.45;
}

.stripe-status.ready {
  border-color: rgba(56, 211, 159, 0.58);
  color: var(--text);
}

.stripe-log {
  margin-top: 14px;
  min-height: 52px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #101817;
  color: var(--muted);
  line-height: 1.45;
}

.muted-note {
  margin: 12px 0 0;
  color: var(--muted);
  line-height: 1.5;
}

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

.alert-card {
  min-height: 78px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel-2);
  display: grid;
  gap: 6px;
}

.alert-card span {
  color: var(--muted);
  line-height: 1.45;
}

.alert-card.good {
  border-color: rgba(56, 211, 159, 0.55);
}

.alert-card.warn {
  border-color: rgba(244, 185, 66, 0.65);
}

.alert-card.danger {
  border-color: rgba(255, 107, 107, 0.72);
}

.monthly-report {
  display: grid;
  gap: 16px;
}

.report-title {
  display: grid;
  gap: 4px;
}

.report-title span,
.monthly-report h3 {
  color: var(--muted);
}

.report-title strong {
  font-size: 1.8rem;
}

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

.report-kpis > div,
.report-list > div {
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel-2);
}

.report-kpis span,
.report-list span {
  color: var(--muted);
}

.report-kpis strong,
.report-list strong {
  display: block;
  margin-top: 4px;
}

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

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

.breakdown-card {
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel-2);
  display: grid;
  gap: 6px;
}

.breakdown-card span,
.breakdown-card small {
  color: var(--muted);
}

.command-layout {
  display: grid;
  gap: 14px;
}

.command-hero {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 160px;
  align-items: center;
  gap: 18px;
  min-height: 180px;
  background:
    linear-gradient(135deg, rgba(56, 211, 159, 0.20), rgba(244, 185, 66, 0.10)),
    rgba(23, 32, 31, 0.96);
}

.command-hero h2 {
  font-size: clamp(1.8rem, 4vw, 3rem);
}

.command-hero p:not(.eyebrow) {
  margin: 10px 0 0;
  color: var(--muted);
  line-height: 1.55;
}

.command-score {
  aspect-ratio: 1;
  border: 1px solid rgba(56, 211, 159, 0.58);
  border-radius: 50%;
  display: grid;
  place-items: center;
  align-content: center;
  background: rgba(16, 24, 23, 0.72);
}

.command-score span {
  color: var(--muted);
}

.command-score strong {
  font-size: 3rem;
}

.wizard-steps,
.system-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
}

.wizard-step,
.system-card {
  min-height: 96px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel-2);
  display: grid;
  gap: 6px;
}

.wizard-step.done,
.system-card.good {
  border-color: rgba(56, 211, 159, 0.5);
}

.wizard-step.open,
.system-card.warn {
  border-color: rgba(244, 185, 66, 0.65);
}

.wizard-step span,
.system-card span {
  font-weight: 800;
}

.wizard-step small,
.system-card small {
  color: var(--muted);
  line-height: 1.45;
}

.wizard-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 14px;
}

.ops-package-list,
.ops-ideas,
.analytics-list {
  display: grid;
  gap: 10px;
}

.ops-package-card,
.ops-idea,
.analytics-card {
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel-2);
  display: grid;
  gap: 6px;
}

.ops-package-card span,
.ops-package-card small,
.ops-idea span,
.analytics-card span,
.analytics-card small {
  color: var(--muted);
  line-height: 1.45;
}

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

.analytics-grid > div {
  min-height: 88px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel-2);
  display: grid;
  gap: 6px;
}

.analytics-grid span,
.analytics-grid small {
  color: var(--muted);
}

.analytics-grid strong {
  font-size: 1.18rem;
}

@media (max-width: 980px) {
  .kpis,
  .workspace,
  .workspace.two,
  .forecast,
  .tax-grid,
  .health-grid,
  .stripe-grid,
  .ops-grid,
  .analytics-grid,
  .accounting-checks,
  .alert-list,
  .report-kpis,
  .package-breakdown,
  .wizard-steps,
  .system-grid,
  .explain,
  .insight-grid {
    grid-template-columns: 1fr 1fr;
  }

  .assumptions {
    position: static;
  }
}

@media (max-width: 680px) {
  .app-shell {
    padding: 16px;
  }

  .topbar,
  .section-heading {
    align-items: flex-start;
  }

  .topbar {
    flex-direction: column;
  }

  .kpis,
  .workspace,
  .workspace.two,
  .forecast,
  .tax-grid,
  .health-grid,
  .stripe-grid,
  .ops-grid,
  .analytics-grid,
  .accounting-checks,
  .alert-list,
  .report-kpis,
  .package-breakdown,
  .command-hero,
  .wizard-steps,
  .system-grid,
  .quick-booking,
  .explain,
  .insight-grid {
    grid-template-columns: 1fr;
  }

  .toolbar {
    width: 100%;
  }

  .icon-button {
    flex: 1;
  }

  .bars > div {
    grid-template-columns: 1fr;
  }
}

@media print {
  body {
    background: #fff;
    color: #111;
  }

  .topbar,
  .tabs,
  .kpis,
  .tab-panel:not([data-panel="reports"]),
  .report-panel .section-heading button,
  .workspace.two > aside {
    display: none !important;
  }

  .app-shell,
  .panel {
    padding: 0;
    box-shadow: none;
    border: 0;
    background: transparent;
  }

  .tab-panel,
  .tab-panel.active,
  .workspace.two {
    display: block;
  }

  .report-kpis,
  .tax-grid,
  .health-grid {
    grid-template-columns: repeat(2, 1fr);
  }
}
