:root {
  --bg: #f4efe7;
  --bg-soft: #fbf8f3;
  --paper: #ffffff;
  --paper-2: #f9f5ee;
  --line: #ded4c6;
  --ink: #201a14;
  --muted: #75685b;
  --primary: #166534;
  --primary-strong: #14532d;
  --primary-soft: #e2f5e8;
  --warning: #c16b1f;
  --warning-soft: #fff0df;
  --info: #2b7fff;
  --info-soft: #e8f1ff;
  --danger: #b9422a;
  --danger-soft: #fee9e4;
  --shadow: 0 18px 38px rgba(58, 41, 24, 0.08);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: "Trebuchet MS", "Segoe UI", Tahoma, sans-serif;
  color: var(--ink);
  background:
    radial-gradient(circle at top left, rgba(22, 101, 52, 0.08), transparent 24%),
    radial-gradient(circle at right top, rgba(193, 107, 31, 0.08), transparent 20%),
    linear-gradient(180deg, #f7f2ea 0%, #f1ebe2 100%);
}

.shell {
  width: min(1240px, calc(100% - 28px));
  margin: 0 auto;
  padding: 28px 0 52px;
}

.topbar,
.userbar,
.grid,
.hero,
.hero-actions,
.hero-balance,
.timeline-main,
.timeline-title-row,
.timeline-actions,
.section-head,
.toggle,
.day-row,
.inline-actions,
.quick-day-actions,
.modal-title-row,
.modal-footer-tools,
.client-card-head {
  display: flex;
}

.topbar,
.hero,
.timeline-main,
.section-head,
.modal-title-row,
.client-card-head {
  justify-content: space-between;
}

.topbar,
.userbar,
.hero,
.hero-actions,
.hero-balance,
.timeline-main,
.timeline-title-row,
.timeline-actions,
.section-head,
.toggle,
.day-row,
.inline-actions,
.quick-day-actions,
.modal-title-row,
.modal-footer-tools,
.client-card-head {
  align-items: center;
}

.topbar {
  margin-bottom: 20px;
}

.userbar {
  gap: 12px;
}

.eyebrow,
.muted,
.day-col span,
.timeline-card p,
.timeline-card small,
.field-hint,
.glance-chip span,
.glance-chip small,
.small-note,
.stat-chip span {
  color: var(--muted);
}

.eyebrow {
  text-transform: uppercase;
  letter-spacing: 0.08em;
  font-size: 0.76rem;
  margin: 0 0 6px;
  font-weight: 700;
}

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

h1,
h2,
h3 {
  color: var(--ink);
}

h1 {
  font-size: clamp(2rem, 3vw, 2.7rem);
}

h2 {
  font-size: clamp(1.55rem, 2vw, 2rem);
  margin-bottom: 0.25rem;
}

h3 {
  font-size: 1.18rem;
  margin-bottom: 0;
}

main {
  display: grid;
  gap: 18px;
}

.card,
.timeline-card,
.day-list,
.hero {
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: 24px;
  box-shadow: var(--shadow);
}

.card,
.hero {
  padding: 22px;
}

.narrow {
  max-width: 460px;
  margin: 40px auto 0;
}

.hero {
  gap: 20px;
}

.dark-hero,
.workspace-hero {
  background:
    linear-gradient(135deg, rgba(22, 101, 52, 0.08), rgba(255, 255, 255, 0.9)),
    var(--paper);
}

.hero-balance {
  min-width: 220px;
  padding: 18px 20px;
  border-radius: 20px;
  background: var(--paper-2);
  border: 1px solid var(--line);
  flex-direction: column;
  align-items: flex-start;
  gap: 8px;
}

.hero-balance strong {
  font-size: 2rem;
  line-height: 1;
}

.compact-balance,
.mini-balance {
  min-width: 180px;
  padding: 14px 16px;
}

.hero-actions {
  gap: 10px;
  flex-wrap: wrap;
}

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

.admin-summary {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

.stat-chip {
  padding: 18px 20px;
  border-radius: 20px;
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.78);
  box-shadow: var(--shadow);
}

.stat-chip strong {
  display: block;
  margin-top: 6px;
  font-size: 1.8rem;
  color: var(--ink);
}

.workspace-card,
.secondary-zone {
  padding: 24px;
}

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

.section-card {
  display: block;
  padding: 22px;
  border-radius: 24px;
  border: 1px solid var(--line);
  background: var(--paper);
  box-shadow: var(--shadow);
  text-decoration: none;
  color: inherit;
}

.section-card strong {
  display: block;
  margin-top: 12px;
  font-size: 1.4rem;
}

.active-section-card {
  background:
    linear-gradient(180deg, rgba(22, 101, 52, 0.08), rgba(255, 255, 255, 0.98)),
    var(--paper);
}

.toolbar-strip {
  padding: 6px 2px 0;
}

.client-board {
  display: grid;
  gap: 14px;
}

.client-card {
  padding: 20px;
  border: 1px solid var(--line);
  border-radius: 22px;
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.98), rgba(247, 242, 234, 0.98));
}

.client-card-main {
  display: grid;
  gap: 16px;
}

.client-card-head {
  gap: 16px;
  align-items: flex-start;
}

.client-balance {
  min-width: 180px;
  padding: 12px 14px;
  border: 1px solid var(--line);
  border-radius: 18px;
  background: var(--paper-2);
}

.client-balance span,
.client-balance strong {
  display: block;
}

.client-glance {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
}

.glance-chip {
  padding: 14px 15px;
  border-radius: 18px;
  border: 1px solid var(--line);
  background: #fffdf9;
}

.glance-chip strong,
.glance-chip span,
.glance-chip small {
  display: block;
}

.glance-chip strong {
  margin: 4px 0;
  color: var(--ink);
  font-size: 1.08rem;
}

.quick-day-actions {
  gap: 10px;
  flex-wrap: wrap;
}

.small-note {
  font-size: 0.95rem;
  font-weight: 600;
}

.grid {
  gap: 18px;
  flex-wrap: wrap;
}

.detail-layout > *,
.quick-actions > *,
.ledger-layout > * {
  flex: 1 1 390px;
}

.stack {
  display: grid;
  gap: 14px;
}

.stack.compact {
  gap: 10px;
}

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

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

input,
select,
button {
  font: inherit;
}

input,
select {
  width: 100%;
  padding: 13px 14px;
  border-radius: 16px;
  border: 1px solid #cfc1b0;
  background: #fffdfa;
  color: var(--ink);
}

input:focus,
select:focus {
  outline: 2px solid rgba(43, 127, 255, 0.16);
  border-color: var(--info);
}

.toggle-panel {
  display: grid;
  gap: 10px;
}

.toggle {
  gap: 10px;
  padding: 12px 14px;
  border-radius: 16px;
  background: var(--paper-2);
  border: 1px solid var(--line);
}

.toggle input {
  width: auto;
  margin: 0;
}

.nested-space {
  margin-top: 10px;
}

.button {
  border: 0;
  border-radius: 16px;
  padding: 11px 16px;
  cursor: pointer;
  transition: transform 0.15s ease, box-shadow 0.15s ease, background 0.15s ease;
  font-weight: 700;
}

.button:hover {
  transform: translateY(-1px);
  box-shadow: 0 10px 18px rgba(32, 26, 20, 0.1);
}

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

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

.button.success {
  background: #1f9d55;
  color: #fff;
}

.button.success:hover {
  background: #18804a;
}

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

.button.ghost.danger {
  background: var(--danger-soft);
  color: var(--danger);
  border-color: #efc4b8;
}

.button.small {
  padding: 9px 12px;
  border-radius: 14px;
  font-size: 0.92rem;
}

.wide {
  width: 100%;
}

.button-link {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  text-decoration: none;
}

.flash-stack {
  display: grid;
  gap: 10px;
}

.flash {
  padding: 14px 16px;
  border-radius: 16px;
  border: 1px solid transparent;
}

.flash.success {
  background: var(--primary-soft);
  color: var(--primary-strong);
  border-color: #bfe0c8;
}

.flash.error {
  background: var(--danger-soft);
  color: var(--danger);
  border-color: #f0c6ba;
}

.day-list {
  display: grid;
  gap: 10px;
  padding: 10px;
  background: var(--bg-soft);
}

.day-row {
  display: grid;
  grid-template-columns: 110px 130px 1fr 150px 210px;
  gap: 14px;
  align-items: center;
  padding: 16px;
  border-radius: 18px;
  background: var(--paper);
  border: 1px solid var(--line);
}

.day-col {
  min-width: 0;
}

.day-col strong,
.day-col span {
  display: block;
}

.day-col.date strong {
  font-size: 1.5rem;
  color: var(--ink);
}

.day-col.actions {
  display: grid;
  gap: 8px;
}

.positive {
  color: var(--primary);
}

.negative {
  color: var(--warning);
}

.badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 110px;
  padding: 8px 12px;
  border-radius: 999px;
  font-size: 0.82rem;
  font-weight: 800;
  text-transform: uppercase;
}

.badge.ok {
  background: var(--primary-soft);
  color: var(--primary-strong);
}

.badge.warn {
  background: var(--warning-soft);
  color: #9a5519;
}

.badge.soft {
  background: var(--info-soft);
  color: #215db4;
}

.timeline-card {
  padding: 16px 18px;
}

.timeline-list {
  display: grid;
  gap: 12px;
}

.timeline-main {
  gap: 16px;
}

.timeline-side {
  text-align: right;
  min-width: 110px;
}

.timeline-side strong,
.timeline-side small {
  display: block;
}

.timeline-actions {
  gap: 10px;
  flex-wrap: wrap;
  margin-top: 14px;
  padding-top: 14px;
  border-top: 1px solid var(--line);
}

.week-list {
  display: grid;
  gap: 10px;
  margin: 14px 0 16px;
}

.receivable-board {
  display: grid;
  gap: 16px;
}

.receivable-card {
  padding: 18px;
  border: 1px solid var(--line);
  border-radius: 22px;
  background: var(--bg-soft);
}

.receivable-card-head,
.receivable-inline-actions {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.receivable-inline-actions {
  margin: 14px 0 16px;
  flex-wrap: wrap;
}

.week-head {
  display: grid;
  grid-template-columns: 90px 120px 1fr 190px;
  gap: 12px;
  padding: 0 14px 8px;
  color: #7f8794;
  font-size: 0.8rem;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.week-row {
  display: grid;
  grid-template-columns: 90px 120px 1fr 190px;
  gap: 12px;
  align-items: center;
  padding: 14px 16px;
  border-radius: 18px;
  background: #fffdf9;
  border: 1px solid var(--line);
}

.week-row strong,
.week-row span {
  display: block;
}

.ops-row {
  background: #111317;
  border-color: #2f333a;
  border-radius: 16px;
  box-shadow: none;
}

.ops-row strong {
  color: #f3f4f6;
}

.week-actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.ops-row .button.ghost {
  background: transparent;
  color: #e5e7eb;
  border-color: #5a606b;
}

.ops-row .button.success {
  background: #2563eb;
}

.ops-row .button.success:hover {
  background: #1d4ed8;
}

.simple-details summary {
  cursor: pointer;
  list-style: none;
  font-weight: 800;
  color: var(--ink);
}

.simple-details summary::-webkit-details-marker {
  display: none;
}

.details-body {
  margin-top: 16px;
}

.top-divider {
  padding-top: 16px;
  border-top: 1px solid var(--line);
}

.top-gap {
  margin-top: 16px;
}

.modal {
  width: min(560px, calc(100% - 24px));
  border: 0;
  border-radius: 28px;
  padding: 0;
  background: transparent;
}

.modal::backdrop {
  background: rgba(31, 23, 14, 0.3);
  backdrop-filter: blur(2px);
}

.dark-modal {
  background: var(--paper);
  box-shadow: 0 26px 60px rgba(31, 23, 14, 0.18);
  border: 1px solid var(--line);
}

.ops-modal {
  background: #1c1d21;
  border-color: #353840;
  color: #f3f4f6;
}

.ops-modal h2,
.ops-modal h3,
.ops-modal label {
  color: #f9fafb;
}

.ops-modal .muted,
.ops-modal .eyebrow,
.ops-modal .field-hint,
.ops-modal .week-row span,
.ops-modal .hero-balance span,
.ops-modal .hero-balance small {
  color: #9aa3af;
}

.ops-modal::backdrop {
  background: rgba(3, 5, 10, 0.72);
}

.ops-modal .modal-body {
  padding-bottom: 22px;
}

.ops-modal .modal-close-row {
  padding: 14px 16px 0;
}

.ops-modal .close-button {
  border-color: #4b5058;
  background: transparent;
  color: #e5e7eb;
}

.ops-modal .close-button:hover {
  background: #26292f;
}

.ops-modal .hero-balance,
.ops-modal .mini-balance {
  background: #252830;
  border-color: #3d424b;
}

.ops-modal input,
.ops-modal select,
.ops-modal textarea {
  width: 100%;
  padding: 13px 14px;
  border-radius: 14px;
  border: 1px solid #4a5059;
  background: #111317;
  color: #f3f4f6;
}

.ops-modal input:focus,
.ops-modal select:focus,
.ops-modal textarea:focus {
  border-color: #4f8df5;
  outline: 2px solid rgba(79, 141, 245, 0.14);
}

.large-modal {
  width: min(940px, calc(100% - 24px));
}

.modal-body {
  padding: 0 24px 24px;
}

.modal-title-row {
  gap: 16px;
  align-items: flex-start;
  margin-bottom: 12px;
}

.modal-close-row {
  display: flex;
  justify-content: flex-end;
  padding: 16px 16px 0;
}

.close-button {
  width: 40px;
  height: 40px;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: var(--paper-2);
  color: var(--ink);
  font-size: 1.1rem;
  line-height: 1;
  cursor: pointer;
}

.modal-footer-tools {
  justify-content: flex-end;
  gap: 10px;
  flex-wrap: wrap;
  margin-top: 18px;
}

.ops-modal .modal-footer-tools {
  border-top: 1px solid #343840;
  padding-top: 16px;
}

.month-nav {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  margin: 4px 0 14px;
}

.month-pill {
  border: 1px solid #4d5460;
  border-radius: 999px;
  padding: 8px 12px;
  background: transparent;
  color: #d3d8df;
  font-weight: 700;
  cursor: pointer;
}

.month-pill.active {
  background: #2563eb;
  border-color: #2563eb;
  color: #fff;
}

.hidden-panel {
  display: none;
}

.empty-state {
  text-align: center;
  padding: 24px;
}

[data-conditional][hidden] {
  display: none !important;
}

@media (max-width: 1100px) {
  .admin-summary,
  .client-glance,
  .section-links {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .week-head,
  .day-row,
  .week-row {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 900px) {
  .summary-strip,
  .section-links {
    grid-template-columns: 1fr;
  }

  .detail-layout > *,
  .quick-actions > * {
    flex: 1 1 100%;
  }
}

@media (max-width: 720px) {
  .shell {
    width: min(100% - 18px, 1240px);
    padding-top: 16px;
  }

  .topbar,
  .userbar,
  .hero,
  .timeline-main,
  .timeline-title-row,
  .timeline-actions,
  .section-head,
  .modal-title-row,
  .client-card-head {
    align-items: flex-start;
    flex-direction: column;
  }

  .form-grid,
  .client-glance,
  .week-head,
  .day-row,
  .week-row {
    grid-template-columns: 1fr;
  }

  .hero-balance,
  .stat-chip {
    width: 100%;
  }
}
