:root {
  color-scheme: light;
  --bg: #f4f3ee;
  --surface: #ffffff;
  --ink: #17211d;
  --muted: #69756f;
  --line: #d9ddd5;
  --brand: #2f6f5e;
  --brand-dark: #1f4c41;
  --accent: #c07439;
  --danger: #b44236;
  --warning-bg: #fff3e8;
  --shadow: 0 16px 40px rgba(26, 43, 37, 0.12);
  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(180deg, #dfe9df 0, var(--bg) 320px);
  color: var(--ink);
}

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

button {
  cursor: pointer;
}

.app-shell,
.auth-shell {
  width: min(100%, 860px);
  margin: 0 auto;
  padding: max(18px, env(safe-area-inset-top)) 16px 32px;
}

.auth-shell {
  min-height: 100vh;
  display: grid;
  align-content: center;
  gap: 18px;
}

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

.auth-header {
  max-width: 620px;
}

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

.plan-card {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  box-shadow: var(--shadow);
  padding: 18px;
}

.plan-card h2 {
  margin: 12px 0 10px;
  font-size: 1.55rem;
}

.plan-card p {
  min-height: 72px;
  color: var(--muted);
}

.featured-plan {
  border-color: #e1b282;
}

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

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

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

h1 {
  margin-bottom: 0;
  font-size: clamp(2rem, 8vw, 3.4rem);
  line-height: 0.98;
}

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

.icon-button,
.primary-button,
.ghost-button,
.danger-button {
  min-height: 42px;
  border: 0;
  border-radius: 8px;
  font-weight: 750;
}

.icon-button {
  width: 44px;
  background: var(--surface);
  color: var(--brand-dark);
  box-shadow: var(--shadow);
}

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

.full-button {
  width: 100%;
}

.ghost-button,
.danger-button {
  padding: 0 12px;
  background: #edf2ed;
  color: var(--brand-dark);
}

.danger-button {
  background: #f8e7e4;
  color: var(--danger);
}

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

.stats-grid article {
  min-width: 0;
  padding: 14px 12px;
  border: 1px solid rgba(255, 255, 255, 0.7);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.78);
  box-shadow: 0 10px 28px rgba(38, 62, 54, 0.08);
}

.stats-grid span {
  display: block;
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 700;
}

.stats-grid strong {
  display: block;
  margin-top: 5px;
  font-size: clamp(1.2rem, 5vw, 1.8rem);
  line-height: 1.1;
}

.tabs {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 6px;
  padding: 5px;
  margin: 0 0 16px;
  border-radius: 8px;
  background: #d8e2d8;
  position: sticky;
  top: 0;
  z-index: 2;
}

.tab {
  min-height: 42px;
  border: 0;
  border-radius: 6px;
  background: transparent;
  color: var(--brand-dark);
  font-size: 0.88rem;
  font-weight: 800;
}

.tab.active {
  background: var(--surface);
  box-shadow: 0 8px 18px rgba(31, 76, 65, 0.12);
}

.view {
  display: none;
}

.view.active {
  display: block;
}

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

.panel {
  padding: 14px;
  margin-bottom: 18px;
}

.panel-heading,
.section-title {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.panel-heading {
  margin-bottom: 12px;
}

.form-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

.hidden {
  display: none !important;
}

.status-message {
  min-height: 22px;
  margin: 0;
  color: var(--brand-dark);
  font-weight: 750;
}

.status-message.error {
  color: var(--danger);
}

.section-title {
  margin: 18px 0 10px;
}

.section-title span {
  color: var(--muted);
  font-weight: 800;
}

label {
  display: grid;
  gap: 7px;
  margin-bottom: 12px;
  color: var(--muted);
  font-size: 0.82rem;
  font-weight: 760;
}

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

textarea {
  resize: vertical;
}

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

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

.customer-card {
  padding: 14px;
}

.card-top,
.card-actions,
.meta-row {
  display: flex;
  align-items: center;
  gap: 8px;
}

.card-top {
  justify-content: space-between;
  align-items: flex-start;
  gap: 12px;
}

.card-top h3 {
  margin: 0 0 4px;
  font-size: 1.05rem;
}

.card-top p {
  margin: 0;
  color: var(--muted);
  font-size: 0.9rem;
}

.badge {
  display: inline-flex;
  align-items: center;
  min-height: 28px;
  padding: 4px 9px;
  border-radius: 999px;
  background: #ecf4ef;
  color: var(--brand-dark);
  font-size: 0.78rem;
  font-weight: 800;
  white-space: nowrap;
}

.badge.overdue {
  background: #f8e7e4;
  color: var(--danger);
}

.badge.due {
  background: var(--warning-bg);
  color: #985b28;
}

.meta-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
  margin: 14px 0;
}

.meta-row {
  min-width: 0;
  flex-direction: column;
  align-items: flex-start;
  padding: 9px;
  border-radius: 8px;
  background: #f5f7f4;
}

.meta-row span {
  color: var(--muted);
  font-size: 0.73rem;
  font-weight: 800;
  text-transform: uppercase;
}

.meta-row strong {
  max-width: 100%;
  overflow-wrap: anywhere;
  font-size: 0.95rem;
}

.card-actions {
  flex-wrap: wrap;
}

.empty-state {
  display: grid;
  gap: 4px;
  padding: 22px;
  border: 1px dashed #bbc6bd;
  border-radius: 8px;
  color: var(--muted);
  text-align: center;
}

.empty-state strong {
  color: var(--ink);
}

@media (max-width: 540px) {
  .app-shell,
  .auth-shell {
    padding-inline: 12px;
  }

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

  .header-actions {
    width: 100%;
    justify-content: stretch;
  }

  .header-actions .ghost-button {
    flex: 1 1 90px;
  }

  .stats-grid,
  .meta-grid,
  .auth-grid,
  .plan-grid {
    grid-template-columns: 1fr;
  }

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

  .two-col {
    grid-template-columns: 1fr;
  }

  .card-actions button {
    flex: 1 1 130px;
  }
}
