/* === LADENA Verkaufstool - CSS === */

* { box-sizing: border-box; margin: 0; padding: 0; -webkit-tap-highlight-color: transparent; }
html, body { height: 100%; }
body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", system-ui, sans-serif;
  background: #F5F2EC;
  color: #2C3338;
  font-size: 16px;
  line-height: 1.5;
  -webkit-text-size-adjust: 100%;
}

.hidden { display: none !important; }

/* === LOGIN-SEITE === */
.login-page {
  background: #2C3338;
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  padding: 20px;
}
.login-container { width: 100%; max-width: 440px; }
.login-card {
  background: #FFFFFF;
  border-radius: 16px;
  padding: 36px 32px;
  box-shadow: 0 20px 60px rgba(0,0,0,0.3);
}
.logo-block { text-align: center; margin-bottom: 28px; }
.logo {
  font-size: 32px;
  font-weight: 700;
  letter-spacing: 0.08em;
  color: #2C3338;
}
.logo sup { font-size: 12px; opacity: 0.6; }
.logo-sub {
  font-size: 12px;
  color: #6B6F75;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  margin-top: 4px;
}
.login-card h1 {
  font-size: 20px;
  font-weight: 600;
  margin-bottom: 8px;
}
.lead {
  font-size: 14px;
  color: #6B6F75;
  margin-bottom: 24px;
}
.footnote {
  font-size: 12px;
  color: #6B6F75;
  text-align: center;
  margin-top: 20px;
  line-height: 1.6;
}

/* === FORMULAR-ELEMENTE === */
.field { margin-bottom: 14px; }
.field-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}
label {
  display: block;
  font-size: 13px;
  color: #6B6F75;
  font-weight: 500;
  margin-bottom: 6px;
}
input[type="text"], input[type="email"], textarea, select {
  width: 100%;
  height: 48px;
  padding: 0 14px;
  border: 1.5px solid #E5E0D6;
  border-radius: 10px;
  font-size: 16px;
  background: #FFFFFF;
  color: #2C3338;
  font-family: inherit;
  -webkit-appearance: none;
  appearance: none;
}
textarea {
  height: auto;
  min-height: 60px;
  padding: 12px 14px;
  resize: vertical;
  line-height: 1.4;
}
select {
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'><path fill='%236B6F75' d='M6 8L0 0h12z'/></svg>");
  background-repeat: no-repeat;
  background-position: right 14px center;
  padding-right: 36px;
}
input:focus, textarea:focus, select:focus {
  outline: none;
  border-color: #2C3338;
}

/* === BUTTONS === */
.btn-primary {
  display: inline-block;
  background: #2C3338;
  color: #FFFFFF;
  border: none;
  border-radius: 10px;
  padding: 14px 28px;
  font-size: 15px;
  font-weight: 600;
  font-family: inherit;
  cursor: pointer;
  min-height: 48px;
  width: 100%;
}
.btn-primary:hover { background: #1F2326; }
.btn-primary:disabled { opacity: 0.6; cursor: not-allowed; }
.btn-primary:active { transform: scale(0.98); }

.btn-large {
  font-size: 17px;
  padding: 16px 32px;
  min-height: 56px;
}

.btn-ghost {
  background: transparent;
  color: #2C3338;
  border: 1.5px solid #E5E0D6;
  border-radius: 10px;
  padding: 10px 20px;
  font-size: 14px;
  font-weight: 500;
  font-family: inherit;
  cursor: pointer;
  min-height: 44px;
}
.btn-ghost:hover { background: #FAF7F0; border-color: #2C3338; }

/* === STATUS-MESSAGES === */
.status {
  margin-top: 16px;
  padding: 12px 16px;
  border-radius: 10px;
  font-size: 14px;
}
.status.success { background: #E8F5E9; color: #1B5E20; border-left: 3px solid #2E7D32; }
.status.error { background: #FCEBEB; color: #A32D2D; border-left: 3px solid #A32D2D; }

/* === APP-HEADER === */
.app-header {
  background: #2C3338;
  color: #F5F2EC;
  padding: 12px 20px;
  position: sticky;
  top: 0;
  z-index: 50;
}
.header-inner {
  max-width: 1100px;
  margin: 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 12px;
}
.header-left { display: flex; align-items: baseline; gap: 12px; }
.header-left .logo { color: #F5F2EC; font-size: 22px; }
.header-left .logo-sub { color: #F5F2EC; opacity: 0.7; }
.header-nav {
  display: flex;
  gap: 4px;
}
.nav-btn {
  background: transparent;
  color: #F5F2EC;
  border: 1.5px solid transparent;
  border-radius: 8px;
  padding: 8px 14px;
  font-size: 14px;
  font-family: inherit;
  cursor: pointer;
  min-height: 40px;
}
.nav-btn.active { background: rgba(255,255,255,0.15); }
.nav-btn:hover { background: rgba(255,255,255,0.08); }

.header-right { display: flex; align-items: center; gap: 12px; }
.user-name { font-size: 13px; opacity: 0.8; }
.header-right .btn-ghost {
  background: rgba(255,255,255,0.1);
  border-color: rgba(255,255,255,0.25);
  color: #F5F2EC;
  padding: 8px 14px;
  min-height: 40px;
}

/* === APP-MAIN === */
.app-main {
  padding-bottom: 40px;
}
.container {
  max-width: 800px;
  margin: 0 auto;
  padding: 20px;
}
.view-title {
  font-size: 22px;
  font-weight: 700;
  margin-bottom: 16px;
}

.card {
  background: #FFFFFF;
  border-radius: 14px;
  padding: 20px;
  margin-bottom: 14px;
  box-shadow: 0 1px 3px rgba(0,0,0,0.04);
}
.card h2 {
  font-size: 13px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: #6B6F75;
  margin-bottom: 14px;
}

/* === SEGMENTED CONTROL === */
.segmented {
  display: flex;
  background: #F5F2EC;
  border-radius: 10px;
  padding: 4px;
  gap: 4px;
  flex-wrap: wrap;
}
.segmented button {
  flex: 1 1 100px;
  min-height: 44px;
  border: none;
  border-radius: 8px;
  background: transparent;
  font-family: inherit;
  font-size: 14px;
  font-weight: 500;
  color: #6B6F75;
  cursor: pointer;
}
.segmented button.active {
  background: #FFFFFF;
  color: #2C3338;
  box-shadow: 0 1px 3px rgba(0,0,0,0.08);
}

/* === UPLOAD-AREA === */
.upload-area {
  border: 2px dashed #E5E0D6;
  border-radius: 12px;
  padding: 20px;
  text-align: center;
  cursor: pointer;
  background: #FAF7F0;
  transition: all 0.15s;
}
.upload-area:hover { border-color: #2C3338; background: #FFFFFF; }
.upload-placeholder { padding: 20px 0; }
.upload-icon { font-size: 40px; margin-bottom: 10px; }
.upload-text { font-size: 15px; font-weight: 500; margin-bottom: 4px; }
.upload-hint { font-size: 12px; color: #6B6F75; }
.upload-preview img {
  max-width: 100%;
  max-height: 300px;
  border-radius: 8px;
  margin: 10px auto;
  display: block;
}
.preview-name { font-size: 13px; color: #6B6F75; margin: 8px 0; }

/* === ACTION-BAR === */
.action-bar {
  margin-top: 8px;
  margin-bottom: 20px;
}

/* === LOADING === */
.loading {
  text-align: center;
  padding: 40px 20px;
}
.spinner {
  width: 44px;
  height: 44px;
  border: 3px solid #E5E0D6;
  border-top-color: #2C3338;
  border-radius: 50%;
  margin: 0 auto 16px;
  animation: spin 0.8s linear infinite;
}
@keyframes spin {
  to { transform: rotate(360deg); }
}
.loading-text { font-size: 14px; color: #6B6F75; }

/* === RESULT === */
.result-card {
  background: #2C3338;
  color: #FFFFFF;
  border-radius: 14px;
  padding: 24px;
}
.result-card h2, .result-card .card-h { color: rgba(255,255,255,0.7); }
.result-header { margin-bottom: 16px; }
.result-label {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  opacity: 0.7;
}
.result-value {
  font-size: 36px;
  font-weight: 700;
  line-height: 1.1;
  margin-top: 4px;
}
.result-range {
  font-size: 14px;
  opacity: 0.8;
  margin-top: 6px;
}
.result-actions {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}
.result-actions .btn-ghost {
  background: rgba(255,255,255,0.1);
  border-color: rgba(255,255,255,0.25);
  color: #FFFFFF;
}
.result-raw {
  font-family: ui-monospace, "SF Mono", Monaco, Menlo, monospace;
  font-size: 13px;
  line-height: 1.5;
  white-space: pre-wrap;
  word-wrap: break-word;
  background: #FAF7F0;
  padding: 14px;
  border-radius: 8px;
  color: #2C3338;
}

/* === HISTORIE === */
.history-list { display: flex; flex-direction: column; gap: 10px; }
.history-item {
  background: #FFFFFF;
  border-radius: 12px;
  padding: 14px 18px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  cursor: pointer;
  box-shadow: 0 1px 3px rgba(0,0,0,0.04);
}
.history-item:hover { background: #FAF7F0; }
.history-meta { font-size: 14px; }
.history-kunde { font-weight: 600; }
.history-date { font-size: 12px; color: #6B6F75; margin-top: 2px; }
.history-amount { font-size: 16px; font-weight: 600; }
.history-status-pending { color: #C77B00; }
.history-status-failed { color: #A32D2D; }

/* === ADMIN === */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 12px;
}
.stat-card {
  background: #FAF7F0;
  border-radius: 10px;
  padding: 14px 16px;
}
.stat-card .stat-label {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: #6B6F75;
  margin-bottom: 4px;
}
.stat-card .stat-value {
  font-size: 22px;
  font-weight: 600;
}

.user-list, .audit-list { display: flex; flex-direction: column; gap: 8px; }
.user-row, .audit-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 14px;
  background: #FAF7F0;
  border-radius: 8px;
  font-size: 14px;
  gap: 12px;
  flex-wrap: wrap;
}
.user-row .user-meta { flex: 1 1 auto; }
.user-row .user-email { font-weight: 500; }
.user-row .user-detail { font-size: 12px; color: #6B6F75; }
.user-row .user-actions { display: flex; gap: 6px; }
.user-row .btn-ghost { padding: 6px 12px; min-height: 32px; font-size: 12px; }
.role-badge {
  display: inline-block;
  padding: 2px 8px;
  background: #E5E0D6;
  border-radius: 4px;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  margin-left: 6px;
}
.role-badge.admin { background: #2C3338; color: #FFFFFF; }
.inactive-marker { color: #A32D2D; font-size: 12px; margin-left: 6px; }

.add-user-details {
  margin-top: 16px;
  padding-top: 16px;
  border-top: 1px solid #E5E0D6;
}
.add-user-details summary {
  cursor: pointer;
  font-weight: 500;
  padding: 8px 0;
}

.audit-row { font-size: 12px; }
.audit-time { color: #6B6F75; min-width: 130px; }
.audit-action { font-weight: 500; }
.audit-detail { color: #6B6F75; flex: 1; }

/* === Mobile === */
@media (max-width: 700px) {
  .field-row { grid-template-columns: 1fr; }
  .header-nav { width: 100%; order: 3; }
  .nav-btn { flex: 1; padding: 8px 8px; font-size: 13px; }
  .result-value { font-size: 30px; }
}

/* === Print === */
@media print {
  @page { size: A4 portrait; margin: 14mm 12mm; }
  body { background: #FFFFFF; font-size: 11pt; }
  .app-header, .action-bar, .result-actions, .header-nav, .header-right, .nav-btn,
  .upload-area, #view-history, #view-admin, .btn-primary, .btn-ghost { display: none !important; }
  .card { box-shadow: none; border: 1px solid #E5E0D6; page-break-inside: avoid; }
  .result-card { background: #FFFFFF; color: #2C3338; border: 2px solid #2C3338; }
  .result-card .result-label, .result-card h2 { color: #6B6F75; }
  .result-raw { background: #FFFFFF; padding: 0; }
}
