:root {
  color-scheme: light;
  --bg: #e7ece8;
  --ink: #17211c;
  --muted: #64716a;
  --line: #d5ddd8;
  --panel: #fbfcfa;
  --panel-soft: #f3f6f2;
  --green: #247657;
  --green-dark: #15543c;
  --rose: #b84343;
  --amber: #b97620;
  --blue: #2f638f;
  --shadow: 0 20px 70px rgba(24, 34, 28, 0.18);
  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(135deg, rgba(36, 118, 87, 0.16), transparent 32%),
    linear-gradient(315deg, rgba(47, 99, 143, 0.14), transparent 40%),
    var(--bg);
  color: var(--ink);
}

button,
input,
select {
  font: inherit;
}

.app-shell {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 28px;
}

.phone {
  width: min(100%, 420px);
  min-height: 860px;
  max-height: calc(100vh - 56px);
  overflow: auto;
  background: var(--panel);
  border: 1px solid rgba(23, 33, 28, 0.1);
  border-radius: 34px;
  box-shadow: var(--shadow);
  padding: 22px;
}

.topbar,
.section-title,
.report-row,
.ledger-item,
.activity-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
}

.topbar {
  margin-bottom: 12px;
}

.company-switcher {
  margin-bottom: 18px;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel-soft);
}

.company-switcher select {
  min-height: 38px;
}

#api-status {
  display: block;
  margin-top: 6px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

#api-status.connected {
  color: var(--green-dark);
}

.eyebrow,
.metric span,
.close-card span,
.report-row span,
.activity-meta,
label {
  color: var(--muted);
}

.eyebrow {
  margin: 0 0 2px;
  font-size: 12px;
  font-weight: 750;
  text-transform: uppercase;
  letter-spacing: 0;
}

h1,
h2,
p {
  margin: 0;
}

h1 {
  font-size: 28px;
  line-height: 1.05;
}

h2 {
  font-size: 17px;
}

.icon-button,
.text-button,
.tab,
.segment,
.primary-button {
  border: 0;
  cursor: pointer;
}

.icon-button {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  background: var(--panel-soft);
  color: var(--green-dark);
  display: grid;
  place-items: center;
}

.icon {
  font-size: 22px;
  line-height: 1;
}

.summary-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

.metric {
  min-height: 86px;
  background: var(--panel-soft);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 13px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
}

.metric.primary {
  background: var(--green);
  color: #fff;
}

.metric.primary span {
  color: rgba(255, 255, 255, 0.76);
}

.metric.warning strong {
  color: var(--amber);
}

.metric strong {
  font-size: 21px;
  line-height: 1.1;
}

.tabs,
.segmented {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 4px;
  background: #e8eee9;
  border-radius: 8px;
  padding: 4px;
  margin: 18px 0;
}

.segmented {
  grid-template-columns: repeat(5, 1fr);
}

.tab,
.segment {
  min-height: 38px;
  border-radius: 6px;
  background: transparent;
  color: var(--muted);
  font-size: 12px;
  font-weight: 750;
}

.tab.active,
.segment.active {
  background: #fff;
  color: var(--ink);
  box-shadow: 0 4px 15px rgba(24, 34, 28, 0.08);
}

.view {
  display: none;
}

.view.active {
  display: block;
}

.section-title {
  margin: 20px 0 10px;
}

.text-button {
  background: transparent;
  color: var(--green-dark);
  font-weight: 800;
}

.ledger-list,
.activity-list,
.category-list,
.alerts {
  display: grid;
  gap: 8px;
}

.ledger-item,
.activity-item,
.report-row,
.close-card {
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 8px;
}

.ledger-item,
.activity-item,
.report-row {
  padding: 12px;
}

.ledger-item.liability .ledger-balance {
  color: var(--rose);
}

.ledger-name,
.activity-title {
  font-weight: 800;
}

.ledger-balance,
.activity-amount {
  font-weight: 850;
  white-space: nowrap;
}

.activity-side {
  display: grid;
  justify-items: end;
  gap: 6px;
}

.mini-danger-button {
  min-height: 30px;
  border-radius: 8px;
  border: 1px solid #efc1c1;
  background: #fff8f8;
  color: var(--rose);
  padding: 0 10px;
  font-size: 12px;
  font-weight: 850;
}

.mini-danger-button:disabled {
  cursor: wait;
  opacity: 0.7;
}

.activity-meta {
  margin-top: 3px;
  font-size: 12px;
}

.form {
  display: grid;
  gap: 12px;
}

#form-fields {
  display: grid;
  gap: 12px;
}

.form-note {
  margin: -4px 0 14px;
  padding: 12px;
  border-radius: 8px;
  border: 1px solid #c9d8d0;
  background: #eef5f0;
  color: var(--green-dark);
  font-size: 13px;
  font-weight: 750;
  line-height: 1.35;
}

label {
  display: grid;
  gap: 6px;
  font-size: 13px;
  font-weight: 750;
}

input,
select {
  width: 100%;
  min-height: 44px;
  border-radius: 8px;
  border: 1px solid var(--line);
  background: #fff;
  color: var(--ink);
  padding: 0 12px;
}

input[readonly] {
  background: #eef3ef;
  color: var(--green-dark);
  font-weight: 800;
}

.inline-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

.upload {
  padding: 12px;
  border: 1px dashed #a9b7af;
  border-radius: 8px;
  background: var(--panel-soft);
}

.primary-button {
  min-height: 48px;
  border-radius: 8px;
  background: var(--green);
  color: #fff;
  font-weight: 850;
}

.primary-button:disabled {
  cursor: wait;
  opacity: 0.72;
}

.feedback {
  display: none;
  gap: 4px;
  padding: 12px;
  border-radius: 8px;
  font-size: 13px;
  line-height: 1.35;
}

.feedback.visible {
  display: grid;
}

.feedback strong {
  color: inherit;
}

.feedback span {
  color: inherit;
}

.feedback.success {
  border: 1px solid #b9d8c4;
  background: #edf7f0;
  color: var(--green-dark);
}

.feedback.error {
  border: 1px solid #efc1c1;
  background: #fff0f0;
  color: var(--rose);
}

.close-card {
  padding: 14px;
  display: grid;
  gap: 14px;
}

.close-card > div {
  display: grid;
  gap: 6px;
}

.close-card strong {
  font-size: 22px;
}

.close-result strong.negative,
.activity-amount.negative {
  color: var(--rose);
}

.close-result strong.positive,
.activity-amount.positive {
  color: var(--green);
}

.alert {
  padding: 12px;
  border-radius: 8px;
  background: #fff7ea;
  border: 1px solid #efd4a9;
  color: #67400f;
  font-weight: 750;
}

.chart {
  height: 42px;
  display: flex;
  overflow: hidden;
  border-radius: 8px;
  margin: 14px 0;
  background: var(--panel-soft);
}

.chart div {
  min-width: 4px;
}

#bar-cash {
  background: var(--green);
}

#bar-bank {
  background: var(--blue);
}

#bar-owner {
  background: var(--amber);
}

#bar-terminal {
  background: #6e5f99;
}

.category-item {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 12px;
  padding: 10px 0;
  border-bottom: 1px solid var(--line);
}

.category-item:last-child {
  border-bottom: 0;
}

@media (max-width: 520px) {
  .app-shell {
    padding: 0;
    place-items: stretch;
  }

  .phone {
    width: 100%;
    min-height: 100vh;
    max-height: none;
    border-radius: 0;
    border: 0;
  }
}
