/* ================================================================
   DATENKERN DESIGN SYSTEM v5.0 — 2026 EDITION
   Tokens · Reset · Typography · Components
   ================================================================ */

/* ── Tokens ─────────────────────────────────────────────────── */
:root {
  /* Brand palette */
  --brand:          #ff007f;
  --brand-dark:     #d6006c;
  --brand-deeper:   #a90057;
  --brand-light:    rgba(224, 23, 58, 0.08);
  --brand-glow:     rgba(224, 23, 58, 0.22);
  --brand-glow-lg:  rgba(224, 23, 58, 0.35);

  /* Accent pink */
  --accent-pink:    #ff1493;
  --accent-pink-l:  rgba(240, 20, 90, 0.10);

  /* Accent blue */
  --accent-blue:    #ff2da8;
  --accent-blue-l:  rgba(255, 20, 147, 0.18);

  /* Backgrounds */
  --bg-body:    #030003;
  --bg-card:    #090009;
  --bg-surface: #070007;
  --bg-hover:   rgba(255, 20, 147, 0.14);
  --bg-active:  rgba(255, 20, 147, 0.22);
  --bg-muted:   rgba(255, 20, 147, 0.10);

  /* Borders */
  --border:        rgba(255, 20, 147, 0.35);
  --border-light:  rgba(255, 20, 147, 0.20);
  --border-medium: rgba(255, 20, 147, 0.50);
  --border-focus:  rgba(224, 23, 58, 0.40);

  /* Text */
  --text-heading:   #ffffff;
  --text-body:      #fff4fb;
  --text-secondary: #c9a7bb;
  --text-muted:     #9f6b8b;

  /* Status */
  --green:        #00c07b;
  --green-light:  rgba(0, 192, 123, 0.10);
  --yellow:       #f5a623;
  --yellow-light: rgba(245, 166, 35, 0.10);
  --blue:         #ff1493;
  --blue-light:   rgba(255, 20, 147, 0.18);
  --red:          #e0173a;
  --red-light:    rgba(224, 23, 58, 0.08);
  --purple:       #ff1493;
  --purple-light: rgba(124, 58, 237, 0.10);
  --cyan:         #ff2da8;
  --cyan-light:   rgba(6, 182, 212, 0.10);

  /* Shadows — layered for depth */
  --shadow-xs:  0 1px 2px rgba(9,16,31,0.04), 0 0 0 1px rgba(9,16,31,0.02);
  --shadow-sm:  0 1px 3px rgba(9,16,31,0.06), 0 2px 8px rgba(9,16,31,0.04);
  --shadow-md:  0 4px 16px rgba(9,16,31,0.09), 0 1px 3px rgba(9,16,31,0.05);
  --shadow-lg:  0 8px 30px rgba(9,16,31,0.12), 0 2px 8px rgba(9,16,31,0.06);
  --shadow-xl:  0 20px 60px rgba(9,16,31,0.16), 0 4px 16px rgba(9,16,31,0.08);
  --shadow-brand: 0 4px 20px var(--brand-glow), 0 1px 4px var(--brand-glow-lg);

  /* Radius */
  --r-xs:   4px;
  --r-sm:   7px;
  --r-md:   11px;
  --r-lg:   16px;
  --r-xl:   22px;
  --r-2xl:  30px;
  --r-full: 9999px;

  /* Layout */
  --sidebar-w:  248px;
  --topbar-h:   58px;

  /* Motion */
  --ease:        cubic-bezier(0.4, 0, 0.2, 1);
  --ease-spring: cubic-bezier(0.34, 1.56, 0.64, 1);
  --t-fast:      120ms;
  --t-base:      180ms;
  --t-slow:      300ms;
  --transition:  180ms cubic-bezier(0.4, 0, 0.2, 1);
}

/* ── Reset ───────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { -webkit-text-size-adjust: 100%; scroll-behavior: smooth; }
body {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  font-size: 14px;
  line-height: 1.6;
  color: var(--text-body);
  background: var(--bg-body);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}
a { color: inherit; text-decoration: none; }
button { font-family: inherit; cursor: pointer; border: none; background: none; }
img, svg { display: block; }

/* ── Typography ──────────────────────────────────────────────── */
h1 { font-size: 1.625rem; font-weight: 800; color: var(--text-heading); line-height: 1.15; letter-spacing: -0.025em; }
h2 { font-size: 1.0625rem; font-weight: 700; color: var(--text-heading); letter-spacing: -0.015em; }
h3 { font-size: 0.9375rem; font-weight: 600; color: var(--text-heading); }
h4 { font-size: 0.8125rem; font-weight: 600; color: var(--text-heading); }
p  { color: var(--text-secondary); font-size: 0.875rem; line-height: 1.65; }

/* ── Card ────────────────────────────────────────────────────── */
.card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  box-shadow: var(--shadow-sm);
  overflow: hidden;
  transition: box-shadow var(--t-base) var(--ease), transform var(--t-base) var(--ease);
}
.card:hover {
  box-shadow: var(--shadow-md);
}

.card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 1rem 1.25rem;
  border-bottom: 1px solid var(--border-light);
  gap: 0.75rem;
}
.card-header h2 { font-size: 0.875rem; }
.card-body { padding: 1.25rem; }

/* ── KPI/Stat cards ───────────────────────────────────────────── */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 1rem;
  margin-bottom: 1.25rem;
}
.stat-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  padding: 1.25rem 1.375rem;
  box-shadow: var(--shadow-sm);
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
  position: relative;
  overflow: hidden;
  transition: box-shadow var(--t-base) var(--ease), transform var(--t-base) var(--ease);
}
.stat-card::after {
  content: '';
  position: absolute;
  top: 0; left: 0; right: 0; height: 3px;
  background: linear-gradient(90deg, var(--brand), var(--accent-pink));
  border-radius: var(--r-lg) var(--r-lg) 0 0;
  opacity: 0;
  transition: opacity var(--t-base) var(--ease);
}
.stat-card:hover { box-shadow: var(--shadow-md); transform: translateY(-2px); }
.stat-card:hover::after { opacity: 1; }

.stat-icon {
  width: 38px; height: 38px;
  border-radius: var(--r-sm);
  background: var(--brand-light);
  display: flex; align-items: center; justify-content: center;
  margin-bottom: 0.5rem;
  color: var(--brand);
}
.stat-label  { font-size: 0.6875rem; font-weight: 600; color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.06em; }
.stat-value  { font-size: 1.875rem; font-weight: 800; color: var(--text-heading); line-height: 1; letter-spacing: -0.03em; }
.stat-change { font-size: 0.75rem; color: var(--text-muted); margin-top: 0.125rem; }

/* ── Page Header ─────────────────────────────────────────────── */
.page-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 1.5rem;
  gap: 1rem;
}
.page-header h1 { margin-bottom: 0.125rem; }
.page-header p  { font-size: 0.8125rem; }
.actions-row { display: flex; align-items: center; gap: 0.5rem; flex-shrink: 0; }

/* ── Buttons ─────────────────────────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.375rem;
  padding: 0.5625rem 1.125rem;
  font-size: 0.8125rem;
  font-weight: 600;
  border-radius: var(--r-md);
  border: 1px solid transparent;
  cursor: pointer;
  transition: all var(--t-base) var(--ease);
  white-space: nowrap;
  line-height: 1;
  letter-spacing: 0.005em;
  position: relative;
  overflow: hidden;
}

.btn-primary {
  background: linear-gradient(135deg, var(--brand) 0%, var(--brand-dark) 100%);
  color: #fff;
  border-color: transparent;
  box-shadow: 0 2px 8px var(--brand-glow), 0 1px 2px rgba(0,0,0,0.12);
}
.btn-primary:hover {
  background: linear-gradient(135deg, var(--accent-pink) 0%, var(--brand) 100%);
  box-shadow: 0 6px 20px var(--brand-glow-lg), 0 2px 6px rgba(0,0,0,0.15);
  transform: translateY(-1px);
}
.btn-primary:active { transform: translateY(0); }

.btn-secondary {
  background: var(--bg-card);
  color: var(--text-body);
  border-color: var(--border-medium);
  box-shadow: var(--shadow-xs);
}
.btn-secondary:hover {
  background: var(--bg-hover);
  border-color: rgba(15,23,42,0.18);
  box-shadow: var(--shadow-sm);
  transform: translateY(-1px);
}

.btn-ghost {
  background: transparent;
  color: var(--text-secondary);
  border-color: transparent;
}
.btn-ghost:hover { background: var(--bg-hover); color: var(--text-body); }

.btn-danger {
  background: linear-gradient(135deg, var(--red), #c01030);
  color: #fff;
  border-color: transparent;
  box-shadow: 0 2px 8px rgba(224,23,58,0.25);
}
.btn-danger:hover { box-shadow: 0 6px 20px rgba(224,23,58,0.35); transform: translateY(-1px); }

.btn-warning {
  background: linear-gradient(135deg, #d97706, #b45309);
  color: #fff;
  border-color: transparent;
  box-shadow: 0 2px 8px rgba(217,119,6,0.25);
}
.btn-warning:hover { box-shadow: 0 6px 20px rgba(217,119,6,0.35); transform: translateY(-1px); }

.btn-sm  { padding: 0.3125rem 0.75rem; font-size: 0.75rem; border-radius: var(--r-sm); }
.btn-lg  { padding: 0.75rem 1.625rem; font-size: 0.9375rem; border-radius: var(--r-lg); }
.btn-xl  { padding: 1rem 2rem; font-size: 1rem; font-weight: 700; border-radius: var(--r-lg); }

/* ── Badges ──────────────────────────────────────────────────── */
.badge {
  display: inline-flex;
  align-items: center;
  padding: 0.2rem 0.5625rem;
  font-size: 0.6875rem;
  font-weight: 700;
  border-radius: var(--r-full);
  border: 1px solid transparent;
  line-height: 1;
  letter-spacing: 0.02em;
}
.badge-primary  { background: var(--brand-light);   color: var(--brand);        border-color: rgba(224,23,58,.18); }
.badge-success  { background: var(--green-light);   color: #047857;             border-color: rgba(0,192,123,.2); }
.badge-warning  { background: var(--yellow-light);  color: #92400e;             border-color: rgba(245,166,35,.2); }
.badge-danger   { background: var(--red-light);     color: var(--brand);        border-color: rgba(224,23,58,.18); }
.badge-info     { background: var(--blue-light);    color: #ff7cc7;             border-color: rgba(255,20,147,.42); }
.badge-purple   { background: var(--purple-light);  color: #5b21b6;             border-color: rgba(124,58,237,.2); }
.badge-cyan     { background: var(--cyan-light);    color: #0e7490;             border-color: rgba(6,182,212,.2); }
.badge-default  { background: var(--bg-muted);      color: var(--text-secondary); border-color: var(--border); }

/* ── Alerts ──────────────────────────────────────────────────── */
.alert {
  display: flex;
  align-items: flex-start;
  gap: 0.75rem;
  padding: 0.875rem 1.125rem;
  border-radius: var(--r-md);
  border: 1px solid;
  font-size: 0.875rem;
  margin-bottom: 1rem;
}
.alert-success { background: var(--green-light);  border-color: rgba(0,192,123,.25);  color: #065f46; }
.alert-warning { background: var(--yellow-light); border-color: rgba(245,166,35,.25); color: #78350f; }
.alert-danger  { background: var(--red-light);    border-color: rgba(224,23,58,.25);  color: #9b0f20; }
.alert-info    { background: var(--blue-light);   border-color: rgba(255,20,147,.45);  color: #ff7cc7; }

/* Flash messages */
.flash-message {
  padding: 0.875rem 1.125rem;
  border-radius: var(--r-md);
  border: 1px solid;
  font-size: 0.875rem;
  margin-bottom: 1rem;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}
.flash-success { background: var(--green-light);  border-color: rgba(0,192,123,.25);  color: #065f46; }
.flash-error   { background: var(--red-light);    border-color: rgba(224,23,58,.25);  color: #9b0f20; }

/* ── Tables ──────────────────────────────────────────────────── */
.dk-table, table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.8125rem;
}
.dk-table th, th {
  padding: 0.625rem 1rem;
  font-size: 0.6875rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.07em;
  color: var(--text-muted);
  text-align: left;
  border-bottom: 1px solid var(--border);
  background: var(--bg-surface);
  white-space: nowrap;
}
.dk-table td, td {
  padding: 0.8125rem 1rem;
  border-top: 1px solid var(--border-light);
  color: var(--text-body);
  vertical-align: middle;
}
.dk-table tbody tr, tbody tr {
  transition: background var(--t-fast) var(--ease);
}
.dk-table tbody tr:hover, tbody tr:hover { background: var(--bg-hover); }
.dk-table tbody tr:first-child td, tbody tr:first-child td { border-top: none; }

/* ── Forms ───────────────────────────────────────────────────── */
.form-group, .pk-field {
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
  margin-bottom: 1rem;
}
label, .form-group label {
  font-size: 0.8125rem;
  font-weight: 500;
  color: var(--text-body);
  display: block;
}

input[type="text"],
input[type="email"],
input[type="password"],
input[type="tel"],
input[type="url"],
input[type="number"],
input[type="date"],
input[type="datetime-local"],
input[type="time"],
input[type="search"],
select,
textarea,
.form-control {
  width: 100%;
  padding: 0.5625rem 0.9375rem;
  font-size: 0.875rem;
  font-family: inherit;
  color: var(--text-body);
  background: var(--bg-card);
  border: 1.5px solid var(--border-medium);
  border-radius: var(--r-md);
  transition: border-color var(--t-base) var(--ease), box-shadow var(--t-base) var(--ease);
  line-height: 1.5;
  appearance: none;
  -webkit-appearance: none;
}
input:focus, select:focus, textarea:focus, .form-control:focus {
  outline: none;
  border-color: var(--brand);
  box-shadow: 0 0 0 3px var(--brand-light), 0 0 0 1px var(--brand);
}
textarea { resize: vertical; min-height: 90px; }
select { background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3E%3Cpath d='M1 1l5 5 5-5' stroke='%238fa0be' stroke-width='1.5' fill='none' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E"); background-repeat: no-repeat; background-position: right 0.75rem center; padding-right: 2.5rem; }

/* ── Grids ───────────────────────────────────────────────────── */
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 1.25rem; }
.grid-3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 1.25rem; }
.grid-4 { display: grid; grid-template-columns: repeat(4, 1fr); gap: 1.25rem; }

/* ── Empty State ─────────────────────────────────────────────── */
.empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 3rem 1rem;
  text-align: center;
  gap: 0.625rem;
}
.empty-state svg { color: var(--text-muted); margin-bottom: 0.5rem; opacity: 0.4; }
.empty-state h3 { font-size: 0.9375rem; font-weight: 600; }
.empty-state p  { color: var(--text-muted); font-size: 0.8125rem; max-width: 32ch; }

/* ── Divider ─────────────────────────────────────────────────── */
.dk-divider { height: 1px; background: var(--border-light); margin: 1rem 0; }

/* ── Responsive ───────────────────────────────────────────────── */
@media (max-width: 1200px) {
  .stats-grid { grid-template-columns: repeat(2, 1fr); }
  .grid-4     { grid-template-columns: repeat(2, 1fr); }
}
@media (max-width: 768px) {
  .stats-grid, .grid-2, .grid-3, .grid-4 { grid-template-columns: 1fr; }
  .page-header { flex-direction: column; align-items: flex-start; }
  h1 { font-size: 1.375rem; }
}

/* ── Performance & Rendering optimizations ───────────────────── */

/* Promote composited layers only for elements that actually animate */
.sidebar            { will-change: transform; }
.pk-slideover       { will-change: transform; }
.pk-modal           { will-change: opacity, transform; }
.pk-slideover-bg    { will-change: opacity; }

/* Layout containment: card, table, stat-card are self-contained */
.card               { contain: layout style; }
.stat-card          { contain: layout style; }
.pk-table-wrap      { contain: layout; }
.pk-kpi             { contain: layout style; }

/* Smooth scrolling only where needed — avoids browser jank globally */
.pk-slideover-body,
.pk-modal-body      { scroll-behavior: smooth; overscroll-behavior: contain; }

/* Hardware-accelerate fixed elements (topbar, sidebar) */
.topbar             { transform: translateZ(0); }

/* Prefers-reduced-motion: kill ALL animations/transitions */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
    scroll-behavior: auto !important;
  }
  #dk-portal-bg-canvas { display: none !important; }
  .sidebar::before { animation: none !important; }
}

/* Image/media lazy: prevent CLS by reserving space */
img[loading="lazy"] { content-visibility: auto; }

/* content-visibility on offscreen heavy sections */
.pk-timeline        { content-visibility: auto; contain-intrinsic-size: 0 400px; }

