:root {
  --ink: #13262b;
  --muted: #5d737a;
  --line: #d5e3e7;
  --paper: #f5faf9;
  --card: rgba(255, 255, 255, 0.9);
  --teal: #0f766e;
  --teal-deep: #0b5f59;
  --teal-soft: #d8f3ef;
  --bronze: #9a6b3f;
  --danger: #b42318;
  --shadow: 0 18px 40px rgba(15, 55, 58, 0.08);
  --radius: 18px;
}

* { box-sizing: border-box; }

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

.page-bg {
  position: fixed;
  inset: 0;
  z-index: -1;
  background:
    radial-gradient(1000px 480px at 8% -10%, #c8efe8 0%, transparent 55%),
    radial-gradient(900px 500px at 100% 0%, #efe2d2 0%, transparent 50%),
    linear-gradient(180deg, #f8fcfb 0%, #eef6f5 100%);
}

.topbar {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: center;
  padding: 16px 22px;
  background: rgba(255, 255, 255, 0.78);
  backdrop-filter: blur(14px);
  border-bottom: 1px solid rgba(213, 227, 231, 0.9);
  position: sticky;
  top: 0;
  z-index: 20;
}

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

.brand-mark {
  width: 42px;
  height: 42px;
  border-radius: 14px;
  display: grid;
  place-items: center;
  font-family: Fraunces, Georgia, serif;
  font-weight: 700;
  color: #fff;
  background: linear-gradient(145deg, #12857c, #0b5f59);
  box-shadow: 0 10px 20px rgba(15, 118, 110, 0.28);
}

.brand h1 {
  margin: 0;
  font-family: Fraunces, Georgia, serif;
  font-size: 1.35rem;
  letter-spacing: -0.02em;
}

.brand p,
.topbar p {
  margin: 2px 0 0;
  color: var(--muted);
  font-size: 0.88rem;
}

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

.container {
  max-width: 1120px;
  margin: 22px auto;
  padding: 0 16px 48px;
}

.card {
  background: var(--card);
  border: 1px solid rgba(213, 227, 231, 0.95);
  border-radius: var(--radius);
  padding: 20px;
  margin-bottom: 16px;
  box-shadow: var(--shadow);
  backdrop-filter: blur(8px);
}

.auth-card,
.hero-strip {
  background:
    linear-gradient(135deg, rgba(255, 255, 255, 0.92), rgba(232, 247, 244, 0.88));
}

.eyebrow {
  margin: 0 0 6px;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  font-size: 0.72rem;
  font-weight: 700;
  color: var(--teal);
}

h2 {
  margin: 0 0 8px;
  font-family: Fraunces, Georgia, serif;
  font-size: 1.55rem;
  letter-spacing: -0.02em;
}

.muted { color: var(--muted); margin: 0; }
.panel-note { margin: 0 0 12px; font-size: 13px; }

.action-loader {
  position: fixed;
  inset: 0;
  z-index: 120;
  display: grid;
  place-items: center;
  padding: 16px;
  background: rgba(12, 28, 32, 0.55);
  backdrop-filter: blur(4px);
}

.action-loader-card {
  min-width: min(320px, 100%);
  padding: 28px 24px;
  border-radius: 16px;
  background: #fff;
  border: 1px solid #d8e6ea;
  text-align: center;
  box-shadow: 0 18px 40px rgba(12, 28, 32, 0.18);
}

.action-loader-card p {
  margin: 14px 0 0;
  font-weight: 600;
  color: var(--ink);
}

.btn:disabled,
.btn[aria-busy="true"] {
  opacity: 0.65;
  cursor: wait;
}

.stats {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: 12px;
  margin-bottom: 14px;
}

.stat-card {
  background: rgba(255, 255, 255, 0.88);
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 16px;
  box-shadow: 0 10px 24px rgba(19, 50, 56, 0.05);
}

.stat-card.accent {
  background: linear-gradient(160deg, #e8f8f5, #dff3ef);
  border-color: #b9e4dd;
}

.stat-card h3 {
  margin: 0;
  font-size: 0.88rem;
  color: var(--muted);
  font-weight: 600;
}

.stat-card p {
  margin: 8px 0 0;
  font-size: 1.7rem;
  font-weight: 700;
  letter-spacing: -0.03em;
}

.ops-head {
  margin-bottom: 14px;
}

.btn {
  border: 0;
  border-radius: 12px;
  padding: 10px 14px;
  cursor: pointer;
  background: linear-gradient(160deg, #149287, var(--teal-deep));
  color: #fff;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  font-weight: 600;
  font-size: 0.92rem;
  transition: transform 0.15s ease, box-shadow 0.15s ease, opacity 0.15s ease;
  box-shadow: 0 8px 18px rgba(15, 118, 110, 0.22);
}

.btn:hover { transform: translateY(-1px); }
.btn:disabled { opacity: 0.55; cursor: not-allowed; transform: none; }
.btn.secondary { background: #186f84; box-shadow: 0 8px 18px rgba(21, 94, 117, 0.2); }
.btn.danger { background: linear-gradient(160deg, #d6453d, var(--danger)); box-shadow: 0 8px 18px rgba(180, 35, 24, 0.2); }
.btn.ghost { background: #334155; box-shadow: none; }
.btn.soft {
  background: #fff;
  color: var(--teal-deep);
  border: 1px solid #b7ddd7;
  box-shadow: none;
}
.btn.tiny {
  padding: 7px 10px;
  font-size: 0.8rem;
  border-radius: 10px;
  box-shadow: none;
}

input, select {
  width: 100%;
  border: 1px solid #c7d7dc;
  border-radius: 12px;
  padding: 11px 12px;
  font-size: 0.95rem;
  background: #fff;
  color: var(--ink);
  outline: none;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

input:focus, select:focus {
  border-color: #72bdb4;
  box-shadow: 0 0 0 4px rgba(15, 118, 110, 0.12);
}

label {
  display: grid;
  gap: 6px;
  font-size: 0.9rem;
  color: #39545c;
  font-weight: 500;
}

.grid-2, .grid-3, .panel-form {
  display: grid;
  gap: 10px;
  align-items: end;
}

.grid-2 { grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); }
.grid-3, .panel-form { grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); }

.tabs {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  margin-bottom: 16px;
}

.tab {
  border: 1px solid #c9dbdf;
  border-radius: 999px;
  padding: 8px 14px;
  background: #fff;
  cursor: pointer;
  color: #35545c;
  font-weight: 600;
}

.tab.active {
  background: var(--teal);
  color: #fff;
  border-color: var(--teal);
}

.tab-panel { display: none; }
.tab-panel.active { display: block; }

.filter-row {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  margin: 14px 0 8px;
}

.chip {
  border: 1px solid #c9dbdf;
  background: #fff;
  color: #3b555d;
  border-radius: 999px;
  padding: 6px 12px;
  font-size: 0.82rem;
  font-weight: 600;
  cursor: pointer;
}

.chip.active {
  background: var(--teal-soft);
  border-color: #9fd5cd;
  color: var(--teal-deep);
}

.list {
  margin: 12px 0 0;
  padding: 0;
  list-style: none;
  display: grid;
  gap: 10px;
}

.list li {
  background: rgba(255, 255, 255, 0.86);
  border: 1px solid #deeaee;
  border-radius: 14px;
  padding: 14px;
}

.row-main {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: flex-start;
  flex-wrap: wrap;
}

.row-title {
  margin: 0;
  font-weight: 700;
  font-size: 1rem;
}

.row-meta {
  margin: 4px 0 0;
  color: var(--muted);
  font-size: 0.88rem;
}

.badge {
  display: inline-flex;
  align-items: center;
  border-radius: 999px;
  padding: 4px 10px;
  font-size: 0.75rem;
  font-weight: 700;
  letter-spacing: 0.02em;
}

.badge.pending { background: #fff4e5; color: #9a5b00; }
.badge.paid { background: #e5f8ef; color: #0f6b45; }
.badge.partial { background: #e8f1ff; color: #1d4f91; }
.badge.deleted { background: #fdeceb; color: #9b1c1c; }

.actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  margin-top: 12px;
}

.status {
  color: #35545c;
  font-size: 0.92rem;
  padding: 10px 14px;
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.7);
  border: 1px solid #d8e6ea;
}

.hidden { display: none !important; }

/* Session gate: never leave the boot card visible after auth resolves */
body.session-ready #bootLoader,
body.session-login #bootLoader,
#bootLoader[hidden] {
  display: none !important;
}

body.session-loading #authCard,
body.session-loading #ownerPanel,
body.session-ready #authCard,
body.session-login #ownerPanel {
  display: none !important;
}

.boot-loader {
  text-align: center;
  padding: 48px 28px;
  max-width: 460px;
  margin: 48px auto 0;
}

.boot-loader h2 {
  margin: 18px 0 8px;
  font-family: Fraunces, Georgia, serif;
  font-size: 1.45rem;
}

.boot-loader .muted {
  margin: 0;
}

.spinner {
  width: 42px;
  height: 42px;
  margin: 0 auto;
  border-radius: 50%;
  border: 3px solid #cfe7e3;
  border-top-color: var(--teal);
  animation: spin 0.8s linear infinite;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

.footer {
  padding: 18px;
  text-align: center;
  border-top: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.75);
}

.footer a {
  margin: 0 10px;
  color: var(--teal);
  text-decoration: none;
  font-weight: 600;
}

.modal {
  position: fixed;
  inset: 0;
  z-index: 50;
  display: grid;
  place-items: center;
  padding: 16px;
  background: rgba(12, 28, 32, 0.45);
  backdrop-filter: blur(6px);
}

.modal-card {
  width: min(680px, 100%);
  position: relative;
  max-height: min(88vh, 820px);
  overflow: auto;
  background: #fff;
  border-radius: 20px;
  border: 1px solid #d7e5e9;
  box-shadow: 0 24px 60px rgba(10, 35, 40, 0.28);
  padding: 18px;
}

.modal-busy {
  position: absolute;
  inset: 0;
  z-index: 3;
  display: grid;
  place-items: center;
  padding: 20px;
  border-radius: 20px;
  background: rgba(255, 255, 255, 0.92);
  text-align: center;
}

.modal-busy p {
  margin: 12px 0 0;
  font-weight: 600;
}

.modal-head {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: flex-start;
  margin-bottom: 14px;
}

.payment-summary {
  display: flex;
  flex-wrap: wrap;
  gap: 14px;
  margin: 14px 0 8px;
  padding: 12px;
  border-radius: 12px;
  background: #f3faf8;
  border: 1px solid #d5ebe6;
  color: #35545c;
  font-size: 0.9rem;
}

.section-title {
  margin: 18px 0 10px;
  font-size: 1rem;
  color: #35545c;
}

.modal-wide {
  width: min(820px, 100%);
}

.card-lite {
  margin: 14px 0;
  padding: 14px 16px;
  border-radius: 14px;
  background: #f6fbfa;
  border: 1px solid #d8e6ea;
}

.worker-section {
  margin: 14px 0;
}

.worker-money-tabs {
  margin: 0 0 14px;
}

.worker-tab-panel {
  display: none;
}

.worker-tab-panel.active {
  display: block;
}

.worker-slip .btn {
  margin-top: 12px;
}

.checkbox-row {
  display: flex;
  align-items: center;
  gap: 8px;
  grid-column: 1 / -1;
  font-size: 0.9rem;
  color: #35545c;
}

.checkbox-row input {
  width: auto;
}

.worker-cash-summary {
  margin-top: 8px;
}

.settle-actions {
  margin-top: 0;
  align-items: end;
}

.ledger-amount.positive { color: #0f6b45; font-weight: 700; }
.ledger-amount.negative { color: #b42318; font-weight: 700; }
#workerCashOutstanding.negative { color: #b42318; }

.list.compact li {
  padding: 10px 12px;
}

.history-row {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  flex-wrap: wrap;
  align-items: center;
}

@media (max-width: 720px) {
  .topbar { align-items: flex-start; flex-direction: column; }
  .brand h1 { font-size: 1.2rem; }
  h2 { font-size: 1.3rem; }
}
