:root {
  color-scheme: light;
  font-family: Roboto, system-ui, sans-serif;
  color: #17233b;
  background: #f1f4fa;
  --surface: #ffffff;
  --navy: #142849;
  --blue: #244fc2;
  --line: #dce4f0;
  --muted: #53627a;
  --green: #236544;
  --amber: #805312;
  --red: #a32d37;
}

* { box-sizing: border-box; }
body { margin: 0; }
button, input, select, textarea { font: inherit; }
button { cursor: pointer; }
button:disabled { cursor: default; opacity: .55; }
:focus-visible { outline: 3px solid #4a79e8; outline-offset: 3px; }
[hidden] { display: none !important; }

.topbar {
  background: linear-gradient(105deg, #13294d 12%, #1a3667);
  color: white;
  border-bottom: 1px solid #829de0;
}
.topbar-inner {
  max-width: 950px;
  margin: auto;
  min-height: 64px;
  padding: 12px 18px;
  display: flex;
  align-items: center;
  gap: 12px;
}
.brand-title { font-size: 1.17rem; font-weight: 750; flex: 1; letter-spacing: .025em; }
.brand-title small { display: block; color: #d3e0ff; font-size: .74rem; font-weight: 600; letter-spacing: .1em; margin-top: 4px; }
.brand-logo {
  display: grid;
  place-content: center;
  width: 110px;
  height: 49px;
  border-radius: 12px;
  overflow: hidden;
  background: white;
}
.brand-logo img { width: 128px; height: auto; }
.brand-settings {
  display: inline-grid;
  place-items: center;
  width: 44px;
  height: 44px;
  flex: 0 0 44px;
  border: 1px solid #5a79b0;
  border-radius: 11px;
  color: #f2f6ff;
  background: #193561;
}
.brand-settings[aria-current="page"] { border-color: #aac2f3; background: #254577; }
.icon { width: 22px; height: 22px; flex-shrink: 0; }

main {
  max-width: 950px;
  margin: auto;
  padding: 20px 16px calc(96px + env(safe-area-inset-bottom));
}
h1, h2, p { margin: 0; }
h1, h2, h3, h4, legend, summary, .metric-label, .record-title, .section-tabs button,
.home-revenue-heading > span, .field > span:first-child, .detail-list dt, .summary-table thead,
.bottom-nav button span { text-transform: uppercase; }
h1 { font-size: clamp(1.7rem, 6vw, 2.25rem); letter-spacing: -.035em; }
h2 { font-size: 1.12rem; line-height: 1.25; }
h3 { font-size: .98rem; line-height: 1.3; margin: 0; }
.muted { color: var(--muted); }
.helper { color: var(--muted); font-size: .88rem; line-height: 1.45; }
.stack { display: grid; gap: 14px; }
.page-heading {
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 12px;
}
.panel, .metric {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 17px;
  box-shadow: 0 2px 8px rgb(25 52 105 / 4%);
}
.panel { padding: 16px; min-width: 0; }
.metric-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
}
.metric { display: grid; padding: 13px; gap: 5px; min-width: 0; }
.metric .metric-label { font-weight: 700; color: var(--muted); font-size: .76rem; line-height: 1.3; overflow-wrap: anywhere; }
.metric strong { font-size: clamp(1rem, 4.5vw, 1.55rem); overflow-wrap: anywhere; }
.metric.attention { background: #fff7e7; border-color: #efddba; }
.metric.positive strong { color: var(--green); }
.metric.negative strong { color: var(--red); }
.metric-symbol {
  display: grid;
  place-items: center;
  width: 34px;
  height: 34px;
  border-radius: 10px;
  color: #254ba7;
  background: #eaf0ff;
}
.metric-symbol .icon { width: 19px; height: 19px; }
.metric.positive .metric-symbol { color: var(--green); background: #e9f6ee; }
.metric.attention .metric-symbol { color: var(--amber); background: #f7ead1; }

.home-hero {
  display: grid;
  gap: 22px;
  padding: 18px;
  border-radius: 20px;
  color: #fff;
  background:
    radial-gradient(circle at 98% 120%, #4771dd 0 26%, transparent 26.3%),
    radial-gradient(circle at 98% 120%, #3159be 0 43%, transparent 43.3%),
    linear-gradient(126deg, #142c58 9%, #284bb0);
  box-shadow: 0 8px 20px rgb(27 52 119 / 18%);
}
.home-heading, .home-highlight {
  display: flex;
  align-items: end;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 12px;
}
.home-heading h1 { font-size: clamp(1.38rem, 5.2vw, 1.9rem); align-self: center; }
.home-period { width: max-content; max-width: 100%; color: #e0e9ff; }
.home-period > span:first-child { font-size: .72rem; letter-spacing: .04em; text-transform: uppercase; }
.home-period input {
  min-height: 40px; background: #f6f8ff; color: var(--navy); font-size: .84rem; border: 0;
}
.home-hero :focus-visible { outline-color: #d6e1ff; }
.home-revenue { display: grid; gap: 3px; min-width: 0; }
.home-revenue-heading {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 6px 12px;
}
.home-revenue-heading > span { color: #e0e9ff; font-size: .82rem; font-weight: 700; }
.currency-switch {
  display: inline-flex;
  padding: 3px;
  border: 1px solid #7898eb;
  border-radius: 11px;
  background: #193879;
}
.currency-switch button {
  min-width: 44px;
  min-height: 40px;
  padding: 4px 8px;
  border: 0;
  border-radius: 8px;
  background: transparent;
  color: #edf3ff;
  font-size: .82rem;
  font-weight: 700;
}
.currency-switch button[aria-pressed="true"] { background: #f6f8ff; color: #1c429e; }
.home-revenue > strong { font-size: clamp(1.5rem, 6.8vw, 2.45rem); letter-spacing: -.025em; overflow-wrap: anywhere; }
.home-revenue > small { color: #e0e9ff; font-size: .8rem; }
.home-highlight .btn { color: #1c429e; border: 0; font-size: .92rem; }
.home-metrics .attention { grid-column: 1 / -1; }
.payment-disclosure { background: #fff7e7; border-color: #efddba; padding: 10px 12px; }
.payment-disclosure-summary {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  gap: 10px;
  align-items: center;
  min-height: 44px;
  cursor: pointer;
  color: var(--amber);
}
.payment-disclosure-summary::-webkit-details-marker { display: none; }
.payment-disclosure-summary .metric-symbol { color: var(--amber); background: #f7ead1; }
.payment-disclosure-summary small {
  display: block;
  margin-top: 3px;
  color: var(--muted);
  font-size: .81rem;
  text-transform: none;
}
.payment-disclosure[open] > summary > .icon { transform: rotate(180deg); }
.payment-disclosure-list { margin-top: 10px; }
.payment-disclosure-link { margin-top: 10px; }
.payment-disclosure-list .record-button { min-height: 48px; }
.payment-disclosure-list .record-aside { color: var(--amber); }
.home-cash .metric { background: #f7f9fe; }
.priority-links { display: grid; gap: 8px; }
.priority-link {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  align-items: center;
  gap: 10px;
  padding: 9px 10px;
  color: var(--navy);
  text-align: left;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: #f7f9fd;
  min-height: 52px;
}
.priority-link > span:last-child { font-size: 1.4rem; color: var(--blue); }
.section-tabs {
  display: flex;
  padding: 4px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: #e8eef9;
}
.section-tabs button {
  flex: 1 1 0;
  min-height: 44px;
  padding: 7px;
  border: 0;
  border-radius: 9px;
  color: var(--muted);
  background: transparent;
  font-size: .8rem;
  font-weight: 700;
}
.section-tabs button[aria-current="page"] {
  background: #fff;
  color: var(--blue);
  box-shadow: 0 2px 5px rgb(35 58 110 / 12%);
}
.monthly-sales-filters { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.monthly-sales-legend, .monthly-sales-chart {
  list-style: none; margin: 0; padding: 0;
}
.monthly-sales-legend { display: flex; flex-wrap: wrap; gap: 8px 14px; color: var(--muted); font-size: .8rem; }
.monthly-sales-legend li { display: flex; align-items: center; gap: 5px; }
.monthly-sales-legend li::before { content: ''; width: 9px; height: 9px; border-radius: 3px; }
.monthly-legend-cash::before { background: #3463ce; }
.monthly-legend-margin::before { background: #28805c; }
.monthly-legend-negative::before { background: #ad3946; }
.monthly-sales-chart { display: grid; gap: 13px; }
.monthly-sales-month { display: grid; gap: 7px; padding: 8px 0 11px; border-bottom: 1px solid var(--line); }
.monthly-sales-lines { display: grid; gap: 5px; }
.monthly-sales-measure {
  display: grid;
  grid-template-columns: 2.85rem minmax(0,1fr) minmax(6.3rem, max-content);
  gap: 6px;
  align-items: center;
  font-size: .77rem;
}
.monthly-sales-measure > span { color: var(--muted); }
.monthly-sales-measure > strong { text-align: right; overflow-wrap: anywhere; }
.monthly-sales-measure > strong.monthly-sales-negative { color: var(--red); }
.monthly-sales-meter { width: 100%; min-width: 0; height: 10px; }
.monthly-sales-meter::-webkit-meter-bar { border: 0; background: #edf1f8; border-radius: 4px; }
.monthly-sales-revenue::-webkit-meter-optimum-value { background: #3463ce; }
.monthly-sales-margin::-webkit-meter-optimum-value { background: #28805c; }
.monthly-sales-negative::-webkit-meter-optimum-value { background: #ad3946; }
.archive-summary { cursor: pointer; min-height: 30px; color: var(--navy); }
.archive-year > summary { font-size: 1.15rem; }
.archive-content { margin-top: 12px; }
.archive-subtotal { font-size: .87rem; }
.archive-month { background: #f7f9fe; }
.cash-out { color: var(--red); }
.cash-notes { white-space: pre-wrap; overflow-wrap: anywhere; }
.cash-date-filter > .field { flex: 1 1 160px; }
.cash-date-filter { align-items: end; }
.cash-method { background: #f7f9fe; border-color: var(--line); }
.cash-method > .payment-disclosure-summary, .cash-method .record-aside { color: var(--navy); }
.cash-method .metric-symbol { color: var(--blue); background: #eaf0ff; }
.cash-method > .payment-disclosure-list { margin-top: 10px; }
.cash-deposit-summary { cursor: pointer; }
.cash-deposit-summary::-webkit-details-marker { display: none; }
.cash-deposit-summary .record-aside { display: flex; align-items: center; justify-content: end; gap: 4px; }
.cash-deposit-summary .icon { width: 16px; height: 16px; }
.cash-deposit[open] > summary .icon { transform: rotate(180deg); }
.record-list.cash-deposit-parts { margin: 8px 0 0 12px; }

.toolbar { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
.toolbar > input { flex: 1 1 190px; }
.toolbar > select { flex: 1 1 105px; }
.btn {
  min-height: 44px;
  display: inline-flex;
  justify-content: center;
  align-items: center;
  gap: 7px;
  border: 1px solid var(--line);
  background: var(--surface);
  color: var(--navy);
  border-radius: 11px;
  padding: 8px 13px;
  font-weight: 700;
  text-align: center;
}
.btn.primary {
  color: white;
  background: linear-gradient(100deg, #244fc2, #2855ca);
  border-color: #244fc2;
  box-shadow: 0 2px 6px rgb(34 73 162 / 18%);
}
.btn:active, .record-button:active, .priority-link:active { filter: brightness(.95); }
.btn.danger { color: var(--red); }
.btn.icon-only { width: 44px; padding: 0; }

.record-list { list-style: none; padding: 0; margin: 0; display: grid; gap: 8px; }
.record-button {
  width: 100%;
  min-height: 60px;
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  gap: 9px 12px;
  padding: 12px;
  border-radius: 15px;
  border: 1px solid var(--line);
  background: var(--surface);
  color: inherit;
  text-align: left;
  box-shadow: 0 2px 6px rgb(25 52 105 / 4%);
}
.record-button strong, .record-button small { display: block; overflow-wrap: anywhere; }
.record-button small { color: var(--muted); margin-top: 4px; line-height: 1.35; }
.record-aside { text-align: right; }
.record-title { font-weight: 700; }
.status {
  display: inline-block;
  padding: 4px 8px;
  border-radius: 16px;
  color: #234681;
  background: #e9effe;
  font-size: .77rem;
  font-weight: 700;
}
.status.ok { color: var(--green); background: #e4f3e9; }
.status.pending { color: var(--amber); background: #fff0d3; }
.status.overdue { color: var(--red); background: #fbe7ea; }
.empty { padding: 18px 12px; color: var(--muted); line-height: 1.5; }
.client-identity { display: flex; align-items: center; gap: 10px; min-width: 0; }
.client-avatar {
  display: grid;
  place-items: center;
  width: 39px;
  height: 39px;
  flex: 0 0 39px;
  color: #2449a2;
  background: linear-gradient(140deg, #edf3ff, #dce7fc);
  border: 1px solid #d8e3f8;
  border-radius: 12px;
  font-weight: 750;
  font-size: .86rem;
}
.client-copy { min-width: 0; overflow-wrap: anywhere; }
.client-balance { display: grid; gap: 4px; justify-items: end; }
.client-balance:empty { display: none; }
.client-currency-grid { display: grid; gap: 10px; }
.client-currency { background: #f7f9fd; }
.client-note { white-space: pre-wrap; }
.client-contacts { grid-template-columns: 1fr; }
.client-payment-part {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(6.4rem, 9rem);
  align-items: center;
  gap: 8px 12px;
  background: #f7f9fd;
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 10px;
}
.client-payment-part strong, .client-payment-part small { display: block; overflow-wrap: anywhere; }
.client-payment-part small { color: var(--muted); margin-top: 4px; }
.receipt-part {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 10px;
  align-items: center;
  overflow-wrap: anywhere;
}
.receipt-part small { color: var(--muted); }
.articles-summary { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.articles-summary .metric { padding-inline: 10px; }
.articles-filters { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
.articles-search-field { grid-column: 1 / -1; }
.articles-card { border-left: 3px solid #b5c8f6; }
.articles-card-content { display: flex; gap: 9px; align-items: center; min-width: 0; }
.articles-card-main { min-width: 0; }
.product-photo { display: block; border: 1px solid var(--line); border-radius: 9px; background: #f7f9fe; }
.product-photo:not([src]) { visibility: hidden; }
.product-photo-thumb { flex: 0 0 52px; width: 52px; height: 52px; object-fit: cover; }
.product-photo-detail { width: min(100%, 420px); height: clamp(165px, 37vh, 310px); object-fit: contain; }
.product-photo-sale { width: 80px; height: 80px; object-fit: cover; }
.product-photo-editor { padding: 10px; border: 1px solid var(--line); border-radius: 10px; }
.product-photo-editor > .btn { justify-self: start; }
.sale-product-photo:empty { display: none; }
.articles-card-stock .status { margin-top: 3px; }
.articles-card-aside { color: var(--navy); }

.inventory-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(96px, 42%);
  align-items: center;
  gap: 12px;
  padding: 12px;
}
.inventory-article, .inventory-count { display: grid; gap: 4px; overflow-wrap: anywhere; }
.inventory-count > .field > span:first-child { font-size: .78rem; }
.inventory-actions {
  position: sticky;
  bottom: 0;
  background: var(--surface);
  padding-block: 10px 4px;
  border-top: 1px solid var(--line);
}

.field { display: grid; gap: 5px; min-width: 0; }
.field > span:first-child { font-weight: 650; font-size: .94rem; }
input, select, textarea {
  width: 100%;
  min-width: 0;
  min-height: 44px;
  border: 1px solid #c7d2e2;
  border-radius: 10px;
  padding: 9px 10px;
  background: var(--surface);
  color: inherit;
  font-size: 1rem;
}
textarea { min-height: 80px; resize: vertical; }
.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
.field.full { grid-column: 1 / -1; }
.form-actions { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: 8px; }
.form-error { color: var(--red); font-size: .9rem; line-height: 1.4; }

dialog {
  width: min(calc(100% - 24px), 575px);
  padding: 0;
  border: 1px solid var(--line);
  border-radius: 20px;
  color: inherit;
  background: var(--surface);
  max-height: calc(100% - 32px);
  box-shadow: 0 16px 50px rgb(15 30 59 / 26%);
}
dialog::backdrop { background: rgb(14 26 49 / 62%); }
.dialog-body { padding: 16px; }
.detail-list {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
  margin: 0;
}
.detail-list dt { color: var(--muted); font-size: .85rem; }
.detail-list dd { margin: 3px 0 0; overflow-wrap: anywhere; }
.table-wrap { overflow-x: auto; }
.summary-table { width: 100%; border-collapse: collapse; text-align: right; white-space: nowrap; font-size: .89rem; }
.summary-table th, .summary-table td { padding: 10px 8px; border-bottom: 1px solid var(--line); }
.summary-table th:first-child { text-align: left; }
.summary-table thead { color: var(--muted); }
.summary-table tfoot { font-weight: 700; }
.storage-note { margin-bottom: 14px; color: var(--red); background: #fbe7ea; }

.bottom-nav {
  position: fixed;
  bottom: 0;
  inset-inline: 0;
  z-index: 3;
  display: flex;
  justify-content: flex-start;
  justify-content: safe center;
  gap: 3px;
  overflow-x: auto;
  overflow-y: hidden;
  overscroll-behavior-x: contain;
  scrollbar-width: none;
  background: #ffffff;
  border-top: 1px solid var(--line);
  box-shadow: 0 -5px 18px rgb(36 57 95 / 7%);
  padding: 5px 4px calc(6px + env(safe-area-inset-bottom));
}
.bottom-nav::-webkit-scrollbar { display: none; }
.bottom-nav button {
  flex: 0 0 auto;
  min-width: 75px;
  min-height: 53px;
  display: grid;
  place-content: center;
  justify-items: center;
  gap: 3px;
  border: none;
  border-radius: 11px;
  color: var(--muted);
  background: none;
  padding: 4px 10px;
  font-weight: 650;
  font-size: .72rem;
}
.bottom-nav button span { white-space: nowrap; }
.bottom-nav button .icon { box-sizing: content-box; padding: 2px 7px; border-radius: 12px; }
.bottom-nav button[aria-current="page"] { color: #1745a5; }
.bottom-nav button[aria-current="page"] .icon { background: #e3ecff; }
.toast {
  z-index: 6;
  position: fixed;
  inset-inline: 14px;
  bottom: calc(74px + env(safe-area-inset-bottom));
  width: fit-content;
  max-width: calc(100% - 28px);
  margin: auto;
  padding: 10px 14px;
  border-radius: 10px;
  background: #223858;
  color: white;
  line-height: 1.4;
}

@media (min-width: 650px) {
  main { padding-inline: 20px; }
  .home-metrics, .articles-summary { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .home-metrics .attention { grid-column: auto; }
  .home-hero { padding: 24px; }
  .articles-filters { grid-template-columns: minmax(0, 2fr) repeat(2, minmax(0, 1fr)); }
  .articles-search-field { grid-column: auto; }
  .articles-grid, .client-list { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .cash-balances, .cash-summary { grid-template-columns: repeat(3, minmax(0, 1fr)); }
}
@media (max-width: 360px) {
  .topbar-inner { gap: 8px; padding-inline: 12px; }
  .brand-logo { width: 78px; height: 44px; }
  .brand-logo img { width: 99px; }
  .brand-title { font-size: 1rem; }
  .brand-title small { font-size: .66rem; }
  main { padding-inline: 12px; }
  .form-grid { grid-template-columns: 1fr; }
  .record-button { grid-template-columns: minmax(0, 1fr) minmax(0, auto); gap: 8px; }
  .record-aside { max-width: 101px; }
  .client-avatar { width: 32px; height: 32px; flex-basis: 32px; }
  .home-hero { padding: 15px; }
}
