:root {
  color-scheme: light;
  --accent: #5b7cfa;
  --neutral: #f5f6fb;
  --ink: #1d2333;
  --muted: #6c7285;
  --paper: #ffffff;
  --shadow: 0 18px 45px rgba(30, 35, 60, 0.12);
  --report-cols: 0.8fr 2fr 0.6fr 0.7fr;
  --report-cols-edit: 0.8fr 2fr 0.6fr 0.7fr 2.25rem 2.6rem;
}

.dark {
  color-scheme: dark;
  --accent: #8aa5ff;
  --neutral: #1a2236;
  --ink: #e7ecff;
  --muted: #a7b1cc;
  --paper: #121a2c;
  --shadow: 0 18px 45px rgba(0, 0, 0, 0.45);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: "Space Grotesk", system-ui, sans-serif;
  color: var(--ink);
  background: radial-gradient(circle at top, #f8f9ff 0%, #e8ecff 55%, #dfe4ff 100%);
}


h1,
h2,
h3 {
  margin: 0 0 0.6rem;
}

p {
  margin: 0 0 1rem;
}

a {
  color: inherit;
}

.app {
  display: flex;
  min-height: 100vh;
}

.editor {
  width: 42%;
  min-width: 360px;
  background: var(--paper);
  padding: 2.5rem 2.75rem 4rem;
  overflow-y: auto;
  border-right: 1px solid rgba(90, 105, 160, 0.15);
}

.editor__header {
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
  margin-bottom: 2rem;
}

.editor__actions {
  display: flex;
  gap: 0.8rem;
  flex-wrap: wrap;
}

.preview {
  flex: 1;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: flex-start;
  padding: 3rem;
}

.preview--full {
  width: 100%;
  align-items: center;
  justify-content: flex-start;
}

.toolbar {
  width: min(260mm, 100%);
  display: flex;
  justify-content: space-between;
  gap: 1.5rem;
  align-items: flex-start;
  margin: 0 auto 1.5rem;
}

.toolbar__title {
  font-family: "Space Grotesk", system-ui, sans-serif;
  font-size: 1.6rem;
  margin: 0 0 0.4rem;
}

.toolbar__actions {
  justify-content: flex-start;
}

.preview .report {
  font-size: 0.9rem;
}

.preview .report__list-header {
  font-size: 0.6rem;
}

.preview .report__list li {
  font-size: 0.75rem;
}

.preview .report__grid {
  grid-template-columns: 1fr;
  gap: 1.25rem;
}

.panel {
  background: var(--neutral);
  border-radius: 1.5rem;
  padding: 1.5rem;
  margin-bottom: 1.5rem;
  border: 1px solid rgba(90, 105, 160, 0.12);
  box-shadow: 0 10px 30px rgba(60, 65, 100, 0.08);
}

.panel__header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
}

.field {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  margin-bottom: 1rem;
}

.field input,
.field select {
  padding: 0.65rem 0.8rem;
  border-radius: 0.75rem;
  border: 1px solid rgba(90, 105, 160, 0.3);
  font-size: 0.95rem;
  font-family: inherit;
}

.field input:focus,
.field select:focus {
  outline: 2px solid rgba(91, 124, 250, 0.35);
  border-color: var(--accent);
}

.list {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.list-header {
  display: grid;
  grid-template-columns: 0.9fr 1.1fr 1fr 0.8fr auto;
  gap: 0.6rem;
  align-items: center;
  font-size: 0.85rem;
  font-weight: 600;
  color: rgba(60, 70, 110, 0.65);
  text-transform: uppercase;
  letter-spacing: 0.03em;
}

.list-item {
  display: grid;
  grid-template-columns: 0.9fr 1.1fr 1fr 0.8fr auto;
  gap: 0.6rem;
  align-items: center;
}

.list-item input {
  width: 100%;
}

.btn {
  border: none;
  padding: 0.55rem 1rem;
  border-radius: 999px;
  font-family: inherit;
  background: var(--paper);
  color: var(--ink);
  box-shadow: 0 4px 12px rgba(30, 35, 60, 0.12);
  cursor: pointer;
  transition: transform 0.15s ease, box-shadow 0.15s ease;
}

.btn:hover {
  transform: translateY(-1px);
  box-shadow: 0 8px 18px rgba(30, 35, 60, 0.15);
}

.btn--primary {
  background: var(--accent);
  color: white;
}

.btn--small {
  padding: 0.45rem 0.85rem;
  font-size: 0.85rem;
}

.btn--ghost {
  border: 1px dashed rgba(207, 0, 15);
  background: transparant;
  box-shadow: none;
}
.btn--ghost--2 {
  border: 1px dashed green;
  background: transparent;
  box-shadow: none;
}
.actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
  margin-bottom: 1rem;
}

.report {
  width: min(260mm, 100%);
  background: var(--paper);
  border-radius: 2rem;
  padding: 2.15rem;
  box-shadow: var(--shadow);
  font-family: "Space Grotesk", system-ui, sans-serif;
  font-size: 0.95rem;
}

.report__header {
  display: flex;
  justify-content: space-between;
  gap: 2rem;
  align-items: flex-start;
  margin-bottom: 2.5rem;
}

.report__section-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
}

.report__section-actions {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 0.75rem;
  flex-wrap: nowrap;
}

.report__section-actions .btn {
  white-space: nowrap;
  flex: 0 0 auto;
}

.report__filter {
  flex: 1 1 14rem;
  min-width: 8rem;
  width: auto;
}

.report__title-input,
.report__subtitle-input {
  width: 100%;
  font: inherit;
  border: none;
  background: transparent;
  padding: 0;
  margin: 0;
  color: inherit;
}

.report__title-input {
  font-family: "Space Grotesk", system-ui, sans-serif;
  font-weight: 700;
  font-size: 2rem;
  line-height: 1.15;
  margin-bottom: 0.4rem;
}

.report__subtitle-input {
  font-family: "Space Grotesk", system-ui, sans-serif;
  font-weight: 600;
  font-size: 1.25rem;
  line-height: 1.2;
  margin-bottom: 0;
}

.report__title-input:focus,
.report__subtitle-input:focus {
  outline: 2px solid rgba(91, 124, 250, 0.35);
  border-radius: 0.5rem;
}

.report__meta {
  display: grid;
  gap: 1.5rem;
  text-align: right;
}

.report__grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 1.6rem;
  margin-bottom: 2.5rem;
}

.report__list {
  list-style: none;
  padding: 0;
  margin: 0;
  display: grid;
  gap: 0.75rem;
}

.report__list-header {
  display: grid;
  grid-template-columns: var(--report-cols);
  margin-bottom: 0.5rem;
  font-size: 0.65rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: rgba(255, 255, 255, 0.9);
  font-family: "Space Grotesk", sans-serif;
  background: #1f2a4a;
  border-radius: 0.85rem;
  overflow: hidden;
}

.report__list-header--editable {
  grid-template-columns: var(--report-cols-edit);
}

.report__list-header span {
  padding: 0.45rem 0.6rem;
  border-right: 1px solid rgba(255, 255, 255, 0.2);
}

.report__list-header span:last-child {
  border-right: none;
}

.report__list li {
  border-radius: 0.85rem;
  background: #f5f7ff;
  display: grid;
  grid-template-columns: var(--report-cols);
  align-items: center;
  font-family: "Space Grotesk", sans-serif;
  font-size: 0.78rem;
  border: 1px solid rgba(90, 105, 160, 0.2);
  overflow: hidden;
}

.report__list li span,
.report__list li strong {
  padding: 0.45rem 0.6rem;
  border-right: 1px solid rgba(90, 105, 160, 0.2);
}

.report__list li strong {
  text-align: right;
  font-weight: 700;
  color: #1f2a4a;
}

.report__list li span:last-child,
.report__list li strong:last-child {
  border-right: none;
}

.report__list li {
  padding: 0.75rem 1rem;
  border-radius: 1rem;
  background: var(--neutral);
  display: grid;
  grid-template-columns: var(--report-cols);
  gap: 0.75rem;
  align-items: center;
  font-family: "Space Grotesk", sans-serif;
  font-size: 0.8rem;
}

.report__list.is-editable li {
  grid-template-columns: var(--report-cols-edit);
}

.inline-input {
  width: 100%;
  border: 1px solid rgba(90, 105, 160, 0.25);
  border-radius: 0.65rem;
  padding: 0.35rem 0.5rem;
  font-family: inherit;
  font-size: 0.82rem;
  background: rgba(255, 255, 255, 0.85);
}

.inline-input:focus {
  outline: 2px solid rgba(91, 124, 250, 0.35);
  border-color: var(--accent);
  background: white;
}

.inline-input--amount {
  text-align: right;
}

.inline-input--tax {
  width: 5.25rem;
  display: inline-block;
  margin: 0 0.35rem;
  text-align: right;
}

.row-remove {
  width: 2.25rem;
  height: 2.25rem;
  padding: 0;
  border-radius: 999px;
  border: 1px solid rgba(207, 0, 15, 0.45);
  background: rgba(255, 255, 255, 0.9);
  color: rgba(207, 0, 15, 0.95);
  cursor: pointer;
  font-weight: 700;
  display: grid;
  place-items: center;
}

.row-move {
  width: 2.25rem;
  height: 2.25rem;
  padding: 0;
  border-radius: 999px;
  border: 1px solid rgba(90, 105, 160, 0.45);
  background: rgba(255, 255, 255, 0.9);
  color: rgba(60, 70, 110, 0.95);
  cursor: grab;
  font-weight: 700;
  display: grid;
  place-items: center;
}

.row-move:hover {
  background: rgba(90, 105, 160, 0.08);
}

.report__list.is-editable li.is-dragging {
  opacity: 0.55;
  cursor: grabbing;
}

.report__list.is-editable li.is-drop-target {
  outline: 2px dashed rgba(91, 124, 250, 0.55);
  outline-offset: 2px;
}

.row-remove:hover {
  background: rgba(207, 0, 15, 0.08);
}

.row-remove--confirm {
  border-color: rgba(46, 140, 90, 0.7);
  color: rgba(46, 140, 90, 0.95);
}

.row-remove--confirm:hover {
  background: rgba(46, 140, 90, 0.1);
}

.no-print {
  display: initial;
}

.only-print {
  display: none;
}

.report__total {
  margin-top: 0.9rem;
  padding: 0.85rem 1rem;
  border-radius: 1rem;
  border: 1px solid rgba(90, 105, 160, 0.2);
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-family: "Space Grotesk", sans-serif;
}

.report__total--income {
  border-color: rgba(46, 140, 90, 0.6);
}

.report__total--expense {
  border-color: rgba(200, 70, 60, 0.6);
}

.summary {
  display: grid;
  gap: 0.85rem;
  padding-top: 1.5rem;
  border-top: 1px solid rgba(90, 105, 160, 0.2);
}

.summary__title {
  margin: 0 0 0.6rem;
  font-size: 1.4rem;
  letter-spacing: 0;
  text-transform: none;
  color: var(--ink);
}

.summary__row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto 1.4rem;
  gap: 1rem;
  align-items: baseline;
  padding: 0.35rem 0.1rem;
}

.summary__row .label {
  margin-bottom: 0;
}

.summary__sign {
  font-weight: 700;
  color: rgba(60, 70, 110, 0.7);
  text-align: right;
}

.summary__row strong {
  text-align: right;
}

.summary__row--subtotal {
  border-top: 1px solid rgba(90, 105, 160, 0.3);
  padding-top: 0.65rem;
}

.summary__net {
  background: #24345f;
  color: white;
  padding: 1rem 1.25rem;
  border-radius: 1.1rem;
}

.summary__net .label,
.summary__net .summary__sign {
  color: rgba(255, 255, 255, 0.85);
}

.summary__net .summary__sign {
  color: rgba(255, 255, 255, 0.9);
}

.summary__net .label {
  font-size: 0.9rem;
}

.label {
  display: block;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  font-size: 0.7rem;
  color: var(--muted);
  margin-bottom: 0.35rem;
}

.eyebrow {
  text-transform: uppercase;
  letter-spacing: 0.2em;
  font-size: 0.65rem;
  color: var(--muted);
}

.muted {
  color: var(--muted);
}

.toast {
  position: sticky;
  top: 1rem;
  margin-bottom: 1.25rem;
  padding: 0.75rem 1rem;
  border-radius: 999px;
  background: rgba(91, 124, 250, 0.15);
  color: var(--accent);
  font-weight: 600;
  width: fit-content;
  opacity: 0;
  transform: translateY(-8px);
  transition: opacity 0.25s ease, transform 0.25s ease;
}

.toast.is-visible {
  opacity: 1;
  transform: translateY(0);
}

@media (max-width: 1100px) {
  .app {
    flex-direction: column;
  }

  .editor {
    width: 100%;
    min-width: 100%;
    border-right: none;
  }

  .preview {
    padding: 2rem;
  }

  .toolbar {
    flex-direction: column;
    align-items: stretch;
  }

  .report__header {
    flex-direction: column;
    text-align: left;
  }

  .report__meta {
    text-align: left;
  }

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

}

@page {
  margin: 8mm;
}

@media print {
  body {
    background: white;
  }

  .editor,
  .toolbar,
  .toast {
    display: none;
  }

  .no-print {
    display: none !important;
  }

  .only-print {
    display: inline !important;
  }

  .preview {
    padding: 0;
  }

  .report {
    box-shadow: none;
    border-radius: 0;
    width: 100%;
    min-height: 281mm;
    padding: 8mm 6mm;
  }

  .report__header {
    flex-direction: row;
    align-items: flex-start;
  }

  .report__meta {
    text-align: right;
    margin-left: auto;
  }

  .report__list-header {
    -webkit-print-color-adjust: exact;
    print-color-adjust: exact;
  }

  .report__list-header--editable {
    grid-template-columns: var(--report-cols);
  }

  .report__list.is-editable li {
    grid-template-columns: var(--report-cols);
  }

  .inline-input {
    border: none;
    background: transparent;
    padding: 0;
  }

  .summary__net {
    -webkit-print-color-adjust: exact;
    print-color-adjust: exact;
  }

  .auth-overlay,
  .user-bar {
    display: none !important;
  }
}

/* ===== Auth overlay ===== */
.auth-overlay {
  position: fixed;
  inset: 0;
  background: rgba(15, 20, 45, 0.65);
  backdrop-filter: blur(6px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
}

.auth-overlay[hidden] {
  display: none;
}

.auth-card {
  background: var(--paper);
  border-radius: 1.75rem;
  padding: 2.5rem 2.75rem;
  width: min(420px, 92vw);
  box-shadow: var(--shadow);
}

.auth-card__title {
  font-size: 1.6rem;
  margin: 0.25rem 0 1.5rem;
}

.auth-tabs {
  display: flex;
  gap: 0.5rem;
  margin-bottom: 1.5rem;
  border-bottom: 1px solid rgba(90, 105, 160, 0.2);
  padding-bottom: 0.75rem;
}

.auth-tab {
  background: none;
  border: none;
  font-family: inherit;
  font-size: 0.95rem;
  font-weight: 600;
  color: var(--muted);
  cursor: pointer;
  padding: 0.4rem 0.75rem;
  border-radius: 0.5rem;
  transition: color 0.15s ease, background 0.15s ease;
}

.auth-tab.is-active {
  color: var(--accent);
  background: rgba(91, 124, 250, 0.1);
}

.auth-form .field {
  margin-bottom: 1.1rem;
}

.auth-form .field label {
  display: block;
  font-size: 0.8rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--muted);
  margin-bottom: 0.4rem;
}

.auth-form .field input {
  width: 100%;
  padding: 0.7rem 0.9rem;
  border-radius: 0.75rem;
  border: 1px solid rgba(90, 105, 160, 0.3);
  font-size: 0.95rem;
  font-family: inherit;
  background: var(--neutral);
  box-sizing: border-box;
}

.auth-form .field input:focus {
  outline: 2px solid rgba(91, 124, 250, 0.35);
  border-color: var(--accent);
  background: white;
}

.auth-error {
  font-size: 0.85rem;
  color: rgba(207, 0, 15, 0.9);
  min-height: 1.4em;
  margin: 0 0 0.75rem;
}

.auth-submit {
  width: 100%;
  padding: 0.75rem;
  font-size: 1rem;
  font-weight: 600;
  border-radius: 0.85rem;
}

/* ===== User bar ===== */
.user-bar {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  width: 100%;
  padding-bottom: 0.5rem;
  margin-bottom: 0.25rem;
  border-bottom: 1px solid rgba(90, 105, 160, 0.12);
}

.user-bar__email {
  font-size: 0.8rem;
  margin-right: auto;
}

.theme-toggle-icon {
  width: 2.2rem;
  min-width: 2.2rem;
  padding: 0;
  border: none;
  background: transparent;
  box-shadow: none;
  text-align: center;
  font-size: 1rem;
  line-height: 1;
  color: var(--muted);
  cursor: pointer;
  display: inline-grid;
  place-items: center;
}

.theme-toggle-icon:hover {
  color: var(--ink);
}

.theme-toggle-icon:focus-visible {
  outline: 2px solid rgba(91, 124, 250, 0.35);
  border-radius: 0.5rem;
}

.theme-toggle-icon wa-icon {
  font-size: 1.05rem;
}

/* ===== Sync status ===== */
.sync-status {
  font-size: 0.8rem;
  color: var(--muted);
  align-self: center;
  transition: opacity 0.3s;
}
.sync-status.is-error {
  color: #c00;
}

/* ===== Overzichten dropdown ===== */
.overzichten-menu {
  position: relative;
}

.overzichten-dropdown {
  position: absolute;
  top: calc(100% + 0.5rem);
  left: 0;
  background: var(--paper);
  border-radius: 1rem;
  box-shadow: var(--shadow);
  border: 1px solid rgba(90, 105, 160, 0.15);
  min-width: 260px;
  z-index: 200;
  padding: 0.5rem 0;
}

.overzichten-dropdown[hidden] {
  display: none;
}

.overzichten-list {
  list-style: none;
  padding: 0;
  margin: 0;
  max-height: 260px;
  overflow-y: auto;
}

.overzichten-list li {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  padding: 0.55rem 1rem;
  font-size: 0.88rem;
  border-bottom: 1px solid rgba(90, 105, 160, 0.08);
  cursor: pointer;
  transition: background 0.12s ease;
}

.overzichten-list li:last-child {
  border-bottom: none;
}

.overzichten-list li:hover {
  background: var(--neutral);
}

.overzichten-list li.is-active {
  font-weight: 600;
  color: var(--accent);
}

.overzichten-list__title {
  flex: 1;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.overzichten-list__date {
  font-size: 0.75rem;
  color: var(--muted);
  white-space: nowrap;
}

.overzichten-list__delete {
  background: none;
  border: none;
  cursor: pointer;
  color: rgba(207, 0, 15, 0.7);
  font-size: 0.85rem;
  padding: 0.2rem 0.4rem;
  border-radius: 0.4rem;
  flex-shrink: 0;
}

.overzichten-list__delete:hover {
  background: rgba(207, 0, 15, 0.08);
}

.overzichten-dropdown__actions {
  padding: 0.5rem 1rem;
  border-top: 1px solid rgba(90, 105, 160, 0.12);
}

.dark body {
  background: radial-gradient(circle at top, #0e1423 0%, #121b2f 55%, #182340 100%);
}

.dark .editor {
  border-right: 1px solid rgba(148, 169, 255, 0.18);
}

.dark .panel {
  border-color: rgba(148, 169, 255, 0.2);
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.3);
}

.dark .btn {
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.35);
}

.dark .btn--ghost {
  border-color: rgba(255, 123, 123, 0.75);
}

.dark .btn--ghost--2 {
  border-color: rgba(121, 221, 137, 0.8);
}

.dark .report {
  border: 1px solid rgba(148, 169, 255, 0.2);
}

.dark .report__list-header {
  background: #0e1527;
}

.dark .report__list li strong {
  color: var(--ink);
}

.dark .inline-input {
  border-color: rgba(148, 169, 255, 0.35);
  background: rgba(17, 25, 44, 0.85);
  color: var(--ink);
}

.dark .inline-input:focus {
  background: #0f182c;
}

.dark .row-remove,
.dark .row-move {
  background: rgba(17, 25, 44, 0.85);
}

.dark .summary__net {
  background: #0f182c;
}

.dark .toast {
  background: rgba(138, 165, 255, 0.22);
  color: #dbe5ff;
}

.dark .auth-card {
  border: 1px solid rgba(148, 169, 255, 0.22);
}

.dark .auth-form .field input {
  border-color: rgba(148, 169, 255, 0.35);
  background: #161f36;
  color: var(--ink);
}

.dark .auth-form .field input:focus {
  background: #121a2f;
}

.dark .user-bar,
.dark .auth-tabs,
.dark .summary,
.dark .summary__row--subtotal,
.dark .overzichten-dropdown__actions {
  border-color: rgba(148, 169, 255, 0.22);
}

.dark .overzichten-dropdown {
  border-color: rgba(148, 169, 255, 0.22);
}

.dark .overzichten-list li {
  border-color: rgba(148, 169, 255, 0.14);
}

.dark #overzichtenMenuBtn,
.dark #saveCloudBtn {
  background: #16a085;
}
