/* =========================================================
   Rümpellos Admin – Custom CSS
   Minimalistisch, strukturiert, lesbar.
   ========================================================= */

:root {
  --sidebar-w: 230px;
  --header-h: 56px;
  --bg: #f4f5f7;
  --surface: #ffffff;

  --sidebar-bg: #0f172a;
  --sidebar-text: rgba(255, 255, 255, 0.55);
  --sidebar-hover-bg: rgba(255, 255, 255, 0.06);
  --sidebar-active-bg: rgba(99, 102, 241, 0.18);
  --sidebar-active-text: #ffffff;
  --sidebar-active-border: #6366f1;
  --sidebar-section: rgba(255, 255, 255, 0.25);

  --primary: #6366f1;
  --primary-hover: #4f46e5;
  --border: #e2e8f0;
  --text: #1e293b;
  --text-muted: #64748b;
  --text-xs: 11px;
  --text-sm: 13px;
  --radius: 8px;
  --shadow: 0 1px 3px rgba(0, 0, 0, 0.07), 0 1px 2px rgba(0, 0, 0, 0.04);
}

*, *::before, *::after { box-sizing: border-box; }

body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  font-size: 14px;
  line-height: 1.5;
  color: var(--text);
  background: var(--bg);
}

/* ===== SIDEBAR ===== */
.sidebar {
  position: fixed;
  top: 0;
  left: 0;
  width: var(--sidebar-w);
  height: 100vh;
  background: var(--sidebar-bg);
  display: flex;
  flex-direction: column;
  z-index: 100;
  overflow-y: auto;
}

.sidebar-brand {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 18px 16px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.06);
  flex-shrink: 0;
}

.brand-icon {
  width: 32px;
  height: 32px;
  background: var(--primary);
  color: white;
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 16px;
  flex-shrink: 0;
}

.brand-name {
  font-size: 15px;
  font-weight: 600;
  color: white;
  letter-spacing: -0.2px;
}

.sidebar-nav {
  flex: 1;
  padding: 12px 0;
}

.nav-section-label {
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.8px;
  color: var(--sidebar-section);
  padding: 14px 16px 4px;
  font-weight: 600;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 16px;
  color: var(--sidebar-text);
  text-decoration: none;
  font-size: 13.5px;
  font-weight: 450;
  transition: background 0.12s, color 0.12s;
  border-left: 3px solid transparent;
}

.nav-item:hover {
  background: var(--sidebar-hover-bg);
  color: white;
}

.nav-item.active {
  background: var(--sidebar-active-bg);
  color: var(--sidebar-active-text);
  border-left-color: var(--sidebar-active-border);
}

.nav-icon {
  width: 16px;
  text-align: center;
  opacity: 0.7;
  flex-shrink: 0;
}

.nav-item.active .nav-icon,
.nav-item:hover .nav-icon {
  opacity: 1;
}

.sidebar-footer {
  padding: 12px 0;
  border-top: 1px solid rgba(255, 255, 255, 0.06);
  flex-shrink: 0;
}

.logout-item {
  color: rgba(255, 255, 255, 0.4);
}

.logout-item:hover {
  color: #ef4444;
  background: rgba(239, 68, 68, 0.08);
}

/* ===== MAIN WRAPPER ===== */
.main-wrapper {
  margin-left: var(--sidebar-w);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

/* ===== TOPBAR ===== */
.topbar {
  position: sticky;
  top: 0;
  height: var(--header-h);
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 24px;
  z-index: 50;
}

.page-title {
  font-size: 17px;
  font-weight: 600;
  color: var(--text);
  margin: 0;
  letter-spacing: -0.3px;
}

.topbar-right {
  display: flex;
  align-items: center;
  gap: 12px;
}

.user-badge {
  font-size: 13px;
  color: var(--text-muted);
  display: flex;
  align-items: center;
  gap: 6px;
}

/* ===== MAIN CONTENT ===== */
.main-content {
  flex: 1;
  padding: 24px;
}

/* ===== PANELS ===== */
.panel {
  background: var(--surface);
  border-radius: var(--radius);
  border: 1px solid var(--border);
  box-shadow: var(--shadow);
  overflow: hidden;
}

.panel-header {
  padding: 14px 18px;
  font-size: 13px;
  font-weight: 600;
  color: var(--text);
  border-bottom: 1px solid var(--border);
  background: #fafafa;
  display: flex;
  align-items: center;
}

.panel > .table {
  margin-bottom: 0;
}

.panel > .detail-table {
  margin: 16px 18px;
}

.panel > p,
.panel > .row {
  padding: 16px 18px;
}

.panel--attribution {
  border-color: rgba(99, 102, 241, 0.2);
  background: rgba(99, 102, 241, 0.02);
}

.panel--attribution .panel-header {
  background: rgba(99, 102, 241, 0.05);
  color: var(--primary);
}

/* ===== KPI CARDS ===== */
.kpi-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  box-shadow: var(--shadow);
}

.kpi-card--warn {
  border-color: rgba(245, 158, 11, 0.3);
  background: rgba(255, 251, 235, 0.5);
}

.kpi-label {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.6px;
  color: var(--text-muted);
  font-weight: 600;
  margin-bottom: 6px;
}

.kpi-value {
  font-size: 24px;
  font-weight: 700;
  color: var(--text);
  letter-spacing: -0.5px;
  line-height: 1.2;
}

.kpi-sub {
  font-size: 12px;
  color: var(--text-muted);
  margin-top: 4px;
}

/* ===== STAT CARDS ===== */
.stat-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  box-shadow: var(--shadow);
  text-align: center;
}

.stat-card--danger {
  border-color: rgba(239, 68, 68, 0.2);
}

.stat-card-title {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.6px;
  color: var(--text-muted);
  font-weight: 600;
  margin-bottom: 8px;
}

.stat-card-main {
  font-size: 32px;
  font-weight: 700;
  color: var(--text);
  letter-spacing: -1px;
  line-height: 1;
  margin-bottom: 6px;
}

.stat-card--danger .stat-card-main {
  color: #ef4444;
}

.stat-card-detail {
  font-size: 12px;
  color: var(--text-muted);
}

/* ===== TABLES ===== */
.table {
  font-size: 13px;
}

.table th {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--text-muted);
  font-weight: 600;
  border-bottom-width: 1px;
  white-space: nowrap;
  padding: 10px 12px;
}

.table td {
  padding: 10px 12px;
  vertical-align: middle;
  border-color: var(--border);
}

.dt-table tbody tr {
  cursor: pointer;
  transition: background 0.1s;
}

.dt-table tbody tr:hover {
  background: rgba(99, 102, 241, 0.04);
}

/* ===== DETAIL TABLE ===== */
.detail-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
  margin: 16px 18px;
  width: calc(100% - 36px);
}

.detail-table tr + tr td {
  border-top: 1px solid var(--border);
}

.detail-table td {
  padding: 8px 4px;
  vertical-align: top;
}

.dt-label {
  color: var(--text-muted);
  font-size: 12px;
  width: 140px;
  flex-shrink: 0;
  padding-right: 12px;
}

/* ===== BADGES ===== */
.badge-source {
  display: inline-block;
  background: rgba(99, 102, 241, 0.1);
  color: var(--primary);
  border-radius: 4px;
  padding: 2px 7px;
  font-size: 11px;
  font-weight: 500;
}

/* ===== LINKS ===== */
.order-link {
  color: var(--primary);
  text-decoration: none;
  font-weight: 500;
}

.order-link:hover {
  text-decoration: underline;
}

/* ===== TIMELINE ===== */
.timeline {
  padding: 16px 18px;
  display: flex;
  flex-direction: column;
  gap: 0;
}

.timeline-item {
  display: flex;
  gap: 12px;
  position: relative;
  padding-bottom: 14px;
}

.timeline-item:last-child {
  padding-bottom: 0;
}

.timeline-item:not(:last-child)::before {
  content: '';
  position: absolute;
  left: 5px;
  top: 14px;
  bottom: 0;
  width: 1px;
  background: var(--border);
}

.timeline-dot {
  width: 11px;
  height: 11px;
  border-radius: 50%;
  background: var(--primary);
  flex-shrink: 0;
  margin-top: 3px;
}

.timeline-body {
  flex: 1;
}

/* ===== ATTRIBUTION CHAIN ===== */
.attribution-chain {
  display: flex;
  align-items: center;
  gap: 0;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
}

.chain-step {
  flex: 1;
  padding: 14px 18px;
  text-align: center;
}

.chain-step--empty .chain-value {
  color: var(--text-muted);
  font-style: italic;
}

.chain-step--success .chain-value {
  color: #10b981;
  font-weight: 600;
}

.chain-label {
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--text-muted);
  font-weight: 600;
  margin-bottom: 4px;
}

.chain-value {
  font-size: 13px;
  font-weight: 500;
  color: var(--text);
}

.chain-arrow {
  font-size: 16px;
  color: var(--text-muted);
  flex-shrink: 0;
}

/* ===== PLZ GRID ===== */
.plz-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  padding: 16px 18px;
}

.plz-item {
  display: flex;
  align-items: center;
  gap: 6px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 5px 10px;
}

.plz-code {
  font-size: 13px;
  font-weight: 600;
  font-family: monospace;
}

.plz-count {
  font-size: 11px;
  color: var(--text-muted);
}

/* ===== UTILITIES ===== */
.text-sm  { font-size: var(--text-sm) !important; }
.text-xs  { font-size: var(--text-xs) !important; }
.mono-sm  { font-family: monospace; font-size: 12px; }

/* ===== LOGIN ===== */
.login-body {
  background: var(--bg);
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
}

.login-container {
  width: 100%;
  max-width: 380px;
  padding: 20px;
}

.login-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 36px 32px;
  box-shadow: 0 4px 24px rgba(0, 0, 0, 0.06);
}

.login-brand {
  text-align: center;
  margin-bottom: 28px;
}

.login-logo {
  width: 48px;
  height: 48px;
  background: var(--primary);
  color: white;
  border-radius: 12px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 22px;
  font-weight: 700;
  margin-bottom: 12px;
}

.login-title {
  font-size: 20px;
  font-weight: 700;
  color: var(--text);
  margin: 0 0 4px;
}

.login-subtitle {
  font-size: 13px;
  color: var(--text-muted);
  margin: 0;
}

.alert-sm {
  font-size: 13px;
  padding: 10px 14px;
  margin-bottom: 16px;
}

/* ===== FORM ===== */
.form-label {
  font-size: 12px;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.4px;
}

.form-control {
  font-size: 14px;
  border-color: var(--border);
  border-radius: 6px;
}

.form-control:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.1);
}

.btn-primary {
  background: var(--primary);
  border-color: var(--primary);
  font-weight: 500;
}

.btn-primary:hover {
  background: var(--primary-hover);
  border-color: var(--primary-hover);
}

/* ===== DATATABLES OVERRIDES ===== */
div.dataTables_wrapper div.dataTables_filter input {
  font-size: 13px;
  border-color: var(--border);
  border-radius: 6px;
  padding: 5px 10px;
}

div.dataTables_wrapper div.dataTables_length select {
  font-size: 13px;
  border-color: var(--border);
  border-radius: 6px;
}

div.dataTables_wrapper div.dataTables_info {
  font-size: 12px;
  color: var(--text-muted);
}

div.dataTables_wrapper {
  padding: 12px;
}

.page-item.active .page-link {
  background-color: var(--primary);
  border-color: var(--primary);
}

.page-link {
  color: var(--primary);
}
