:root {
  color-scheme: light;
  font-family: system-ui, sans-serif;
  color: #331c2b;
  background: #fff5f8;
  --accent: #a21856;
  --border: #ebd3df;
  --muted: #704c60;
}
* { box-sizing: border-box; }
.sync-toolbar { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin-top: 20px; }
#sync-status { color: var(--muted); font-size: .85rem; margin-right: auto; }
button:disabled { opacity: .55; cursor: wait; }
body { margin: 0; }
main { width: min(100%, 1120px); padding: 40px 24px; margin: auto; }
header, .toolbar, .actions { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
header, .toolbar { justify-content: space-between; min-width: 0; }
header > div { min-width: 0; }
h1, h2, p { margin: 0; }
h1 { font-size: clamp(2rem, 6vw, 3.4rem); letter-spacing: -.055em; margin-bottom: 6px; }
h2 { font-size: 1.3rem; }
.brand { display: flex; align-items: center; flex-wrap: wrap; gap: 12px; margin-bottom: 12px; color: var(--accent); }
.brand-name { font-family: Georgia, serif; font-size: 1.85rem; font-weight: 700; letter-spacing: -.04em; }
.brand-admin { padding: 4px 8px; border: 1px solid var(--border); border-radius: 6px; font-size: .65rem; font-weight: 800; letter-spacing: .12em; }
header p, footer, #count { color: var(--muted); }
.stats, .filters, .fields { display: grid; gap: 12px; }
.stats { grid-template-columns: repeat(4, minmax(0, 1fr)); margin: 28px 0 16px; }
.stats small { display: block; margin-top: 5px; }
.stats article, .panel { border: 1px solid var(--border); border-radius: 18px; background: #fff; padding: 18px; }
.stats article { color: var(--muted); }
.stats strong { display: block; margin-top: 5px; font-size: clamp(1.2rem, 4vw, 1.8rem); color: var(--accent); overflow-wrap: anywhere; }
.filters { grid-template-columns: minmax(0, 2fr) repeat(4, minmax(0, 1fr)); margin: 18px 0 12px; }
.fields { grid-template-columns: repeat(2, minmax(0, 1fr)); margin-top: 16px; }
.wide { grid-column: 1 / -1; }
label { display: grid; align-content: start; gap: 5px; font-size: .84rem; font-weight: 650; }
input, select, textarea, button { font: inherit; color: inherit; border: 1px solid var(--border); border-radius: 9px; padding: 9px 11px; background: #fff; }
input, select, textarea { width: 100%; min-width: 0; }
button { cursor: pointer; font-weight: 650; }
button:hover { background: #ffeff5; }
.primary { background: var(--accent); color: #fff; border-color: var(--accent); }
.primary:hover { background: #831444; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.table-wrap { overflow-x: auto; margin-top: 10px; }
table { width: 100%; min-width: 780px; border-collapse: collapse; text-align: left; }
th, td { padding: 12px 8px; border-bottom: 1px solid var(--border); vertical-align: top; overflow-wrap: anywhere; }
th { background: #fff5f8; font-size: .82rem; }
td { font-size: .9rem; }
.customer-name { display: block; margin-bottom: 5px; font-size: 1.05rem; font-weight: 800; color: #000; }
td:nth-child(1), td:nth-child(4) { max-width: 225px; white-space: pre-line; }
td:last-child { white-space: nowrap; }
td button + button { margin-left: 5px; }
.empty { text-align: center; color: var(--muted); padding: 26px 0 14px; }
footer, #notice, #balance { margin-top: 12px; font-size: .9rem; }
dialog { width: min(640px, calc(100vw - 24px)); max-height: calc(100vh - 24px); overflow: auto; padding: clamp(14px, 4vw, 20px); border: 1px solid var(--border); border-radius: 18px; color: inherit; }
dialog::backdrop { background: #30172780; }
dialog .actions { margin-top: 12px; justify-content: flex-end; }
@media (max-width: 900px) {
  .stats { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .filters { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .filters label:first-child { grid-column: span 2; }
}
@media (max-width: 600px) {
  main { padding: 24px 14px; }
  header { align-items: flex-start; }
  header > .primary { flex: 0 0 auto; }
  .stats { gap: 8px; margin-top: 20px; }
  .stats article, .panel { padding: 12px; }
  .filters { grid-template-columns: minmax(0, 1fr); }
  .filters label:first-child { grid-column: auto; }
  .toolbar { align-items: flex-start; }
  .toolbar .actions { width: 100%; }
  .toolbar .actions button { flex: 1 1 auto; }
  .table-wrap { overflow: visible; }
  table { min-width: 0; border-collapse: separate; border-spacing: 0 10px; }
  thead { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; border: 0; }
  tbody { display: grid; gap: 10px; }
  tbody tr { display: grid; min-width: 0; padding: 8px 12px; border: 1px solid var(--border); border-radius: 12px; background: #fff; }
  tbody td { display: grid; grid-template-columns: minmax(84px, 0.7fr) minmax(0, 1.3fr); gap: 10px; max-width: none !important; padding: 8px 0; border-bottom: 1px solid var(--border); white-space: pre-line; }
  tbody td::before { content: attr(data-label); color: var(--muted); font-size: .78rem; font-weight: 700; }
  tbody td:last-child { white-space: normal; border-bottom: 0; }
  tbody td:last-child > button { justify-self: start; }
  td button + button { margin-left: 0; }
}
@media (max-width: 380px) {
  main { padding: 18px 10px; }
  header { flex-direction: column; }
  header > .primary { width: 100%; }
  .stats article { padding: 10px; font-size: .8rem; }
  .stats strong { font-size: 1.2rem; }
  .fields { grid-template-columns: minmax(0, 1fr); }
  .wide { grid-column: auto; }
  dialog .actions { display: grid; grid-template-columns: 1fr 1fr; }
}
@media (max-height: 600px) {
  dialog { max-height: calc(100vh - 16px); }
}
