:root {
  color-scheme: light;
  --bg: #f4f7f6;
  --surface: #ffffff;
  --surface-strong: #f9fbfb;
  --card-bg: #ffffff;
  --field-bg: #ffffff;
  --field-border: #cdd8d4;
  --ink: #17211f;
  --muted: #63716d;
  --line: #dfe7e4;
  --teal: #16756b;
  --teal-dark: #0d514a;
  --primary-ink: #ffffff;
  --mint: #e6f5ef;
  --gold-soft: #fff4df;
  --gold: #a96512;
  --danger: #b84b42;
  --topbar-bg: rgba(255, 255, 255, 0.92);
  --focus-ring: rgba(22, 117, 107, 0.14);
  --accent-border: #b6d6ce;
  --metric-accent-bg: linear-gradient(135deg, #ffffff 0%, #e8f6f2 100%);
  --history-bg: linear-gradient(135deg, #ffffff 0%, #f6fbfa 100%);
  --ghost-hover-border: #b9c9c4;
  --ghost-hover: #eef5f3;
  --secondary-border: #c7d4d0;
  --secondary-hover: #d9efe7;
  --empty-border: #cdd8d4;
  --settings-backdrop: rgba(18, 29, 27, 0.38);
  --toast-bg: #17211f;
  --toast-ink: #ffffff;
  --paid-action-bg: #0d665d;
  --paid-action-hover: #095149;
  --paid-action-ink: #ffffff;
  --paid-done-bg: #e6f5ef;
  --paid-done-hover: #d9efe7;
  --paid-done-ink: #0d514a;
  --shadow: 0 18px 45px rgba(25, 38, 35, 0.08);
  --radius: 8px;
  --content-max: 1180px;
  --page-gutter: clamp(22px, 3vw, 34px);
  --font: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

:root[data-theme="dark"] {
  color-scheme: dark;
  --bg: #0f1514;
  --surface: #17211f;
  --surface-strong: #111a18;
  --card-bg: #192521;
  --field-bg: #101816;
  --field-border: #344742;
  --ink: #edf6f3;
  --muted: #a7bab4;
  --line: #2d3d39;
  --teal: #36c6b3;
  --teal-dark: #8ff0df;
  --primary-ink: #071211;
  --mint: #173d37;
  --gold-soft: #3a2a15;
  --gold: #f2bc69;
  --danger: #ff8a80;
  --topbar-bg: rgba(18, 27, 25, 0.92);
  --focus-ring: rgba(54, 198, 179, 0.22);
  --accent-border: #2d675e;
  --metric-accent-bg: linear-gradient(135deg, #192521 0%, #14332f 100%);
  --history-bg: linear-gradient(135deg, #192521 0%, #14211f 100%);
  --ghost-hover-border: #3f5751;
  --ghost-hover: #21312d;
  --secondary-border: #31514b;
  --secondary-hover: #1c4942;
  --empty-border: #344742;
  --settings-backdrop: rgba(4, 8, 7, 0.62);
  --toast-bg: #edf6f3;
  --toast-ink: #101816;
  --paid-action-bg: #36c6b3;
  --paid-action-hover: #55dcca;
  --paid-action-ink: #071211;
  --paid-done-bg: #173d37;
  --paid-done-hover: #1f5149;
  --paid-done-ink: #8ff0df;
  --shadow: 0 18px 45px rgba(0, 0, 0, 0.28);
}

* {
  box-sizing: border-box;
}

html,
body {
  min-width: 320px;
  margin: 0;
  overflow-x: hidden;
  color: var(--ink);
  background: var(--bg);
  font-family: var(--font);
}

body.settings-open {
  overflow: hidden;
}

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

button {
  border: 0;
  cursor: pointer;
}

button:disabled {
  cursor: not-allowed;
  opacity: 0.6;
}

.app-shell {
  min-height: 100vh;
}

.topbar {
  border-bottom: 1px solid var(--line);
  background: var(--topbar-bg);
  backdrop-filter: blur(18px);
  position: sticky;
  top: 0;
  z-index: 20;
}

.topbar-content,
.workspace {
  width: 100%;
  max-width: 1248px;
  margin-inline: auto;
  padding-left: var(--page-gutter);
  padding-right: var(--page-gutter);
}

.topbar-content {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  min-height: 104px;
  padding-top: 18px;
  padding-bottom: 18px;
}

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

.brand-mark {
  width: 48px;
  height: 48px;
  border-radius: 12px;
  box-shadow: 0 12px 30px rgba(13, 81, 74, 0.18);
}

.topbar h1,
.panel h2,
.settings-header h2 {
  margin: 0;
  letter-spacing: 0;
}

.topbar h1 {
  font-size: clamp(30px, 4vw, 46px);
  line-height: 1;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.eyebrow {
  margin: 0 0 8px;
  color: var(--teal);
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.topbar-actions,
.button-group,
.google-actions,
.card-actions {
  display: flex;
  align-items: center;
  gap: 10px;
}

.workspace {
  display: grid;
  gap: 18px;
  padding-top: 18px;
  padding-bottom: 34px;
}

.main-grid {
  display: grid;
  grid-template-columns: minmax(280px, 430px) minmax(0, 1fr);
  gap: 18px;
  align-items: start;
}

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

.panel {
  padding: 18px;
}

.panel-heading,
.settings-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 14px;
  margin-bottom: 16px;
}

.panel h2 {
  font-size: 18px;
  line-height: 1.2;
}

.panel-heading p {
  margin: 5px 0 0;
  color: var(--muted);
  font-size: 13px;
}

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

.summary-grid > *,
.main-grid > *,
.workspace > * {
  min-width: 0;
}

.metric-card {
  display: grid;
  gap: 8px;
  min-height: 92px;
  padding: 18px;
  box-shadow: none;
}

.metric-card span {
  color: var(--muted);
  font-size: 13px;
  font-weight: 800;
}

.metric-card strong {
  font-size: clamp(26px, 3vw, 36px);
  line-height: 1;
}

.metric-card.accent {
  border-color: var(--accent-border);
  background: var(--metric-accent-bg);
}

.form-grid,
.settings-form,
.settings-section,
.log-list,
.history-list {
  display: grid;
  gap: 14px;
}

.form-grid,
.two-column,
.form-grid > *,
.two-column > * {
  min-width: 0;
}

label {
  display: grid;
  gap: 6px;
  min-width: 0;
}

label span {
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

input,
textarea,
select {
  width: 100%;
  min-width: 0;
  border: 1px solid var(--field-border);
  border-radius: 7px;
  background: var(--field-bg);
  color: var(--ink);
  outline: none;
  padding: 10px 11px;
}

textarea {
  resize: vertical;
}

input:focus,
textarea:focus,
select:focus {
  border-color: var(--teal);
  box-shadow: 0 0 0 3px var(--focus-ring);
}

.two-column {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

.primary-button,
.icon-button,
.icon-only {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 40px;
  border-radius: 7px;
  font-weight: 800;
  white-space: nowrap;
}

.primary-button,
.icon-button.primary {
  background: var(--teal);
  color: var(--primary-ink);
}

.primary-button:hover,
.icon-button.primary:hover {
  background: var(--teal-dark);
}

.primary-button {
  width: 100%;
  padding: 11px 14px;
}

.icon-button {
  padding: 9px 12px;
}

.icon-only {
  width: 38px;
  height: 38px;
  padding: 0;
}

.menu-button {
  display: inline-grid;
  place-items: center;
  width: 46px;
  height: 46px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface-strong);
  color: var(--ink);
}

.menu-button:hover {
  border-color: var(--ghost-hover-border);
  background: var(--ghost-hover);
}

.menu-button svg {
  width: 22px;
  height: 22px;
}

.ghost {
  border: 1px solid var(--line);
  background: var(--surface-strong);
  color: var(--ink);
}

.ghost:hover {
  border-color: var(--ghost-hover-border);
  background: var(--ghost-hover);
}

.secondary {
  border: 1px solid var(--secondary-border);
  background: var(--mint);
  color: var(--teal-dark);
}

.secondary:hover {
  background: var(--secondary-hover);
}

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

.icon-button svg,
.icon-only svg,
.primary-button svg,
.empty-state svg {
  width: 18px;
  height: 18px;
  flex: 0 0 auto;
}

.hidden {
  display: none !important;
}

.work-card,
.history-card {
  display: grid;
  gap: 10px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--card-bg);
  padding: 13px;
}

.work-card-header,
.history-card-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
}

.work-card strong,
.history-card strong {
  display: block;
  font-size: 16px;
}

.work-card span,
.history-card span,
.work-meta,
.history-meta {
  color: var(--muted);
  font-size: 13px;
  line-height: 1.45;
}

.work-meta,
.history-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 8px 14px;
}

.badge {
  display: inline-flex;
  align-items: center;
  min-height: 25px;
  border-radius: 999px;
  padding: 4px 9px;
  font-size: 12px;
  font-weight: 800;
  background: var(--gold-soft);
  color: var(--gold);
}

.history-card {
  border-color: var(--secondary-border);
  background: var(--history-bg);
}

.history-card .button-group {
  flex-wrap: wrap;
}

.paid-toggle {
  border: 1px solid transparent;
  border-radius: 999px;
  padding: 8px 14px;
  box-shadow: 0 7px 18px rgba(13, 81, 74, 0.12);
}

.paid-toggle span {
  color: inherit;
}

.paid-toggle.is-unpaid {
  background: var(--paid-action-bg);
  color: var(--paid-action-ink);
}

.paid-toggle.is-unpaid:hover {
  background: var(--paid-action-hover);
}

.paid-toggle.is-paid {
  border-color: var(--secondary-border);
  background: var(--paid-done-bg);
  color: var(--paid-done-ink);
}

.paid-toggle.is-paid:hover {
  background: var(--paid-done-hover);
}

.history-badges {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 8px;
}

.status-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-height: 25px;
  border-radius: 999px;
  padding: 4px 9px;
  font-size: 12px;
  font-weight: 800;
}

.status-badge svg {
  width: 14px;
  height: 14px;
  flex: 0 0 auto;
}

.status-badge span {
  color: inherit;
  font-size: inherit;
  line-height: 1;
}

.status-badge.paid {
  background: var(--mint);
  color: var(--teal-dark);
}

.status-badge.unpaid {
  background: var(--gold-soft);
  color: var(--gold);
}

.empty-state {
  display: grid;
  place-items: center;
  gap: 8px;
  min-height: 160px;
  border: 1px dashed var(--empty-border);
  border-radius: var(--radius);
  background: var(--surface-strong);
  color: var(--muted);
}

.empty-state p {
  margin: 0;
  font-weight: 800;
}

.settings-backdrop {
  position: fixed;
  inset: 0;
  z-index: 80;
  display: flex;
  justify-content: flex-end;
  background: var(--settings-backdrop);
}

.settings-menu {
  width: min(520px, 100%);
  height: 100%;
  overflow-y: auto;
  border-left: 1px solid var(--line);
  background: var(--surface);
  box-shadow: -20px 0 50px rgba(13, 24, 21, 0.16);
  padding: 20px;
}

.settings-header h2 {
  font-size: 28px;
}

.settings-form {
  padding-bottom: 20px;
}

.settings-section {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface-strong);
  padding: 14px;
}

.settings-section h3 {
  margin: 0;
  font-size: 15px;
}

.account-card {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  gap: 12px;
  align-items: center;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: var(--card-bg);
  padding: 11px;
}

.account-avatar {
  display: grid;
  place-items: center;
  width: 42px;
  height: 42px;
  overflow: hidden;
  border-radius: 999px;
  background: var(--mint);
  color: var(--teal-dark);
}

.account-avatar img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.account-card strong,
.account-card span {
  display: block;
}

.account-card span,
.settings-note {
  color: var(--muted);
  font-size: 12px;
}

.settings-note {
  margin: -4px 0 0;
  line-height: 1.45;
}

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

.google-button-shell {
  min-height: 40px;
}

.toggle-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  cursor: pointer;
}

.toggle-copy {
  display: grid;
  gap: 2px;
}

.toggle-copy strong {
  color: var(--ink);
  font-size: 14px;
}

.toggle-copy small {
  color: var(--muted);
  font-size: 12px;
}

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

.toggle-switch {
  position: relative;
  flex: 0 0 auto;
  width: 48px;
  height: 28px;
  border: 1px solid var(--field-border);
  border-radius: 999px;
  background: var(--field-bg);
  transition: background 160ms ease, border-color 160ms ease;
}

.toggle-switch::after {
  content: "";
  position: absolute;
  top: 3px;
  left: 3px;
  width: 20px;
  height: 20px;
  border-radius: 999px;
  background: var(--muted);
  transition: transform 160ms ease, background 160ms ease;
}

.toggle-row input:checked + .toggle-switch {
  border-color: var(--teal);
  background: var(--mint);
}

.toggle-row input:checked + .toggle-switch::after {
  transform: translateX(20px);
  background: var(--teal);
}

.toggle-row input:focus-visible + .toggle-switch {
  box-shadow: 0 0 0 3px var(--focus-ring);
}

.toast {
  position: fixed;
  right: 18px;
  bottom: 18px;
  z-index: 90;
  max-width: min(360px, calc(100vw - 36px));
  border-radius: var(--radius);
  background: var(--toast-bg);
  color: var(--toast-ink);
  box-shadow: var(--shadow);
  padding: 12px 14px;
  font-weight: 800;
}

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

  .main-grid {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 620px) {
  :root {
    --page-gutter: 23px;
  }

  .topbar {
    position: static;
  }

  .topbar-content {
    min-height: 108px;
    align-items: center;
    gap: 12px;
    padding-top: 18px;
    padding-bottom: 14px;
  }

  .topbar h1 {
    font-size: 32px;
  }

  .brand-mark {
    width: 42px;
    height: 42px;
    border-radius: 10px;
  }

  .topbar-actions {
    justify-content: flex-end;
  }

  .topbar-actions,
  .button-group,
  .card-actions {
    flex-wrap: wrap;
  }

  .workspace {
    gap: 12px;
    padding: 12px;
  }

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

  .metric-card {
    min-height: 74px;
    padding: 10px;
  }

  .metric-card span {
    font-size: 11px;
  }

  .metric-card strong {
    font-size: 22px;
  }

  .panel {
    padding: 12px;
  }

  .panel-heading {
    align-items: stretch;
    flex-direction: column;
    gap: 10px;
  }

  .panel-heading > .icon-button,
  .history-card .icon-button,
  .card-actions .icon-button {
    width: 100%;
  }

  .log-panel .panel-heading {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    align-items: center;
    gap: 10px;
  }

  .log-panel .panel-heading > .icon-button {
    width: auto;
    min-height: 40px;
    padding-inline: 12px;
    justify-self: end;
  }

  .two-column {
    grid-template-columns: 1fr 1fr;
    gap: 8px;
  }

  .primary-button {
    white-space: normal;
    text-align: center;
    line-height: 1.2;
  }

  .primary-button span {
    min-width: 0;
  }

  input,
  textarea,
  select {
    padding: 9px 10px;
  }

  .work-card-header,
  .history-card-header {
    display: grid;
  }

  .log-list {
    gap: 10px;
  }

  .work-card {
    gap: 11px;
    padding: 13px;
    border-color: var(--accent-border);
    background: linear-gradient(180deg, var(--card-bg) 0%, var(--surface-strong) 100%);
  }

  .work-card-header {
    grid-template-columns: minmax(0, 1fr) auto;
    align-items: start;
    gap: 10px;
  }

  .work-card-header > div {
    display: grid;
    gap: 3px;
    min-width: 0;
  }

  .work-card strong {
    font-size: 15px;
    line-height: 1.2;
  }

  .work-card .badge {
    justify-self: end;
    min-height: 28px;
    padding: 5px 11px;
  }

  .work-meta {
    padding-top: 4px;
    border-top: 1px solid var(--line);
  }

  .work-card .card-actions {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 8px;
  }

  .work-card .card-actions .icon-button {
    width: 100%;
    min-height: 42px;
    padding: 8px 10px;
  }

  .history-badges {
    justify-content: flex-start;
  }

  .settings-menu {
    padding: 16px 12px;
  }
}

@media (max-width: 390px) {
  .summary-grid,
  .two-column {
    grid-template-columns: 1fr;
  }
}
