:root {
  color-scheme: dark;
  font-family: Inter, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  background: #080b0b;
  color: #f4f5f5;
  --bg: #080b0b;
  --sidebar: #0d1112;
  --panel: #101418;
  --line: #252c31;
  --muted: #8f989e;
  --mint: #74dcba;
  --red: #ff8f98;
  --blue: #73a7ff;
  --amber: #e4be5c;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  min-width: 960px;
  min-height: 100vh;
  background: var(--bg);
}

button, input, select { font: inherit; }
button { cursor: pointer; }

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

.sidebar {
  display: flex;
  flex-direction: column;
  padding: 28px 20px;
  border-right: 1px solid #23292d;
  background: var(--sidebar);
}

.sidebar-brand {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 48px;
}

.sidebar-brand strong {
  display: block;
  margin-top: 4px;
  font-size: 18px;
}

.brand-mark {
  display: grid;
  place-items: center;
  width: 48px;
  height: 48px;
  border: 1px solid #33433f;
  border-radius: 14px;
  background: #14201d;
  color: #75dfbb;
  font-size: 24px;
  font-weight: 700;
}

.eyebrow {
  margin: 0;
  color: #8a9399;
  font-size: 12px;
  font-weight: 700;
  letter-spacing: .14em;
  text-transform: uppercase;
}

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

.nav-item {
  padding: 12px;
  border-radius: 10px;
  color: #d6d9db;
}

.nav-item.active {
  background: #17211f;
  color: #7be1be;
}

.sidebar-footer {
  display: grid;
  gap: 12px;
  margin-top: auto;
}

.user-email {
  overflow: hidden;
  color: #8a9399;
  font-size: 13px;
  text-overflow: ellipsis;
}

.content {
  width: 100%;
  max-width: 1540px;
  padding: 36px 44px 60px;
}

.page-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
}

h1 { margin: 8px 0 0; font-size: 32px; }
h2 { margin: 0; font-size: 21px; }
h3 { margin: 0; font-size: 13px; }

.picker-group {
  display: flex;
  align-items: center;
  gap: 8px;
}

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

.select-menu {
  position: relative;
  min-width: 190px;
}

.select-menu[open] { z-index: 50; }

.select-menu summary {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  min-height: 46px;
  padding: 0 15px 0 17px;
  border: 1px solid #293137;
  border-radius: 12px;
  outline: none;
  background: #101518;
  color: #d9dddf;
  cursor: pointer;
  list-style: none;
  user-select: none;
}

.select-menu summary::-webkit-details-marker { display: none; }

.select-menu summary:hover {
  border-color: #3e4b50;
  background: #141b1e;
}

.select-menu summary:focus-visible,
.select-menu[open] summary {
  border-color: #5bc9a4;
  box-shadow: 0 0 0 3px #16352c;
}

.select-chevron {
  width: 9px;
  height: 9px;
  border-right: 1.5px solid #aeb6ba;
  border-bottom: 1.5px solid #aeb6ba;
  transform: translateY(-2px) rotate(45deg);
  transition: transform .16s ease;
}

.select-menu[open] .select-chevron {
  transform: translateY(2px) rotate(225deg);
}

.select-options {
  position: absolute;
  top: calc(100% + 8px);
  right: 0;
  z-index: 20;
  width: max(100%, 220px);
  max-height: 330px;
  overflow-y: auto;
  padding: 6px;
  border: 1px solid #303a3f;
  border-radius: 13px;
  background: #11171a;
  box-shadow: 0 18px 48px #000a;
}

.select-options a {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  min-height: 40px;
  padding: 9px 11px;
  border-radius: 8px;
  color: #d9dddf;
  text-decoration: none;
  white-space: nowrap;
}

.select-options a:hover,
.select-options a:focus-visible {
  outline: none;
  background: #1a2423;
  color: #f4f5f5;
}

.select-options a.selected {
  background: #182824;
  color: var(--mint);
}

.select-check {
  color: var(--mint);
  font-size: 14px;
}

.store-select { min-width: 270px; }

@media (prefers-reduced-motion: reduce) {
  .select-chevron { transition: none; }
}

.section-tabs {
  display: flex;
  grid-auto-flow: column;
  justify-content: start;
  gap: 28px;
  margin-top: 28px;
  border-bottom: 1px solid var(--line);
}

.section-tabs a {
  padding: 0 2px 13px;
  border-bottom: 2px solid transparent;
  color: var(--muted);
  text-decoration: none;
}

.section-tabs a:hover { color: #d9dddf; }

.section-tabs a.active {
  border-color: var(--mint);
  color: var(--mint);
}

.data-line {
  margin: 22px 0 16px;
  color: var(--muted);
  font-size: 14px;
}

.data-warning {
  margin-bottom: 16px;
  padding: 12px 14px;
  border: 1px solid #564929;
  border-radius: 10px;
  background: #252116;
  color: #efd184;
  font-size: 13px;
}

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

.metric-card {
  min-width: 0;
  min-height: 166px;
  padding: 22px 20px;
  border: 1px solid var(--line);
  border-radius: 18px;
  background: var(--panel);
}

.metric-card span,
.metric-card small {
  display: block;
  color: var(--muted);
}

.metric-comparison {
  min-height: 18px;
  line-height: 1.35;
}

.metric-card strong {
  display: block;
  margin: 28px 0 18px;
  font-size: clamp(23px, 2vw, 30px);
  font-variant-numeric: tabular-nums;
  letter-spacing: -.04em;
  white-space: nowrap;
}

.primary-card strong { font-size: clamp(27px, 2.4vw, 36px); }
.positive { color: var(--mint) !important; }
.negative { color: var(--red) !important; }

.progress {
  width: 100%;
  height: 5px;
  overflow: hidden;
  border-radius: 10px;
  background: #30383d;
}

.progress i {
  display: block;
  height: 100%;
  border-radius: inherit;
  background: var(--mint);
}

.factor-strip {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  margin-top: 16px;
  border: 1px solid var(--line);
  border-radius: 16px;
  background: var(--panel);
}

.factor-strip div {
  min-width: 0;
  padding: 18px;
  border-right: 1px solid var(--line);
}

.factor-strip div:last-child { border-right: 0; }

.factor-strip span {
  display: block;
  min-height: 30px;
  margin-bottom: 8px;
  color: #7f898f;
  font-size: 12px;
}

.factor-strip strong {
  font-size: 18px;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.factor-strip .metric-comparison {
  display: block;
  margin-top: 9px;
  color: var(--muted);
  font-size: 11px;
}

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

.panel-heading {
  display: flex;
  align-items: end;
  justify-content: space-between;
  padding: 22px 24px;
}

.charts-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.15fr) minmax(430px, .85fr);
  gap: 18px;
  margin-top: 18px;
  align-items: start;
}

.chart-container {
  min-height: 320px;
  padding: 0 18px 20px;
}

.chart-container svg {
  display: block;
  width: 100%;
  height: auto;
  overflow: visible;
}

.chart-legend {
  display: flex;
  flex-wrap: wrap;
  gap: 16px;
  padding: 0 24px 12px;
  color: var(--muted);
  font-size: 11px;
}

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

.chart-legend i {
  display: inline-block;
  width: 18px;
  height: 3px;
  border-radius: 3px;
}

.legend-current { background: var(--mint); }
.legend-average {
  height: 0 !important;
  border-top: 2px dashed #667178;
  background: transparent;
}
.legend-previous { background: #667178; }
.legend-drop { background: var(--red); }
.legend-spike { background: var(--blue); }

.chart-grid { stroke: #293137; stroke-width: 1; }
.chart-axis { fill: #7f898f; font: 11px Inter, sans-serif; }
.chart-line { fill: none; stroke: var(--mint); stroke-width: 3; stroke-linejoin: round; stroke-linecap: round; }
.chart-baseline { stroke: #737d83; stroke-width: 1.5; stroke-dasharray: 7 7; opacity: .75; }
.chart-threshold { stroke-width: 1; stroke-dasharray: 4 7; opacity: .24; }
.chart-threshold.drop { stroke: var(--red); }
.chart-threshold.spike { stroke: var(--blue); }
.chart-threshold-label { font: 10px Inter, sans-serif; opacity: .72; }
.chart-threshold-label.drop { fill: var(--red); }
.chart-threshold-label.spike { fill: var(--blue); }
.chart-line-drop { stroke: var(--red); stroke-width: 3.4; stroke-linecap: round; }
.chart-line-spike { stroke: var(--blue); stroke-width: 3.4; stroke-linecap: round; }
.chart-point { fill: var(--mint); stroke: #11251f; stroke-width: 4; }
.chart-point.drop { fill: var(--red); stroke: #32191d; }
.chart-point.spike { fill: var(--blue); stroke: #152440; }
.chart-bar-positive { fill: #67c9a8; }
.chart-bar-negative { fill: #e67f88; }
.chart-bar-previous { fill: #515b61; }
.chart-value { fill: #d9dddf; font: 11px Inter, sans-serif; }
.chart-value.previous { fill: #778188; font-size: 10px; }
.chart-value.negative { fill: var(--red); }
.chart-empty { margin: 100px 0; color: var(--muted); text-align: center; }

.stores-panel { margin-top: 0; }
.table-wrap { overflow-x: auto; }
.stores-table { min-width: 1740px; }

table {
  width: 100%;
  border-collapse: collapse;
}

th,
td {
  padding: 14px 18px;
  border-top: 1px solid var(--line);
  text-align: right;
  white-space: nowrap;
}

th {
  color: #7f898f;
  font-size: 12px;
  font-weight: 600;
}

td {
  color: #d9dddf;
  font-size: 14px;
  font-variant-numeric: tabular-nums;
}

.store-sales-value,
.store-sales-change {
  display: block;
}

.store-sales-change {
  margin-top: 4px;
  font-size: 11px;
  line-height: 1.2;
}

th:first-child,
td:first-child {
  position: sticky;
  left: 0;
  z-index: 1;
  background: var(--panel);
  text-align: left;
}

.sort-button {
  padding: 0;
  border: 0;
  background: transparent;
  color: inherit;
  font-weight: inherit;
  white-space: nowrap;
}

.sort-button::after {
  content: "↕";
  margin-left: 6px;
  color: #59636a;
}

.sort-button[data-direction="asc"]::after { content: "↑"; color: var(--mint); }
.sort-button[data-direction="desc"]::after { content: "↓"; color: var(--mint); }

.pnl-picker {
  justify-content: flex-end;
  margin-bottom: 16px;
}

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

.pnl-kpis .metric-card { min-height: 140px; }
.pnl-kpis .metric-card strong { margin-bottom: 0; }

.pnl-grid {
  display: grid;
  grid-template-columns: minmax(480px, 1.15fr) minmax(340px, .85fr);
  gap: 18px;
  align-items: start;
}

.statement-group {
  padding: 0 24px 18px;
}

.statement-group + .statement-group {
  padding-top: 18px;
  border-top: 1px solid var(--line);
}

.statement-group h3 {
  margin-bottom: 8px;
  color: #7f898f;
  letter-spacing: .08em;
  text-transform: uppercase;
}

.statement-row,
.expense-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  padding: 11px 0;
  color: #cbd0d2;
}

.statement-row strong,
.expense-row strong {
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.statement-row.deduction strong { color: #aeb6ba; }

.statement-row.subtotal {
  margin-top: 4px;
  border-top: 1px solid #30383d;
  font-weight: 700;
}

.statement-row.total {
  color: var(--mint);
  font-size: 18px;
  font-weight: 700;
}

.result-group { padding-bottom: 22px; }
.expense-column { display: grid; gap: 18px; }

.expense-group {
  padding: 0 24px 18px;
}

.expense-group + .expense-group {
  padding-top: 18px;
  border-top: 1px solid var(--line);
}

.expense-group h3 {
  margin-bottom: 4px;
  color: #9ca5aa;
}

.expense-row {
  padding: 9px 0;
  color: var(--muted);
  font-size: 13px;
}

.empty-state {
  display: grid;
  place-items: center;
  max-width: 760px;
  margin: 120px auto 0;
  padding: 64px;
  border: 1px solid var(--line);
  border-radius: 22px;
  background: var(--panel);
  text-align: center;
}

.empty-state h2 { margin: 20px 0 0; font-size: 24px; }
.empty-icon { color: var(--mint); font-size: 32px; }

.auth-page {
  display: grid;
  min-width: 0;
  place-items: center;
  padding: 24px;
}

.auth-card {
  width: min(100%, 420px);
  padding: 38px;
  border: 1px solid var(--line);
  border-radius: 20px;
  background: var(--panel);
}

.auth-card .brand-mark { margin-bottom: 28px; }
.auth-card h1 { margin: 8px 0; }
.muted { margin: 0 0 28px; color: var(--muted); }
.auth-form { display: grid; gap: 10px; }
.auth-form label { margin-top: 8px; color: #b7bdc1; font-size: 13px; }

.auth-form input {
  width: 100%;
  padding: 12px 14px;
  border: 1px solid #30383e;
  border-radius: 9px;
  outline: none;
  background: #0b0f11;
  color: #f4f5f5;
}

.auth-form input:focus {
  border-color: #5bc9a4;
  box-shadow: 0 0 0 3px #16352c;
}

button {
  padding: 12px 16px;
  border: 0;
  border-radius: 9px;
  background: #72d7b2;
  color: #07100d;
  font-weight: 700;
}

.auth-form button { margin-top: 18px; }

button.secondary {
  width: 100%;
  border: 1px solid #30383e;
  background: transparent;
  color: #d6d9db;
}

.error {
  margin-bottom: 18px;
  padding: 11px 12px;
  border-radius: 8px;
  background: #351c1f;
  color: #ffafb6;
  font-size: 13px;
}

@media (max-width: 1180px) {
  .content { padding-right: 28px; padding-left: 28px; }
  .charts-grid { grid-template-columns: 1fr; }
  .metric-card { padding-right: 16px; padding-left: 16px; }
  .pnl-grid { grid-template-columns: minmax(0, 1fr); }
}

.header-actions {
  display: flex;
  align-items: center;
  gap: 14px;
}

.action-link {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 46px;
  padding: 0 17px;
  border: 1px solid #30383e;
  border-radius: 10px;
  color: #d6d9db;
  text-decoration: none;
  white-space: nowrap;
}

.action-link:hover,
.action-link:focus-visible {
  border-color: #4a595e;
  outline: none;
  background: #141a1d;
  color: #fff;
}

a.nav-item { text-decoration: none; }

.finance-content { max-width: 1680px; }
.editor-tabs { gap: 22px; overflow-x: auto; }
.editor-panel { overflow: visible; margin-top: 22px; }
.editor-heading { align-items: center; }
.editor-heading .eyebrow { margin-bottom: 7px; }
.editor-heading button.secondary { width: auto; }

.finance-form input[type="text"],
.finance-form input[type="date"],
.finance-form input[type="month"] {
  width: 100%;
  min-height: 46px;
  padding: 0 13px;
  border: 1px solid #30383e;
  border-radius: 10px;
  outline: none;
  background: #0b1012;
  color: #eef0f1;
  color-scheme: dark;
}

.finance-form input:focus {
  border-color: #5bc9a4;
  box-shadow: 0 0 0 3px #16352c;
}

.finance-form input:disabled { opacity: .45; }
.money-field { max-width: 190px; text-align: right; font-variant-numeric: tabular-nums; }
.date-field { max-width: 180px; }

.editor-table th:first-child,
.editor-table td:first-child { min-width: 190px; }

.editor-table td { vertical-align: middle; }
.payroll-method-table { min-width: 640px; }
.payroll-method-table .payroll-method-select { max-width: 220px; }
.editor-table tfoot th,
.editor-table tfoot td { border-top-color: #3a444a; }

.check-control {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  color: var(--muted);
  font-size: 12px;
  white-space: nowrap;
}

.check-control input { accent-color: var(--red); }

.editor-grid {
  display: grid;
  gap: 14px;
  padding: 0 24px 24px;
}

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

.field-card {
  display: grid;
  gap: 12px;
  padding: 18px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: #0c1114;
}

.field-card h3 { color: #e5e8e9; font-size: 16px; }
.field-card label,
.form-grid label,
.category-create label,
.reason-field {
  display: grid;
  gap: 7px;
  min-width: 0;
  color: #919ba1;
  font-size: 12px;
}

.field-error {
  color: var(--red);
  font-size: 10px;
  line-height: 1.35;
}

.form-select { width: 100%; min-width: 150px; }
.form-select summary { min-height: 46px; background: #0b1012; }
.form-select .select-options { right: auto; left: 0; min-width: 100%; }

.select-options button {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 100%;
  min-height: 40px;
  padding: 9px 11px;
  border-radius: 8px;
  background: transparent;
  color: #d9dddf;
  font-weight: 500;
  text-align: left;
  white-space: nowrap;
}

.select-options button:hover,
.select-options button:focus-visible {
  outline: none;
  background: #1a2423;
}

.select-options button.selected { background: #182824; color: var(--mint); }

.expense-editor-list { display: grid; }
.expense-editor-row { position: relative; padding: 20px 24px; border-top: 1px solid var(--line); }
.expense-editor-row:focus-within { z-index: 2; }
.expense-editor-row.is-removing { background: #241719; opacity: .72; }
.expense-editor-row.is-locked input[readonly] { color: #a5adb1; cursor: default; }
.expense-editor-row.is-locked .form-select { pointer-events: none; opacity: .72; }

.expense-row-title {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  margin-bottom: 16px;
}

.row-actions { display: flex; gap: 9px; }
.row-actions button.secondary { width: auto; }
.remove-button {
  border: 0;
  background: transparent;
  color: var(--red);
  cursor: pointer;
  font: inherit;
  font-size: 12px;
}
.remove-button:hover,
.remove-button:focus-visible { color: #ffc0c4; outline: none; text-decoration: underline; }
.remove-button:disabled { cursor: default; opacity: .35; text-decoration: none; }

.form-grid { display: grid; gap: 12px; align-items: end; }
.six-columns { grid-template-columns: 140px 1fr 1fr 150px 150px 1fr; }
.five-columns { grid-template-columns: 150px 1fr 1fr 150px 1fr; }
.panel-form { padding: 0 24px 24px; }
.add-panel { border-style: dashed; }
.list-order { color: var(--muted); font-size: 12px; }
.empty-inline { margin: 0; padding: 24px; color: var(--muted); }

.category-create {
  display: flex;
  align-items: end;
  gap: 16px;
  margin: 18px 0 0;
  padding: 18px 20px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: #0d1215;
}

.category-create label { width: 320px; }
.category-create span { padding-bottom: 13px; color: var(--muted); font-size: 12px; }

.save-bar {
  position: sticky;
  bottom: 16px;
  z-index: 10;
  display: flex;
  align-items: end;
  gap: 16px;
  margin-top: 18px;
  padding: 16px;
  border: 1px solid #33423e;
  border-radius: 14px;
  background: #111817f2;
  box-shadow: 0 14px 40px #0008;
  backdrop-filter: blur(12px);
}

.reason-field { flex: 1; }
.reason-field.has-error input,
.reason-field input[aria-invalid="true"] {
  border-color: var(--red);
  box-shadow: 0 0 0 3px #481f25;
}
.save-bar .primary { min-height: 46px; padding: 0 22px; }

.form-message {
  margin-top: 18px;
  padding: 13px 15px;
  border: 1px solid;
  border-radius: 10px;
  font-size: 13px;
}

.form-message.error { border-color: #65353b; }
.form-message.success { border-color: #295443; background: #12261f; color: var(--mint); }

.confirmation-page {
  display: grid;
  min-width: 960px;
  min-height: 100vh;
  place-items: start center;
  padding: 60px 32px;
}

.confirmation-card { width: min(100%, 980px); padding: 34px; }
.confirmation-card h1 { margin-bottom: 12px; }
.confirmation-count { margin: 0 0 24px; color: var(--muted); }
.confirmation-count strong { color: #fff; }
.confirmation-list { overflow: hidden; border: 1px solid var(--line); border-radius: 14px; }
.confirmation-item { padding: 17px 18px; border-top: 1px solid var(--line); }
.confirmation-item:first-child { border-top: 0; }
.confirmation-item > div:first-child { display: flex; justify-content: space-between; gap: 20px; }
.confirmation-item > div:first-child span { color: var(--muted); font-size: 12px; }

.change-values {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 24px minmax(0, 1fr);
  gap: 12px;
  margin-top: 12px;
  color: var(--muted);
  line-height: 1.45;
}

.change-values i { color: #536068; font-style: normal; text-align: center; }
.change-values strong { color: var(--mint); }
.confirmation-reason { display: grid; gap: 6px; margin-top: 18px; color: var(--muted); font-size: 12px; }
.confirmation-reason strong { color: #d9dddf; font-size: 14px; }
.confirmation-actions { display: flex; justify-content: flex-end; gap: 12px; margin-top: 26px; }
.confirmation-actions form { margin: 0; }
.confirmation-actions .primary { min-height: 46px; }

.history-page { display: block; }
.history-card { width: min(100%, 1180px); margin: 0 auto; }
.history-tabs { margin-bottom: 22px; }
.history-list { display: grid; gap: 14px; }
.history-entry { padding: 20px; }
.history-heading { display: flex; justify-content: space-between; gap: 20px; color: var(--muted); font-size: 12px; }
.history-heading div { display: flex; gap: 12px; }
.history-heading strong { color: #e9ebec; font-size: 14px; }
.history-reason { margin: 14px 0; color: #c8cdcf; }
.history-item { display: grid; grid-template-columns: 240px 1fr; gap: 18px; padding-top: 12px; border-top: 1px solid var(--line); color: var(--muted); font-size: 13px; }
.history-item + .history-item { margin-top: 12px; }

@media (max-width: 1300px) {
  .six-columns { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .five-columns { grid-template-columns: repeat(3, minmax(0, 1fr)); }
}

@media (max-width: 1180px) {
  .rates-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .header-actions { gap: 9px; }
  .editor-tabs { gap: 16px; }
}
