:root {
  color-scheme: light;
  --ink: #202124;
  --muted: #5f6670;
  --line: #d9dee6;
  --line-soft: #eceff3;
  --surface: #ffffff;
  --page: #f6f7f9;
  --brand: #b3261e;
  --brand-dark: #17191c;
  --focus: #2459c7;
  --ok: #177245;
  --ok-bg: #eaf6ef;
  --warn: #9a6500;
  --warn-bg: #fff4df;
  --danger: #b3261e;
  --danger-bg: #fdebea;
  --blue-bg: #eef4ff;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  background: var(--page);
  color: var(--ink);
  font-weight: 400;
}

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

strong,
b,
h1,
h2,
h3 {
  font-weight: 500;
}

.login-screen {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 20px;
}

.login-card {
  width: min(420px, 100%);
  background: var(--surface);
  border: 0.5px solid var(--line);
  border-radius: 12px;
  padding: 24px;
  display: grid;
  gap: 16px;
}

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

.hint {
  margin: 0;
  color: var(--muted);
  font-size: 0.86rem;
  line-height: 1.4;
}

.is-hidden {
  display: none !important;
}

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

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

.eyebrow {
  margin: 0 0 4px;
  color: var(--brand);
  font-size: 0.78rem;
  font-weight: 500;
  letter-spacing: 0;
  text-transform: uppercase;
}

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

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

h2 {
  font-size: 1.25rem;
}

h3 {
  font-size: 1rem;
}

.today-pill {
  white-space: nowrap;
  border: 0.5px solid var(--line);
  background: var(--surface);
  border-radius: 999px;
  padding: 10px 14px;
  color: var(--muted);
  font-weight: 500;
}

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

.summary-band {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 12px;
  margin-bottom: 18px;
}

.report-selector {
  display: grid;
  grid-template-columns: minmax(220px, 280px) minmax(220px, 280px);
  gap: 12px;
  align-items: end;
  margin: 0 0 14px;
}

.report-selector label {
  color: var(--muted);
}

.summary-title {
  min-height: 96px;
  background: var(--brand-dark);
  color: #fff;
  border-radius: 12px;
  padding: 16px;
  display: grid;
  align-content: space-between;
}

.summary-title .eyebrow {
  color: #ffcb35;
}

.summary-title span {
  color: #d5d9df;
  font-weight: 500;
}

.metric {
  min-height: 96px;
  background: var(--surface);
  border: 0.5px solid var(--line);
  border-radius: 12px;
  padding: 16px;
  display: grid;
  align-content: space-between;
}

.metric span {
  color: var(--muted);
  font-size: 0.9rem;
}

.metric strong {
  font-size: 1.7rem;
}

.metric.warning strong {
  color: var(--warn);
}

.metric.highlight {
  border-color: #f1d79b;
  background: var(--warn-bg);
}

.metric.highlight strong {
  color: var(--brand-dark);
}

.workspace {
  display: grid;
  grid-template-columns: minmax(360px, 0.95fr) minmax(460px, 1.05fr);
  gap: 18px;
  align-items: start;
}

.entry-panel,
.dashboard-panel,
.branch-summary-panel {
  background: var(--surface);
  border: 0.5px solid var(--line);
  border-radius: 12px;
  padding: 18px;
}

.dashboard-panel {
  grid-column: 1 / -1;
}

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

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

.form-grid {
  grid-template-columns: repeat(2, 1fr);
}

.form-grid.single-field {
  grid-template-columns: minmax(220px, 420px);
}

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

label {
  display: grid;
  gap: 6px;
  color: var(--muted);
  font-size: 0.86rem;
  font-weight: 500;
}

input,
select,
textarea {
  width: 100%;
  min-height: 52px;
  border: 0.5px solid var(--line);
  border-radius: 12px;
  padding: 12px 14px;
  color: var(--ink);
  background: #fff;
}

textarea {
  resize: vertical;
}

input:focus,
select:focus,
textarea:focus {
  outline: 3px solid color-mix(in srgb, var(--focus) 20%, transparent);
  border-color: var(--focus);
}

input:disabled,
select:disabled,
textarea:disabled,
button:disabled {
  cursor: not-allowed;
  opacity: 0.62;
}

.is-readonly .step-card:first-of-type::before {
  content: "This record is read-only. Unlock it from the dashboard before editing.";
  display: block;
  border-radius: 12px;
  padding: 12px;
  color: var(--ok);
  background: var(--ok-bg);
}

.section-title {
  margin: 20px 0 10px;
  font-weight: 500;
}

.header-fields {
  margin-bottom: 14px;
}

.step-card {
  display: grid;
  gap: 14px;
  margin-top: 14px;
  padding: 14px;
  border: 0.5px solid var(--line);
  border-radius: 12px;
  background: #fff;
}

.step-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
}

.step-head h3 {
  margin-top: 3px;
  font-size: 1.22rem;
}

.step-label {
  color: var(--muted);
  font-size: 0.82rem;
}

.running-total,
.total-strip {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  border-radius: 12px;
  padding: 12px;
  background: #f1f3f5;
}

.running-total span,
.total-strip span,
.summary-cell span {
  color: var(--muted);
  font-size: 0.82rem;
}

.running-total strong,
.total-strip strong {
  font-size: 1.3rem;
}

.cash-field {
  border-color: #c7d8ff;
  background: var(--blue-bg);
}

.cash-split {
  display: grid;
  gap: 10px;
}

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

.summary-cell {
  display: grid;
  gap: 5px;
  min-width: 0;
  border: 0.5px solid var(--line-soft);
  border-radius: 12px;
  padding: 12px;
  background: #fff;
}

.summary-cell.full {
  grid-column: 1 / -1;
}

.split-title {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

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

.form-message {
  min-height: 20px;
  margin-top: 10px;
  color: var(--warn);
  font-size: 0.9rem;
  font-weight: 500;
}

.form-message.success {
  color: var(--ok);
}

.status-line {
  margin: 8px 0 0;
  color: var(--muted);
  font-weight: 500;
}

.submission-notice {
  display: grid;
  gap: 6px;
  margin: 16px 0;
  border: 0.5px solid #bfe4ce;
  border-radius: 12px;
  padding: 16px;
  background: var(--ok-bg);
  color: var(--ok);
}

.submission-notice span {
  display: inline-flex;
  width: fit-content;
  margin-bottom: 6px;
  border-radius: 999px;
  padding: 5px 10px;
  background: #d9f0e3;
  font-size: 0.78rem;
  font-weight: 500;
}

.submission-notice strong {
  display: block;
  color: var(--ink);
  font-size: 1.05rem;
}

.submission-notice p {
  margin: 4px 0 0;
  color: var(--muted);
}

.cash-difference {
  margin-top: 10px;
  border: 0.5px solid var(--line);
  border-radius: 12px;
  padding: 12px;
  font-weight: 500;
}

.cash-difference.balanced {
  color: var(--ok);
  background: var(--ok-bg);
}

.cash-difference.unbalanced {
  color: var(--danger);
  background: var(--danger-bg);
}

.field-error {
  border-color: var(--warn);
  background: #fff8ed;
}

.expense-row {
  display: grid;
  grid-template-columns: minmax(160px, 1fr) 170px 110px minmax(150px, 0.8fr) 48px;
  gap: 8px;
  align-items: center;
  border: 0.5px solid var(--line);
  border-radius: 12px;
  padding: 10px;
  background: #fbfcfd;
}

.note-field {
  margin-top: 16px;
}

.calculation-strip {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
  margin: 18px 0;
  padding: 12px;
  border-radius: 8px;
  background: #f0f3f5;
}

.calculation-strip div {
  display: grid;
  gap: 4px;
}

.calculation-strip span {
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 500;
}

.calculation-strip strong {
  font-size: 1rem;
}

.primary-button,
.ghost-button,
.small-button,
.icon-button,
.dark-button {
  border: 0.5px solid var(--line);
  border-radius: 12px;
  min-height: 48px;
  cursor: pointer;
  font-weight: 500;
}

.primary-button {
  background: var(--brand-dark);
  color: #fff;
  padding: 0 16px;
  border-color: var(--brand-dark);
}

.primary-button:hover {
  background: #000;
}

.ghost-button,
.small-button {
  background: #fff;
  color: var(--ink);
  padding: 0 12px;
}

.dark-button {
  background: var(--brand-dark);
  color: #fff;
  border-color: var(--brand-dark);
  padding: 0 14px;
}

.small-button {
  min-height: 48px;
}

.icon-button {
  width: 48px;
  min-height: 48px;
  background: var(--danger-bg);
  color: var(--danger);
}

.button-row {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}

.button-row .primary-button {
  flex: 1 1 160px;
}

.button-row .ghost-button,
.button-row .small-button {
  flex: 1 1 140px;
}

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

.summary-item {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  border-bottom: 1px solid var(--line);
  padding: 10px 0;
  font-weight: 500;
}

.summary-item span {
  color: var(--muted);
}

.filters {
  grid-template-columns: 1fr 1fr;
  margin-bottom: 16px;
}

.branch-status {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 10px;
  margin-bottom: 16px;
}

.status-item {
  border: 0.5px solid var(--line);
  border-radius: 999px;
  padding: 12px;
  display: flex;
  justify-content: space-between;
  gap: 8px;
  font-weight: 500;
}

.status-item.done span {
  color: var(--ok);
}

.status-item.waiting span {
  color: var(--warn);
}

.status-item.done {
  background: var(--ok-bg);
  border-color: #c9e8d4;
}

.status-item.waiting {
  background: var(--warn-bg);
  border-color: #f1d79b;
}

.records-list {
  display: grid;
  gap: 14px;
}

.record-card {
  border: 0.5px solid #dfe5ec;
  border-radius: 12px;
  overflow: hidden;
  background: #fff;
}

.record-header {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  align-items: flex-start;
  padding: 16px;
  background: #fff;
}

.record-header strong {
  display: block;
  margin-top: 4px;
  font-size: 1.2rem;
  font-weight: 500;
}

.record-kicker,
.record-meta span,
.record-channel span,
.record-total span {
  display: block;
  color: var(--muted);
  font-size: 0.72rem;
  font-weight: 500;
  text-transform: uppercase;
}

.status-pill {
  border-radius: 999px;
  padding: 7px 11px;
  background: #eef2f7;
  color: var(--muted);
  font-size: 0.82rem;
  font-weight: 500;
  white-space: nowrap;
}

.status-draft {
  background: var(--warn-bg);
  color: var(--warn);
}

.status-submitted {
  background: #eaf2ff;
  color: #2459c7;
}

.status-locked {
  background: var(--ok-bg);
  color: #167a4a;
}

.status-void {
  background: var(--danger-bg);
  color: var(--danger);
}

.record-meta {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 1px;
  background: var(--line);
  border-top: 1px solid var(--line);
}

.record-meta div {
  min-width: 0;
  padding: 12px 16px;
  background: #f8fafc;
}

.record-meta strong,
.record-channel strong,
.record-total strong {
  display: block;
  margin-top: 4px;
  font-weight: 500;
  overflow-wrap: anywhere;
}

.record-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(135px, 1fr));
  background: #fff;
  border-top: 1px solid var(--line);
}

.record-channel {
  min-width: 0;
  background: #fff;
  padding: 13px 16px;
  border-right: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
}

.record-channel:last-child {
  border-right: 0;
}

.record-totals {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  background: #fff;
}

.record-total {
  min-width: 0;
  background: #fff;
  padding: 13px 16px;
  border-right: 1px solid var(--line);
}

.record-total:last-child {
  border-right: 0;
}

.record-action-bar {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  justify-content: flex-end;
  padding: 12px 16px;
  background: #fff;
  border-top: 1px solid var(--line);
}

.record-action-bar .small-button {
  min-width: 108px;
  min-height: 38px;
}

.danger-button {
  color: var(--danger);
  border-color: #f1c4c7;
  background: #fff;
}

.expense-report {
  margin-top: 18px;
}

.expense-report h3 {
  margin-bottom: 10px;
}

.empty-state {
  color: var(--muted);
  border: 1px dashed var(--line);
  border-radius: 8px;
  padding: 16px;
}

.report-row {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  padding: 10px 0;
  border-bottom: 1px solid var(--line);
}

@media (max-width: 1000px) {
  .workspace,
  .summary-band,
  .report-selector {
    grid-template-columns: 1fr;
  }

  .metric,
  .summary-title {
    min-height: 82px;
  }
}

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

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

  .topbar {
    gap: 10px;
    padding-bottom: 14px;
  }

  h1 {
    font-size: 2.15rem;
    line-height: 1.05;
  }

  h2 {
    font-size: 1.1rem;
  }

  .entry-panel,
  .dashboard-panel,
  .branch-summary-panel {
    padding: 14px;
  }

  .summary-band {
    gap: 10px;
    margin-bottom: 12px;
  }

  .metric,
  .summary-title {
    min-height: 76px;
    padding: 13px;
  }

  .metric strong {
    font-size: 1.35rem;
  }

  input,
  select,
  textarea {
    min-height: 48px;
    font-size: 1rem;
  }

  .section-title {
    margin-top: 16px;
  }

  .top-actions {
    width: 100%;
    align-items: stretch;
    flex-direction: column;
  }

  .form-grid,
  .money-grid,
  .filters,
  .report-selector,
  .branch-status,
  .calculation-strip {
    grid-template-columns: 1fr;
  }

  .expense-row {
    grid-template-columns: 1fr;
  }

  .record-header {
    flex-direction: column;
  }

  .record-meta,
  .record-totals {
    grid-template-columns: 1fr;
  }

  .record-action-bar {
    justify-content: stretch;
  }

  .record-action-bar .small-button {
    flex: 1 1 130px;
  }

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

  .record-channel:last-child:nth-child(odd) {
    grid-column: 1 / -1;
  }

  .sticky-actions {
    position: sticky;
    bottom: 0;
    z-index: 10;
    margin: 18px -14px -14px;
    padding: 12px 14px;
    background: var(--surface);
    border-top: 1px solid var(--line);
  }

  .split-title {
    align-items: stretch;
  }

  .small-button {
    width: 100%;
  }

  .calculation-strip {
    gap: 8px;
    padding: 10px;
  }

  .icon-button {
    width: 100%;
  }
}

@media (max-width: 430px) {
  h1 {
    font-size: 1.85rem;
  }

  .login-card {
    padding: 18px;
  }

  .today-pill,
  .ghost-button {
    width: 100%;
    text-align: center;
  }

  .entry-panel,
  .dashboard-panel,
  .branch-summary-panel {
    border-radius: 8px;
  }

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