:root {
  color-scheme: light;
  --bg: #f4f7f6;
  --surface: #ffffff;
  --surface-soft: #eaf6f3;
  --ink: #17211f;
  --muted: #63706c;
  --line: #dbe5e2;
  --primary: #0f766e;
  --primary-strong: #115e59;
  --accent: #f59e0b;
  --danger: #b91c1c;
  --success: #15803d;
  --shadow: 0 18px 44px rgba(15, 118, 110, 0.12);
  font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
}

button,
input,
select {
  font: inherit;
}

button,
.link-button {
  cursor: pointer;
}

a {
  color: var(--primary);
}

.app-shell {
  width: min(1180px, calc(100% - 28px));
  margin: 0 auto;
  padding: 18px 0 36px;
}

.auth-layout,
.locked-layout {
  min-height: 100vh;
  display: grid;
  align-items: center;
  gap: 18px;
  width: min(1040px, calc(100% - 28px));
  margin: 0 auto;
  padding: 32px 0;
}

.auth-layout {
  grid-template-columns: 1fr 420px;
}

.brand-panel,
.auth-panel,
.locked-card,
.metric,
.panel {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
}

.brand-panel,
.auth-panel,
.locked-card {
  padding: 24px;
}

.topbar,
.row-heading,
.toolbar,
.customer-card,
.directory-row,
.report-line,
.status-bar,
.top-actions,
.inline-actions,
.card-actions,
.status-control {
  display: flex;
  gap: 12px;
}

.topbar {
  align-items: center;
  justify-content: space-between;
  padding: 16px 0 18px;
}

.brand-logo {
  width: 150px;
  height: 150px;
  display: block;
  margin-bottom: 18px;
  object-fit: contain;
  border-radius: 12px;
}

.title-lockup {
  display: flex;
  align-items: center;
  gap: 12px;
}

.topbar-logo {
  width: 52px;
  height: 52px;
  flex: 0 0 auto;
  object-fit: contain;
  border-radius: 8px;
  background: #fff;
}
.row-heading,
.toolbar,
.customer-card,
.directory-row,
.report-line {
  align-items: center;
  justify-content: space-between;
}

.status-bar {
  align-items: center;
  flex-wrap: wrap;
  margin-bottom: 14px;
  color: var(--muted);
  font-size: 0.88rem;
}

.status-bar span {
  border: 1px solid var(--line);
  border-radius: 999px;
  background: #fff;
  padding: 8px 10px;
}

.online {
  color: var(--success);
}

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

.eyebrow {
  margin: 0 0 4px;
  color: var(--primary);
  font-size: 0.83rem;
  font-weight: 800;
}

h1,
h2,
p {
  margin-top: 0;
}

h1 {
  margin-bottom: 0;
  font-size: clamp(1.8rem, 3.5vw, 3.3rem);
  letter-spacing: 0;
}

h2 {
  margin-bottom: 4px;
  font-size: 1.05rem;
}

.lead {
  max-width: 680px;
  margin-top: 14px;
  color: var(--muted);
  font-size: 1.05rem;
  line-height: 1.6;
}

.feature-strip,
.auth-tabs,
.tabs,
.backup-actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.feature-strip {
  margin-top: 22px;
}

.feature-strip span {
  border-radius: 999px;
  background: var(--surface-soft);
  color: var(--primary);
  padding: 8px 10px;
  font-weight: 800;
  font-size: 0.82rem;
}

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

.content-grid {
  grid-template-columns: 0.9fr 1.4fr;
  align-items: start;
}

.metric {
  padding: 16px;
}

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

.metric strong {
  display: block;
  margin-top: 6px;
  font-size: clamp(1.25rem, 2vw, 1.9rem);
}

.metric-alert strong,
.balance {
  color: var(--danger);
}

.tabs,
.auth-tabs {
  margin: 18px 0;
  overflow-x: auto;
}

.tab,
.ghost-button,
.primary-button,
.danger-button,
.file-button,
.icon-button,
.whatsapp-button {
  min-height: 42px;
  border: 1px solid transparent;
  border-radius: 8px;
  padding: 10px 14px;
  font-weight: 800;
  text-decoration: none;
}

.small-button {
  min-height: 34px;
  padding: 6px 10px;
  font-size: 0.82rem;
}

.tab {
  background: #e9efed;
  color: var(--muted);
}

.tab.active,
.primary-button,
.link-button {
  background: var(--primary);
  color: #fff;
}

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

.danger-button {
  background: #fff4f4;
  color: var(--danger);
  border-color: #fecaca;
}

.whatsapp-button {
  display: inline-grid;
  place-items: center;
  background: #e8f7ef;
  color: var(--success);
  border-color: #bbf7d0;
  white-space: nowrap;
}

.icon-button {
  display: grid;
  width: 42px;
  place-items: center;
  background: #fff;
  border-color: var(--line);
  padding: 0;
}

.panel {
  padding: 16px;
}

.narrow-panel {
  max-width: 560px;
}

.panel-heading p,
.person-meta,
.transaction-note,
.demo-credentials,
label {
  color: var(--muted);
}

.panel-heading p {
  margin-bottom: 0;
  font-size: 0.9rem;
}

label {
  display: grid;
  gap: 6px;
  font-size: 0.88rem;
  font-weight: 800;
}

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

input:focus,
select:focus {
  outline: 3px solid rgba(15, 118, 110, 0.18);
  border-color: var(--primary);
}

.stacked-form,
.modal-card,
.customer-list,
.directory,
.report-lines,
.demo-credentials {
  display: grid;
  gap: 12px;
}

.demo-credentials {
  margin-top: 16px;
  border-top: 1px solid var(--line);
  padding-top: 14px;
  font-size: 0.86rem;
}

.segmented {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}

.segmented label {
  color: var(--ink);
}

.segmented input {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}

.segmented span {
  display: grid;
  min-height: 42px;
  place-items: center;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
}

.segmented input:checked + span {
  background: var(--surface-soft);
  border-color: var(--primary);
  color: var(--primary);
}

.toolbar {
  align-items: end;
  margin-bottom: 14px;
}

.compact-toolbar {
  justify-content: flex-start;
  margin-top: 14px;
}

.search-box {
  flex: 1;
}

.customer-card,
.directory-row,
.report-line {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 12px;
  background: #fff;
}

.customer-card {
  text-align: left;
}

.customer-card button {
  all: unset;
  cursor: pointer;
  display: block;
  width: 100%;
}

.person-name {
  display: block;
  color: var(--ink);
  font-weight: 900;
}

.person-meta,
.transaction-note {
  display: block;
  font-size: 0.84rem;
}

.card-actions,
.status-control {
  align-items: center;
  flex-wrap: wrap;
}

.balance {
  white-space: nowrap;
  font-weight: 900;
}

.ledger-panel {
  margin-top: 14px;
}

.table-wrap {
  margin-top: 12px;
  overflow-x: auto;
}

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

th,
td {
  border-bottom: 1px solid var(--line);
  padding: 11px 8px;
  text-align: left;
  vertical-align: top;
}

th {
  color: var(--muted);
  font-size: 0.8rem;
}

.type-credit {
  color: var(--danger);
  font-weight: 900;
}

.type-payment {
  color: var(--success);
  font-weight: 900;
}

.empty-state,
.notice-preview {
  display: grid;
  gap: 6px;
  padding: 18px;
  border: 1px dashed var(--line);
  border-radius: 8px;
  color: var(--muted);
  background: #fff;
}

.empty-state {
  text-align: center;
}

.notice-preview strong {
  color: var(--danger);
}

.status-pill {
  display: inline-grid;
  min-width: 132px;
  place-items: center;
  border-radius: 999px;
  padding: 8px 10px;
  font-size: 0.82rem;
  font-weight: 900;
}

.status-active {
  color: var(--success);
  background: #e8f7ef;
}

.status-payment_pending {
  color: #a16207;
  background: #fef3c7;
}

.status-deactivated {
  color: var(--danger);
  background: #fee2e2;
}

dialog {
  width: min(460px, calc(100% - 28px));
  border: 0;
  border-radius: 8px;
  padding: 0;
  box-shadow: 0 24px 70px rgba(23, 33, 31, 0.28);
}

dialog::backdrop {
  background: rgba(23, 33, 31, 0.45);
}

.modal-card {
  padding: 18px;
}

.file-button {
  display: grid;
  place-items: center;
  background: #fff;
  border: 1px solid var(--line);
  color: var(--primary);
}

.file-button input {
  display: none;
}

@media (max-width: 840px) {
  .auth-layout,
  .summary-grid,
  .content-grid {
    grid-template-columns: 1fr;
  }

  .app-shell {
    width: min(100% - 18px, 620px);
    padding-top: 8px;
  }

  .toolbar,
  .row-heading,
  .customer-card,
  .directory-row,
  .report-line,
  .topbar {
    align-items: stretch;
    flex-direction: column;
  }

  .title-lockup {
    align-items: center;
  }

  .tabs {

    position: sticky;
    top: 0;
    z-index: 3;
    background: var(--bg);
    padding: 8px 0;
  }

  .tab {
    flex: 1;
  }
}

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

  .toolbar,
  .tabs,
  .stacked-form,
  .ghost-button,
  .primary-button,
  .danger-button,
  .file-button,
  .whatsapp-button,
  .status-bar {
    display: none !important;
  }

  .app-shell {
    width: 100%;
  }

  .metric,
  .panel {
    box-shadow: none;
  }
}
