/* Tektena Design-System (Tokens und Komponenten), übernommen aus BankKonverter. */

:root {
  /* Flaechen */
  --surface-page: #F5F7FA;
  --surface-card: #FFFFFF;
  --surface-subtle: #EDF1F6;
  --surface-inset: #E3E9F0;

  /* Linien */
  --border-default: #D3DBE4;
  --border-strong: #7E8C9C;

  /* Text */
  --text-primary: #16202B;
  --text-secondary: #4A5765;
  --text-muted: #64707D;
  --text-on-accent: #FFFFFF;

  /* Akzent (Primaerfarbe) */
  --accent-900: #12303F;
  --accent-700: #1B4965;
  --accent-500: #2C6E96;
  --accent-100: #DCEAF3;

  /* Status */
  --status-success: #1E7A46;
  --status-success-bg: #E4F3EA;
  --status-warning: #8A5A00;
  --status-warning-bg: #FCF1DC;
  --status-error: #A32020;
  --status-error-bg: #FBE6E6;

  /* Schriften */
  --font-ui: "Inter", "Source Sans 3", -apple-system, "Segoe UI", system-ui, sans-serif;
  --font-num: "Inter", ui-monospace, "SF Mono", "Consolas", monospace;
  --font-mono: ui-monospace, "SF Mono", "Consolas", monospace;

  /* Typografie */
  --text-display: 28px;
  --text-h1: 22px;
  --text-h2: 18px;
  --text-h3: 15px;
  --text-body: 14px;
  --text-body-s: 13px;
  --text-caption: 12px;
  --text-label: 12px;

  /* Raster */
  --space-1: 4px;
  --space-2: 8px;
  --space-3: 12px;
  --space-4: 16px;
  --space-5: 24px;
  --space-6: 32px;

  --radius-sm: 4px;
  --radius-md: 6px;
  --radius-lg: 8px;

  --shadow-card: 0 1px 2px rgba(22, 32, 43, .06), 0 1px 3px rgba(22, 32, 43, .08);
  --shadow-modal: 0 8px 28px rgba(22, 32, 43, .18);
}

html { scrollbar-gutter: stable; }

body {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  margin: 0;
  background: var(--surface-page);
  color: var(--text-primary);
  font-family: var(--font-ui);
  font-size: var(--text-body);
  line-height: 21px;
  -webkit-font-smoothing: antialiased;
}

a { color: inherit; text-decoration: none; }
code { font-family: var(--font-mono); font-size: .95em; }

button:focus-visible,
a:focus-visible {
  outline: 2px solid var(--accent-500);
  outline-offset: 2px;
}

/* --- Navigation --- */
.app-nav {
  position: sticky;
  top: 0;
  z-index: 50;
  height: 56px;
  background: var(--surface-card);
  border-bottom: 1px solid var(--border-default);
}
.app-nav-inner {
  max-width: 1440px;
  height: 100%;
  margin: 0 auto;
  padding: 0 var(--space-5);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-4);
}
.brand { display: flex; align-items: center; gap: var(--space-3); }
.brand img { height: 32px; width: auto; }
.brand-name {
  display: block;
  line-height: 1;
  font-weight: 600;
  font-size: var(--text-h3);
  color: var(--text-primary);
}
.brand-company {
  display: block;
  margin-top: 2px;
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: .14em;
  color: var(--text-muted);
}
.brand-company:hover { color: var(--accent-500); }

.nav-links { display: flex; align-items: center; gap: var(--space-5); font-size: var(--text-body-s); }
.nav-link { color: var(--text-secondary); }
.nav-link:hover { text-decoration: underline; }
.nav-link.active { color: var(--accent-700); font-weight: 600; }

.nav-user { display: flex; align-items: center; gap: var(--space-4); }
.avatar {
  width: 36px;
  height: 36px;
  border-radius: 9999px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 600;
  font-size: var(--text-body-s);
  background: var(--accent-700);
  color: var(--text-on-accent);
  cursor: pointer;
  list-style: none;
}
.avatar::-webkit-details-marker { display: none; }
.user-menu { position: relative; }
.user-menu-panel {
  position: absolute;
  right: 0;
  margin-top: var(--space-2);
  width: 224px;
  padding: var(--space-1) 0;
  background: var(--surface-card);
  border: 1px solid var(--border-default);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-modal);
}
.user-menu-head {
  padding: 10px var(--space-4);
  border-bottom: 1px solid var(--border-default);
}
.user-menu-item {
  display: block;
  padding: var(--space-2) var(--space-4);
  font-size: var(--text-body-s);
  color: var(--text-primary);
}
.user-menu-item:hover { background: var(--surface-subtle); }
.user-menu-item.danger { color: var(--status-error); }

@media (max-width: 767px) {
  .nav-links { display: none; }
  .app-nav-inner { padding: 0 var(--space-4); }
}

/* Mobile-Navigation unter der Kopfzeile */
.mobile-nav {
  display: none;
  gap: var(--space-2);
  padding: var(--space-2) var(--space-4);
  background: var(--surface-card);
  border-bottom: 1px solid var(--border-default);
  overflow-x: auto;
  font-size: var(--text-body-s);
}
@media (max-width: 767px) { .mobile-nav { display: flex; } }

/* --- Seitenlayout --- */
.page {
  flex: 1;
  width: 100%;
  max-width: 1440px;
  margin: 0 auto;
  padding: var(--space-6) var(--space-5);
  box-sizing: border-box;
}
@media (max-width: 767px) { .page { padding: var(--space-5) var(--space-4); } }
.page-header { margin-bottom: var(--space-5); }
.page-title { margin: 0; font-size: var(--text-h1); line-height: 30px; font-weight: 600; color: var(--text-primary); }
.page-subtitle { margin: var(--space-1) 0 0; font-size: var(--text-body-s); color: var(--text-secondary); }

/* --- Karten --- */
.card {
  background: var(--surface-card);
  border: 1px solid var(--border-default);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-card);
}
.card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-3);
  padding: var(--space-3) var(--space-5);
  border-bottom: 1px solid var(--border-default);
}
.card-title { margin: 0; font-size: var(--text-h3); line-height: 22px; font-weight: 600; color: var(--text-primary); }
.card-body { padding: var(--space-5); }

/* Kennzahlen */
.stat-label {
  margin: 0;
  font-size: var(--text-label);
  font-weight: 600;
  letter-spacing: .04em;
  text-transform: uppercase;
  color: var(--text-secondary);
}
.stat-value {
  margin: var(--space-1) 0 0;
  font-size: var(--text-display);
  line-height: 36px;
  font-weight: 600;
  color: var(--text-primary);
}
.stat-icon {
  width: 40px;
  height: 40px;
  border-radius: var(--radius-md);
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--accent-100);
  color: var(--accent-700);
}
.stat-meta { margin: var(--space-3) 0 0; font-size: var(--text-caption); color: var(--text-muted); }

/* Balken */
.bar { background: var(--surface-subtle); border-radius: var(--radius-sm); overflow: hidden; }
.bar-fill { height: 100%; background: var(--accent-500); border-radius: var(--radius-sm); }

/* --- Buttons --- */
.btn-base {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-2);
  height: 38px;
  padding: 0 var(--space-4);
  font-family: inherit;
  font-weight: 600;
  font-size: var(--text-body);
  border-radius: var(--radius-md);
  border: 1px solid transparent;
  cursor: pointer;
  transition: background-color .15s ease, opacity .15s ease;
  white-space: nowrap;
}
.btn-base:disabled { opacity: .45; cursor: not-allowed; }
.btn-primary { background: var(--accent-700); color: var(--text-on-accent); }
.btn-primary:hover:not(:disabled) { background: var(--accent-900); }
.btn-secondary { background: var(--surface-card); color: var(--text-primary); border-color: var(--border-strong); }
.btn-secondary:hover:not(:disabled) { background: var(--surface-subtle); }
.btn-tertiary { height: auto; padding: 0; background: transparent; color: var(--accent-500); font-weight: 400; }
.btn-tertiary:hover:not(:disabled) { text-decoration: underline; }
.btn-destructive { background: transparent; color: var(--status-error); border-color: var(--status-error); }
.btn-destructive:hover:not(:disabled) { background: var(--status-error-bg); }
.btn-sm { height: 32px; padding: 0 var(--space-3); font-size: var(--text-body-s); }

.icon-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  border-radius: var(--radius-sm);
  border: 1px solid transparent;
  background: transparent;
  color: var(--text-secondary);
  cursor: pointer;
}
.icon-btn:hover { background: var(--surface-subtle); color: var(--accent-700); }
.icon-btn.danger:hover { background: var(--status-error-bg); color: var(--status-error); }

/* --- Formulare --- */
.field {
  display: block;
  width: 100%;
  box-sizing: border-box;
  height: 36px;
  padding: 0 var(--space-3);
  background: var(--surface-card);
  color: var(--text-primary);
  border: 1px solid var(--border-default);
  border-radius: var(--radius-sm);
  font-family: inherit;
  font-size: var(--text-body);
}
.field:focus-visible { outline: 2px solid var(--accent-500); outline-offset: 1px; }
.field[readonly] { background: var(--surface-subtle); color: var(--text-secondary); }
.field[aria-invalid="true"] { border-color: var(--status-error); }
textarea.field { height: auto; padding: var(--space-2) var(--space-3); }
.field-mono { font-family: var(--font-mono); font-size: var(--text-body-s); }

.field-label {
  display: block;
  margin-bottom: var(--space-1);
  font-size: var(--text-label);
  font-weight: 600;
  letter-spacing: .04em;
  text-transform: uppercase;
  color: var(--text-secondary);
}
.field-hint { margin: var(--space-1) 0 0; font-size: var(--text-caption); color: var(--text-muted); }
.field-error { margin-top: var(--space-1); font-size: var(--text-caption); color: var(--status-error); }

.checkbox {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  font-size: var(--text-body-s);
  color: var(--text-secondary);
  cursor: pointer;
}
.checkbox input { accent-color: var(--accent-700); width: 16px; height: 16px; }
.checkbox-tile {
  padding: var(--space-2);
  border: 1px solid var(--border-default);
  border-radius: var(--radius-sm);
  background: var(--surface-card);
}
.checkbox-tile:hover { background: var(--surface-subtle); }

/* --- Hinweise --- */
.alert {
  padding: var(--space-3) var(--space-4);
  border-radius: var(--radius-sm);
  border: 1px solid;
  font-size: var(--text-body-s);
}
.alert-error { background: var(--status-error-bg); border-color: var(--status-error); color: var(--status-error); }

/* --- Tabellen --- */
.table-wrap { overflow-x: auto; }
.data-table { width: 100%; border-collapse: collapse; font-size: var(--text-body-s); }
.data-table th {
  padding: var(--space-2) var(--space-4);
  text-align: left;
  font-size: var(--text-label);
  font-weight: 600;
  letter-spacing: .04em;
  text-transform: uppercase;
  color: var(--text-secondary);
  background: var(--surface-subtle);
  border-bottom: 1px solid var(--border-default);
  white-space: nowrap;
}
.data-table td {
  padding: 10px var(--space-4);
  border-bottom: 1px solid var(--border-default);
  color: var(--text-primary);
  vertical-align: top;
}
.data-table tbody tr:last-child td { border-bottom: 0; }
.data-table tbody tr:hover td { background: var(--surface-page); }
.data-table .num { text-align: right; font-family: var(--font-num); font-variant-numeric: tabular-nums; }
.data-table .empty { padding: var(--space-4); color: var(--text-muted); font-style: italic; }

/* --- Badges --- */
.badge {
  display: inline-block;
  padding: 2px var(--space-2);
  border-radius: var(--radius-sm);
  font-size: var(--text-caption);
  font-weight: 600;
  white-space: nowrap;
}
.badge-success { background: var(--status-success-bg); color: var(--status-success); }
.badge-error { background: var(--status-error-bg); color: var(--status-error); }
.badge-neutral { background: var(--surface-subtle); color: var(--text-secondary); font-weight: 400; }
.badge-accent { background: var(--accent-100); color: var(--accent-700); }

.text-muted { color: var(--text-muted); }
.text-secondary { color: var(--text-secondary); }
.text-error { color: var(--status-error); }
.text-success { color: var(--status-success); }
.mono { font-family: var(--font-mono); }

/* --- Footer --- */
.app-footer { background: var(--surface-card); border-top: 1px solid var(--border-default); }
.app-footer-inner {
  max-width: 1440px;
  margin: 0 auto;
  padding: 20px var(--space-5);
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
  font-size: var(--text-caption);
  color: var(--text-secondary);
}
.app-footer p { margin: 0; }
.footer-links { display: flex; flex-wrap: wrap; gap: var(--space-1) var(--space-4); }
.footer-links a { color: var(--accent-500); }
.footer-links a:hover { text-decoration: underline; }
.footer-placeholder { color: var(--text-muted); cursor: not-allowed; }
