/* ================================================================
   ARISTOS — Top-Navigation Layout
   ================================================================ */

@import url('https://fonts.googleapis.com/css2?family=Cormorant+Garamond:ital,wght@0,300;0,400;0,600;1,300&family=Inter:wght@400;500;600&display=swap');

/* ── Variables ─────────────────────────────────────────────────── */
:root {
  --header-h:  60px;
  --topbar-h:  54px;

  --bg:        #f5f5f3;
  --white:     #ffffff;
  --ink:       #0a0a0a;
  --ink-soft:  #1a1a1a;

  --text:      #1a1a1a;
  --text-sec:  #555555;
  --text-muted:#888888;
  --text-dim:  #aaaaaa;

  --border:    #e8e8e8;
  --border-in: #cccccc;

  --danger:    #c0392b;
  --warn-bg:   #fdf6e3;
  --warn-bd:   #d4a800;

  --display:  'Cormorant Garamond', Georgia, serif;
  --body:     'Inter', -apple-system, Helvetica, sans-serif;
}

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

body {
  font-family: var(--body);
  font-size: 14px;
  font-weight: 400;
  line-height: 1.6;
  color: var(--text);
  background: var(--bg);
  /* Column layout: header → topbar → main */
  display: flex;
  flex-direction: column;
  height: 100vh;
  overflow: hidden;
  -webkit-font-smoothing: antialiased;
}

a { color: var(--text); text-decoration: none; }
a:hover { color: var(--ink); text-decoration: underline; }

/* ================================================================
   TOP HEADER
   ================================================================ */

.app-header {
  height: var(--header-h);
  flex-shrink: 0;
  background: var(--ink);
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  padding: 0 32px;
  gap: 24px;
  position: relative;
  z-index: 100;
}

/* ── Brand (left) ──────────────────────────────────────────────── */
.header-brand {
  /* sits in left grid cell, aligned left */
}
.brand-name {
  font-family: var(--display);
  font-size: 20px;
  font-weight: 300;
  letter-spacing: 6px;
  text-transform: uppercase;
  color: #ffffff;
  line-height: 1;
}
.brand-sub {
  font-family: var(--body);
  font-size: 8px;
  font-weight: 500;
  letter-spacing: 4px;
  text-transform: uppercase;
  color: #666666;
  margin-top: 5px;
  line-height: 1;
}

/* ── Horizontal navigation (center) ───────────────────────────── */
.header-nav {
  display: flex;
  align-items: center;
  gap: 0;
}

.nav-link {
  display: inline-block;
  padding: 10px 14px;
  font-family: var(--body);
  font-size: 11px;
  font-weight: 500;
  letter-spacing: 3px;
  text-transform: uppercase;
  color: rgba(255,255,255,.45);
  text-decoration: none;
  border-bottom: 1px solid transparent;
  transition: color .2s, border-color .2s;
  line-height: 1;
  white-space: nowrap;
}
.nav-link:hover { color: #aaaaaa; text-decoration: none; }
.nav-link.active { color: #ffffff; border-bottom-color: rgba(255,255,255,.65); }

/* ── User area + Search (right) ───────────────────────────────── */
.header-user {
  display: flex;
  justify-content: flex-end;
  align-items: center;
  gap: 14px;
}

/* ── Global Search ─────────────────────────────────────────────── */
.header-search {
  position: relative;
  display: flex;
  align-items: center;
}
.header-search-icon {
  position: absolute;
  left: 10px;
  color: rgba(255,255,255,.3);
  font-size: 15px;
  pointer-events: none;
  line-height: 1;
  top: 50%;
  transform: translateY(-50%);
}
.header-search-input {
  background: rgba(255,255,255,.07);
  border: 1px solid rgba(255,255,255,.12);
  color: #ffffff;
  padding: 6px 12px 6px 32px;
  font-size: 12px;
  font-family: var(--body);
  outline: none;
  width: 160px;
  border-radius: 2px;
  transition: background .2s, border-color .2s, width .25s ease;
}
.header-search-input::placeholder { color: rgba(255,255,255,.28); }
.header-search-input:focus {
  background: rgba(255,255,255,.11);
  border-color: rgba(255,255,255,.3);
  width: 210px;
}

/* Mobile search (in dropdown) */
.mobile-search { padding: 12px 24px 4px; }
.mobile-search-input {
  width: 100%;
  background: rgba(255,255,255,.08);
  border: 1px solid rgba(255,255,255,.12);
  color: #ffffff;
  padding: 9px 14px;
  font-size: 14px;
  font-family: var(--body);
  outline: none;
  border-radius: 2px;
}
.mobile-search-input::placeholder { color: rgba(255,255,255,.3); }
.mobile-search-input:focus { border-color: rgba(255,255,255,.35); }

/* app.js injects .sidebar-user inside #sidebarUser */
.sidebar-user {
  display: flex;
  align-items: center;
  gap: 12px;
  font-family: var(--body);
  font-size: 10px;
  font-weight: 500;
  letter-spacing: 1.5px;
  text-transform: uppercase;
  color: rgba(255,255,255,.38);
}
.btn-logout {
  background: none; border: none;
  color: rgba(255,255,255,.28);
  cursor: pointer; font-size: 16px;
  padding: 0; line-height: 1;
  transition: color .18s;
}
.btn-logout:hover { color: rgba(255,255,255,.8); }

/* ── Hamburger (hidden on desktop) ────────────────────────────── */
.hamburger {
  display: none;
  flex-direction: column;
  justify-content: center;
  gap: 5px;
  width: 30px; height: 30px;
  background: none; border: none;
  cursor: pointer; padding: 3px;
  flex-shrink: 0;
}
.hamburger span { display: block; height: 1.5px; background: rgba(255,255,255,.7); border-radius: 1px; }

/* ================================================================
   MOBILE NAV DROPDOWN  (#sidebar — kept for app.js compatibility)
   ================================================================ */

.mobile-nav {
  display: none;             /* hidden by default; shown when .open */
  position: fixed;
  top: var(--header-h);
  left: 0; right: 0;
  background: #111111;
  border-bottom: 1px solid #222222;
  z-index: 90;
  padding: 8px 0 16px;
}
.mobile-nav.open { display: block; }

.mobile-nav-close {
  position: absolute;
  top: 10px; right: 16px;
  background: none; border: none;
  color: #555555; font-size: 18px;
  cursor: pointer; line-height: 1;
}
.mobile-nav-close:hover { color: #ffffff; }

/* Override nav-link inside mobile dropdown */
.mobile-nav .nav-link {
  display: block;
  padding: 14px 24px;
  color: rgba(255,255,255,.5);
  border-bottom: none;
  border-left: 2px solid transparent;
}
.mobile-nav .nav-link:hover { color: rgba(255,255,255,.85); background: rgba(255,255,255,.03); }
.mobile-nav .nav-link.active { color: #ffffff; border-left-color: rgba(255,255,255,.55); background: rgba(255,255,255,.04); }

/* ── Overlay ───────────────────────────────────────────────────── */
.overlay { display: none; position: fixed; inset: 0; background: rgba(0,0,0,.45); z-index: 80; }
.overlay.active { display: block; }

/* ================================================================
   TOPBAR — page title + context actions (below main header)
   ================================================================ */

.topbar {
  height: var(--topbar-h);
  flex-shrink: 0;
  background: var(--white);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  padding: 0 40px;
  gap: 20px;
}
.page-title {
  font-family: var(--display);
  font-size: 22px;
  font-weight: 300;
  font-style: italic;
  letter-spacing: .5px;
  color: var(--ink);
  flex: 1;
  line-height: 1;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.topbar-actions { display: flex; gap: 8px; align-items: center; flex-shrink: 0; }

/* ================================================================
   MAIN CONTENT
   ================================================================ */

.main { flex: 1; overflow: hidden; min-height: 0; }
.content { height: 100%; overflow-y: auto; padding: 36px 40px; }
.content::-webkit-scrollbar { width: 4px; }
.content::-webkit-scrollbar-track { background: transparent; }
.content::-webkit-scrollbar-thumb { background: var(--border); }

/* ================================================================
   CARDS
   ================================================================ */

.card {
  background: var(--white);
  border: 1px solid var(--border);
  border-top: 2px solid var(--ink);
  border-radius: 2px;
  overflow: hidden;
}
.card-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 16px 24px; border-bottom: 1px solid var(--border); gap: 16px;
}
.card-header h2 {
  font-family: var(--body);
  font-size: 11px; font-weight: 600;
  letter-spacing: 2px; text-transform: uppercase; color: #666666;
}
.card-body { padding: 24px; }
.card-footer { padding: 14px 24px; border-top: 1px solid var(--border); background: #fafafa; display: flex; gap: 8px; }
.mb-3 { margin-bottom: 14px; }
.mb-4 { margin-bottom: 24px; }
.mt-4 { margin-top: 24px; }

/* ================================================================
   STATS GRID
   ================================================================ */

.stats-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(185px, 1fr)); gap: 16px; margin-bottom: 28px; }
.stats-grid-3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 16px; margin-bottom: 24px; }
.stats-grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; margin-bottom: 24px; }

.stat-card {
  background: var(--white);
  border: 1px solid var(--border);
  border-top: 2px solid var(--ink);
  border-radius: 2px;
  padding: 24px 22px 20px;
}
.stat-card-accent { border-top-color: #888888; }
.stat-card-success { border-top-color: #888888; }
.stat-icon { display: none; }
.stat-label { font-size: 11px; font-weight: 600; letter-spacing: 2px; text-transform: uppercase; color: #666666; margin-bottom: 12px; line-height: 1; }
.stat-value { font-family: var(--body); font-size: 36px; font-weight: 600; line-height: 1; color: var(--ink); letter-spacing: -.5px; }

/* ================================================================
   KUNDEN GRID
   ================================================================ */

.kunden-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(290px, 1fr)); gap: 16px; }
.kunden-card { background: var(--white); border: 1px solid var(--border); border-top: 2px solid var(--ink); border-radius: 2px; overflow: hidden; transition: box-shadow .2s; }
.kunden-card:hover { box-shadow: 0 2px 12px rgba(0,0,0,.08); }
.kunden-card-header { display: flex; align-items: center; gap: 14px; padding: 18px 20px; border-bottom: 1px solid var(--border); }
.kunden-avatar { width: 40px; height: 40px; background: var(--bg); border: 1px solid var(--border); color: var(--ink); display: flex; align-items: center; justify-content: center; font-family: var(--display); font-size: 20px; font-weight: 400; font-style: italic; flex-shrink: 0; border-radius: 2px; }
.kunden-name { font-weight: 600; font-size: 15px; color: var(--ink); line-height: 1.3; }
.kunden-contact { font-size: 13px; color: var(--text-sec); margin-top: 3px; }
.kunden-stats { display: flex; border-bottom: 1px solid var(--border); }
.kunden-stat { flex: 1; text-align: center; padding: 14px 6px; border-right: 1px solid var(--border); }
.kunden-stat:last-child { border-right: none; }
.kunden-stat-value { font-family: var(--display); font-size: 24px; font-weight: 400; color: var(--ink); }
.kunden-stat-label { font-size: 10px; font-weight: 600; color: var(--text-sec); text-transform: uppercase; letter-spacing: 1.5px; margin-top: 3px; }
.kunden-card-actions { display: flex; gap: 6px; padding: 12px 16px; flex-wrap: wrap; }

/* ================================================================
   TABLES
   ================================================================ */

.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
th { text-align: left; padding: 12px 20px; font-family: var(--body); font-size: 12px; font-weight: 600; text-transform: uppercase; letter-spacing: 1.5px; color: #333333; background: #f0f0f0; border-bottom: 1px solid var(--border); white-space: nowrap; }
td { padding: 14px 20px; border-bottom: 1px solid var(--border); vertical-align: middle; color: var(--text); font-size: 14px; background: var(--white); line-height: 1.5; }
tr:last-child td { border-bottom: none; }
tr.clickable { cursor: pointer; }
tr.clickable:hover td, tbody tr:hover td { background: #fafafa; }
.text-right { text-align: right; }
.text-sm { font-size: 12px; }
.text-muted { color: var(--text-sec); }

/* ================================================================
   BADGES
   ================================================================ */

.badge { display: inline-block; padding: 3px 10px; font-size: 11px; font-weight: 600; letter-spacing: .8px; text-transform: uppercase; white-space: nowrap; border: 1px solid; border-radius: 2px; }
.badge-eingelagert { color: var(--text-sec); border-color: var(--border); background: #f5f5f5; }
.badge-verkauft    { color: #ffffff; border-color: #2d6a4f; background: #2d6a4f; }
.badge-zurueck     { color: #c1121f; border-color: rgba(193,18,31,.35); background: #fdf0ee; }
.badge-warn        { color: #7a5c00; border-color: var(--warn-bd); background: var(--warn-bg); }
.badge-danger      { color: var(--danger); border-color: rgba(192,57,43,.35); background: #fdf0ee; }
.badge-z-neu-etikett { color: #fff;    border-color: #2d6a4f; background: #2d6a4f; }
.badge-z-neuwertig   { color: #1a6b44; border-color: #b0dfc6; background: #eaf7f0; }
.badge-z-sehr-gut    { color: #1a4f8a; border-color: #b3cef5; background: #eaf1fb; }
.badge-z-gut         { color: #555;    border-color: #ccc;    background: #f5f5f5; }
.badge-z-gebraucht   { color: #7a4700; border-color: #f0c070; background: #fdf5e0; }
.badge-echt          { color: #1a4f8a; border-color: #b3cef5; background: #eaf1fb; font-size:10px; }

/* ================================================================
   BUTTONS
   ================================================================ */

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  padding: 10px 20px;
  font-family: var(--body); font-size: 13px; font-weight: 600; letter-spacing: .4px;
  cursor: pointer; border: 1px solid; border-radius: 2px;
  transition: background .18s, color .18s, border-color .18s;
  white-space: nowrap; text-decoration: none; line-height: 1;
}
.btn:disabled { opacity: .4; cursor: not-allowed; }
.btn-primary { background: var(--ink); color: #fff; border-color: var(--ink); }
.btn-primary:hover:not(:disabled) { background: #333333; border-color: #333333; }
.btn-outline { background: var(--white); color: var(--text); border-color: #cccccc; }
.btn-outline:hover:not(:disabled) { border-color: var(--ink); color: var(--ink); }
.btn-success { background: #f0f7f0; color: #2d6a2d; border-color: #b8d8b8; }
.btn-success:hover:not(:disabled) { background: #2d6a2d; color: #fff; border-color: #2d6a2d; }
.btn-danger { background: #fdf0ee; color: var(--danger); border-color: rgba(192,57,43,.3); }
.btn-danger:hover:not(:disabled) { background: var(--danger); color: #fff; border-color: var(--danger); }
.btn-sm  { padding: 7px 14px; font-size: 12px; }
.btn-xs  { padding: 4px 10px; font-size: 11px; }
.btn-lg  { padding: 13px 28px; font-size: 14px; }

/* ================================================================
   FORMS
   ================================================================ */

.form-group { margin-bottom: 20px; }
.form-group label { display: block; font-size: 13px; font-weight: 500; color: #333333; margin-bottom: 7px; line-height: 1; }
.form-control { width: 100%; padding: 10px 14px; border: 1px solid var(--border-in); border-radius: 2px; font-size: 15px; font-family: var(--body); font-weight: 400; color: var(--ink); background: var(--white); outline: none; transition: border-color .18s, box-shadow .18s; line-height: 1.4; }
.form-control:focus { border-color: var(--ink); box-shadow: 0 0 0 3px rgba(10,10,10,.08); }
.form-control::placeholder { color: var(--text-dim); }
select.form-control { cursor: pointer; }
textarea.form-control { resize: vertical; min-height: 80px; }

.search-bar { margin-bottom: 20px; }
.search-input { padding: 9px 14px; border: 1px solid var(--border-in); border-radius: 2px; font-size: 14px; font-family: var(--body); outline: none; width: 100%; max-width: 340px; background: var(--white); color: var(--ink); transition: border-color .18s; }
.search-input:focus { border-color: var(--ink); box-shadow: 0 0 0 3px rgba(10,10,10,.08); }
.search-input::placeholder { color: var(--text-dim); }

.form-actions { margin-top: 28px; display: flex; gap: 10px; justify-content: flex-end; }
.modal-footer { display: flex; gap: 10px; justify-content: flex-end; margin-top: 24px; padding-top: 20px; border-top: 1px solid var(--border); }

/* ── Einbuchen rows ────────────────────────────────────────────── */
.artikel-row { background: var(--bg); border: 1px solid var(--border); border-radius: 2px; padding: 20px; margin-bottom: 12px; }
.artikel-row-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 16px; }
.artikel-row-num { font-size: 11px; font-weight: 600; letter-spacing: 2px; text-transform: uppercase; color: var(--text-sec); }
.artikel-row-grid { display: grid; grid-template-columns: 2fr 1fr 1fr 1fr 1fr 1fr; gap: 14px; }
.artikel-row-grid .form-group { margin-bottom: 0; }
.section-divider { display: flex; align-items: center; justify-content: space-between; padding: 18px 0 14px; border-top: 1px solid var(--border); margin-top: 4px; }
.section-divider h3 { font-size: 11px; font-weight: 600; letter-spacing: 2px; text-transform: uppercase; color: var(--text-sec); }

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

.modal-overlay { display: none; position: fixed; inset: 0; background: rgba(0,0,0,.45); z-index: 300; align-items: center; justify-content: center; padding: 16px; }
.modal-overlay.active { display: flex; }
.modal { background: var(--white); border: 1px solid var(--border); border-radius: 2px; box-shadow: 0 8px 40px rgba(0,0,0,.18); width: 100%; max-width: 500px; max-height: 90vh; overflow-y: auto; }
.modal-header { display: flex; align-items: center; justify-content: space-between; padding: 20px 28px 16px; border-bottom: 1px solid var(--border); }
.modal-title { font-size: 11px; font-weight: 600; letter-spacing: 2px; text-transform: uppercase; color: #666666; }
.modal-close { background: none; border: none; font-size: 18px; cursor: pointer; color: var(--text-muted); padding: 2px 6px; transition: color .15s; border-radius: 2px; }
.modal-close:hover { color: var(--ink); }
.modal-body { padding: 24px 28px; }

/* ================================================================
   TOASTS
   ================================================================ */

.toasts { position: fixed; bottom: 28px; right: 28px; z-index: 500; display: flex; flex-direction: column; gap: 8px; }
.toast { background: var(--ink); color: rgba(255,255,255,.9); padding: 13px 20px; border-radius: 2px; font-size: 13px; font-weight: 400; box-shadow: 0 4px 20px rgba(0,0,0,.25); opacity: 0; transform: translateY(8px); transition: opacity .22s, transform .22s; max-width: 320px; border-left: 3px solid rgba(255,255,255,.2); }
.toast.show { opacity: 1; transform: translateY(0); }
.toast-error   { border-left-color: #e07070; }
.toast-success { border-left-color: rgba(255,255,255,.45); }

/* ================================================================
   STATES
   ================================================================ */

.loading    { padding: 72px; text-align: center; color: var(--text-muted); font-size: 12px; letter-spacing: 3px; text-transform: uppercase; }
.loading-sm { padding: 24px; text-align: center; color: var(--text-muted); font-size: 12px; letter-spacing: 2px; }
.empty-state { padding: 72px; text-align: center; color: var(--text-muted); font-size: 14px; }
.empty { text-align: center; color: var(--text-muted); padding: 32px !important; font-size: 13px; }
.error-state { padding: 72px; text-align: center; }
.error-state h3 { color: var(--danger); margin-bottom: 10px; font-size: 14px; font-weight: 600; }
.error-msg { padding: 12px 16px; color: var(--danger); font-size: 13px; }

/* ================================================================
   MISC
   ================================================================ */

.section-title { font-size: 11px; font-weight: 600; letter-spacing: 2px; text-transform: uppercase; color: #666666; margin: 28px 0 14px; }
.kunde-info-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 20px; }
.label { font-size: 11px; font-weight: 600; color: var(--text-sec); text-transform: uppercase; letter-spacing: 1px; margin-right: 6px; }
.actions { white-space: nowrap; display: flex; gap: 4px; }
.ml-2 { margin-left: 8px; }

/* ── Letzte Aktivitäten ────────────────────────────────────────── */
.aktivitaet-row { display: flex; align-items: center; gap: 14px; padding: 12px 24px; border-bottom: 1px solid var(--border); font-size: 14px; }
.aktivitaet-row:last-child { border-bottom: none; }
.aktivitaet-icon { width: 26px; height: 26px; display: flex; align-items: center; justify-content: center; font-size: 13px; font-weight: 700; flex-shrink: 0; border-radius: 2px; background: #f0f0f0; color: var(--text-sec); }
.aktivitaet-icon-einlieferung { background: #f0f0f0; color: var(--text-sec); }
.aktivitaet-icon-verkauf      { background: #e8f5ee; color: #2d6a4f; }
.aktivitaet-icon-rueckgabe    { background: #fdf0ee; color: #c1121f; }
.aktivitaet-meta { flex: 1; min-width: 0; line-height: 1.4; }
.aktivitaet-name { font-weight: 500; color: var(--ink); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.aktivitaet-detail { font-size: 12px; color: var(--text-sec); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.aktivitaet-right { display: flex; flex-direction: column; align-items: flex-end; gap: 2px; flex-shrink: 0; }
.aktivitaet-betrag { font-weight: 600; font-size: 14px; color: var(--ink); }
.aktivitaet-datum { font-size: 11px; color: var(--text-muted); white-space: nowrap; }

.abrechnungs-summary { background: var(--ink); border-radius: 2px; padding: 32px 36px; margin-bottom: 28px; }
.summary-row { display: flex; justify-content: space-between; padding: 5px 0; font-size: 14px; color: rgba(255,255,255,.4); line-height: 1.5; }
.summary-row.total { font-family: var(--display); font-size: 34px; font-weight: 400; color: #ffffff; border-top: 1px solid rgba(255,255,255,.1); margin-top: 14px; padding-top: 16px; letter-spacing: -.3px; }

/* ── Abrechnung kombinierte Tabelle ────────────────────────────── */
.abr-verkauft   td { border-left: 3px solid #2d6a4f !important; background: #f6fdf8 !important; }
.abr-eingelagert td { color: var(--text-muted); }
.abr-zurueck    td { text-decoration: line-through; color: var(--text-dim); }

/* ── Erinnerungen ──────────────────────────────────────────────── */
.erinnerungen-card { border-top-color: var(--warn-bd); }
.erinnerung-row td { background: var(--warn-bg); }
.erinnerung-row:hover td { background: #faefc8 !important; }

/* ── Bar chart ─────────────────────────────────────────────────── */
.bar-chart { display: flex; align-items: flex-end; gap: 8px; height: 200px; padding-bottom: 4px; border-bottom: 1px solid var(--border); border-left: 1px solid var(--border); padding-left: 8px; overflow-x: auto; min-width: 0; }
.bar-chart::-webkit-scrollbar { height: 3px; }
.bar-chart::-webkit-scrollbar-thumb { background: var(--border); }
.bar-group { display: flex; flex-direction: column; align-items: center; min-width: 52px; flex: 1; }
.bar-wrapper { display: flex; flex-direction: column; align-items: center; justify-content: flex-end; height: 170px; width: 100%; }
.bar-val { font-size: 10px; color: var(--text-sec); margin-bottom: 4px; white-space: nowrap; text-align: center; }
.bar { width: 72%; background: #cccccc; border-top: 2px solid #999999; min-height: 2px; transition: height .45s, background .18s; cursor: default; }
.bar:hover { background: var(--ink); border-top-color: var(--ink); }
.bar-label { font-size: 11px; color: var(--text-sec); margin-top: 7px; letter-spacing: .5px; }
.bar-count  { font-size: 10px; color: var(--text-muted); margin-top: 2px; }
.rank { display: inline-flex; align-items: center; justify-content: center; width: 22px; height: 22px; background: var(--ink); color: white; font-size: 11px; font-weight: 600; margin-right: 8px; flex-shrink: 0; border-radius: 2px; }
.prov-detail { display: flex; flex-direction: column; }
.prov-row { display: flex; justify-content: space-between; align-items: center; padding: 12px 0; border-bottom: 1px solid var(--border); font-size: 14px; line-height: 1.5; }
.prov-row:last-child { border-bottom: none; }

/* ── KI-Scan ───────────────────────────────────────────────────── */
.ki-scan-btn { letter-spacing: .5px; }
.ki-hint {
  font-size: 11px; color: var(--text-muted);
  letter-spacing: .3px; margin-top: 5px; line-height: 1;
}
@keyframes ki-spin { to { transform: rotate(360deg); } }
.ki-spin { display: inline-block; animation: ki-spin .9s linear infinite; margin-right: 2px; }

/* ── Foto ──────────────────────────────────────────────────────── */
.form-control-file { display: block; width: 100%; padding: 6px 0; font-size: 13px; cursor: pointer; color: var(--text-sec); font-family: var(--body); }
.foto-preview { margin-top: 10px; }
.foto-preview-img { max-width: 130px; max-height: 100px; border: 1px solid var(--border); object-fit: cover; display: block; border-radius: 2px; }
.artikel-foto-thumb { width: 40px; height: 40px; object-fit: cover; border: 1px solid var(--border); cursor: pointer; transition: opacity .15s; display: block; flex-shrink: 0; border-radius: 2px; }
.artikel-foto-thumb:hover { opacity: .7; }
.foto-fullscreen { position: fixed; inset: 0; background: rgba(0,0,0,.92); z-index: 600; display: flex; align-items: center; justify-content: center; cursor: zoom-out; animation: fi .2s ease; }
@keyframes fi { from { opacity: 0; } to { opacity: 1; } }
.foto-fullscreen img { max-width: 90vw; max-height: 90vh; object-fit: contain; border-radius: 2px; }

/* ================================================================
   PWA INSTALL BANNER
   ================================================================ */

.install-banner {
  position: fixed;
  bottom: 0; left: 0; right: 0;
  background: #1a1a1a;
  border-top: 1px solid #2e2e2e;
  padding: 12px 16px 12px 20px;
  display: flex;
  align-items: center;
  gap: 13px;
  z-index: 400;
  box-shadow: 0 -4px 24px rgba(0,0,0,.5);
  /* safe area for notched phones */
  padding-bottom: calc(12px + env(safe-area-inset-bottom, 0px));
}
.install-banner-icon {
  width: 40px; height: 40px;
  background: #0a0a0a;
  border: 1px solid #333;
  border-radius: 8px;
  display: flex; align-items: center; justify-content: center;
  font-family: Georgia, serif;
  font-size: 22px;
  font-style: italic;
  color: #ffffff;
  flex-shrink: 0;
}
.install-banner-text { flex: 1; min-width: 0; }
.install-banner-title {
  font-size: 13px; font-weight: 600;
  color: #ffffff; line-height: 1.3;
}
.install-banner-sub {
  font-size: 11px;
  color: rgba(255,255,255,.45);
  margin-top: 2px;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.install-banner-btn {
  padding: 8px 16px;
  background: #ffffff;
  color: #0a0a0a;
  border: none;
  border-radius: 2px;
  font-family: var(--body);
  font-size: 12px;
  font-weight: 600;
  letter-spacing: .5px;
  cursor: pointer;
  flex-shrink: 0;
  transition: background .15s;
}
.install-banner-btn:hover { background: #e0e0e0; }
.install-banner-close {
  background: none; border: none;
  color: rgba(255,255,255,.35);
  font-size: 16px; cursor: pointer;
  padding: 4px 6px; line-height: 1;
  flex-shrink: 0;
  transition: color .15s;
}
.install-banner-close:hover { color: rgba(255,255,255,.8); }

/* ================================================================
   PRINT
   ================================================================ */

@media print {
  .app-header, .mobile-nav, .overlay, .topbar, .toasts, .modal-overlay { display: none !important; }
  .main { overflow: visible; }
  .content { height: auto; padding: 0; overflow: visible; }
  body { height: auto; overflow: visible; display: block; }
}

/* ================================================================
   RESPONSIVE
   ================================================================ */

@media (max-width: 1100px) {
  .app-header { grid-template-columns: auto 1fr auto; gap: 16px; }
  .header-nav { gap: 0; }
  .nav-link { padding: 10px 10px; font-size: 10px; letter-spacing: 2px; }
}

@media (max-width: 900px) {
  .artikel-row-grid { grid-template-columns: 1fr 1fr 1fr; }
  .stats-grid-3 { grid-template-columns: 1fr 1fr; }
  .stats-grid-2 { grid-template-columns: 1fr; }
  .kunde-info-grid { grid-template-columns: 1fr 1fr; }
}

@media (max-width: 768px) {
  /* Switch header to: brand | spacer | hamburger */
  .app-header { grid-template-columns: 1fr auto; padding: 0 20px; }
  .header-nav  { display: none; }   /* hide desktop nav */
  .header-user { display: none; }   /* hide desktop user info */
  .hamburger   { display: flex; }   /* show hamburger */

  .topbar  { padding: 0 20px; }
  .content { padding: 20px 16px; }
  .abrechnungs-summary { padding: 24px; }

  .kunden-grid { grid-template-columns: 1fr; }
  .stats-grid  { grid-template-columns: repeat(2, 1fr); }
  .artikel-row-grid { grid-template-columns: 1fr 1fr; }
  .search-input { max-width: 100%; }
  .kunde-info-grid { grid-template-columns: 1fr; }

  .table-wrap table thead { display: none; }
  .table-wrap table, .table-wrap tbody, .table-wrap tr, .table-wrap td { display: block; width: 100%; }
  .table-wrap tr { border: 1px solid var(--border); margin-bottom: 10px; border-radius: 2px; }
  .table-wrap td { padding: 10px 16px; border-bottom: 1px solid var(--border); text-align: left !important; font-size: 14px; }
  .table-wrap td:last-child { border-bottom: none; }
  .table-wrap td[data-label]::before { content: attr(data-label); display: block; font-size: 10px; font-weight: 600; color: var(--text-sec); text-transform: uppercase; letter-spacing: 1px; margin-bottom: 3px; }
  .actions { flex-wrap: wrap; }
}

@media (max-width: 480px) {
  .stats-grid { grid-template-columns: 1fr; }
  .stats-grid-3 { grid-template-columns: 1fr; }
  .artikel-row-grid { grid-template-columns: 1fr; }
  .kunden-card-actions .btn { width: 100%; }
}

/* ── 375 px (iPhone SE / small Android) ───────────────────────── */
@media (max-width: 390px) {
  .content { padding: 16px 12px; }
  .topbar  { padding: 0 14px; }
  .page-title { font-size: 18px; }
  .stat-card  { padding: 18px 14px 14px; }
  .stat-value { font-size: 30px; }
  .card-body  { padding: 16px; }
  .card-header { padding: 12px 16px; }
  th, td { padding: 10px 12px; }
  .abrechnungs-summary { padding: 20px 16px; }
  .modal { max-height: 95vh; }
  .modal-body   { padding: 16px 20px; }
  .modal-header { padding: 14px 20px 12px; }
  .btn { padding: 9px 16px; }
  .btn-lg { padding: 12px 20px; font-size: 13px; }
  .install-banner-sub { display: none; }
}

/* ── Safe area for notched/dynamic island iPhones ─────────────── */
@supports (padding-top: env(safe-area-inset-top)) {
  .app-header {
    padding-top: env(safe-area-inset-top);
    height: calc(var(--header-h) + env(safe-area-inset-top));
  }
}
