:root {
  --bg: #f5f7f1;
  --panel: #ffffff;
  --panel2: #eef3ea;
  --text: #17212b;
  --muted: #667789;
  --accent: #0b84ff;
  --accent2: #0ea574;
  --danger: #d34e4e;
  --border: #d8e1d5;
  --surface-shadow: 0 10px 28px rgba(17, 33, 44, 0.08);
  --radius: 10px;
  --font: "DM Sans", system-ui, sans-serif;
}

:root[data-theme="dark"] {
  --bg: #0f1419;
  --panel: #1a222d;
  --panel2: #232d3b;
  --text: #e8eef5;
  --muted: #8b9aab;
  --accent: #3d9cf5;
  --accent2: #5ce1a8;
  --danger: #f06b6b;
  --border: #2e3a4a;
  --surface-shadow: none;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  line-height: 1.45;
}

a {
  color: var(--accent);
}

#app {
  max-width: 1280px;
  margin: 0 auto;
  padding: 1.25rem 1.5rem 3rem;
}

header.app-header {
  display: block;
  margin-bottom: 1.5rem;
  padding-bottom: 1rem;
  border-bottom: 1px solid var(--border);
}

.app-logo-img {
  height: 38px;
  width: auto;
  object-fit: contain;
  align-self: flex-end;
}

.app-logo-fallback {
  font-weight: 700;
  color: var(--accent2);
}

.nav-row {
  width: 100%;
  align-items: flex-end;
}

nav.tabs {
  display: flex;
  gap: 0.35rem;
  flex-wrap: wrap;
}

nav.tabs button {
  background: var(--panel2);
  border: 1px solid var(--border);
  color: var(--muted);
  padding: 0.45rem 0.9rem;
  border-radius: var(--radius);
  cursor: pointer;
  font-family: inherit;
  font-size: 0.9rem;
}

nav.tabs button:hover {
  color: var(--text);
  border-color: var(--accent);
}

nav.tabs button.active {
  background: var(--accent);
  color: #061018;
  border-color: var(--accent);
  font-weight: 600;
}

.user-pill {
  font-size: 0.85rem;
  color: var(--muted);
  display: flex;
  align-items: center;
  gap: 0.4rem;
}

.user-pill strong {
  color: var(--text);
}

.grid-kpis {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 0.85rem;
  margin-bottom: 1.25rem;
}

.kpi {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1rem;
  box-shadow: var(--surface-shadow);
}

.kpi .label {
  font-size: 0.78rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--muted);
  margin-bottom: 0.35rem;
}

.kpi .value {
  font-size: 1.35rem;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}

.charts-row {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(320px, 1fr));
  gap: 1rem;
  margin-bottom: 1.5rem;
}

.chart-card {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1rem;
  box-shadow: var(--surface-shadow);
}

.chart-card h3 {
  margin: 0 0 0.75rem;
  font-size: 0.95rem;
  font-weight: 600;
}

.chart-wrap {
  position: relative;
  height: 260px;
}

.panel {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.25rem;
  margin-bottom: 1.25rem;
  box-shadow: var(--surface-shadow);
}

.panel h2 {
  margin: 0 0 1rem;
  font-size: 1.05rem;
}

.toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin-bottom: 1rem;
}

button.primary {
  background: var(--accent2);
  color: #04120c;
  border: none;
  padding: 0.5rem 1rem;
  border-radius: var(--radius);
  font-weight: 600;
  cursor: pointer;
  font-family: inherit;
}

button.primary:hover {
  filter: brightness(1.06);
}

button.ghost {
  background: transparent;
  border: 1px solid var(--border);
  color: var(--text);
  padding: 0.45rem 0.85rem;
  border-radius: var(--radius);
  cursor: pointer;
  font-family: inherit;
}

button.ghost:hover {
  border-color: var(--muted);
}

.table-scroll {
  overflow-x: auto;
  border: 1px solid var(--border);
  border-radius: var(--radius);
}

table.data {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.82rem;
}

table.data th,
table.data td {
  padding: 0.85rem 0.6rem;
  text-align: left;
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
  vertical-align: middle;
}

table.data th {
  background: var(--panel2);
  color: var(--muted);
  font-weight: 600;
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

table.data tr:hover td {
  background: #edf4f0;
}

table.data td.num {
  text-align: right;
  font-variant-numeric: tabular-nums;
}

table.data th.num {
  text-align: right;
}

table.data tbody tr[data-id] {
  cursor: pointer;
}

.form-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 0.75rem 1rem;
}

label.field {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
  font-size: 0.82rem;
  color: var(--muted);
}

label.field input,
label.field select,
label.field textarea {
  background: var(--panel2);
  border: 1px solid var(--border);
  color: var(--text);
  padding: 0.45rem 0.55rem;
  border-radius: 6px;
  font-family: inherit;
  font-size: 0.9rem;
}

label.field textarea {
  min-height: 4rem;
  resize: vertical;
}

.login-screen {
  max-width: 400px;
  margin: 4rem auto;
  padding: 2rem;
  background: var(--panel);
  border-radius: var(--radius);
  border: 1px solid var(--border);
  box-shadow: var(--surface-shadow);
}

.login-screen h1 {
  margin-top: 0;
  font-size: 1.25rem;
}

.login-screen .hint {
  font-size: 0.8rem;
  color: var(--muted);
  margin-top: 1rem;
}

.msg-error {
  color: var(--danger);
  font-size: 0.88rem;
  margin: 0.5rem 0;
}

.settings-section {
  margin-bottom: 1.5rem;
}

.settings-section h3 {
  margin: 0 0 0.75rem;
  font-size: 0.95rem;
  color: var(--accent2);
}

.mwst-tier {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr 100px;
  gap: 0.5rem;
  margin-bottom: 0.5rem;
  align-items: end;
}

@media (max-width: 720px) {
  .mwst-tier {
    grid-template-columns: 1fr 1fr;
  }
}

.badge {
  display: inline-block;
  padding: 0.15rem 0.45rem;
  border-radius: 4px;
  font-size: 0.72rem;
  font-weight: 600;
}

.badge-lager {
  background: #2a3d51;
  color: #9fd4ff;
}

.badge-verkauft {
  background: #1e3d2f;
  color: var(--accent2);
}

.badge-betrieb {
  background: #41322b;
  color: #ffcf9f;
}

.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.65);
  display: flex;
  align-items: flex-start;
  justify-content: center;
  padding: 2rem 1rem;
  overflow-y: auto;
  z-index: 50;
}

.modal {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  width: min(720px, 100%);
  padding: 1.25rem;
  margin-bottom: 2rem;
  box-shadow: 0 24px 60px rgba(11, 18, 26, 0.24);
}

.modal h2 {
  margin-top: 0;
}

.modal-header {
  display: flex;
  align-items: stretch;
  justify-content: space-between;
  gap: 1rem;
  flex-wrap: wrap;
}

.modal-title-wrap {
  flex: 1 1 14rem;
  min-width: 12rem;
}

.modal-title-row {
  display: flex;
  align-items: center;
  gap: 0.65rem;
}

.icon-button.emoji-help {
  min-width: 2.2rem;
  height: 2.2rem;
  padding: 0;
  border-radius: 999px;
  font-size: 1.2rem;
  line-height: 1;
}

.modal-media {
  display: flex;
  align-items: stretch;
  gap: 0.75rem;
  flex: 0 1 34rem;
  min-width: min(100%, 20rem);
}

.modal-brand {
  width: 112px;
  min-width: 112px;
  height: 112px;
  border-radius: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
}

.modal-brand-logo {
  width: 100%;
  height: 100%;
  object-fit: contain;
}

.modal-brand-app {
  font-size: 2rem;
}

.modal-slideshow {
  position: relative;
  flex: 1 1 auto;
  min-width: 0;
  height: 112px;
  border-radius: 12px;
  overflow: hidden;
  background: #dfe8dc;
  border: 1px solid var(--border);
  box-shadow: var(--surface-shadow);
}

.modal-slideshow.is-empty {
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--panel2);
}

.modal-hero-photo {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.modal-slideshow-controls {
  position: absolute;
  left: 0.6rem;
  right: 0.6rem;
  bottom: 0.6rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
}

.modal-slideshow-controls .ghost {
  min-width: 2.25rem;
  padding: 0.3rem 0.55rem;
  background: rgba(16, 21, 29, 0.74);
  border-color: rgba(255, 255, 255, 0.18);
  color: #fff;
}

.modal-photo-count {
  color: #fff;
}

.modal-slideshow-empty {
  color: var(--muted);
  font-size: 0.88rem;
  padding: 1rem;
  text-align: center;
}

.subdialog-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(10, 14, 20, 0.7);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1rem;
  z-index: 30;
}

.subdialog-backdrop[hidden] {
  display: none !important;
}

.subdialog {
  width: min(40rem, 100%);
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 1rem;
  box-shadow: 0 18px 44px rgba(0, 0, 0, 0.32);
}

.subdialog-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 0.8rem;
}

.modal-actions {
  display: flex;
  gap: 0.5rem;
  margin-top: 1rem;
  flex-wrap: wrap;
}

.cockpit-lead {
  color: var(--muted);
  margin-top: 0;
  margin-bottom: 1rem;
  font-size: 0.92rem;
  max-width: 72ch;
}

.cockpit-lead a {
  color: var(--accent2);
}

.cockpit-section {
  margin-bottom: 2rem;
}

.cockpit-section h2 {
  margin: 0 0 0.75rem;
  font-size: 1.05rem;
  font-weight: 600;
  color: var(--accent2);
  letter-spacing: 0.02em;
}

.chart-sub {
  margin: -0.35rem 0 0.65rem;
  font-size: 0.78rem;
  color: var(--muted);
  line-height: 1.35;
}

.chart-tall {
  height: 300px;
}

.settings-sub {
  margin: 1rem 0 0.5rem;
  font-size: 0.88rem;
  font-weight: 600;
  color: var(--muted);
}

/* Navigation: Bestand-Untermenü */
.nav-dropdown {
  position: relative;
  display: inline-block;
}

.nav-dropdown-toggle {
  background: var(--panel2);
  border: 1px solid var(--border);
  color: var(--muted);
  padding: 0.45rem 0.9rem;
  border-radius: var(--radius);
  cursor: pointer;
  font-family: inherit;
  font-size: 0.9rem;
}

.nav-dropdown-toggle:hover {
  color: var(--text);
  border-color: var(--accent);
}

.nav-dropdown-toggle.active {
  background: var(--accent);
  color: #061018;
  border-color: var(--accent);
  font-weight: 600;
}

.nav-dropdown-panel {
  position: absolute;
  top: calc(100% + 4px);
  left: 0;
  min-width: 12rem;
  z-index: 80;
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding: 0.35rem;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.35);
}

.nav-dropdown-panel[hidden] {
  display: none !important;
}

.nav-dropdown-panel button {
  background: var(--panel2);
  border: 1px solid transparent;
  color: var(--muted);
  padding: 0.4rem 0.65rem;
  border-radius: 8px;
  cursor: pointer;
  font-family: inherit;
  font-size: 0.88rem;
  text-align: left;
}

.nav-dropdown-panel button:hover {
  color: var(--text);
  border-color: var(--border);
}

.nav-dropdown-panel button.active {
  color: var(--accent2);
  border-color: var(--accent2);
  font-weight: 600;
}

.tenant-tag {
  font-size: 0.78rem;
  margin-left: 0.5rem;
  padding: 0.12rem 0.45rem;
  border-radius: 6px;
  background: var(--panel2);
  border: 1px solid var(--border);
  color: var(--muted);
}

.nav-user-logo {
  height: 38px;
  max-width: 140px;
  object-fit: contain;
  margin-right: 0.35rem;
  vertical-align: middle;
  align-self: flex-end;
}

.nav-spacer {
  flex: 1;
}

.inventory-lead {
  font-size: 0.9rem;
  color: var(--muted);
  max-width: 48rem;
  margin: 0 0 0.35rem;
}

.inventory-title {
  margin: 0 0 0.75rem;
  font-size: 1.1rem;
  font-weight: 600;
}

.toolbar .historie-filter {
  margin: 0;
  flex: 0 0 auto;
}

.toolbar .historie-filter select {
  min-width: 10rem;
}

.td-logo {
  width: 7rem;
  text-align: center;
  vertical-align: middle;
  display: table-cell;
}

.td-first-photo {
  width: 7rem;
  text-align: center;
}

.first-photo {
  width: 96px;
  height: 64px;
  object-fit: cover;
  border-radius: 6px;
  border: 1px solid var(--border);
  background: #ffffff;
  box-shadow: 0 8px 20px rgba(15, 24, 34, 0.14);
}

.photo-ph {
  display: inline-block;
  width: 96px;
  height: 64px;
  border-radius: 6px;
  background: var(--panel2);
  border: 1px dashed var(--border);
}

.brand-logo-td {
  height: 64px;
  width: auto;
  max-width: 96px;
  object-fit: contain;
  vertical-align: middle;
  display: block;
  margin: 0 auto;
  filter: saturate(1.08) contrast(1.03);
}

.brand-logo-ph {
  display: inline-block;
  width: 96px;
  height: 64px;
  border-radius: 4px;
  background: var(--panel2);
  border: 1px dashed var(--border);
  margin: 0 auto;
}

.muted-mini {
  font-size: 0.78rem;
  color: var(--muted);
}

.field-inline {
  display: flex;
  gap: 0.5rem;
  align-items: center;
}

.field-inline select {
  flex: 1;
  min-width: 0;
}

.form-grid .full-width-field {
  grid-column: 1 / -1;
}

.admin-logo-preview {
  height: 32px;
  max-width: 72px;
  object-fit: contain;
  vertical-align: middle;
}

.admin-panel h2 {
  margin-top: 0;
}

.th-sort {
  background: transparent;
  border: none;
  color: inherit;
  font: inherit;
  text-transform: inherit;
  letter-spacing: inherit;
  cursor: pointer;
  padding: 0;
}

.inline-switch {
  flex-direction: row;
  align-items: center;
  gap: 0.45rem;
}

.pager {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  margin-top: 0.7rem;
  justify-content: flex-end;
}

.settings-tabs {
  margin-bottom: 0.75rem;
}

.photo-strip-wrap {
  margin: 0.75rem 0 1rem;
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 0.6rem;
  background: var(--panel2);
  box-shadow: var(--surface-shadow);
}

.photo-strip-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 0.45rem;
}

.photo-actions {
  display: flex;
  gap: 0.5rem;
  align-items: center;
}

.photo-strip {
  display: flex;
  flex-wrap: wrap;
  gap: 0.45rem;
}

.thumb-card {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
}

.thumb-remove {
  font-size: 0.75rem;
  padding: 0.2rem 0.45rem;
}

.thumb {
  width: 90px;
  height: 65px;
  object-fit: cover;
  border-radius: 6px;
  border: 1px solid var(--border);
  background: #ffffff;
  box-shadow: 0 8px 18px rgba(15, 24, 34, 0.12);
}

:root[data-theme="dark"] .modal-slideshow {
  background: #10151d;
}

:root[data-theme="dark"] table.data tr:hover td {
  background: #1e2835;
}

:root[data-theme="dark"] .first-photo,
:root[data-theme="dark"] .thumb {
  background: #111821;
}

.thumb-broken {
  opacity: 0.55;
  filter: grayscale(1);
}
