:root {
  color-scheme: light;
  --bg: #f6f7f4;
  --surface: #ffffff;
  --ink: #1d2528;
  --muted: #677175;
  --line: #dfe5e1;
  --brand: #176b5b;
  --brand-dark: #0e4d41;
  --accent: #c47d22;
  --danger: #a33b35;
  --shadow: 0 18px 45px rgba(27, 42, 38, 0.08);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  font-family: Arial, Helvetica, sans-serif;
  background: var(--bg);
  color: var(--ink);
}

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

.auth-screen {
  position: fixed;
  inset: 0;
  z-index: 20;
  display: grid;
  place-items: center;
  padding: 24px;
  background: rgba(246, 247, 244, 0.96);
}

.auth-screen[hidden] {
  display: none;
}

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

.auth-card {
  width: min(420px, 100%);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 24px;
  background: var(--surface);
  box-shadow: 0 24px 80px rgba(20, 31, 29, 0.16);
}

.auth-logo {
  width: 76px;
  height: 76px;
  margin-bottom: 12px;
}

.auth-help {
  color: var(--muted);
}

.auth-error {
  margin: 12px 0 0;
  color: var(--danger);
  font-weight: 800;
}

.link-button {
  width: 100%;
  min-height: 38px;
  margin-top: 10px;
  border: 0;
  background: transparent;
  color: var(--brand);
  cursor: pointer;
  font-weight: 800;
}

.app-locked {
  display: none;
}

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

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

.brand-lockup {
  display: flex;
  align-items: center;
  gap: 14px;
}

.brand-logo {
  width: 68px;
  height: 68px;
  flex: 0 0 auto;
}

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

.language-select {
  width: auto;
  min-width: 120px;
  min-height: 38px;
}

.sync-status {
  display: inline-flex;
  align-items: center;
  min-height: 34px;
  border-radius: 999px;
  padding: 0 12px;
  background: rgba(23, 107, 91, 0.1);
  color: var(--brand-dark);
  font-size: 13px;
  font-weight: 900;
}

.sync-status[data-status="syncing"] {
  background: rgba(196, 125, 34, 0.15);
  color: #7b4b11;
}

.sync-status[data-status="offline"],
.sync-status[data-status="localOnly"] {
  background: rgba(163, 59, 53, 0.12);
  color: var(--danger);
}

.eyebrow {
  margin: 0 0 6px;
  color: var(--brand);
  font-size: 13px;
  font-weight: 700;
  text-transform: uppercase;
}

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

h1 {
  margin-bottom: 0;
  font-size: clamp(30px, 5vw, 46px);
  letter-spacing: 0;
}

h2 {
  margin-bottom: 18px;
  font-size: 20px;
}

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

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

.metric {
  min-height: 110px;
  padding: 18px;
}

.metric span {
  display: block;
  margin-bottom: 12px;
  color: var(--muted);
  font-size: 14px;
}

.metric strong {
  display: block;
  font-size: 28px;
}

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

.admin-dashboard {
  margin-bottom: 18px;
  padding: 20px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  box-shadow: var(--shadow);
}

.dashboard-header,
.dashboard-split {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 18px;
}

.dashboard-header {
  margin-bottom: 16px;
}

.dashboard-header h2,
.dashboard-split h3 {
  margin-bottom: 0;
}

.dashboard-date {
  color: var(--muted);
  font-size: 14px;
  font-weight: 700;
  text-align: right;
}

.dashboard-grid {
  display: grid;
  grid-template-columns: repeat(6, minmax(0, 1fr));
  gap: 10px;
  margin-bottom: 18px;
}

.dashboard-card {
  min-height: 92px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 14px;
  background: #fbfcfa;
}

.dashboard-card span {
  display: block;
  margin-bottom: 10px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 800;
}

.dashboard-card strong {
  display: block;
  font-size: 20px;
}

.dashboard-card.warning strong {
  color: var(--danger);
}

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

.dashboard-split section {
  flex: 1;
  min-width: 0;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 14px;
}

.dashboard-split h3 {
  font-size: 16px;
  margin-bottom: 12px;
}

.mini-list {
  display: grid;
  gap: 9px;
}

.mini-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  border-bottom: 1px solid var(--line);
  padding-bottom: 9px;
}

.mini-item:last-child {
  border-bottom: 0;
  padding-bottom: 0;
}

.mini-item span {
  display: block;
  margin-top: 3px;
  color: var(--muted);
  font-size: 13px;
}

.rules-panel,
.business-panel {
  margin-bottom: 18px;
}

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

.rules-header h2 {
  margin-bottom: 0;
}

.rules-text {
  min-height: 190px;
  resize: vertical;
  line-height: 1.5;
}

.client-lookup-panel {
  margin-bottom: 18px;
}

.lookup-form {
  display: grid;
  grid-template-columns: 1fr auto;
  align-items: end;
  gap: 12px;
  margin-bottom: 14px;
}

.lookup-result {
  color: var(--muted);
}

.lookup-actions,
.detail-actions {
  margin-top: 12px;
  margin-bottom: 12px;
}

.lookup-card {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
}

.lookup-card div {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 12px;
  background: #fbfcfa;
}

.lookup-card span {
  display: block;
  margin-bottom: 6px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 800;
}

.lookup-card strong {
  color: var(--ink);
}

.workspace {
  display: grid;
  grid-template-columns: 1.5fr 1fr;
  gap: 18px;
  margin-bottom: 18px;
}

.single-panel {
  grid-template-columns: 1fr;
}

.panel {
  padding: 20px;
}

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

label {
  display: grid;
  gap: 7px;
  color: var(--muted);
  font-size: 14px;
  font-weight: 700;
}

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

input:focus,
select:focus,
textarea:focus {
  outline: 3px solid rgba(23, 107, 91, 0.18);
  border-color: var(--brand);
}

.primary-button,
.ghost-button {
  min-height: 44px;
  border-radius: 7px;
  border: 0;
  padding: 0 16px;
  cursor: pointer;
  font-weight: 800;
}

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

.primary-button:hover {
  background: var(--brand-dark);
}

.ghost-button {
  background: transparent;
  color: var(--danger);
  border: 1px solid rgba(163, 59, 53, 0.35);
}

.quick-pay-button {
  min-height: 34px;
  border: 1px solid rgba(23, 107, 91, 0.25);
  border-radius: 7px;
  padding: 0 10px;
  background: rgba(23, 107, 91, 0.1);
  color: var(--brand-dark);
  cursor: pointer;
  font-size: 13px;
  font-weight: 800;
  white-space: nowrap;
}

.quick-pay-button:hover {
  background: rgba(23, 107, 91, 0.18);
}

.payment-form {
  display: grid;
  gap: 14px;
}

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

.list-header h2 {
  margin-bottom: 0;
}

.list-header input {
  max-width: 320px;
}

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

.list-tools input,
.list-tools select {
  min-height: 38px;
}

.tool-button,
.danger-button,
.icon-button {
  min-height: 34px;
  border-radius: 7px;
  padding: 0 10px;
  cursor: pointer;
  font-size: 13px;
  font-weight: 800;
}

.tool-button {
  border: 1px solid var(--line);
  background: #fff;
  color: var(--ink);
}

.tool-button:hover {
  border-color: rgba(23, 107, 91, 0.45);
  color: var(--brand-dark);
}

.danger-button {
  border: 1px solid rgba(163, 59, 53, 0.25);
  background: rgba(163, 59, 53, 0.08);
  color: var(--danger);
}

.icon-button {
  width: 38px;
  border: 1px solid var(--line);
  background: #fff;
  color: var(--ink);
  font-size: 24px;
  line-height: 1;
}

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

.table-wrap {
  overflow-x: auto;
}

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

.deposit-table {
  min-width: 1080px;
}

th,
td {
  padding: 13px 10px;
  border-bottom: 1px solid var(--line);
  text-align: left;
  font-size: 14px;
  vertical-align: top;
}

th {
  color: var(--muted);
  font-size: 12px;
  text-transform: uppercase;
}

.status {
  display: inline-flex;
  align-items: center;
  min-height: 28px;
  border-radius: 999px;
  padding: 0 10px;
  font-size: 12px;
  font-weight: 800;
}

.status.paid {
  background: rgba(23, 107, 91, 0.12);
  color: var(--brand-dark);
}

.status.open {
  background: rgba(196, 125, 34, 0.14);
  color: #7b4b11;
}

.status.late {
  background: rgba(163, 59, 53, 0.13);
  color: var(--danger);
}

.empty-state {
  margin: 18px 0 0;
  color: var(--muted);
}

.empty-row {
  color: var(--muted);
  text-align: center;
}

.detail-dialog {
  width: min(720px, calc(100% - 28px));
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 0;
  color: var(--ink);
  box-shadow: 0 24px 80px rgba(20, 31, 29, 0.22);
}

.detail-dialog::backdrop {
  background: rgba(29, 37, 40, 0.38);
}

.dialog-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 20px;
  border-bottom: 1px solid var(--line);
}

.dialog-header h2 {
  margin-bottom: 0;
}

#dialogBody {
  padding: 20px;
}

.detail-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 10px;
  margin-bottom: 20px;
}

.detail-grid div {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 12px;
}

.detail-grid span,
.payment-item span,
.receipt-top span {
  display: block;
  color: var(--muted);
  font-size: 13px;
}

.receipt-top small {
  display: block;
  margin-top: 3px;
  color: var(--muted);
  font-size: 12px;
}

.detail-grid strong {
  display: block;
  margin-top: 6px;
}

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

.payment-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 12px;
}

.receipt-card {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 18px;
  background: #fff;
}

.receipt-top {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 18px;
}

.receipt-top img {
  width: 54px;
  height: 54px;
}

.receipt-card dl {
  display: grid;
  gap: 10px;
  margin: 0;
}

.receipt-card dl div {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  border-bottom: 1px solid var(--line);
  padding-bottom: 8px;
}

.receipt-card dt {
  color: var(--muted);
  font-weight: 700;
}

.receipt-card dd {
  margin: 0;
  text-align: right;
  font-weight: 800;
}

.print-button {
  width: 100%;
}

@media print {
  body * {
    visibility: hidden;
  }

  .detail-dialog,
  .detail-dialog * {
    visibility: visible;
  }

  .detail-dialog {
    position: fixed;
    inset: 0;
    width: 100%;
    box-shadow: none;
    border: 0;
  }

  .dialog-header,
  .print-button {
    display: none;
  }
}

@media (max-width: 880px) {
  .summary-grid,
  .workspace,
  .form-grid,
  .lookup-form,
  .lookup-card,
  .detail-grid,
  .dashboard-grid {
    grid-template-columns: 1fr;
  }

  .topbar,
  .list-header,
  .rules-header,
  .dashboard-header,
  .dashboard-split,
  .mini-item {
    align-items: stretch;
    flex-direction: column;
  }

  .list-header input {
    max-width: none;
  }

  .list-tools {
    align-items: stretch;
    flex-direction: column;
  }

  .payment-item {
    align-items: stretch;
    flex-direction: column;
  }
}

@media (min-width: 881px) and (max-width: 1180px) {
  .summary-grid,
  .dashboard-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}
