:root {
  --font-family:
    "Inter", "Adwaita Sans", system-ui, -apple-system, BlinkMacSystemFont,
    Roboto, "Segoe UI", "Helvetica Neue", Arial, "Noto Sans", sans-serif,
    "Apple Color Emoji", "Noto Color Emoji", "Segoe UI Emoji", "Segoe UI Symbol";
  --body-color: #efefef;
  --body-background: #1a1a1a;
  --input-border: 2px solid #555;
  --input-background: #222;
  --input-color: #efefef;
  --input-focus-border-color: #66b0ff;
  --input-focus-box-shadow: 0 0 0 3px rgba(102, 176, 255, 0.35);
  --button-primary-border-color: #555;
  --button-primary-background: #2a2a2a;
  --button-primary-color: #efefef;
  --button-primary-focus-border-color: #888;
  --button-primary-focus-background: #3a3a3a;
  --panel-background: #2a2a2a;
  --panel-border-color: #555;
  --item-border-color: #333;
  --total-background: #1e1e1e;
  --price-color: #8bc34a;
  --price-color-light: #6a9f3a;
  --card-background: #242424;
  --card-hover: #2e2e2e;
  --sheet-background: #222;
}

html {
  color-scheme: dark;
}

* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

body {
  font-family: var(--font-family);
  color: var(--body-color);
  background: var(--body-background);
  margin: 0 auto;
  max-width: 600px;
  min-height: 100dvh;
}

input[type="text"] {
  color: var(--input-color);
  background: var(--input-background);
  border: var(--input-border);
  border-radius: 10px;
  padding: 14px 16px;
  font-size: 1.05rem;
  width: 100%;
  appearance: none;
  outline: none;
}

input:focus {
  border-color: var(--input-focus-border-color);
  box-shadow: var(--input-focus-box-shadow);
}

button {
  font-family: var(--font-family);
  cursor: pointer;
}

/* ===== Session List ===== */

.list-header-bar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 16px;
  border-bottom: 2px solid var(--item-border-color);
  position: sticky;
  top: 0;
  background: var(--body-background);
  z-index: 10;
}

.app-title {
  font-size: 1.3rem;
  font-weight: 700;
}

.button-header {
  padding: 8px 14px;
  font-size: 0.85rem;
  border: 2px solid var(--button-primary-border-color);
  background: var(--button-primary-background);
  color: var(--button-primary-color);
  border-radius: 10px;
  font-weight: 600;
}

.button-header:hover,
.button-header:focus {
  border-color: var(--button-primary-focus-border-color);
  background: var(--button-primary-focus-background);
}

#sessionList {
  padding: 8px 16px;
}

.session-card {
  background: var(--card-background);
  border-radius: 12px;
  padding: 16px;
  margin-bottom: 8px;
  display: flex;
  align-items: center;
  gap: 12px;
  cursor: pointer;
  transition: background 0.15s;
}

.session-card:hover,
.session-card:active {
  background: var(--card-hover);
}

.session-card-info {
  flex: 1;
  min-width: 0;
}

.session-card-name {
  font-size: 1.05rem;
  font-weight: 600;
  margin-bottom: 3px;
}

.session-card-meta {
  font-size: 0.8rem;
  color: #888;
}

.session-card-total {
  font-size: 1.1rem;
  font-weight: 700;
  color: var(--price-color);
  white-space: nowrap;
  flex-shrink: 0;
}

.empty-state {
  text-align: center;
  padding: 60px 16px;
  color: #666;
  font-size: 1rem;
  line-height: 1.6;
}

/* ===== FAB ===== */

.fab-container {
  padding: 8px 16px 16px;
}

.fab {
  display: block;
  width: 100%;
  padding: 16px;
  font-size: 1.5rem;
  font-weight: 700;
  color: #fff;
  background: var(--price-color-light);
  border: none;
  border-radius: 12px;
  transition: background 0.15s;
}

.fab:hover,
.fab:focus {
  background: var(--price-color);
}

/* ===== Detail Header ===== */

.detail-header {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 16px;
  border-bottom: 2px solid var(--item-border-color);
  position: sticky;
  top: 0;
  background: var(--body-background);
  z-index: 10;
}

.back-btn {
  background: none;
  border: none;
  color: var(--body-color);
  font-size: 1.3rem;
  padding: 4px 8px;
  flex-shrink: 0;
}

.session-title {
  flex: 1;
  font-size: 1.1rem;
  font-weight: 600;
  cursor: pointer;
  padding: 4px 0;
}

/* ===== Total Bar ===== */

.total-bar {
  background: var(--total-background);
  padding: 16px;
  border-bottom: 2px solid var(--item-border-color);
}

.total-main {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.total-label {
  font-size: 0.95rem;
  color: #888;
  text-transform: uppercase;
  letter-spacing: 1.5px;
  font-weight: 600;
}

.total-value {
  font-size: 2rem;
  font-weight: 800;
  color: var(--price-color);
  letter-spacing: -0.5px;
}

.total-info {
  font-size: 0.72rem;
  color: #777;
  margin-top: 6px;
  line-height: 1.4;
}

/* ===== Add Bar ===== */

.add-bar {
  position: sticky;
  bottom: 0;
  padding: 8px 16px;
  background: var(--body-background);
  z-index: 10;
}

.add-btn-wide {
  display: block;
  width: 100%;
  padding: 16px;
  font-size: 1.5rem;
  font-weight: 700;
  color: #fff;
  background: var(--price-color-light);
  border: none;
  border-radius: 12px;
  transition: background 0.15s;
}

.add-btn-wide:hover,
.add-btn-wide:focus {
  background: var(--price-color);
}

/* ===== Item List ===== */

#itemList {
  padding: 0 16px;
}

.item {
  border-bottom: 1px solid var(--item-border-color);
  padding: 12px 0;
  display: flex;
  gap: 10px;
  align-items: flex-start;
}

.item-info {
  flex: 1;
  min-width: 0;
}

.item-name {
  font-size: 1.05rem;
  font-weight: 500;
  word-break: break-word;
  margin-bottom: 6px;
}

.item-qty-row {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
}

.qty-btn {
  width: 32px;
  height: 32px;
  border-radius: 8px;
  border: 2px solid var(--button-primary-border-color);
  background: var(--button-primary-background);
  color: var(--button-primary-color);
  font-size: 1.1rem;
  font-weight: 700;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  line-height: 1;
}

.qty-btn:hover,
.qty-btn:focus {
  border-color: var(--button-primary-focus-border-color);
  background: var(--button-primary-focus-background);
}

.qty-value {
  font-size: 1rem;
  font-weight: 700;
  min-width: 20px;
  text-align: center;
  color: var(--body-color);
}

.item-unit {
  font-size: 0.82rem;
  color: #888;
  margin-left: 2px;
}

.item-pfand {
  font-size: 0.78rem;
  color: #888;
}

.item-right {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 8px;
  flex-shrink: 0;
}

.item-price {
  font-size: 1.15rem;
  font-weight: 700;
  color: var(--price-color);
  white-space: nowrap;
}

.item-actions {
  display: flex;
  gap: 12px;
  flex-shrink: 0;
}

.action-edit,
.action-del {
  color: #777;
  cursor: pointer;
  background: none;
  border: none;
  text-decoration: underline;
  font-size: 0.82rem;
  padding: 2px;
}

.action-edit:hover,
.action-del:hover {
  color: var(--body-color);
}

.action-del:hover {
  color: #ef5350;
}

/* ===== Bottom Sheet ===== */

.sheet-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.5);
  z-index: 1000;
  display: flex;
  align-items: flex-end;
}

.bottom-sheet {
  width: 100%;
  max-width: 600px;
  margin: 0 auto;
  background: var(--sheet-background);
  border-radius: 20px 20px 0 0;
  padding: 12px 20px 32px;
  max-height: calc(100vh - 60px);
  overflow-y: auto;
  animation: slideUp 0.25s ease-out;
}

@keyframes slideUp {
  from { transform: translateY(100%); }
  to { transform: translateY(0); }
}

.sheet-handle {
  width: 40px;
  height: 4px;
  background: #555;
  border-radius: 2px;
  margin: 0 auto 16px;
}

.sheet-header {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 24px;
}

.sheet-back {
  background: none;
  border: none;
  color: var(--body-color);
  font-size: 1.3rem;
  padding: 4px 0;
}

.sheet-title {
  font-size: 1.1rem;
  font-weight: 600;
}

/* Price display in sheet */

.sheet-price-display {
  text-align: center;
  font-size: 3rem;
  font-weight: 800;
  color: var(--price-color);
  padding: 20px 0;
  letter-spacing: -1px;
  word-break: break-all;
}

.sheet-price-small {
  font-size: 1.5rem;
  padding: 8px 0 20px;
  color: var(--price-color);
}

/* Sign toggle */

.sheet-sign-row {
  display: flex;
  align-items: center;
  gap: 10px;
  justify-content: center;
  margin-bottom: 20px;
}

.sign-btn {
  width: 48px;
  height: 48px;
  border-radius: 12px;
  border: 2px solid var(--button-primary-border-color);
  background: var(--button-primary-background);
  color: var(--button-primary-color);
  font-size: 1.5rem;
  font-weight: 700;
  cursor: pointer;
}

.sign-btn:hover,
.sign-btn:focus {
  border-color: var(--button-primary-focus-border-color);
  background: var(--button-primary-focus-background);
}

.sign-label {
  font-size: 0.85rem;
  color: #888;
}

/* Numpad */

.sheet-numpad {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
  margin-bottom: 16px;
}

.num-btn {
  padding: 16px;
  font-size: 1.3rem;
  font-weight: 600;
  border: 2px solid var(--button-primary-border-color);
  background: var(--button-primary-background);
  color: var(--button-primary-color);
  border-radius: 12px;
  cursor: pointer;
  transition: background 0.1s;
}

.num-btn:hover,
.num-btn:focus {
  border-color: var(--button-primary-focus-border-color);
  background: var(--button-primary-focus-background);
}

.num-comma {
  font-weight: 800;
}

/* Sheet action button */

.sheet-action-btn {
  display: block;
  width: 100%;
  padding: 16px;
  font-size: 1.1rem;
  font-weight: 700;
  border: none;
  border-radius: 12px;
  cursor: pointer;
  transition: background 0.15s;
  color: #fff;
  background: var(--price-color-light);
}

.sheet-action-btn:hover,
.sheet-action-btn:focus {
  background: var(--price-color);
}

.sheet-action-btn:disabled {
  background: #444;
  color: #777;
  cursor: default;
}

.sheet-add-btn {
  margin-top: 8px;
}

/* Sheet field */

.sheet-field {
  margin-bottom: 16px;
}

/* ===== Confirm Sheet ===== */

.confirm-body {
  padding: 8px 0 24px;
  font-size: 1.05rem;
  color: var(--body-color);
  line-height: 1.5;
}

.confirm-actions {
  display: flex;
  gap: 10px;
}

.confirm-actions .button {
  flex: 1;
  text-align: center;
}

.confirm-del-btn {
  border: 2px solid #d14836;
  background: transparent;
  color: #d14836;
  font-weight: 600;
}

.confirm-del-btn:hover,
.confirm-del-btn:focus {
  background: #d14836;
  color: #fff;
}

/* ===== Delete button in edit modal ===== */

.modal-delete-section {
  padding-top: 12px;
  border-top: 2px solid #444;
}

.del-session-btn-inline {
  display: block;
  width: 100%;
  padding: 12px;
  font-size: 0.9rem;
  font-weight: 600;
  text-align: center;
  cursor: pointer;
  border-radius: 10px;
  border: 2px solid #d14836;
  background: transparent;
  color: #d14836;
}

.del-session-btn-inline:hover,
.del-session-btn-inline:focus {
  background: #d14836;
  color: #fff;
}

.button {
  display: inline-block;
  appearance: none;
  font-size: 0.9rem;
  cursor: pointer;
  padding: 10px 16px;
  border: 2px solid;
  border-radius: 10px;
  font-weight: 600;
}

.button-primary {
  border-color: var(--button-primary-border-color);
  background: var(--button-primary-background);
  color: var(--button-primary-color);
}

.button-primary:hover,
.button-primary:focus {
  border-color: var(--button-primary-focus-border-color);
  background: var(--button-primary-focus-background);
  color: var(--button-primary-color);
}

/* ===== Shared modal content styles (used inside bottom-sheets) ===== */

.modal-section {
  margin-bottom: 24px;
}

.modal-section:last-child {
  margin-bottom: 0;
}

.modal-section-title {
  font-size: 0.8rem;
  color: #666;
  margin-bottom: 10px;
  text-transform: uppercase;
  letter-spacing: 1px;
  font-weight: 600;
}

.modal-section input[type="text"] {
  border-radius: 10px;
}

.modal-buttons {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}

.modal-footer {
  margin-top: 24px;
  display: flex;
  gap: 10px;
  justify-content: flex-end;
  flex-wrap: wrap;
}

.modal-footer .button {
  flex: 1;
  text-align: center;
}

.import-area {
  width: 100%;
  min-height: 150px;
  background: var(--input-background);
  border: var(--input-border);
  border-radius: 10px;
  color: var(--input-color);
  padding: 12px;
  font-family: monospace;
  font-size: 0.85rem;
  resize: vertical;
  margin-bottom: 12px;
}

.import-area:focus {
  outline: none;
  border-color: var(--input-focus-border-color);
  box-shadow: var(--input-focus-box-shadow);
}

hr {
  margin: 1.2rem 0;
  border: none;
  border-top: 2px solid #444;
}

.app-footer {
  margin-top: 8px;
  font-size: 0.8rem;
  color: #555;
  text-align: center;
  padding: 0 16px 24px;
}

.app-footer a {
  color: #777;
  text-decoration: none;
}

.app-footer a:hover {
  text-decoration: underline;
}

.hidden {
  display: none !important;
}

/* ===== Export/Import ===== */

.ei-big-btn {
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 20px;
  margin: 8px 0;
  background: var(--button-primary-background);
  border: var(--input-border);
  border-radius: 14px;
  cursor: pointer;
  transition: background 0.15s;
}

.ei-big-btn:active {
  background: var(--card-hover);
}

.ei-big-icon {
  font-size: 1.6rem;
  margin-bottom: 4px;
}

.ei-big-label {
  font-size: 1.1rem;
  font-weight: 600;
}

.ei-big-desc {
  font-size: 0.8rem;
  color: #777;
  margin-top: 2px;
}

.ei-upload-area {
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 30px;
  margin: 12px 0;
  border: 2px dashed #555;
  border-radius: 14px;
  cursor: pointer;
  transition: background 0.15s;
}

.ei-upload-area:active {
  background: var(--card-hover);
}

.ei-upload-icon {
  font-size: 2rem;
  margin-bottom: 6px;
}

.ei-upload-text {
  font-size: 1rem;
  font-weight: 500;
}

.ei-or {
  text-align: center;
  color: #777;
  margin: 8px 0;
  font-size: 0.9rem;
}

.ei-summary {
  padding: 12px 0;
  font-size: 0.9rem;
  color: #999;
  text-align: center;
}

.sheet-action-btn {
  display: block;
  width: 100%;
  padding: 14px;
  margin-top: 12px;
  background: var(--button-primary-background);
  border: var(--input-border);
  border-radius: 10px;
  font-size: 1rem;
  font-weight: 500;
  cursor: pointer;
  color: var(--button-primary-color);
}

.sheet-action-btn:active {
  background: var(--card-hover);
}

/* ===== Consent Banner / Backup Nudge ===== */

.consent-banner {
  position: fixed;
  bottom: 0;
  left: 0;
  width: 100%;
  background: var(--card-background);
  border-top: 2px solid var(--item-border-color);
  z-index: 999;
  padding: 12px 16px;
  animation: slideUp 0.3s ease-out;
}

.consent-banner-content {
  max-width: 600px;
  margin: 0 auto;
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 0.82rem;
  color: var(--body-color);
  line-height: 1.4;
}

.consent-banner-content span {
  flex: 1;
}

.consent-btn {
  flex-shrink: 0;
  padding: 8px 14px;
  font-size: 0.82rem;
  font-weight: 600;
  border-radius: 8px;
  border: 2px solid var(--button-primary-border-color);
  background: var(--button-primary-background);
  color: var(--button-primary-color);
  cursor: pointer;
  white-space: nowrap;
}

.consent-btn-secondary {
  border-color: transparent;
  background: transparent;
  color: #888;
}

.consent-btn-secondary:hover {
  color: var(--body-color);
}

/* ===== Desktop ===== */

@media (min-width: 721px) {
  body {
    padding: 20px 0;
    min-height: unset;
  }

  input[type="text"] {
    padding: 12px 14px;
    font-size: 1rem;
  }

  .list-header-bar {
    border-radius: 12px 12px 0 0;
  }

  .session-card {
    padding: 14px 16px;
  }

  .fab {
    padding: 14px;
  }

  .total-bar {
    padding: 14px 16px;
  }

  #itemList {
    padding: 0 16px;
  }

  .bottom-sheet {
    max-width: 500px;
    margin: 0 auto;
    border-radius: 20px 20px 0 0;
  }

  .modal-footer .button {
    flex: none;
  }

  .item {
    padding: 10px 0;
  }

  .empty-state {
    padding: 40px 16px;
  }

  .add-btn-wide {
    padding: 14px;
  }

  .num-btn {
    padding: 14px;
  }
}

/* ===== Light Theme ===== */

@media (prefers-color-scheme: light) {
@font-face {
  font-family: "Inter";
  src: url("/assets/fonts/InterVariable.ttf") format("truetype");
  font-weight: 100 900;
  font-display: swap;
}

:root {
    --body-color: #1a1a1a;
    --body-background: #f2f2f2;
    --input-border: 2px solid #ccc;
    --input-background: #fff;
    --input-color: #1a1a1a;
    --input-focus-border-color: #4a90d9;
    --input-focus-box-shadow: 0 0 0 3px rgba(74, 144, 217, 0.25);
    --button-primary-border-color: #ccc;
    --button-primary-background: #fff;
    --button-primary-color: #1a1a1a;
    --button-primary-focus-border-color: #aaa;
    --button-primary-focus-background: #f0f0f0;
    --panel-background: #fff;
    --panel-border-color: #ddd;
    --item-border-color: #e0e0e0;
    --total-background: #fff;
    --price-color: #2e7d32;
    --price-color-light: #388e3c;
    --card-background: #fff;
    --card-hover: #f7f7f7;
    --sheet-background: #f7f7f7;
  }

  html {
    color-scheme: light;
  }

  .total-bar {
    border-bottom: 2px solid #e0e0e0;
  }

  .detail-header {
    border-bottom: 2px solid #e0e0e0;
  }

  .list-header-bar {
    border-bottom: 2px solid #e0e0e0;
  }

  .modal-delete-section {
    border-top-color: #ddd;
  }

  .del-session-btn-inline {
    border-color: #d14836;
  }

  .sheet-action-btn:disabled {
    background: #ddd;
    color: #aaa;
  }
}

/* ===== Print Styles ===== */

@media print {
  body {
    background: #fff !important;
    color: #000 !important;
    padding: 0 !important;
    min-height: auto !important;
  }

  .fab,
  .fab-container,
  .add-bar,
  .list-header-bar,
  .app-footer,
  .sheet-overlay,
  .bottom-sheet,
  .item-actions,
  .back-btn,
  .button-header,
  .qty-btn,
  .detail-header,
  #sessionDetailView .add-bar {
    display: none !important;
  }

  body.printing-detail .total-bar {
    display: block !important;
  }

  .session-card {
    border: 1px solid #ccc;
    break-inside: avoid;
    background: #fff;
    color: #000;
  }

  #sessionList {
    padding: 0;
  }

  .item {
    border-bottom: 1px solid #ccc;
    background: #fff;
    color: #000;
  }

  .item-name {
    color: #000;
  }

  .item-unit,
  .item-pfand {
    color: #555;
  }

  .item-price {
    color: #000;
  }

  .empty-state {
    color: #555;
  }

  .total-main {
    padding: 10px 0;
  }

  .total-label {
    color: #555;
  }

  .total-value {
    color: #000;
  }

  body.printing-detail #sessionListView {
    display: none !important;
  }

  body.printing-detail #sessionDetailView {
    display: block !important;
  }

  body:not(.printing-detail) #sessionDetailView {
    display: none !important;
  }
}
