/* Cleaning Business Profit Tracker
   Local stylesheet only: no external fonts or images. */

:root {
  --forest: #173b35;
  --forest-deep: #102823;
  --emerald: #258c72;
  --ivory: #f8f7f3;
  --ivory-card: #fffcf7;
  --gold: #d5ae73;
  --slate: #334155;
  --ink: #173b35;
  --body: #334155;
  --muted: #334155;
  --line: #e4ddd0;
  --border: #8d9aa8;
  --bg: var(--ivory);
  --surface: #ffffff;
  --focus: #173b35;
  --danger: #8f1d1d;
  --danger-bg: #fdf3f3;
  --ok-bg: #e8f5f1;
  --warn-bg: #fbf6ec;
  --warn-text: #3d3118;
  --shadow: 0 14px 34px rgba(23, 59, 53, 0.07);
  --radius: 18px;
  --font: "Segoe UI", system-ui, -apple-system, BlinkMacSystemFont, "Helvetica Neue", Arial, sans-serif;
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

[hidden] {
  display: none !important;
}

html {
  scroll-behavior: smooth;
  color-scheme: light;
}

body {
  margin: 0;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  background: var(--bg);
  color: var(--body);
  font-family: var(--font);
  font-size: 1rem;
  line-height: 1.55;
}

body::before {
  content: "";
  display: block;
  height: 4px;
  background: var(--gold);
}

main {
  flex: 1;
  padding: 1.25rem 0 2.75rem;
}

.wrap {
  width: min(1120px, 100%);
  margin-inline: auto;
  padding-inline: 1rem;
}

h1,
h2,
h3,
p {
  overflow-wrap: anywhere;
}

h1 {
  margin: 0.35rem 0 0.7rem;
  color: var(--ivory);
  font-size: clamp(1.75rem, 2vw + 1.2rem, 2.6rem);
  line-height: 1.12;
  letter-spacing: -0.025em;
  text-wrap: balance;
}

h2 {
  margin: 0 0 0.7rem;
  color: var(--forest);
  font-size: 1.35rem;
  line-height: 1.25;
  letter-spacing: -0.015em;
}

h3 {
  margin: 1.35rem 0 0.4rem;
  color: var(--forest);
  font-size: 1.05rem;
  line-height: 1.35;
}

a {
  color: var(--forest);
  text-underline-offset: 0.15em;
}

a:hover {
  color: var(--forest-deep);
}

p,
ul,
ol,
dl {
  margin-top: 0.75rem;
  margin-bottom: 0;
}

.skip-link {
  position: absolute;
  left: 1rem;
  top: -4rem;
  z-index: 5;
  background: var(--forest);
  color: var(--ivory);
  padding: 0.6rem 0.9rem;
  border-radius: 8px;
  text-decoration: none;
}

.skip-link:focus {
  top: 0.75rem;
  color: var(--ivory);
}

.site-header {
  background: var(--forest);
  color: var(--ivory);
  border-bottom: 4px solid var(--gold);
  padding: 1.85rem 0 1.9rem;
}

.eyebrow {
  margin: 0;
  color: var(--gold);
  font-size: 0.92rem;
  font-weight: 700;
  letter-spacing: 0.01em;
}

.lede {
  margin: 0;
  max-width: 40rem;
  color: var(--ivory);
  font-size: 1.125rem;
  line-height: 1.5;
}

.layout {
  display: grid;
  gap: 1.15rem;
  margin-top: 1.15rem;
}

.layout > * {
  min-width: 0;
}

.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 1.15rem 1rem 1.25rem;
}

.results-card {
  background: var(--ivory-card);
  border-top: 4px solid var(--gold);
}

.intro,
.hint,
.result-note,
.disclaimer,
.guide p,
.guide li {
  color: var(--body);
}

.intro,
.hint {
  margin-top: 0;
}

.hint,
.result-note,
.field-error,
.result-flag {
  font-size: 0.92rem;
}

.hint {
  margin-top: 0.4rem;
  color: var(--slate);
}

.field {
  margin-top: 1.05rem;
}

.field label {
  display: block;
  margin-bottom: 0.4rem;
  color: var(--forest);
  font-weight: 600;
  letter-spacing: -0.01em;
}

.req {
  color: var(--slate);
  font-size: 0.85rem;
  font-weight: 500;
}

input,
select,
button {
  font: inherit;
}

.field input[type="text"],
.field input[type="search"],
.field input[type="date"],
select {
  width: 100%;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: #fff;
  color: var(--forest);
}

.field input[type="text"],
.field input[type="search"],
.field input[type="date"],
select {
  min-height: 46px;
  padding: 0.55rem 0.8rem;
}

.currency-picker {
  position: relative;
}

.currency-toggle {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  width: 100%;
  min-height: 46px;
  padding: 0.55rem 0.8rem;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: #fff;
  color: var(--forest);
  font-weight: 600;
  text-align: left;
  cursor: pointer;
}

.currency-toggle-label {
  min-width: 0;
  overflow-wrap: anywhere;
}

.currency-caret {
  flex: 0 0 auto;
  width: 0.55rem;
  height: 0.55rem;
  margin-top: -0.2rem;
  border-right: 2px solid currentColor;
  border-bottom: 2px solid currentColor;
  transform: rotate(45deg);
}

.currency-toggle[aria-expanded="true"] .currency-caret {
  margin-top: 0.15rem;
  transform: rotate(225deg);
}

.currency-panel {
  position: absolute;
  z-index: 30;
  left: 0;
  right: 0;
  top: calc(100% + 0.35rem);
  display: flex;
  flex-direction: column;
  gap: 0.45rem;
  max-height: 320px;
  overflow: hidden;
  padding: 0.7rem;
  border: 1px solid var(--border);
  border-top: 3px solid var(--gold);
  border-radius: 12px;
  background: #fff;
  box-shadow: var(--shadow);
}

.currency-search-label {
  margin: 0;
  color: var(--forest);
  font-size: 0.92rem;
  font-weight: 600;
}

.currency-panel .hint {
  margin-top: 0;
}

.currency-list {
  min-height: 0;
  max-height: 220px;
  margin: 0;
  padding: 0.2rem;
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--ivory);
}

.currency-option {
  padding: 0.45rem 0.65rem;
  border-radius: 8px;
  color: var(--forest);
  cursor: pointer;
  overflow-wrap: anywhere;
}

.currency-option.is-active {
  background: var(--ok-bg);
  box-shadow: inset 3px 0 0 var(--emerald);
}

.currency-option[aria-selected="true"] {
  font-weight: 700;
}

.with-prefix {
  display: flex;
  align-items: center;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: #fff;
  min-width: 0;
}

.field .with-prefix input[type="text"] {
  width: 100%;
  min-height: 46px;
  border: 0;
  border-radius: 0;
  background: transparent;
  color: var(--forest);
  padding: 0.55rem 0.8rem;
  min-width: 0;
  box-shadow: none;
}

.prefix,
.suffix {
  flex: 0 0 auto;
  color: var(--forest);
  font-weight: 700;
  padding-inline: 0.75rem;
}

.suffix {
  color: var(--slate);
  font-weight: 600;
}

a:focus-visible,
button:focus-visible,
input:focus-visible,
textarea:focus-visible,
select:focus-visible,
.btn:focus-visible,
.currency-toggle:focus-visible,
.with-prefix:focus-within,
.error-summary:focus,
.result-summary:focus,
.skip-link:focus,
.table-scroll:focus-visible {
  outline: 3px solid var(--focus);
  outline-offset: 3px;
}

.btn-primary:focus-visible,
.skip-link:focus {
  outline-color: var(--ivory);
  box-shadow: 0 0 0 3px var(--forest), 0 0 0 6px var(--gold);
}

.with-prefix input:focus-visible {
  outline: none;
}

.with-prefix.is-invalid {
  border-color: var(--danger);
  background: var(--danger-bg);
}

.field-error {
  margin-top: 0.35rem;
  color: var(--danger);
  font-weight: 600;
}

.status,
.stale-warning,
.notice {
  margin-top: 0.75rem;
  padding: 0.75rem 0.9rem;
  border-radius: 10px;
}

.status:empty {
  display: none;
}

.status,
.notice {
  background: var(--ok-bg);
  border: 1px solid #b7d9ce;
  color: var(--forest);
}

.notice-warn,
.stale-warning {
  background: var(--warn-bg);
  border: 1px solid var(--gold);
  color: var(--warn-text);
}

.error-summary {
  margin-top: 1rem;
  padding: 0.95rem 1rem;
  border: 1px solid #e4b4b4;
  border-radius: 12px;
  background: var(--danger-bg);
  color: var(--forest);
}

.error-summary h3,
.error-summary p,
.error-summary ul {
  margin-top: 0;
}

.error-summary ul {
  margin: 0.5rem 0 0;
  padding-left: 1.2rem;
}

.actions,
.dialog-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
}

.actions {
  margin-top: 1.35rem;
}

.btn {
  min-height: 46px;
  padding: 0.6rem 1.05rem;
  border-radius: 10px;
  border: 2px solid var(--forest);
  cursor: pointer;
  font-weight: 600;
  line-height: 1.3;
  text-align: center;
  transition: background-color 0.15s ease, border-color 0.15s ease, color 0.15s ease;
}

.btn-primary {
  background: var(--forest);
  color: var(--ivory);
}

.btn-primary:hover {
  background: var(--forest-deep);
  border-color: var(--forest-deep);
}

.btn-secondary {
  background: var(--ivory);
  color: var(--forest);
}

.btn-secondary:hover {
  background: #f3eee4;
  border-color: var(--emerald);
}

.btn:disabled {
  background: #e7e4dc;
  color: var(--slate);
  border-color: #c9c3b6;
  cursor: not-allowed;
}

.result-client {
  margin-top: 0;
  font-weight: 700;
  color: var(--forest);
}

.result-summary {
  margin-top: 0.85rem;
  color: var(--forest);
  font-weight: 600;
}

.result-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(7.5rem, auto);
  gap: 0.35rem 1rem;
  align-items: start;
  padding: 0.95rem 0;
  border-top: 1px solid var(--line);
}

.result-row h3 {
  margin: 0;
  font-size: 1rem;
}

.result-note,
.result-flag {
  margin: 0.25rem 0 0;
}

.result-value {
  margin: 0;
  color: var(--forest);
  font-size: 1.15rem;
  font-weight: 700;
  text-align: right;
  font-variant-numeric: tabular-nums;
  overflow-wrap: anywhere;
}

.result-value.is-empty {
  color: var(--slate);
  font-size: 0.95rem;
  font-weight: 500;
}

.result-value.is-negative {
  color: var(--danger);
}

.result-row.is-profit {
  margin: 0.85rem 0 0.35rem;
  padding: 1rem 1rem 1.05rem;
  border: 1px solid rgba(23, 59, 53, 0.12);
  border-left: 4px solid var(--gold);
  border-radius: 14px;
  background: #fff;
}

.result-row.is-profit h3 {
  font-size: 1.08rem;
}

.result-row.is-profit .result-value:not(.is-empty) {
  font-size: clamp(1.65rem, 2vw + 1rem, 2.15rem);
  line-height: 1.15;
  letter-spacing: -0.03em;
}

.result-row.is-profit.is-positive {
  background: var(--ok-bg);
  border-color: #b7d9ce;
  border-left-color: var(--emerald);
}

.result-row.is-profit.is-negative {
  background: var(--danger-bg);
  border-color: #e4b4b4;
  border-left-color: var(--danger);
}

.result-row.is-profit.is-even {
  background: var(--ivory);
  border-left-color: var(--gold);
}

.results-card.is-stale .result-value {
  opacity: 0.8;
}

.disclaimer {
  margin-top: 0.65rem;
  padding-top: 0.95rem;
  border-top: 1px solid var(--line);
  font-size: 0.95rem;
}

.guide {
  margin-top: 2.75rem;
  display: grid;
  gap: 1.15rem;
}

.guide section {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 1.2rem 1rem 1.3rem;
}

.guide h2 {
  padding-bottom: 0.45rem;
  border-bottom: 2px solid var(--gold);
}

.guide p,
.guide li {
  max-width: 68ch;
}

.guide ol,
.guide ul {
  padding-left: 1.25rem;
}

.guide li + li {
  margin-top: 0.55rem;
}

.figure-list {
  max-width: 36rem;
  margin-top: 0.75rem;
}

.figure-list div {
  display: grid;
  grid-template-columns: minmax(0, 1.4fr) minmax(0, 1fr);
  gap: 0.75rem;
  padding: 0.55rem 0;
  border-bottom: 1px solid var(--line);
}

.figure-list dt,
.figure-list dd {
  margin: 0;
}

.figure-list dt {
  font-weight: 600;
  color: var(--forest);
}

.figure-list dd {
  text-align: right;
  font-variant-numeric: tabular-nums;
  color: var(--forest);
  font-weight: 600;
}

.site-footer {
  background: var(--forest);
  color: var(--ivory);
  border-top: 4px solid var(--gold);
  padding: 2rem 0 1.75rem;
}

.footer-grid {
  display: grid;
  gap: 1.5rem 2rem;
}

.site-footer p,
.site-footer li {
  color: var(--ivory);
}

.site-footer p {
  margin: 0;
  max-width: 65ch;
}

.site-footer .footer-name {
  margin-bottom: 0.45rem;
  max-width: 18rem;
  color: var(--ivory);
  font-size: 1.08rem;
  font-weight: 700;
  letter-spacing: -0.015em;
  line-height: 1.3;
}

.site-footer nav,
.site-footer li,
.site-footer a {
  min-width: 0;
  max-width: 100%;
}

.site-footer h2 {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 0.45rem;
  margin: 0 0 0.7rem;
  padding: 0;
  border: 0;
  color: var(--ivory);
  font-size: 0.78rem;
  font-weight: 700;
  letter-spacing: 0.14em;
  line-height: 1.25;
  text-transform: uppercase;
}

.site-footer h2::after {
  content: "";
  display: block;
  width: 2.25rem;
  height: 2px;
  border-radius: 1px;
  background: var(--gold);
}

.site-footer .footer-heading {
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
  max-width: 100%;
}

.site-footer .footer-icon {
  width: 1.05rem;
  height: 1.05rem;
  flex: 0 0 auto;
  color: var(--gold);
  overflow: visible;
}

.site-footer ul {
  margin: 0;
  padding: 0;
  list-style: none;
}

.site-footer li {
  margin: 0;
}

.site-footer a {
  display: inline-flex;
  align-items: center;
  min-height: 44px;
  color: var(--ivory);
  font-weight: 500;
  letter-spacing: 0;
  text-transform: none;
  text-decoration: underline;
  text-decoration-color: var(--gold);
  text-decoration-thickness: 1px;
  text-underline-offset: 0.28em;
  overflow-wrap: break-word;
}

.site-footer a:hover {
  color: var(--gold);
  text-decoration-thickness: 2px;
}

.site-footer a:focus-visible {
  outline: 3px solid var(--ivory);
  outline-offset: 3px;
  box-shadow: 0 0 0 3px var(--forest), 0 0 0 6px var(--gold);
}

.site-footer a[aria-current="page"] {
  color: var(--ivory);
  font-weight: 700;
  text-decoration-thickness: 2px;
}

.site-footer .footer-note {
  max-width: 68ch;
  margin-top: 1.5rem;
  padding-top: 1.15rem;
  border-top: 1px solid rgba(213, 174, 115, 0.45);
}

.guide section {
  scroll-margin-top: 1rem;
}

@media (min-width: 720px) {
  .footer-grid {
    grid-template-columns: minmax(0, 1.45fr) minmax(8rem, 0.7fr) minmax(11rem, 0.9fr);
    align-items: start;
  }
}

dialog {
  width: min(32rem, calc(100vw - 2rem));
  max-height: calc(100vh - 2rem);
  overflow: auto;
  border: 1px solid var(--line);
  border-top: 4px solid var(--gold);
  border-radius: var(--radius);
  padding: 1.3rem 1.15rem 1.2rem;
  color: var(--body);
  background: var(--ivory-card);
  box-shadow: 0 22px 50px rgba(23, 59, 53, 0.24);
}

dialog::backdrop {
  background: rgba(23, 59, 53, 0.62);
}

dialog h2 {
  margin-top: 0;
}

.dialog-actions {
  margin-top: 1.25rem;
}

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

@media (min-width: 720px) {
  .wrap {
    padding-inline: 1.5rem;
  }

  .card,
  .guide section {
    padding: 1.5rem 1.45rem 1.55rem;
  }

  main {
    padding-top: 1.5rem;
  }
}

@media (min-width: 900px) {
  .layout {
    grid-template-columns: minmax(0, 1.08fr) minmax(0, 0.92fr);
    align-items: start;
    gap: 1.5rem;
  }

  .results-card {
    position: sticky;
    top: 1rem;
  }
}

@media (max-width: 640px) {
  .actions,
  .dialog-actions {
    flex-direction: column;
  }

  .actions .btn,
  .dialog-actions .btn {
    width: 100%;
  }

  .result-row,
  .figure-list div {
    grid-template-columns: 1fr;
  }

  .result-value,
  .figure-list dd {
    text-align: left;
  }
}

@media (max-width: 359px) {
  .wrap {
    padding-inline: 0.75rem;
  }

  .card,
  .guide section {
    padding: 1rem 0.85rem 1.1rem;
  }

  h1 {
    font-size: 1.65rem;
  }
}

.view-nav {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin-top: 1.2rem;
}

.view-nav a {
  display: inline-flex;
  align-items: center;
  min-height: 44px;
  padding: 0.35rem 0.9rem;
  border: 1px solid rgba(213, 174, 115, 0.85);
  border-radius: 999px;
  color: var(--ivory);
  text-decoration: none;
  font-weight: 600;
}

.view-nav a:hover {
  background: rgba(248, 247, 243, 0.12);
  color: var(--ivory);
}

.view-nav a[aria-current="page"] {
  background: var(--ivory);
  color: var(--forest);
  border-color: var(--ivory);
}

.view-nav a:focus-visible {
  outline-color: var(--ivory);
  box-shadow: 0 0 0 3px var(--forest), 0 0 0 6px var(--gold);
}

.record-list {
  display: grid;
  gap: 0.75rem;
  margin-top: 1rem;
}

.record-card {
  border: 1px solid var(--line);
  border-left: 4px solid var(--gold);
  border-radius: 14px;
  padding: 0.9rem 0.95rem 1rem;
  background: var(--ivory-card);
}

.record-card h3 {
  margin: 0;
  font-size: 1.08rem;
}

.record-card p {
  margin-top: 0.35rem;
}

.record-notes {
  white-space: pre-wrap;
}

.record-summary {
  display: grid;
  gap: 0.35rem;
  margin-top: 1rem;
}

.record-summary p {
  margin: 0;
  color: var(--forest);
  font-weight: 600;
}

.empty-state {
  margin-top: 1rem;
  padding: 0.9rem 1rem;
  border: 1px dashed var(--border);
  border-radius: 12px;
  background: var(--ivory);
}

textarea {
  width: 100%;
  min-height: 5.5rem;
  padding: 0.6rem 0.75rem;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: #fff;
  color: var(--forest);
  font: inherit;
  resize: vertical;
}

.file-button {
  position: relative;
}

.file-button:focus-within {
  outline: 3px solid var(--focus);
  outline-offset: 3px;
}

.btn-danger {
  background: var(--danger);
  border-color: var(--danger);
  color: #fff;
}

.btn-danger:hover {
  background: #741717;
  border-color: #741717;
}

.btn-danger:focus-visible {
  outline-color: #fff;
  box-shadow: 0 0 0 3px var(--danger), 0 0 0 6px var(--gold);
}

#storage-banner {
  margin-bottom: 1rem;
}

#view-clients,
#view-visits,
#view-dashboard {
  display: grid;
  gap: 1rem;
}

.dashboard-filters {
  display: grid;
  gap: 0.25rem 1rem;
}

@media (min-width: 720px) {
  .dashboard-filters {
    grid-template-columns: minmax(0, 1.4fr) minmax(0, 1fr);
    align-items: start;
  }
}

.date-pair {
  display: grid;
  gap: 0.75rem;
  margin-top: 0.35rem;
}

@media (min-width: 640px) {
  .date-pair {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

.metric-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 11rem), 1fr));
  gap: 0.75rem;
  margin-top: 1rem;
}

.metric-grid:empty {
  display: none;
}

.metric {
  margin: 0;
  padding: 0.85rem 0.9rem 0.95rem;
  border: 1px solid var(--line);
  border-top: 3px solid var(--gold);
  border-radius: 14px;
  background: var(--ivory-card);
}

.metric dt {
  margin: 0;
  color: var(--slate);
  font-size: 0.92rem;
  font-weight: 600;
}

.metric dd {
  margin: 0.3rem 0 0;
  color: var(--forest);
  font-size: 1.35rem;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  overflow-wrap: anywhere;
}

.metric dd.is-negative {
  color: var(--danger);
}

#view-dashboard,
#view-dashboard .card,
.table-scroll {
  min-width: 0;
}

.table-scroll {
  width: 100%;
  max-width: 100%;
  margin-top: 0.75rem;
  overflow-x: auto;
}

.dashboard-table {
  width: 100%;
  min-width: 40rem;
  border-collapse: collapse;
}

.dashboard-table th,
.dashboard-table td {
  padding: 0.6rem 0.7rem;
  border-bottom: 1px solid var(--line);
  color: var(--forest);
  text-align: left;
  vertical-align: top;
}

.dashboard-table th {
  font-size: 0.92rem;
  font-weight: 700;
}

.dashboard-table .num {
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.dashboard-table .is-negative {
  color: var(--danger);
  font-weight: 700;
}

.bar-chart {
  display: grid;
  gap: 0.75rem;
  margin-top: 0.85rem;
}

.bar-row {
  display: grid;
  grid-template-columns: minmax(0, 8.5rem) minmax(0, 1fr) auto;
  gap: 0.55rem;
  align-items: center;
}

.bar-label,
.bar-value {
  color: var(--forest);
  font-weight: 600;
  overflow-wrap: anywhere;
}

.bar-value {
  font-variant-numeric: tabular-nums;
}

.bar-value.is-negative {
  color: var(--danger);
}

.bar-track {
  height: 0.8rem;
  overflow: hidden;
  border-radius: 999px;
  background: #e7f3ef;
}

.bar-fill {
  display: block;
  height: 100%;
  border-radius: 999px;
  background: var(--emerald);
}

.bar-fill.is-negative {
  background: var(--danger);
}

@media (max-width: 640px) {
  .bar-row {
    grid-template-columns: 1fr;
    gap: 0.3rem;
  }
}

@media (prefers-reduced-motion: reduce) {
  html {
    scroll-behavior: auto;
  }

  *,
  *::before,
  *::after {
    animation: none !important;
    transition: none !important;
  }
}
