/* ============================================================
   Barefill Dashboard – Design System Implementation
   Monochrome palette only (navy / logistics-blue / grey / white)
   strictly per DESIGN_SYSTEM.md. No status traffic-light colours.
   ============================================================ */

@font-face {
  font-family: "Sora";
  src: url("/fonts/sora/Sora-Variable.woff2") format("woff2");
  font-display: swap;
  font-style: normal;
  font-weight: 100 800;
}

:root {
  --haiti: #0f112e;
  --haiti-light: #1a1d42;
  --accent-blue: #78c5ff;
  --hover-blue: #136fa7;
  --bg-gray: #e8eaed;
  --text-secondary: #5f6368;
  --surface: #ffffff;
  --surface-soft: #fbfdff;
  --panel-dark: #101113;

  --haiti-88: rgba(15, 17, 46, 0.88);
  --haiti-68: rgba(15, 17, 46, 0.68);
  --haiti-16: rgba(15, 17, 46, 0.16);
  --haiti-10: rgba(15, 17, 46, 0.10);
  --haiti-06: rgba(15, 17, 46, 0.06);
  --accent-blue-soft: rgba(120, 197, 255, 0.18);

  --shadow-soft: 0 18px 45px rgba(15, 17, 46, 0.10);
  --shadow-panel: 0 24px 70px rgba(15, 17, 46, 0.12);

  --r-card: 8px;
  --r-card-sm: 6px;
  --r-pill: 999px;

  --sidebar-w: 256px;
  --topbar-h: 68px;

  --ease-out: cubic-bezier(0.22, 1, 0.36, 1);
  --font-barefill-sans: "Sora", -apple-system, BlinkMacSystemFont, "Segoe UI", system-ui, Roboto, "Noto Sans", Ubuntu, Cantarell, "Helvetica Neue", Arial, sans-serif;

  font-family: var(--font-barefill-sans);
}

* { box-sizing: border-box; }

html, body {
  margin: 0; padding: 0; height: 100%;
  background: #fff;
  color: var(--haiti);
  font-family: var(--font-barefill-sans);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}
body { overflow: hidden; }

button { font-family: inherit; cursor: pointer; }
a { color: inherit; text-decoration: none; }

::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-thumb { background: var(--haiti-16); border-radius: 999px; border: 2px solid transparent; background-clip: padding-box; }
::-webkit-scrollbar-thumb:hover { background: var(--haiti-68); background-clip: padding-box; }

/* ============================================================ shell */
.app { display: grid; grid-template-columns: var(--sidebar-w) 1fr; height: 100vh; }

/* ---------- Sidebar ---------- */
.sidebar {
  position: sticky; top: 0; height: 100vh;
  background: var(--haiti);
  border-right: 1px solid rgba(255, 255, 255, 0.08);
  display: flex; flex-direction: column; z-index: 40;
}
.sidebar__brand {
  display: flex; align-items: center; justify-content: center;
  padding: 22px 20px; border-bottom: 1px solid rgba(255, 255, 255, 0.08); flex-shrink: 0;
}
.sidebar__brand img { width: 152px; height: auto; display: block; }

.sidebar__section {
  padding: 18px 14px 8px; font-size: 0.74rem; font-weight: 700; color: #fff;
}

.nav { display: flex; flex-direction: column; gap: 2px; padding: 0 12px; overflow-y: auto; flex: 1; }
.nav__item {
  display: flex; align-items: center; gap: 8px;
  padding: 10px 12px; border-radius: var(--r-card-sm);
  color: rgba(255, 255, 255, 0.82); font-size: 0.9rem; font-weight: 600;
  border: 1px solid transparent; background: none; width: 100%; text-align: left;
  transition: background 180ms var(--ease-out), color 180ms var(--ease-out);
}
.nav__item svg { width: 19px; height: 19px; flex-shrink: 0; stroke-width: 1.9; }
.nav__item:hover { background: rgba(255, 255, 255, 0.07); }
.nav__item.is-active { background: rgba(120, 197, 255, 0.14); color: #fff; }
.nav__item.is-disabled { opacity: 0.4; cursor: not-allowed; }
.nav__item.is-disabled:hover { background: none; }
.nav__lock { margin-left: auto; }
.nav__lock svg { width: 14px; height: 14px; stroke: rgba(255, 255, 255, 0.55); }

.sidebar__foot {
  border-top: 1px solid rgba(255, 255, 255, 0.08); padding: 14px 16px;
  display: flex; align-items: center; gap: 10px; flex-shrink: 0;
}
.sidebar__foot .avatar { background: var(--haiti-light); border: 1px solid rgba(255, 255, 255, 0.14); }
.sidebar__foot .who b { font-size: 0.85rem; display: block; color: #fff; }
.sidebar__foot .who span { font-size: 0.72rem; color: rgba(255, 255, 255, 0.6); }

/* ---------- Main / Topbar ---------- */
.main { display: flex; flex-direction: column; min-width: 0; height: 100vh; overflow: hidden; }
.topbar {
  flex-shrink: 0; height: var(--topbar-h);
  display: flex; align-items: center; gap: 14px; padding: 0 24px;
  background: rgba(255, 255, 255, 0.85);
  backdrop-filter: saturate(140%) blur(12px);
  -webkit-backdrop-filter: saturate(140%) blur(12px);
  border-bottom: 1px solid var(--haiti-10); z-index: 30;
}
.icon-btn.burger { display: none; }

.search { position: relative; flex: 1; max-width: 520px; }
.search svg { position: absolute; left: 14px; top: 50%; transform: translateY(-50%); width: 18px; height: 18px; stroke: var(--text-secondary); }
.search input {
  width: 100%; height: 44px; border: 1px solid var(--haiti-10); border-radius: var(--r-pill);
  background: var(--surface); padding: 0 16px 0 42px; font-size: 0.92rem; color: var(--haiti);
  transition: border-color 160ms var(--ease-out);
}
.search input::placeholder { color: var(--text-secondary); }
.search input:focus { outline: none; border-color: var(--haiti); }
.search kbd {
  position: absolute; right: 10px; top: 50%; transform: translateY(-50%);
  font-size: 0.66rem; font-weight: 700; color: var(--text-secondary);
  border: 1px solid var(--haiti-10); border-radius: 6px; padding: 2px 6px; background: var(--bg-gray);
}
.topbar__spacer { flex: 1; }
.topbar__actions { display: flex; align-items: center; gap: 8px; }

.icon-btn {
  position: relative; width: 44px; height: 44px; border-radius: var(--r-pill);
  border: 1px solid var(--haiti-10); background: var(--surface);
  display: inline-flex; align-items: center; justify-content: center; color: var(--haiti);
  transition: background 160ms var(--ease-out);
}
.icon-btn:hover { background: var(--bg-gray); }
.icon-btn svg { width: 19px; height: 19px; stroke-width: 1.9; }
.icon-btn .dot {
  position: absolute; top: 8px; right: 9px; width: 9px; height: 9px; border-radius: 999px;
  background: var(--accent-blue); border: 2px solid var(--surface);
}

.lang {
  display: inline-flex; align-items: center; gap: 6px; height: 44px; padding: 0 14px;
  border-radius: var(--r-pill); border: 1px solid var(--haiti-10); background: var(--surface);
  font-size: 0.82rem; font-weight: 700; transition: background 160ms var(--ease-out);
}
.lang:hover { background: var(--bg-gray); }
.lang svg { width: 17px; height: 17px; }

.avatar-ph {
  width: 44px; height: 44px; border-radius: 999px; overflow: hidden; padding: 0;
  border: 1px solid var(--haiti-10); background: var(--bg-gray);
  display: inline-flex; flex-shrink: 0; cursor: pointer;
}
.avatar-ph svg { width: 100%; height: 100%; display: block; }
.avatar {
  width: 38px; height: 38px; border-radius: 999px; background: var(--haiti);
  color: #fff; font-weight: 800; font-size: 0.85rem;
  display: inline-flex; align-items: center; justify-content: center; flex-shrink: 0;
}
.sidebar__foot .avatar { width: 36px; height: 36px; }

/* ---------- Content ---------- */
.content {
  flex: 1; min-height: 0; overflow-y: auto; scrollbar-gutter: stable both-edges;
  /* horizontal padding 14 + the 10px reserved gutter on each edge = a clean,
     symmetric 24px to both window edges, aligned with the topbar's 24px. */
  padding: 24px 14px; display: flex; flex-direction: column; gap: 20px; min-width: 0; background: #fff;
}
.page-head h1 { font-size: 1.65rem; font-weight: 700; margin: 0; letter-spacing: -0.01em; }
.page-head p { margin: 4px 0 0; color: var(--haiti-68); font-size: 0.92rem; }

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  height: 44px; padding: 0 22px; border-radius: var(--r-pill);
  font-size: 0.88rem; font-weight: 700; border: 1px solid transparent;
  transition: background 180ms var(--ease-out);
}
.btn svg { width: 17px; height: 17px; }
.btn--primary { background: var(--haiti); color: #fff; }
.btn--primary:hover { background: var(--haiti-light); }
.btn--ghost { background: var(--surface); color: var(--haiti); border-color: var(--haiti-16); }
.btn--ghost:hover { background: var(--bg-gray); }
.btn--sm { height: 38px; padding: 0 16px; font-size: 0.82rem; }

/* ---------- Card ---------- */
.card {
  background: var(--surface); border: 1px solid var(--haiti-10);
  border-radius: var(--r-card); box-shadow: none; min-width: 0;
}

/* Edge-crispness hardening: promote every box to its own GPU layer so its
   1px borders snap onto whole device pixels at any browser zoom or Windows
   display-scaling. This is the one thing that can make a geometrically exact
   (0° skew, measured) box *look* slightly tilted at fractional pixel ratios.
   translateZ(0) is a pure depth shift — no rotation, geometry stays identical. */
.card, .kpi { transform: translateZ(0); }
.card__head {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 16px 18px; border-bottom: 1px solid var(--haiti-10);
}
.card__head h2 { font-size: 1.0rem; font-weight: 700; margin: 0; }
.card__body { padding: 18px; }

.screenshot-carousel {
  position: relative;
  border-radius: var(--r-card-sm);
  overflow: hidden;
  border: 1px solid var(--haiti-10);
  background: #f3f5f7;
  aspect-ratio: 16 / 9;
  min-height: 220px;
}

.screenshot-carousel img {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  opacity: 0;
  transition: opacity 400ms var(--ease-out);
}

.screenshot-carousel img.is-active { opacity: 1; }

/* ============================================================ KPI cards
   Light, modern stat cards ("show the data, hide the chrome"): white surface,
   tinted icon chip, large value, subtle delta pill. On-brand navy/blue/grey. */
.kpi-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 16px; }
.kpi {
  background: var(--surface); color: var(--haiti);
  border: 1px solid var(--haiti-10); border-radius: 12px;
  box-shadow: 0 1px 2px rgba(15, 17, 46, 0.04);
  padding: 18px 20px; display: flex; flex-direction: column; min-width: 0;
  /* bottom edge lines up with the active "Dashboard" nav box in the sidebar. */
  min-height: 161px;
}
.kpi__top { display: flex; align-items: flex-start; justify-content: space-between; gap: 10px; }
/* reserve two lines for the label so the value starts at the same height on
   every card, whether the title wraps to one line or two. */
.kpi__label { font-size: 0.82rem; font-weight: 600; line-height: 1.25; color: var(--text-secondary); min-height: 2.5em; }
.kpi__chip {
  flex-shrink: 0; width: 40px; height: 40px; border-radius: 11px;
  display: inline-flex; align-items: center; justify-content: center;
  background: var(--accent-blue-soft); color: var(--hover-blue);
}
.kpi__chip svg { width: 20px; height: 20px; stroke-width: 2; }
.kpi__value { font-size: 2.2rem; font-weight: 800; line-height: 1; margin: 10px 0 0; letter-spacing: -0.01em; font-variant-numeric: tabular-nums; }
.kpi__foot { display: flex; align-items: center; gap: 10px; margin-top: auto; }
.kpi__delta {
  display: inline-flex; align-items: center; gap: 2px;
  padding: 3px 9px 3px 6px; border-radius: 999px;
  font-size: 0.78rem; font-weight: 700; font-variant-numeric: tabular-nums;
}
.kpi__delta svg { width: 13px; height: 13px; stroke-width: 2.6; }
.kpi__delta--up { background: var(--accent-blue-soft); color: var(--hover-blue); }
.kpi__delta--down { background: var(--haiti-06); color: var(--text-secondary); }
.kpi__cmp { font-size: 0.76rem; color: var(--text-secondary); font-weight: 500; }

/* ============================================================ layout grids */
.grid-2 { display: grid; grid-template-columns: 1.6fr 1fr; gap: 20px; }
.grid-3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 16px; }
.grid-2 > *, .grid-3 > * { min-width: 0; }

/* ---------- charts ---------- */
.chart-wrap { padding: 8px 0 0 6px; }
.chart-stats {
  display: flex; flex-wrap: wrap; gap: 18px; padding: 14px 18px 2px;
  align-items: center;
}
.chart-stats .s {
  min-width: auto;
}
.chart-stats .s b { font-size: 1rem; font-weight: 700; font-variant-numeric: tabular-nums; letter-spacing: 0; }
.chart-stats .s span { display: inline; font-size: 0.72rem; color: var(--text-secondary); font-weight: 600; margin-left: 6px; }

/* throughput – Chart.js canvas (responsive, fills a fixed-height box) */
.chart-canvas { position: relative; height: 280px; padding: 6px 18px 16px; }

/* segmented range switch (Tage / Wochen / Monate) */
.seg { display: inline-flex; gap: 2px; background: var(--bg-gray); border-radius: 8px; padding: 3px; flex-shrink: 0; }
.seg__btn {
  border: none; background: none; cursor: pointer;
  padding: 6px 11px; border-radius: 6px;
  font-size: 0.8rem; font-weight: 600; color: var(--text-secondary);
  transition: color 150ms var(--ease-out), background 150ms var(--ease-out);
}
.seg__btn.is-active { background: var(--surface); color: var(--haiti); box-shadow: 0 1px 2px rgba(15, 17, 46, 0.08); }
.seg__btn:hover:not(.is-active) { color: var(--haiti); }

/* donut (legend removed – chart only, info on hover/click) */
.donut-host { position: relative; display: flex; justify-content: center; width: 100%; }
.donut { position: relative; width: 220px; height: 220px; max-width: 100%; }
.donut__ring, .donut__active {
  position: absolute; inset: 0; border-radius: 50%;
  -webkit-mask: radial-gradient(circle, transparent 0 66px, #000 66.5px);
  mask: radial-gradient(circle, transparent 0 66px, #000 66.5px);
}
.donut__ring { transition: opacity 140ms var(--ease-out); }
.donut__active { pointer-events: none; }
.donut.is-dim .donut__ring { opacity: 0.4; }
.donut__ring { cursor: pointer; }
.donut__center {
  position: absolute; inset: 0; display: flex; flex-direction: column;
  align-items: center; justify-content: center; pointer-events: none;
}
.donut__center b { font-size: 44px; font-weight: 800; line-height: 1; color: var(--haiti); }
.donut__center span { font-size: 15px; font-weight: 600; color: var(--text-secondary); margin-top: 4px; }
.donut-tip {
  position: absolute; left: 0; top: 0; pointer-events: none;
  transform: translate(-50%, calc(-100% - 12px));
  background: var(--surface); border: 1px solid var(--haiti-16);
  border-radius: 6px; padding: 8px 11px; color: var(--haiti); white-space: nowrap; z-index: 5;
}
.donut-tip b { display: block; font-weight: 600; font-size: 0.84rem; }
.donut-tip span { color: var(--text-secondary); font-size: 0.76rem; }

.card--center { display: flex; flex-direction: column; }
.card--center .card__body { flex: 1; display: flex; align-items: center; justify-content: center; }

/* horizontal bars */
.hbars { display: flex; flex-direction: column; gap: 13px; }
.hbar { display: grid; grid-template-columns: 132px 1fr 30px; align-items: center; gap: 10px; font-size: 0.84rem; }
.hbar .nm { font-weight: 600; color: var(--haiti-88); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.hbar .track { height: 8px; background: var(--bg-gray); border-radius: 999px; overflow: hidden; }
.hbar .track > span { display: block; height: 100%; border-radius: 999px; background: var(--haiti); }
.hbar .vv { text-align: right; font-weight: 700; font-variant-numeric: tabular-nums; }

/* bar chart – HTML/CSS. Grid lines, bars and y-labels all live inside
   .bc__area so the baseline (0k) sits exactly at the foot of the bars, with
   the weekday labels comfortably below it. */
.bc { position: relative; width: 100%; padding: 10px 0 36px 38px; }
.bc__area { position: relative; height: 210px; }
.bc__grid { position: absolute; left: 0; right: 0; height: 1px; background: var(--haiti-10); }
.bc__ylab {
  position: absolute; left: -38px; width: 30px; text-align: right; transform: translateY(50%);
  font-size: 11px; font-weight: 600; color: var(--text-secondary);
}
.bc__cols { position: relative; display: flex; align-items: flex-end; gap: 14px; height: 100%; }
.bc__col { position: relative; flex: 1; display: flex; align-items: flex-end; justify-content: center; height: 100%; }
.bc__bar { width: 56%; min-width: 8px; border-radius: 3px 3px 0 0; background: var(--haiti); }
.bc__bar.alt { background: var(--accent-blue); }
.bc__xlab {
  position: absolute; top: 100%; left: 50%; transform: translate(-50%, 12px);
  font-size: 11px; font-weight: 600; color: var(--text-secondary); white-space: nowrap;
}

/* trend mini bar charts – HTML/CSS, upright bars */
.trend { display: flex; flex-direction: column; gap: 10px; }
.trend__name { font-size: 0.86rem; font-weight: 700; color: var(--haiti-88); }
.trend__value { font-size: 1.85rem; font-weight: 800; letter-spacing: -0.02em; font-variant-numeric: tabular-nums; }
.trend__value span { font-size: 1rem; color: var(--text-secondary); }
.spark { display: flex; align-items: flex-end; gap: 3px; width: 100%; aspect-ratio: 160 / 56; }
.spark__bar { flex: 1; min-height: 2px; border-radius: 2px 2px 0 0; background: var(--haiti-16); }
.spark__bar.is-last { background: var(--haiti); }
.trend__foot { display: flex; align-items: center; justify-content: space-between; }

/* ---------- alerts ---------- */
.alerts { display: flex; flex-direction: column; }
.alert {
  display: grid; grid-template-columns: 1fr auto; gap: 6px 12px;
  padding: 14px 18px; border-bottom: 1px solid var(--haiti-10); align-items: start;
}
.alert:last-child { border-bottom: none; }
.alert:hover { background: var(--surface-soft); }
.alert__main b { font-size: 0.9rem; font-weight: 600; }
.alert__main .meta { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 8px; align-items: center; }
.alert__main .ref { font-size: 0.73rem; font-weight: 600; color: var(--haiti-88); background: var(--bg-gray); padding: 2px 8px; border-radius: 6px; font-variant-numeric: tabular-nums; }
.alert__main .action { font-size: 0.78rem; color: var(--text-secondary); margin-top: 6px; }
.alert__time { font-size: 0.74rem; color: var(--text-secondary); white-space: nowrap; font-weight: 600; }

/* ---------- tables ---------- */
.table-scroll { overflow-x: auto; }
table.data { width: 100%; border-collapse: collapse; font-size: 0.86rem; }
table.data th {
  text-align: left; font-size: 0.82rem; font-weight: 600;
  color: var(--haiti); padding: 12px 14px; border-bottom: 1px solid var(--haiti-10);
  white-space: nowrap; background: var(--surface);
}
table.data td { padding: 13px 14px; border-bottom: 1px solid var(--haiti-06); vertical-align: middle; white-space: nowrap; }
table.data tr:last-child td { border-bottom: none; }
table.data tbody tr:hover { background: var(--surface-soft); }
table.data .mono { font-variant-numeric: tabular-nums; font-weight: 600; }
table.data .muted { color: var(--text-secondary); }

/* ============================================================ mobile */
.scrim { display: none; position: fixed; inset: 0; background: rgba(15, 17, 46, 0.45); z-index: 39; }
.scrim.show { display: block; }

@media (max-width: 1180px) { .grid-2 { grid-template-columns: 1fr; } }

@media (max-width: 1024px) {
  .app { grid-template-columns: 1fr; }
  .sidebar { position: fixed; left: 0; top: 0; width: 280px; transform: translateX(-100%); transition: transform 300ms var(--ease-out); box-shadow: var(--shadow-panel); }
  .sidebar.open { transform: translateX(0); }
  .icon-btn.burger { display: inline-flex; }
  .kpi-grid { grid-template-columns: repeat(2, 1fr); }
  .grid-3 { grid-template-columns: 1fr; }
}

@media (max-width: 720px) {
  .topbar { padding: 0 14px; gap: 10px; }
  .topbar__spacer { display: none; }
  .search { max-width: none; }
  .search kbd { display: none; }
  #fullscreen { display: none; }
  .lang { display: none; }
  .content { padding: 16px; gap: 16px; }
  .page-head h1 { font-size: 1.4rem; }
  .kpi-grid { grid-template-columns: 1fr; }
  .chart-stats { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 10px; }
  .chart-stats .s { min-width: 0; }
  .chart-stats .s span { display: block; margin-left: 0; margin-top: 2px; }
}

@media (prefers-reduced-motion: reduce) {
  * { animation: none !important; transition: none !important; }
}
