/* ============================================================
   SKG Kasse – Apple Human Interface Guidelines Design System
   ============================================================ */

/* ── System Colors ── */
:root {
  --sys-blue:   #007aff;
  --sys-green:  #34c759;
  --sys-red:    #ff3b30;
  --sys-orange: #ff9500;
  --sys-yellow: #ffcc00;
  --sys-indigo: #5856d6;

  --sys-bg:                    #ffffff;
  --sys-secondary-bg:          #f2f2f7;
  --sys-grouped-bg:            #f2f2f7;
  --sys-secondary-grouped-bg:  #ffffff;
  --sys-tertiary-grouped-bg:   #f2f2f7;

  --sys-label:            #000000;
  --sys-secondary-label:  rgba(60, 60, 67, .60);
  --sys-tertiary-label:   rgba(60, 60, 67, .30);
  --sys-placeholder:      rgba(60, 60, 67, .30);
  --sys-separator:        rgba(60, 60, 67, .29);
  --sys-opaque-sep:       #c6c6c8;

  --sys-fill:            rgba(120, 120, 128, .20);
  --sys-secondary-fill:  rgba(120, 120, 128, .16);

  --nav-bg:  rgba(242, 242, 247, .85);
  --tab-bg:  rgba(242, 242, 247, .85);

  --nav-height:  30px;
  --tab-height:  20px;

  --radius-xs: 6px;
  --radius-sm: 10px;
  --radius:    12px;
  --radius-lg: 16px;
  --radius-xl: 20px;

  --shadow-sm: 0 1px 3px rgba(0,0,0,.10), 0 1px 2px rgba(0,0,0,.06);
  --shadow:    0 4px 12px rgba(0,0,0,.10), 0 2px 4px rgba(0,0,0,.06);
  --shadow-lg: 0 10px 32px rgba(0,0,0,.14), 0 4px 8px rgba(0,0,0,.08);
}

@media (prefers-color-scheme: dark) {
  :root {
    --sys-blue:   #0a84ff;
    --sys-green:  #30d158;
    --sys-red:    #ff453a;
    --sys-orange: #ff9f0a;
    --sys-yellow: #ffd60a;
    --sys-indigo: #5e5ce6;

    --sys-bg:                    #000000;
    --sys-secondary-bg:          #1c1c1e;
    --sys-grouped-bg:            #000000;
    --sys-secondary-grouped-bg:  #1c1c1e;
    --sys-tertiary-grouped-bg:   #2c2c2e;

    --sys-label:            #ffffff;
    --sys-secondary-label:  rgba(235, 235, 245, .60);
    --sys-tertiary-label:   rgba(235, 235, 245, .30);
    --sys-placeholder:      rgba(235, 235, 245, .30);
    --sys-separator:        rgba(84, 84, 88, .65);
    --sys-opaque-sep:       #38383a;

    --sys-fill:            rgba(120, 120, 128, .36);
    --sys-secondary-fill:  rgba(120, 120, 128, .28);

    --nav-bg:  rgba(28, 28, 30, .90);
    --tab-bg:  rgba(28, 28, 30, .90);
  }
}

/* ── Reset ── */
*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html {
  touch-action: manipulation;
  -webkit-text-size-adjust: 100%;
  height: 100%;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Helvetica Neue', sans-serif;
  background: var(--sys-grouped-bg);
  color: var(--sys-label);
  line-height: 1.4;
  height: 100%;
  overflow: hidden;
  -webkit-font-smoothing: antialiased;
  touch-action: manipulation;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0,0,0,0);
  white-space: nowrap;
  border: 0;
}


/* ============================================================
   LOGIN SCREEN
   ============================================================ */

.login-overlay {
  position: fixed;
  inset: 0;
  background: var(--sys-grouped-bg);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 2000;
  padding: env(safe-area-inset-top, 20px) env(safe-area-inset-right, 0) env(safe-area-inset-bottom, 0) env(safe-area-inset-left, 0);
}

.login-card {
  width: 100%;
  max-width: 360px;
  padding: 0 1.25rem;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0;
}

.login-brand {
  text-align: center;
  margin-bottom: 2rem;
}

.login-logo {
  width: 72px;
  height: 72px;
  border-radius: 18px;
  box-shadow: var(--shadow);
  margin-bottom: .75rem;
}

.login-app-title {
  font-size: 1.75rem;
  font-weight: 700;
  letter-spacing: -.02em;
  color: var(--sys-label);
  margin-bottom: .2rem;
}

.login-subtitle {
  font-size: .9rem;
  color: var(--sys-secondary-label);
}

/* PIN dots row */
.login-pin-dots {
  font-size: 1.6rem;
  letter-spacing: .55rem;
  height: 2rem;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--sys-label);
  margin-bottom: .5rem;
  user-select: none;
  min-width: 200px;
  text-align: center;
}

.ios-pin-dots {
  font-size: 1.4rem;
  letter-spacing: .5rem;
  height: 1.8rem;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--sys-label);
  margin: .5rem 0;
  user-select: none;
}

.login-error {
  min-height: 1.25rem;
  text-align: center;
  color: var(--sys-red);
  font-size: .9rem;
  font-weight: 600;
  margin-bottom: .5rem;
}

/* iOS-style PIN pad (circular keys) */
.ios-pinpad {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: .75rem;
  width: 100%;
  max-width: 300px;
  margin: .5rem auto;
}

.ios-key {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  width: 76px;
  height: 76px;
  border-radius: 50%;
  background: var(--sys-secondary-grouped-bg);
  border: none;
  cursor: pointer;
  transition: background .12s, transform .08s;
  user-select: none;
  -webkit-tap-highlight-color: transparent;
  position: relative;
  box-shadow: var(--shadow-sm);
  color: var(--sys-label);
  justify-self: center;
}

.ios-key:active {
  background: var(--sys-fill);
  transform: scale(.94);
}

.ios-key-digit {
  font-size: 1.5rem;
  font-weight: 400;
  line-height: 1;
  letter-spacing: 0;
}

.ios-key-spacer {
  width: 76px;
  height: 76px;
  justify-self: center;
}

.ios-key-back {
  background: var(--sys-secondary-bg);
  color: var(--sys-label);
}

.ios-key-back svg {
  opacity: .75;
}

.ios-key-text {
  font-size: .95rem;
  font-weight: 600;
  color: var(--sys-blue);
  background: transparent;
  box-shadow: none;
  width: 76px;
  height: 76px;
}

.login-hint {
  text-align: center;
  color: var(--sys-tertiary-label);
  font-size: .8rem;
  margin-top: 1rem;
}


/* ============================================================
   APP SHELL
   ============================================================ */

.app {
  display: flex;
  flex-direction: column;
  height: 100%;
  height: 100dvh;
  background: var(--sys-grouped-bg);
}


/* ============================================================
   NAVIGATION BAR
   ============================================================ */

.nav-bar {
  position: relative;
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: calc(var(--nav-height) + env(safe-area-inset-top, 0px));
  padding-top: env(safe-area-inset-top, 0px);
  padding-left: max(1rem, env(safe-area-inset-left, 0px));
  padding-right: max(1rem, env(safe-area-inset-right, 0px));
  background: var(--nav-bg);
  backdrop-filter: saturate(180%) blur(20px);
  -webkit-backdrop-filter: saturate(180%) blur(20px);
  border-bottom: .5px solid var(--sys-separator);
  flex-shrink: 0;
}

.nav-bar-leading,
.nav-bar-trailing {
  display: flex;
  align-items: center;
  gap: .25rem;
  min-width: 80px;
}

.nav-bar-trailing {
  justify-content: flex-end;
}

.nav-bar-center {
  display: flex;
  align-items: center;
  gap: .4rem;
  flex: 1;
  justify-content: center;
}

.nav-logo {
  width: 22px;
  height: 22px;
  border-radius: 5px;
}

.nav-title {
  font-size: 1.0625rem;
  font-weight: 600;
  color: var(--sys-label);
  letter-spacing: -.01em;
}

.nav-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  border-radius: 50%;
  border: none;
  background: transparent;
  color: var(--sys-blue);
  cursor: pointer;
  position: relative;
  -webkit-tap-highlight-color: transparent;
  transition: background .12s;
}

.nav-btn:active {
  background: var(--sys-fill);
}

.nav-btn-destructive {
  color: var(--sys-red);
}

.nav-icon {
  width: 20px;
  height: 20px;
}

.sync-pending-count:empty { display: none; }
.sync-pending-count:not(:empty) {
  position: absolute;
  top: 2px;
  right: 2px;
  min-width: 16px;
  height: 16px;
  padding: 0 4px;
  border-radius: 999px;
  background: var(--sys-red);
  color: #fff;
  font-size: .65rem;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  line-height: 1;
}

.is-offline .nav-btn[id="sync-server-btn"] {
  opacity: .4;
}


/* ============================================================
   CONTENT AREA
   ============================================================ */

.app-content {
  flex: 1;
  overflow-y: auto;
  overflow-x: hidden;
  -webkit-overflow-scrolling: touch;
  overscroll-behavior-y: contain;
}


/* ============================================================
   TAB BAR
   ============================================================ */

.tab-bar {
  display: flex;
  align-items: flex-start;
  justify-content: space-around;
  padding-top: .35rem;
  padding-bottom: max(0px, env(safe-area-inset-bottom, 0px));
  padding-left: env(safe-area-inset-left, 0px);
  padding-right: env(safe-area-inset-right, 0px);
  background: var(--tab-bg);
  backdrop-filter: saturate(180%) blur(20px);
  -webkit-backdrop-filter: saturate(180%) blur(20px);
  border-top: .5px solid var(--sys-separator);
  flex-shrink: 0;
  z-index: 100;
}

.tab-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: .25rem;
  flex: 1;
  border: none;
  background: transparent;
  color: var(--sys-secondary-label);
  cursor: pointer;
  padding: 0 .5rem;
  -webkit-tap-highlight-color: transparent;
  transition: color .15s;
}

.tab-item.active {
  color: var(--sys-blue);
}

.tab-item:active {
  opacity: .7;
}

.tab-icon {
  width: 24px;
  height: 24px;
}

.tab-label {
  font-size: .65rem;
  font-weight: 500;
  letter-spacing: .01em;
}


/* ============================================================
   VIEW: KASSE
   ============================================================ */

.view-kasse {
  display: block;
}

.view-kasse.hidden {
  display: none;
}

.kasse-layout {
  display: grid;
  grid-template-columns: 1fr 300px;
  grid-template-rows: auto 1fr;
  gap: 0;
  min-height: calc(100dvh - var(--nav-height) - env(safe-area-inset-top, 0px) - var(--tab-height) - env(safe-area-inset-bottom, 0px));
}

/* Desktop: subtabs row 1 col 1, kasse-main row 2 col 1, order-section spans both rows col 2 */
.kasse-subtabs {
  grid-column: 1;
  grid-row: 1;
}

.kasse-main {
  grid-column: 1;
  grid-row: 2;
  padding: .4rem .75rem .75rem;
  display: flex;
  flex-direction: column;
  gap: .5rem;
  min-width: 0;
  overflow: visible;
}

.order-section {
  grid-column: 2;
  grid-row: 1 / 3;
}

/* Subtabs (Standard / VIP) */
.kasse-subtabs {
  display: flex;
  gap: .3rem;
  padding: .3rem;
  background: var(--sys-fill);
  border-radius: 10px;
  flex-shrink: 0;
}

.kasse-subtab {
  flex: 1;
  padding: .55rem 1rem;
  background: transparent;
  border: none;
  border-radius: 8px;
  color: var(--sys-label);
  font-family: inherit;
  font-size: .95rem;
  font-weight: 600;
  cursor: pointer;
  transition: background .15s, box-shadow .15s;
  -webkit-tap-highlight-color: transparent;
}

.kasse-subtab[data-subtab="standard"].active {
  background: var(--sys-blue);
  color: #fff;
  box-shadow: 0 2px 8px rgba(0, 122, 255, .35);
}

.kasse-subtab[data-subtab="vip"].active {
  background: #c8920a;
  color: #fff;
  box-shadow: 0 2px 8px rgba(200, 146, 10, .40);
}

.kasse-subtab:disabled {
  opacity: .35;
  cursor: not-allowed;
}

.kasse-subtab.is-locked {
  opacity: .45;
  cursor: not-allowed;
}

/* Item grid */
.items-section {
  flex: 1;
  min-height: 0;
}

.items-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(130px, 1fr));
  gap: .4rem;
}

.vip-grid {
  grid-template-columns: repeat(auto-fill, minmax(130px, 1fr));
}

/* Drink buttons */
.drink-btn {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: .25rem;
  padding: .6rem .4rem;
  height: 120px;
  background: var(--sys-secondary-grouped-bg);
  border: .5px solid var(--sys-separator);
  border-radius: var(--radius);
  color: var(--sys-label);
  font-family: inherit;
  font-size: .95rem;
  font-weight: 500;
  cursor: pointer;
  transition: background .12s, transform .08s;
  position: relative;
  -webkit-tap-highlight-color: transparent;
  box-shadow: var(--shadow-sm);
}

.drink-btn:active {
  background: var(--sys-fill);
  transform: scale(.97);
}

@keyframes drinkAdded {
  0%   { transform: scale(1);    box-shadow: 0 0 0 0 rgba(52,199,89,.55); }
  25%  { transform: scale(.93);  box-shadow: 0 0 0 0 rgba(52,199,89,.55); }
  55%  { transform: scale(1.07); box-shadow: 0 0 0 8px rgba(52,199,89,.0); }
  100% { transform: scale(1);    box-shadow: 0 0 0 0 rgba(52,199,89,.0); }
}

.drink-btn--added {
  animation: drinkAdded .32s ease;
  background: rgba(52, 199, 89, .18) !important;
}

.drink-btn .icon {
  font-size: 1.8rem;
  line-height: 1;
}

.drink-btn .name {
  display: -webkit-box;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
  overflow: hidden;
  text-overflow: ellipsis;
  line-height: 1.2;
  min-height: calc(2 * 1.2em);
  text-align: center;
}

.drink-btn .price {
  font-size: .78rem;
  color: var(--sys-secondary-label);
  font-variant-numeric: tabular-nums;
}

/* Alcohol-free highlight */
.drink-btn--af {
  background: rgba(52, 199, 89, .13);
  border-color: var(--sys-green);
  border-width: 1.5px;
}

.drink-btn--af:active {
  background: rgba(52, 199, 89, .22);
}

.drink-btn--af::after {
  content: 'AF';
  position: absolute;
  top: .3rem;
  left: .3rem;
  padding: .1rem .3rem;
  background: var(--sys-green);
  color: #fff;
  font-size: .6rem;
  font-weight: 700;
  border-radius: 4px;
  line-height: 1.4;
  letter-spacing: .03em;
}

/* VIP star */
.vip-crown {
  font-size: .9em;
  margin-left: .1rem;
}

/* Add item button */
.drink-btn--add {
  border-style: dashed;
  border-color: var(--sys-blue);
  background: rgba(0, 122, 255, .06);
  color: var(--sys-blue);
}

.drink-btn--add:active {
  background: rgba(0, 122, 255, .12);
}

.drink-btn--add .price,
.drink-btn--add .inventar-count {
  display: none !important;
}

/* Delete badge */
.drink-btn-delete {
  position: absolute;
  top: .3rem;
  right: .3rem;
  width: 20px;
  height: 20px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  background: var(--sys-fill);
  color: var(--sys-secondary-label);
  font-size: .75rem;
  font-weight: 700;
  cursor: pointer;
}

.drink-btn-delete:active {
  background: rgba(255, 59, 48, .2);
  color: var(--sys-red);
}


/* ── Order Section ── */
.order-section {
  background: var(--sys-secondary-grouped-bg);
  border-left: .5px solid var(--sys-separator);
  display: flex;
  flex-direction: column;
  padding: .75rem;
  gap: .5rem;
  overflow: hidden;
}

.section-title {
  font-size: .72rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .05em;
  color: var(--sys-secondary-label);
  padding-bottom: .35rem;
  border-bottom: .5px solid var(--sys-separator);
}

.order-list {
  list-style: none;
  flex: 1;
  overflow-y: auto;
  min-height: 80px;
  -webkit-overflow-scrolling: touch;
}

.order-empty {
  padding: 1.5rem 0;
  text-align: center;
  color: var(--sys-tertiary-label);
  font-size: .9rem;
}

.order-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: .6rem 0;
  border-bottom: .5px solid var(--sys-separator);
  gap: .5rem;
}

.order-item:last-child {
  border-bottom: none;
}

.order-item-info {
  display: flex;
  align-items: center;
  gap: .4rem;
  flex: 1;
  min-width: 0;
}

.order-item-qty {
  min-width: 22px;
  height: 22px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: var(--sys-blue);
  color: #fff;
  font-size: .7rem;
  font-weight: 700;
  border-radius: 6px;
  flex-shrink: 0;
}

.order-item-remove {
  width: 28px;
  height: 28px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: rgba(255, 59, 48, .12);
  border: none;
  border-radius: 50%;
  color: var(--sys-red);
  cursor: pointer;
  font-size: 1rem;
  font-weight: 600;
  flex-shrink: 0;
  -webkit-tap-highlight-color: transparent;
  transition: background .12s;
}

.order-item-remove:active {
  background: rgba(255, 59, 48, .25);
}

.order-total {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding-top: .5rem;
  border-top: .5px solid var(--sys-separator);
  font-size: 1rem;
  font-weight: 600;
  flex-shrink: 0;
}

.order-total-label {
  color: var(--sys-secondary-label);
}

.order-total-amount {
  color: var(--sys-green);
  font-variant-numeric: tabular-nums;
}

.order-complete-btn {
  width: 100%;
  padding: .75rem;
  background: var(--sys-green);
  border: none;
  border-radius: var(--radius-sm);
  color: #fff;
  font-family: inherit;
  font-size: .95rem;
  font-weight: 600;
  cursor: pointer;
  transition: opacity .15s, transform .08s;
  flex-shrink: 0;
  -webkit-tap-highlight-color: transparent;
}

.order-complete-btn:active:not(:disabled) {
  opacity: .85;
  transform: scale(.98);
}

.order-complete-btn:disabled {
  opacity: .35;
  cursor: not-allowed;
}

.order-cash-balance {
  padding: .5rem .6rem;
  background: rgba(0, 122, 255, .08);
  border: .5px solid rgba(0, 122, 255, .25);
  border-radius: var(--radius-sm);
  flex-shrink: 0;
}

.order-cash-balance-title {
  font-size: .75rem;
  color: var(--sys-secondary-label);
  font-weight: 500;
  margin-bottom: .15rem;
}

.order-cash-balance-value {
  color: var(--sys-green);
  font-size: 1rem;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}


/* ============================================================
   VIEW: HISTORY
   ============================================================ */

.view-history {
  display: none;
}

.view-history.active {
  display: block;
}

.view-content-inner {
  padding: .75rem;
}

.view-section-title {
  font-size: 1.4rem;
  font-weight: 700;
  letter-spacing: -.02em;
  color: var(--sys-label);
  margin-bottom: .75rem;
  padding-top: .25rem;
}

.history-list {
  list-style: none;
}

.history-item {
  background: var(--sys-secondary-grouped-bg);
  border-radius: var(--radius);
  margin-bottom: .5rem;
  overflow: hidden;
  box-shadow: var(--shadow-sm);
}

.history-item-pending {
  border-left: 3px solid var(--sys-orange);
}

.history-item-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: .75rem 1rem;
  cursor: pointer;
  gap: .5rem;
  -webkit-tap-highlight-color: transparent;
}

.history-item-header:active {
  background: var(--sys-fill);
}

.history-item-date {
  font-size: .85rem;
  color: var(--sys-secondary-label);
  flex: 1;
  min-width: 0;
}

.history-item-nr {
  display: inline-block;
  font-size: .7rem;
  color: #fff;
  background: var(--sys-blue);
  padding: .1rem .35rem;
  border-radius: 999px;
  margin-right: .35rem;
  font-weight: 700;
}

.history-item-meta {
  display: inline-flex;
  align-items: center;
  gap: .3rem;
}

.history-item-source {
  font-size: .7rem;
  padding: .1rem .35rem;
  border-radius: 999px;
  background: var(--sys-fill);
  color: var(--sys-secondary-label);
}

.history-item-user {
  font-size: .7rem;
  padding: .1rem .35rem;
  border-radius: 999px;
  background: rgba(0, 122, 255, .12);
  border: .5px solid rgba(0, 122, 255, .3);
  color: var(--sys-blue);
  font-weight: 600;
}

.history-item-actions {
  display: inline-flex;
  align-items: center;
  gap: .4rem;
  flex-shrink: 0;
}

.history-item-total {
  font-weight: 700;
  color: var(--sys-green);
  font-variant-numeric: tabular-nums;
  font-size: .95rem;
}

.history-item-delete {
  padding: .25rem .6rem;
  border: .5px solid rgba(255, 59, 48, .4);
  background: rgba(255, 59, 48, .08);
  border-radius: 999px;
  color: var(--sys-red);
  font-family: inherit;
  font-size: .78rem;
  font-weight: 600;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}

.history-item-delete:active {
  background: rgba(255, 59, 48, .18);
}

.history-item-cancelled .history-item-total {
  color: var(--sys-secondary-label);
  text-decoration: line-through;
}

.history-item-cancelled-badge {
  font-size: .7rem;
  padding: .1rem .35rem;
  border-radius: 999px;
  background: var(--sys-fill);
  color: var(--sys-secondary-label);
  font-weight: 600;
}

.history-item-details {
  padding: 0 1rem .75rem;
  border-top: .5px solid var(--sys-separator);
}

.history-item-details ul {
  list-style: none;
  padding-top: .5rem;
}

.history-item-details li {
  display: flex;
  justify-content: space-between;
  padding: .3rem 0;
  font-size: .875rem;
  color: var(--sys-secondary-label);
  border-bottom: .5px solid var(--sys-separator);
}

.history-item-details li:last-child {
  border-bottom: none;
}

.history-empty {
  text-align: center;
  padding: 3rem 1.5rem;
  color: var(--sys-secondary-label);
  font-size: .95rem;
}

.export-row {
  margin-top: .75rem;
  display: flex;
  flex-wrap: wrap;
  gap: .5rem;
}

.export-btn {
  padding: .5rem 1rem;
  background: var(--sys-secondary-grouped-bg);
  border: .5px solid var(--sys-separator);
  border-radius: var(--radius-sm);
  color: var(--sys-blue);
  font-family: inherit;
  font-size: .875rem;
  font-weight: 500;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  transition: background .12s;
}

.export-btn:active {
  background: var(--sys-fill);
}

.export-btn-danger {
  color: var(--sys-red);
  border-color: rgba(255, 59, 48, .3);
}


/* ============================================================
   VIEW: STATS
   ============================================================ */

.view-stats {
  display: none;
}

.view-stats.active {
  display: block;
}

.stats-by-date-list {
  list-style: none;
}

.stats-date-item {
  background: var(--sys-secondary-grouped-bg);
  border-radius: var(--radius);
  margin-bottom: .5rem;
  overflow: hidden;
  box-shadow: var(--shadow-sm);
}

.stats-date-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: .75rem 1rem;
  cursor: pointer;
  gap: .5rem;
  -webkit-tap-highlight-color: transparent;
}

.stats-date-header:active {
  background: var(--sys-fill);
}

.stats-date-label {
  font-weight: 600;
  color: var(--sys-label);
  font-size: .95rem;
}

.stats-date-header-actions {
  display: flex;
  align-items: center;
  gap: .5rem;
  flex-shrink: 0;
}

.stats-date-csv-btn {
  font: inherit;
  font-size: .78rem;
  font-weight: 600;
  padding: .25rem .55rem;
  border-radius: 999px;
  border: .5px solid var(--sys-separator);
  background: var(--sys-fill);
  color: var(--sys-blue);
  cursor: pointer;
}

.stats-date-total {
  font-weight: 700;
  color: var(--sys-green);
  font-variant-numeric: tabular-nums;
}

.stats-date-details {
  padding: 0 1rem .75rem;
  border-top: .5px solid var(--sys-separator);
}

.stats-date-details .stats-table {
  margin-bottom: .5rem;
}

.stats-date-pfand {
  font-size: .82rem;
  color: var(--sys-secondary-label);
  margin-top: .35rem;
}

.stats-selected {
  margin-top: .75rem;
  background: var(--sys-secondary-grouped-bg);
  border-radius: var(--radius);
  padding: .75rem 1rem;
  box-shadow: var(--shadow-sm);
}

.stats-selected-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: .5rem;
  margin-bottom: .5rem;
}

.stats-selected-title {
  font-size: .95rem;
  font-weight: 600;
  color: var(--sys-label);
}

.stats-selected-toggle {
  border: .5px solid var(--sys-separator);
  background: var(--sys-fill);
  color: var(--sys-blue);
  border-radius: 999px;
  padding: .3rem .65rem;
  font-family: inherit;
  font-size: .78rem;
  font-weight: 600;
  cursor: pointer;
}

.stats-selected-toggle:active {
  background: var(--sys-secondary-fill);
}

.stats-selected-table-wrap {
  width: 100%;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}

.stats-table {
  width: 100%;
  border-collapse: collapse;
  font-size: .875rem;
}

.stats-table th,
.stats-table td {
  padding: .6rem .75rem;
  text-align: left;
  border-bottom: .5px solid var(--sys-separator);
}

.stats-table th {
  font-size: .72rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .05em;
  color: var(--sys-secondary-label);
  background: var(--sys-tertiary-grouped-bg);
}

.stats-table tr:last-child td {
  border-bottom: none;
}

.stats-table td { font-variant-numeric: tabular-nums; }
.stats-table .col-name { font-weight: 500; }
.stats-table .col-qty { text-align: right; }
.stats-table .col-price { text-align: right; color: var(--sys-secondary-label); }
.stats-table .col-revenue { text-align: right; color: var(--sys-green); font-weight: 600; }

.stats-total-row td {
  font-weight: 700;
  border-top: 1px solid var(--sys-separator);
  padding-top: .75rem;
}

.stats-pfand-block {
  margin-top: 1rem;
  padding: .75rem;
  background: var(--sys-tertiary-grouped-bg);
  border-radius: var(--radius-sm);
}

.stats-pfand-row {
  display: flex;
  justify-content: space-between;
  font-size: .875rem;
  font-variant-numeric: tabular-nums;
}

.stats-pfand-row .revenue { color: var(--sys-secondary-label); }

.stats-empty {
  text-align: center;
  padding: 3rem 1.5rem;
  color: var(--sys-secondary-label);
  font-size: .95rem;
}

.ios-select {
  width: 100%;
  padding: .6rem .75rem;
  font-family: inherit;
  font-size: .95rem;
  border: .5px solid var(--sys-separator);
  border-radius: var(--radius-sm);
  background: var(--sys-secondary-grouped-bg);
  color: var(--sys-label);
  appearance: none;
  -webkit-appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='%238e8e93'%3E%3Cpath d='M7 10l5 5 5-5z'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right .75rem center;
  padding-right: 2rem;
}


/* ============================================================
   MODAL OVERLAY
   ============================================================ */

.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, .40);
  display: flex;
  align-items: flex-end;
  justify-content: center;
  z-index: 1000;
  opacity: 0;
  visibility: hidden;
  transition: opacity .25s ease, visibility .25s ease;
  padding: 0;
}

.modal-overlay.modal-open {
  opacity: 1;
  visibility: visible;
}

/* Pin-gate overlays center their dialog */
#stats-pin-overlay,
#storno-pin-overlay {
  align-items: center;
  padding: 1rem;
}


/* ============================================================
   IOS DIALOG (centered, for PIN gates)
   ============================================================ */

.ios-dialog {
  width: 100%;
  max-width: 310px;
  background: var(--sys-secondary-grouped-bg);
  border-radius: var(--radius-xl);
  padding: 1.25rem;
  box-shadow: var(--shadow-lg);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: .5rem;
  transform: scale(.9);
  transition: transform .25s ease;
}

.modal-overlay.modal-open .ios-dialog {
  transform: scale(1);
}

.ios-dialog-title {
  font-size: 1.0625rem;
  font-weight: 700;
  text-align: center;
  color: var(--sys-label);
}

.ios-dialog-hint {
  font-size: .82rem;
  color: var(--sys-secondary-label);
  text-align: center;
  margin-bottom: .25rem;
}

.ios-dialog-actions {
  width: 100%;
  border-top: .5px solid var(--sys-separator);
  margin-top: .25rem;
  padding-top: .75rem;
}

.ios-dialog-btn {
  width: 100%;
  padding: .6rem;
  border: none;
  background: transparent;
  color: var(--sys-blue);
  font-family: inherit;
  font-size: 1rem;
  font-weight: 600;
  cursor: pointer;
  border-radius: var(--radius-sm);
  -webkit-tap-highlight-color: transparent;
}

.ios-dialog-btn:active {
  background: var(--sys-fill);
}


/* ============================================================
   IOS SHEET (bottom sheet, for functional modals)
   ============================================================ */

.ios-sheet {
  width: 100%;
  max-width: 560px;
  background: var(--sys-secondary-grouped-bg);
  border-radius: var(--radius-xl) var(--radius-xl) 0 0;
  padding: .75rem 1.25rem max(1.25rem, env(safe-area-inset-bottom, 0px));
  box-shadow: var(--shadow-lg);
  transform: translateY(100%);
  transition: transform .3s cubic-bezier(.32, .72, 0, 1);
  max-height: 90dvh;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
}

.ios-sheet-tall {
  max-height: 92dvh;
}

.modal-overlay.modal-open .ios-sheet {
  transform: translateY(0);
}

.ios-sheet-handle {
  width: 36px;
  height: 4px;
  border-radius: 2px;
  background: var(--sys-fill);
  margin: 0 auto .75rem;
}

.ios-sheet-title {
  font-size: 1.25rem;
  font-weight: 700;
  color: var(--sys-label);
  margin-bottom: 1rem;
  letter-spacing: -.01em;
}

.ios-sheet-actions {
  display: flex;
  gap: .5rem;
  margin-top: .75rem;
}

.ios-sheet-btn {
  flex: 1;
  padding: .75rem;
  border-radius: var(--radius-sm);
  border: none;
  font-family: inherit;
  font-size: .95rem;
  font-weight: 600;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  transition: opacity .12s;
}

.ios-sheet-btn:active { opacity: .8; }

.ios-sheet-btn-cancel {
  background: var(--sys-fill);
  color: var(--sys-label);
}

.ios-sheet-btn-primary {
  background: var(--sys-blue);
  color: #fff;
}


/* ============================================================
   PINPAD (in sheets)
   ============================================================ */

.pinpad-display {
  padding: .75rem 1rem;
  font-size: 1.6rem;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  text-align: right;
  background: var(--sys-grouped-bg);
  border: .5px solid var(--sys-separator);
  border-radius: var(--radius-sm);
  margin-bottom: .75rem;
  color: var(--sys-label);
  user-select: none;
}

.pinpad-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: .35rem;
  margin-bottom: .75rem;
}

.pinpad-btn {
  padding: .75rem;
  font-size: 1.2rem;
  font-weight: 500;
  font-family: inherit;
  color: var(--sys-label);
  background: var(--sys-secondary-grouped-bg);
  border: .5px solid var(--sys-separator);
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: background .1s;
  -webkit-tap-highlight-color: transparent;
}

.pinpad-btn:active {
  background: var(--sys-fill);
  transform: scale(.97);
}

.pinpad-btn-back {
  color: var(--sys-secondary-label);
}


/* ============================================================
   CASH REASON BUTTONS
   ============================================================ */

.cash-reason-row {
  display: flex;
  flex-wrap: wrap;
  gap: .35rem;
  margin-bottom: .75rem;
}

.cash-reason-btn {
  padding: .4rem .75rem;
  border-radius: 999px;
  border: .5px solid var(--sys-separator);
  background: var(--sys-fill);
  color: var(--sys-secondary-label);
  font-family: inherit;
  font-size: .85rem;
  font-weight: 500;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  transition: background .12s, color .12s;
}

.cash-reason-btn.active {
  background: var(--sys-blue);
  border-color: var(--sys-blue);
  color: #fff;
}


/* ============================================================
   ADMIN MODAL EXTRAS
   ============================================================ */

.admin-role-row {
  display: flex;
  gap: .3rem;
  flex-wrap: wrap;
  margin-bottom: .75rem;
}

.admin-role-btn {
  padding: .35rem .65rem;
  background: var(--sys-fill);
  border: .5px solid transparent;
  border-radius: 999px;
  color: var(--sys-secondary-label);
  font-family: inherit;
  font-size: .85rem;
  font-weight: 600;
  cursor: pointer;
  transition: background .12s, color .12s;
  -webkit-tap-highlight-color: transparent;
}

.admin-role-btn:active {
  opacity: .75;
}

.admin-role-btn.active {
  background: var(--sys-blue);
  border-color: var(--sys-blue);
  color: #fff;
}

.admin-users-panel {
  width: 100%;
  margin-bottom: .5rem;
}

.admin-users-form {
  background: var(--sys-grouped-bg);
  border-radius: var(--radius-sm);
  padding: .75rem;
  margin-bottom: .75rem;
}

.admin-items-form {
  margin-bottom: .5rem;
}

.admin-items-row {
  margin-bottom: .6rem;
}

.modal-label {
  display: block;
  font-size: .78rem;
  font-weight: 500;
  color: var(--sys-secondary-label);
  margin-bottom: .25rem;
}

.modal-input {
  width: 100%;
  padding: .55rem .75rem;
  font-size: .95rem;
  font-family: inherit;
  border: .5px solid var(--sys-separator);
  border-radius: var(--radius-sm);
  background: var(--sys-secondary-grouped-bg);
  color: var(--sys-label);
  box-sizing: border-box;
  appearance: none;
  -webkit-appearance: none;
}

.modal-input:focus {
  outline: none;
  border-color: var(--sys-blue);
  box-shadow: 0 0 0 3px rgba(0, 122, 255, .2);
}

.admin-users-list {
  display: flex;
  flex-direction: column;
  gap: .4rem;
}

.admin-user-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: .5rem;
  padding: .55rem .75rem;
  background: var(--sys-grouped-bg);
  border-radius: var(--radius-sm);
}

.admin-user-meta { display: flex; flex-direction: column; gap: .1rem; }
.admin-user-name { font-weight: 700; font-size: .9rem; }
.admin-user-sub { color: var(--sys-secondary-label); font-size: .8rem; }
.admin-user-actions { display: inline-flex; gap: .3rem; }
.admin-user-actions .export-btn { padding: .3rem .6rem; font-size: .8rem; }

/* ── modal-actions (legacy compat) ── */
.modal-actions {
  display: flex;
  gap: .5rem;
  justify-content: flex-end;
  margin-top: .75rem;
}

.modal-btn {
  padding: .55rem 1.1rem;
  font-family: inherit;
  font-size: .9rem;
  font-weight: 600;
  border-radius: var(--radius-sm);
  cursor: pointer;
  border: .5px solid var(--sys-separator);
  background: var(--sys-fill);
  color: var(--sys-label);
  -webkit-tap-highlight-color: transparent;
}

.modal-btn-cancel:active { opacity: .75; }

.modal-btn-ok {
  background: var(--sys-blue);
  border-color: var(--sys-blue);
  color: #fff;
}

.modal-btn-ok:active { opacity: .85; }


/* ============================================================
   RESPONSIVE — PHONE (≤ 700px)
   ============================================================ */

@media (max-width: 700px) {
  /* Kasse view: exact available height, no external scroll */
  .view-kasse {
    height: calc(100dvh - var(--nav-height) - env(safe-area-inset-top, 0px) - var(--tab-height) - env(safe-area-inset-bottom, 0px));
    display: flex;
    flex-direction: column;
    overflow: hidden;
  }

  .kasse-layout {
    display: flex;
    flex-direction: column;
    flex: 1;
    min-height: 0;
    overflow: hidden;
  }

  /* Drink grid scrolls internally */
  .kasse-main {
    flex: 1;
    min-height: 0;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    padding: .4rem .75rem .75rem;
  }

  /* Subtabs sit above scroll area, never scroll away */
  .kasse-subtabs {
    flex-shrink: 0;
    padding: .3rem .75rem .4rem;
  }

  /* Order summary always visible at bottom */
  .order-section {
    flex-shrink: 0;
    flex-grow: 0;
    border-left: none;
    border-top: .5px solid var(--sys-separator);
    max-height: none;
  }

  /* Compact list: fixed height, scrolls if many items */
  .order-list {
    flex: none;
    max-height: 80px;
    overflow-y: auto;
  }

  .order-empty {
    padding: .6rem 0;
  }

  .items-grid {
    grid-template-columns: repeat(auto-fill, minmax(108px, 1fr));
    gap: .3rem;
  }

  .drink-btn {
    height: 108px;
    font-size: .88rem;
  }

  .drink-btn .icon { font-size: 1.55rem; }

  .stats-table {
    min-width: 480px;
  }

  .ios-key {
    width: 68px;
    height: 68px;
  }

  .ios-key-spacer { width: 68px; height: 68px; }
}

@media (max-width: 380px) {
  .items-grid {
    grid-template-columns: repeat(auto-fill, minmax(96px, 1fr));
  }

  .drink-btn {
    height: 100px;
    font-size: .82rem;
  }

  .ios-key {
    width: 60px;
    height: 60px;
  }

  .ios-key-spacer { width: 60px; height: 60px; }
  .ios-key-digit { font-size: 1.3rem; }
}


/* ============================================================
   UTILITY
   ============================================================ */

/* Subtab panel visibility (managed by JS via data-panel + display:none) */
.kasse-panel { display: block; }
