:root {
  --bg: #3b444b;
  --primary: #607d8b;
  --primary-dark: #455a64;
  --accent: #1976d2;
  --text: #ffffff;
  --muted: #d3d3d3;
  --green: #00cc00;
  --red: #ff0000;
  --sheet: #455a64;
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  font-family: Roboto, system-ui, sans-serif;
  background: var(--bg);
  color: var(--text);
}

.app {
  min-height: 100%;
  display: flex;
  flex-direction: column;
}

.toolbar {
  display: flex;
  align-items: center;
  gap: 8px;
  min-height: 52px;
  padding: 8px 12px;
  background: var(--bg);
  box-shadow: 0 4px 10px rgb(0 0 0 / 28%);
  position: sticky;
  top: 0;
  z-index: 5;
}
.toolbar h1 {
  font-size: 20px;
  font-weight: 500;
  margin: 0;
  flex: 1;
}
.toolbar .actions {
  display: flex;
  gap: 4px;
  flex-wrap: wrap;
  justify-content: flex-end;
}
.icon-btn {
  background: transparent;
  border: 0;
  color: var(--text);
  font: inherit;
  font-size: 14px;
  padding: 6px 8px;
  cursor: pointer;
  white-space: nowrap;
}
.icon-btn.back { font-size: 22px; padding: 4px 8px 4px 0; }

.screen { display: none; flex: 1; }
.screen.active { display: flex; flex-direction: column; }

.generator {
  padding: 16px;
  display: flex;
  flex-direction: column;
  min-height: calc(100vh - 52px);
}
.field-label {
  font-size: 13px;
  color: var(--muted);
  margin-bottom: 4px;
}
.selects { margin-bottom: 20px; }
.selects select {
  width: 100%;
  margin-bottom: 8px;
  font: inherit;
  font-size: 16px;
  color: var(--text);
  background: var(--primary-dark);
  border: 0;
  border-bottom: 1px solid var(--muted);
  padding: 8px 4px;
}
h2.section {
  font-size: 18px;
  margin: 0;
  font-weight: 700;
}
.hint {
  color: var(--muted);
  font-size: 14px;
  margin: 4px 0 0;
}

.toggles {
  display: flex;
  gap: 8px;
  margin-top: 12px;
}
.toggle {
  flex: 1;
  min-width: 0;
  border: 0;
  border-radius: 5px;
  padding: 10px 8px;
  font: inherit;
  font-size: 16px;
  cursor: pointer;
  background: var(--muted);
  color: var(--primary-dark);
}
.toggle.on {
  background: var(--accent);
  color: var(--text);
}

.dates {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 12px;
  font-size: 16px;
}
.date-field {
  flex: 1;
  position: relative;
}
.date-field input[type="text"] {
  width: 100%;
  height: 40px;
  text-align: center;
  font: inherit;
  font-size: 16px;
  color: var(--text);
  background: transparent;
  border: 0;
  border-bottom: 1px solid var(--muted);
  cursor: pointer;
}
.date-field input[type="date"] {
  position: absolute;
  inset: 0;
  opacity: 0;
  cursor: pointer;
}

.grow { flex: 1; }

.btn-report {
  width: 100%;
  height: 60px;
  margin-top: 24px;
  border: 0;
  border-radius: 10px;
  background: var(--accent);
  color: var(--text);
  font: inherit;
  font-size: 18px;
  cursor: pointer;
}
.btn-report:disabled { opacity: .5; cursor: default; }

.report {
  padding: 8px 16px 16px;
}
.totals-card {
  background: var(--primary-dark);
  border-radius: 8px;
  padding: 12px;
  margin-bottom: 8px;
}
.totals-card h2 {
  font-size: 16px;
  margin: 0 0 8px;
}
.total-row, .kv {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  padding: 2px 0;
  font-size: 16px;
}
.totals-card hr {
  border: 0;
  border-top: 1px solid var(--primary);
  margin: 8px 0;
}
.net-row {
  display: flex;
  justify-content: space-between;
  font-size: 18px;
  font-weight: 700;
}

.doc {
  padding: 12px 0 6px;
  border-bottom: 1.5px solid var(--primary);
  cursor: pointer;
}
.doc-top {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 12px;
}
.doc-type { font-size: 22px; }
.doc-date { font-size: 16px; margin-top: 2px; }
.doc-sum { font-size: 22px; white-space: nowrap; }
.doc-sum.sell { color: var(--green); }
.doc-sum.payback { color: var(--red); }

.pay {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  padding: 6px 0;
}
.pay-name { font-size: 16px; font-weight: 700; }
.pay-kind { font-size: 13px; color: var(--muted); }
.pay-sum { font-size: 16px; }

.empty {
  color: var(--muted);
  text-align: center;
  font-size: 16px;
  padding: 48px 24px;
}
.spinner {
  margin: 80px auto;
  width: 36px;
  height: 36px;
  border: 3px solid var(--muted);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin .8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

.details { padding: 8px 16px 24px; }
.details-date {
  text-align: center;
  font-size: 16px;
  margin: 8px 0 4px;
}
.pos { padding: 8px 0; border-bottom: 1.5px solid var(--primary-dark); }
.pos:last-child { border-bottom: 0; }
.pos-top { display: flex; justify-content: space-between; gap: 12px; font-size: 16px; }
.pos-meta { font-size: 16px; color: var(--muted); }
.pos-qty { text-align: right; }
.sum-line {
  display: flex;
  justify-content: space-between;
  margin-top: 12px;
  font-size: 22px;
  font-weight: 700;
}
.kkt { margin-top: 8px; font-size: 16px; }
.kkt .kv { padding: 4px 0; }
.customer { margin-top: 8px; font-size: 16px; }

.overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgb(0 0 0 / 45%);
  z-index: 20;
  align-items: flex-end;
  justify-content: center;
}
.overlay.open { display: flex; }
.overlay.center { align-items: center; }
.sheet {
  width: 100%;
  max-width: 520px;
  background: var(--sheet);
  border-radius: 20px 20px 0 0;
  padding: 16px;
}
.overlay.center .sheet { border-radius: 10px; margin: 16px; }
.sheet h3 { font-size: 24px; margin: 0 0 12px; font-weight: 500; }
.sheet label, .radio, .check {
  display: block;
  padding: 8px 0;
  font-size: 16px;
}
.sheet input[type="email"], .sheet input[type="text"] {
  width: 100%;
  font: inherit;
  font-size: 16px;
  color: var(--text);
  background: transparent;
  border: 0;
  outline: none;
}
.to-row { display: flex; align-items: center; gap: 4px; }
.to-row span { white-space: nowrap; }
.line { height: 1px; background: var(--muted); margin: 2px 0 8px; }
.from { color: var(--muted); font-size: 16px; margin-top: 12px; }
.file-chip {
  margin-top: 16px;
  background: var(--accent);
  border-radius: 10px;
  padding: 12px 16px;
  font-size: 16px;
  word-break: break-all;
}
.sheet .btn, .sheet .btn-secondary {
  width: 100%;
  margin-top: 12px;
  border: 0;
  border-radius: 10px;
  padding: 12px;
  font: inherit;
  font-size: 16px;
  cursor: pointer;
}
.sheet .btn { background: var(--accent); color: var(--text); }
.sheet .btn-secondary {
  background: var(--primary);
  color: var(--text);
}

.alert-title { font-size: 20px; margin: 0 0 8px; }
.alert-text { font-size: 16px; margin: 0 0 16px; }
.alert-ok {
  background: transparent;
  border: 0;
  color: var(--accent);
  font: inherit;
  font-size: 16px;
  font-weight: 700;
  cursor: pointer;
  float: right;
}

button:disabled { opacity: .55; cursor: default; }
hidden, [hidden] { display: none !important; }
