/* ==========================================================================
   Almetra design system — shadcn/ui theme as configured in Figma
   ("Theme by Shadcn UI"). Token names mirror the Figma variables.
   ========================================================================== */
:root {
  /* base */
  --background: #ffffff;
  --foreground: #0a0a0a;
  --card: #ffffff;
  --card-foreground: #0a0a0a;
  --popover: #ffffff;
  --popover-foreground: #0a0a0a;
  --primary: #3b82f6;
  --primary-hover: #2f74e8;
  --primary-foreground: #fafafa;
  --secondary: #f5f5f5;
  --muted: #f5f5f5;
  --muted-foreground: #737373;
  --accent: #f5f5f5;
  --border: #e5e5e5;
  --input: #e5e5e5;
  --input-bg: #ffffff;           /* custom/background-dark:input/30 */
  --sidebar: #fafafa;
  --sidebar-foreground: #0a0a0a;
  --sidebar-accent: #f5f5f5;
  --sidebar-accent-foreground: #171717;
  --ring: #a3a3a3;
  --lime: #f5ffb0;               /* brand-colors/lime */
  --lime-foreground: #0a0a0a;

  /* semantic */
  --success: #16a34a;
  --destructive: #dc2626;
  --warning: #f59e0b;
  --info: #3b82f6;

  /* radius */
  --radius-sm: 6px;
  --radius-md: 8px;
  --radius-xl: 14px;

  /* shadows */
  --shadow-xs: 0 1px 1px rgba(0, 0, 0, 0.05);
  --shadow-sm: 0 1px 3px 0 rgba(0, 0, 0, 0.1), 0 1px 2px -1px rgba(0, 0, 0, 0.1);
  --shadow-md: 0 4px 6px 0 rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.1);
  --footer-shadow: 0 -2px 2px rgba(0, 0, 0, 0.12);

  --font-sans: "Inter", -apple-system, BlinkMacSystemFont, "Helvetica Neue", Arial, sans-serif;
  color-scheme: light;
}

.dark {
  --background: #0a0a0a;
  --foreground: #fafafa;
  --card: #171717;
  --card-foreground: #fafafa;
  --popover: #171717;
  --popover-foreground: #fafafa;
  --primary: #3b82f6;
  --primary-hover: #5591f7;
  --primary-foreground: #fafafa;
  --secondary: #262626;
  --muted: #262626;
  --muted-foreground: #a1a1a1;
  --accent: #262626;
  --border: rgba(255, 255, 255, 0.1);
  --input: rgba(255, 255, 255, 0.15);
  --input-bg: rgba(255, 255, 255, 0.045);
  --sidebar: #171717;
  --sidebar-foreground: #fafafa;
  --sidebar-accent: #262626;
  --sidebar-accent-foreground: #fafafa;
  --ring: #737373;
  --success: #22c55e;
  --destructive: #f87171;
  --footer-shadow: 0 -2px 2px rgba(0, 0, 0, 0.4);
  color-scheme: dark;
}

*, *::before, *::after { box-sizing: border-box; }
html, body { margin: 0; overflow: hidden; }
body {
  background: var(--background);
  color: var(--foreground);
  font-family: var(--font-sans);
  font-size: 14px;
  line-height: 20px;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  transition: background-color 0.3s, color 0.3s;
}
button { font: inherit; color: inherit; background: none; border: 0; padding: 0; cursor: pointer; }
p { margin: 0; }
svg.i { display: block; flex: none; }

/* ==========================================================================
   Button
   ========================================================================== */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  height: 36px;
  padding: 8px 16px;
  border-radius: var(--radius-md);
  font-size: 14px;
  font-weight: 500;
  line-height: 20px;
  white-space: nowrap;
  transition: background-color 0.15s, color 0.15s, border-color 0.15s, box-shadow 0.15s, transform 0.1s;
  outline: none;
}
.btn:focus-visible { box-shadow: 0 0 0 3px color-mix(in srgb, var(--ring) 50%, transparent); }
.btn:active { transform: translateY(0.5px); }
.btn-primary { background: var(--primary); color: var(--primary-foreground); }
.btn-primary:hover { background: var(--primary-hover); }
.btn-outline {
  background: var(--input-bg);
  border: 1px solid var(--input);
  color: var(--foreground);
  box-shadow: var(--shadow-xs);
}
.btn-outline:hover, .btn-outline[aria-expanded="true"] { background: var(--accent); }
.btn-ghost { color: var(--foreground); }
.btn-ghost:hover, .btn-ghost[aria-expanded="true"] { background: var(--accent); }
.btn-link { color: var(--primary); }
.btn-link:hover { text-decoration: underline; text-underline-offset: 4px; }
.btn-icon { width: 36px; padding: 0; flex: none; }

/* ==========================================================================
   Badge
   ========================================================================== */
.badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 4px;
  padding: 2px 8px;
  border: 1px solid transparent;
  border-radius: var(--radius-md);
  font-size: 12px;
  font-weight: 600;
  line-height: 16px;
  white-space: nowrap;
  overflow: hidden;
}
.badge-secondary { background: var(--secondary); color: var(--muted-foreground); }
.badge-accent { background: var(--accent); color: var(--popover-foreground); font-weight: 500; }
.badge-station {
  padding: 4px 8px;
  border-radius: 9999px;
  background: var(--border);
  color: var(--popover-foreground);
  font-size: 16px;
}
.dark .badge-station { background: #333; }

/* ==========================================================================
   Card
   ========================================================================== */
.card {
  background: var(--card);
  color: var(--card-foreground);
  border: 1px solid var(--border);
  border-radius: var(--radius-xl);
  box-shadow: var(--shadow-sm);
}
.card-title { font-size: 16px; font-weight: 600; line-height: 16px; }
.card-desc { margin-top: 6px; font-size: 14px; line-height: 20px; color: var(--muted-foreground); }

/* ==========================================================================
   Dropdown menu
   ========================================================================== */
.menu {
  position: absolute;
  z-index: 50;
  min-width: 180px;
  padding: 4px;
  background: var(--popover);
  color: var(--popover-foreground);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-md);
  transform-origin: top right;
  animation: menu-in 0.14s ease-out;
}
.menu[hidden] { display: none; }
.menu-label { padding: 6px 8px; font-size: 14px; font-weight: 600; line-height: 20px; }
.menu-sep { height: 1px; margin: 4px -4px; background: var(--border); }
.menu-item {
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
  padding: 6px 8px;
  border-radius: var(--radius-sm);
  font-size: 14px;
  line-height: 20px;
  text-align: left;
  white-space: nowrap;
  outline: none;
}
.menu-item:hover, .menu-item:focus-visible { background: var(--accent); }
.menu-item .i { color: var(--foreground); }
.menu-item[aria-checked="true"]::after {
  content: "";
  width: 8px; height: 8px; margin-left: auto;
  border-radius: 50%;
  background: var(--primary);
}
@keyframes menu-in { from { opacity: 0; transform: scale(0.96) translateY(-2px); } }

/* ==========================================================================
   Skeleton, tooltip, progress, toast
   ========================================================================== */
.skeleton {
  background: var(--accent);
  border-radius: var(--radius-md);
  animation: pulse 2s cubic-bezier(0.4, 0, 0.6, 1) infinite;
}
@keyframes pulse { 50% { opacity: 0.5; } }

.tip {
  position: fixed;
  z-index: 100;
  padding: 6px 12px;
  border-radius: var(--radius-sm);
  background: var(--foreground);
  color: var(--background);
  font-size: 12px;
  line-height: 16px;
  white-space: nowrap;
  pointer-events: none;
  opacity: 0;
  transform: translate(-50%, calc(-100% - 6px)) scale(0.96);
  transition: opacity 0.12s, transform 0.12s;
}
.tip.is-on { opacity: 1; transform: translate(-50%, calc(-100% - 8px)); }
.tip b { font-weight: 600; }

.progress {
  position: relative;
  height: 8px;
  overflow: hidden;
  border-radius: 9999px;
  background: color-mix(in srgb, var(--primary) 20%, transparent);
}
.progress > span { position: absolute; inset: 0 auto 0 0; background: var(--primary); border-radius: inherit; transition: width 0.6s cubic-bezier(0.22, 1, 0.36, 1); }

.toast {
  position: fixed;
  right: 24px;
  bottom: 24px;
  z-index: 100;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 12px 16px;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  background: var(--popover);
  color: var(--popover-foreground);
  box-shadow: var(--shadow-md);
  font-size: 14px;
  font-weight: 500;
  animation: toast-in 0.25s cubic-bezier(0.22, 1, 0.36, 1);
}
.toast .i { color: var(--success); }
@keyframes toast-in { from { opacity: 0; transform: translateY(8px); } }

.spin { animation: spin 0.9s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

/* ==========================================================================
   Navbar + sidebar (Pro Blocks)
   ========================================================================== */
.navbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 64px;
  padding: 0 24px;
  background: var(--background);
  border-bottom: 1px solid var(--border);
  box-shadow: var(--shadow-xs);
}
.navbar-left { display: flex; align-items: center; }
.app-selector {
  display: flex;
  align-items: center;
  gap: 8px;
  width: 224px;
  height: 48px;
  padding: 8px 12px;
  border-radius: var(--radius-md);
  background: var(--input-bg);
  font-size: 14px;
  font-weight: 500;
  line-height: 16px;
  text-align: left;
  transition: background-color 0.15s;
}
.app-selector:hover { background: var(--accent); }
.app-icon {
  display: grid;
  place-items: center;
  width: 32px;
  height: 32px;
  border-radius: 8px;
  background: var(--lime);
  color: var(--lime-foreground);
}
.navbar-right { display: flex; align-items: center; gap: 16px; }
.shift-clock { display: flex; flex-direction: column; }
.shift-clock__loc { display: flex; align-items: center; gap: 4px; color: var(--muted-foreground); font-size: 11px; font-weight: 500; line-height: 14px; }
.shift-clock__time { font-size: 14px; font-weight: 600; line-height: 20px; font-variant-numeric: tabular-nums; }
.navbar-actions { display: flex; align-items: center; gap: 4px; }
.avatar {
  display: grid;
  place-items: center;
  width: 40px;
  height: 40px;
  border-radius: 9999px;
  background: var(--muted);
  font-size: 14px;
  transition: box-shadow 0.15s;
}
.avatar:hover { box-shadow: 0 0 0 2px var(--border); }

.sidebar { background: var(--sidebar); color: var(--sidebar-foreground); }
.sidebar-group { padding: 8px; border-bottom: 1px solid var(--border); }
.sidebar-group:last-child { border-bottom: 0; }
.sidebar-menu { display: flex; flex-direction: column; gap: 4px; }
.sidebar-btn {
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
  height: 32px;
  padding: 8px;
  border-radius: var(--radius-md);
  font-size: 14px;
  line-height: 1;
  text-align: left;
  white-space: nowrap;
  transition: background-color 0.15s;
}
.sidebar-btn span { flex: 1; overflow: hidden; text-overflow: ellipsis; }
.sidebar-btn:hover { background: var(--sidebar-accent); }
.sidebar-btn[aria-current="page"] { background: var(--sidebar-accent); color: var(--sidebar-accent-foreground); font-weight: 500; }
.sidebar-btn .i { transition: transform 0.2s; }
.sidebar-btn[aria-expanded="true"] .i { transform: rotate(90deg); }
.sidebar-sub { display: flex; flex-direction: column; gap: 2px; margin: 2px 0 4px 14px; padding-left: 10px; border-left: 1px solid var(--border); }
.sidebar-sub[hidden] { display: none; }
.sidebar-sub .sidebar-btn { height: 28px; color: var(--muted-foreground); font-size: 13px; }

/* ==========================================================================
   Insights components
   ========================================================================== */

/* KPI row ("Main KPI") */
.kpi { display: flex; flex-direction: column; gap: 4px; padding: 8px 0; }
.kpi-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 8px; padding: 0 4px; }
.kpi-label { font-size: 14px; font-weight: 600; line-height: 1; white-space: nowrap; }
.kpi-value { display: flex; align-items: center; gap: 4px; padding: 2px; font-size: 16px; font-weight: 600; line-height: 1; white-space: nowrap; }
.kpi-value.is-muted { color: var(--muted-foreground); font-size: 14px; font-weight: 500; }
.kpi-value .up { color: var(--success); }
.kpi-value .bad { color: var(--destructive); }
.kpi-sub { display: flex; justify-content: space-between; padding: 0 4px; }
.kpi-sub__label { color: var(--muted-foreground); font-size: 11px; line-height: 14px; text-transform: uppercase; }
.kpi-sub__value { color: var(--muted-foreground); font-size: 12px; font-weight: 600; line-height: 16px; }
.hours { display: flex; gap: 4px; padding: 4px; }
.hour {
  flex: 1 0 0;
  min-width: 0;
  height: 20px;
  padding: 2px 4px;
  border: 1px solid transparent;
  border-radius: var(--radius-md);
  background: var(--muted);
  color: var(--muted-foreground);
  font-size: 12px;
  font-weight: 600;
  line-height: 16px;
  text-align: center;
  white-space: nowrap;
  overflow: hidden;
  transition: background-color 0.15s, color 0.15s, border-color 0.15s;
}
.hour.is-past { background: var(--secondary); }
.hour.is-now { background: var(--input); }
.dark .hour.is-now { background: #404040; }
.hour:hover { border-color: var(--ring); color: var(--foreground); }
.hour.is-bad { color: var(--destructive); }

/* Infobox */
.infobox { display: flex; align-items: center; gap: 2px; width: 248px; max-width: 100%; }
.prio { display: grid; place-items: center; padding: 2px; flex: none; }
.prio--priority { color: var(--destructive); }
.prio--interesting { color: var(--warning); }
.prio--improvement, .prio--recurring { color: var(--info); }
.infobox .badge { flex: 1; justify-content: flex-start; }
.infobox .badge span { overflow: hidden; text-overflow: ellipsis; }

/* Insight card */
.insight {
  display: flex;
  flex-direction: column;
  gap: 12px;
  padding: 16px 0;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius-xl);
  box-shadow: var(--shadow-sm);
  overflow: hidden;
  transition: box-shadow 0.2s, border-color 0.2s, opacity 0.3s, transform 0.3s, max-height 0.45s cubic-bezier(0.4, 0, 0.2, 1), padding 0.45s, margin 0.45s;
  max-height: 200px;
}
.insight:hover { border-color: color-mix(in srgb, var(--foreground) 18%, var(--border)); box-shadow: var(--shadow-md); }
.insight-head { display: flex; align-items: flex-start; gap: 8px; padding: 0 16px; }
.insight-text { display: flex; flex-direction: column; gap: 6px; flex: 1; min-width: 0; }
.insight-title { font-size: 16px; font-weight: 600; line-height: 1; }
.insight-body { padding: 0 24px; }
.insight-preview { font-size: 14px; line-height: 20px; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.insight .resolve { position: relative; }
.insight .resolve .btn { width: 36px; padding: 0; }
.menu--float { position: fixed; width: 300px; transform-origin: top right; }
.insight-done { display: none; width: 24px; height: 24px; color: var(--success); }
.insight.is-resolved .resolve { display: none; }
.insight.is-resolved .insight-done { display: block; animation: pop 0.35s cubic-bezier(0.34, 1.56, 0.64, 1); }
.insight.is-resolved .insight-preview { text-align: center; }
.insight.is-leaving { max-height: 0; padding-top: 0; padding-bottom: 0; margin-top: -10px; opacity: 0; border-width: 0; }
@keyframes pop { from { transform: scale(0.4); opacity: 0; } }

/* Empty / error states */
.empty { display: flex; flex-direction: column; align-items: center; gap: 8px; padding: 24px 0 8px; text-align: center; animation: fade 0.35s ease-out; }
.empty-icon { display: grid; place-items: center; width: 40px; height: 40px; border-radius: var(--radius-md); background: var(--muted); }
.empty-title { font-size: 18px; font-weight: 500; line-height: 28px; }
.empty-desc { color: var(--muted-foreground); font-size: 14px; }
.empty-desc a { color: inherit; text-underline-offset: 3px; cursor: pointer; }
.empty-desc a:hover { color: var(--foreground); }
@keyframes fade { from { opacity: 0; transform: translateY(4px); } }

/* Previous shift */
.prev { display: flex; flex-direction: column; gap: 8px; }
.prev-head { display: flex; align-items: center; justify-content: space-between; padding: 4px 4px 0; }
.prev-title { padding: 4px 0; font-size: 16px; font-weight: 600; line-height: 1; }
.prev-meta { color: var(--muted-foreground); font-size: 11px; line-height: 14px; }
.prev-meta a { color: inherit; text-decoration: underline; cursor: pointer; }
.prev-meta a:hover { color: var(--foreground); }
.order { display: flex; align-items: center; justify-content: space-between; padding: 0 4px 8px; }
.order-name { font-size: 14px; font-weight: 600; line-height: 14px; }
.order-id { margin-top: 4px; color: var(--muted-foreground); font-size: 11px; line-height: 1; }
.order-progress { display: flex; align-items: center; gap: 4px; font-size: 12px; font-weight: 600; line-height: 1; }
.order-progress .progress { width: 137px; }

/* Monitoring column */
.column {
  display: flex;
  flex-direction: column;
  gap: 4px;
  width: 420px;
  flex: 1 1 0;
  min-width: 0;
  max-width: 420px;
  background: var(--sidebar);
  border-radius: var(--radius-xl);
  box-shadow: var(--shadow-sm);
  overflow: hidden;
  align-self: flex-start;
}
.column-head { display: flex; align-items: center; gap: 6px; padding: 16px 16px 12px; }
.column-count { color: var(--muted-foreground); font-size: 11px; line-height: 14px; }
.column-body { display: flex; flex-direction: column; gap: 8px; padding: 0 16px 24px; }
.insight-list { display: flex; flex-direction: column; gap: 10px; padding: 2px 0; }
.insight-list > .btn-link { width: 100%; }
.column-foot { display: flex; gap: 8px; padding: 12px 24px; background: var(--card); box-shadow: var(--footer-shadow); }
.column-foot .btn { flex: 1; }
.column-loading { display: flex; flex-direction: column; gap: 8px; padding: 8px 16px 24px; }
