/* ────────────────────────────────────────────────────────────────────────
   tes.sonus.id ERP — design system
   Goals: information-dense, scannable, native-feeling, mobile-ready.
   No "AI dashboard" aesthetic: editorial typography, calm palette,
   firm contrast, real data hierarchy.
   ──────────────────────────────────────────────────────────────────── */

:root {
  /* Brand */
  --bg-app:     #f6f7f9;
  --bg-card:    #ffffff;
  --bg-soft:    #f1f3f6;
  --bg-hover:   #f8fafc;
  --bg-stripe:  #fafbfc;

  /* Text */
  --fg:         #0f172a;
  --fg-muted:   #64748b;
  --fg-subtle:  #94a3b8;
  --fg-on-dark: #f8fafc;

  /* Lines */
  --line:       #e2e8f0;
  --line-soft:  #eef1f5;
  --line-dark:  #cbd5e1;

  /* Accents */
  --pri:        #1e3a8a;     /* deep navy, professional */
  --pri-hover:  #1e40af;
  --pri-soft:   #eff3ff;
  --acc:        #2563eb;     /* used for links */
  --ok:         #15803d;
  --ok-soft:    #dcfce7;
  --warn:       #b45309;
  --warn-soft:  #fef3c7;
  --err:        #b91c1c;
  --err-soft:   #fee2e2;
  --hot:        #dc2626;
  --hot-soft:   #ffe4e6;
  --info:       #0369a1;
  --info-soft:  #e0f2fe;
  --neutral:    #475569;
  --neutral-soft:#e2e8f0;

  /* Sidebar */
  --side-bg:        #0b1322;
  --side-fg:        #94a3b8;
  --side-fg-active: #ffffff;
  --side-hover-bg:  #15213a;
  --side-active-bg: #1e3a8a;

  /* Dimensions */
  --sidebar-w:   240px;
  --topbar-h:    56px;
  --radius:      8px;
  --radius-sm:   6px;
  --radius-lg:   12px;

  /* Shadows */
  --sh-sm: 0 1px 2px rgba(15,23,42,0.05);
  --sh:    0 1px 3px rgba(15,23,42,0.06), 0 1px 2px rgba(15,23,42,0.04);
  --sh-md: 0 4px 8px -2px rgba(15,23,42,0.08), 0 2px 4px -2px rgba(15,23,42,0.06);

  /* Type */
  --font-sans: ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto,
               "Helvetica Neue", Arial, sans-serif;
  --font-mono: ui-monospace, "SF Mono", Menlo, Monaco, Consolas, "Liberation Mono",
               "Courier New", monospace;

  --t-fast: 0.12s cubic-bezier(0.4, 0, 0.2, 1);
  --t:      0.2s cubic-bezier(0.4, 0, 0.2, 1);
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  font-family: var(--font-sans);
  font-size: 14px;
  line-height: 1.5;
  color: var(--fg);
  background: var(--bg-app);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

a { color: var(--acc); text-decoration: none; }
a:hover { color: var(--pri-hover); text-decoration: underline; }

h1, h2, h3, h4, h5, h6 { margin: 0; font-weight: 600; letter-spacing: -0.01em; }
h1 { font-size: 1.5rem; }
h2 { font-size: 1.25rem; }
h3 { font-size: 1.125rem; }

code, pre, .mono { font-family: var(--font-mono); }

hr { border: 0; border-top: 1px solid var(--line); margin: 16px 0; }

/* ════════════════════════════════════════════════════════════════════════
   APP SHELL
   ════════════════════════════════════════════════════════════════════════ */
.ts-app {
  display: flex;
  min-height: 100vh;
  width: 100%;
}

.ts-sidebar {
  width: var(--sidebar-w);
  flex-shrink: 0;
  background: var(--side-bg);
  color: var(--side-fg);
  display: flex;
  flex-direction: column;
  position: sticky;
  top: 0;
  height: 100vh;
  z-index: 50;
  /* Subtle inner vertical gradient — gives the dark panel a hint of
     depth without screaming "dark mode". */
  background-image:
    linear-gradient(180deg, #0d1626 0%, #0a121f 50%, #08101c 100%);
  border-right: 1px solid rgba(255,255,255,0.04);
}

/* ── Desktop sidebar collapse → icon rail ─────────────────────────────
   Tombol chevron di pojok kanan-atas sidebar toggles html.sidebar-collapsed
   (persist di localStorage). Width animasi 240px → 64px: teks fade-out dan
   ke-clip sama overflow, icon tetap kelihatan (rail ala VSCode). Mobile
   drawer ngga kena — toggle topbar tetap mobile-only. */
.ts-side-collapse {
  display: none;
  margin-left: auto;
  background: transparent;
  border: 0;
  color: #64748b;
  width: 28px; height: 28px;
  border-radius: 6px;
  align-items: center; justify-content: center;
  cursor: pointer;
  flex-shrink: 0;
}
.ts-side-collapse:hover { color: #fff; background: rgba(255,255,255,0.08); }
.ts-side-collapse i {
  font-size: 14px;
  transition: transform 0.32s cubic-bezier(0.33, 0, 0.15, 1);
}

@media (min-width: 993px) {
  .ts-side-collapse { display: inline-flex; }
  .ts-sidebar {
    transition: width 0.32s cubic-bezier(0.33, 0, 0.15, 1);
    overflow-x: hidden;
    will-change: width;
  }

  /* Semua yang bikin icon geser (padding, lebar logo/teks, gap) ikut
     di-transition dengan curve yang SAMA kayak width sidebar — icon "jalan"
     bareng animasi, ngga lompat di akhir. Teks cukup fade cepat. */
  .ts-nav-link {
    transition: background var(--t-fast), color var(--t-fast),
                padding-left 0.32s cubic-bezier(0.33, 0, 0.15, 1);
  }
  .ts-nav-group > summary {
    transition: color var(--t-fast), background var(--t-fast),
                padding-left 0.32s cubic-bezier(0.33, 0, 0.15, 1);
  }
  .ts-brand { transition: gap 0.32s cubic-bezier(0.33, 0, 0.15, 1); }
  .ts-brand img {
    transition: width 0.32s cubic-bezier(0.33, 0, 0.15, 1), opacity 0.16s ease;
  }
  .ts-brand-text,
  .ts-user > div {
    max-width: 150px;
    overflow: hidden;
    white-space: nowrap;
    transition: max-width 0.32s cubic-bezier(0.33, 0, 0.15, 1), opacity 0.16s ease;
  }
  .ts-user { transition: padding-left 0.32s cubic-bezier(0.33, 0, 0.15, 1); }
  .ts-logout button span {
    display: inline-block;
    max-width: 64px;
    overflow: hidden;
    white-space: nowrap;
    vertical-align: bottom;
    transition: max-width 0.32s cubic-bezier(0.33, 0, 0.15, 1), opacity 0.16s ease;
  }
  .ts-nav-link > span,
  .ts-nav-group > summary > span,
  .ts-nav-filter {
    transition: opacity 0.16s ease;
    white-space: nowrap;
  }
  .ts-nav-link.ts-nav-sub::after { transition: opacity 0.16s ease; }

  html.sidebar-collapsed .ts-sidebar { width: 64px; }
  html.sidebar-collapsed .ts-nav-link > span,
  html.sidebar-collapsed .ts-nav-group > summary > span,
  html.sidebar-collapsed .ts-nav-filter {
    opacity: 0;
    pointer-events: none;
  }
  html.sidebar-collapsed .ts-side-collapse i { transform: rotate(180deg); }

  /* Brand: logo & teks menyusut mulus, tombol chevron meluncur ke tengah
     (18px padding + 14px = 32 = titik tengah rail 64px). */
  html.sidebar-collapsed .ts-brand { gap: 0; }
  html.sidebar-collapsed .ts-brand img { width: 0; opacity: 0; }
  html.sidebar-collapsed .ts-brand-text { max-width: 0; opacity: 0; }

  /* Icon di tengah rail (6px nav padding + 17px + 9px setengah icon = 32). */
  html.sidebar-collapsed .ts-nav-link,
  html.sidebar-collapsed .ts-nav-link.active,
  html.sidebar-collapsed .ts-nav-link.ts-nav-sub,
  html.sidebar-collapsed .ts-nav-link.ts-nav-sub.active { padding-left: 17px; }
  html.sidebar-collapsed .ts-nav-link.ts-nav-sub::after { opacity: 0; }
  html.sidebar-collapsed .ts-nav-group > summary { padding-left: 19px; }

  /* Footer: icon user geser dikit ke tengah, teks menyusut. */
  html.sidebar-collapsed .ts-user { padding-left: 7px; }
  html.sidebar-collapsed .ts-user > div { max-width: 0; opacity: 0; }
  html.sidebar-collapsed .ts-logout button span { max-width: 0; opacity: 0; }
}
@media (prefers-reduced-motion: reduce) {
  .ts-sidebar, .ts-side-collapse i, .ts-nav-link, .ts-nav-group > summary,
  .ts-brand, .ts-brand img, .ts-brand-text, .ts-user, .ts-user > div,
  .ts-logout button span { transition: none; }
}

.ts-brand {
  display: flex; align-items: center; gap: 10px;
  padding: 14px 18px 12px;
  border-bottom: 1px solid rgba(255,255,255,0.06);
  flex-shrink: 0;
}
.ts-brand img { width: 30px; height: 30px; border-radius: 6px; }
.ts-brand-text strong { color: #fff; display: block; font-size: 13.5px; font-weight: 600; line-height: 1.15; }
.ts-brand-text small { color: #64748b; font-size: 11px; letter-spacing: 0.04em; }

/* ── Filter input — sticky right under brand. Pure CSS focus ring. ── */
.ts-nav-filter {
  position: relative;
  padding: 10px 12px 8px;
  flex-shrink: 0;
}
.ts-nav-filter i.bi-search {
  position: absolute;
  left: 22px; top: 50%; transform: translateY(-50%);
  color: rgba(148,163,184,0.6);
  font-size: 13px;
  line-height: 1;
  pointer-events: none;
}
.ts-nav-filter input {
  width: 100%;
  background: rgba(255,255,255,0.04);
  border: 1px solid rgba(255,255,255,0.08);
  color: #e2e8f0;
  font-size: 12.5px;
  padding: 6px 26px 6px 28px;
  border-radius: var(--radius-sm);
  outline: none;
  transition: border-color var(--t-fast), background var(--t-fast);
}
.ts-nav-filter input:focus {
  border-color: rgba(96,165,250,0.6);
  background: rgba(255,255,255,0.06);
}
.ts-nav-filter input::placeholder { color: rgba(148,163,184,0.6); }
.ts-nav-filter-clear {
  position: absolute;
  right: 18px; top: 50%; transform: translateY(-30%);
  background: none; border: 0;
  color: rgba(148,163,184,0.6);
  cursor: pointer; padding: 4px; line-height: 1;
  font-size: 13px;
}
.ts-nav-filter-clear:hover { color: #fff; }

.ts-nav {
  flex: 1;
  padding: 4px 6px 16px;
  overflow-y: auto;
  /* Custom scrollbar styling — slim, low contrast so it doesn't fight
     the link list visually. */
  scrollbar-width: thin;
  scrollbar-color: rgba(148,163,184,0.18) transparent;
}
.ts-nav::-webkit-scrollbar { width: 6px; }
.ts-nav::-webkit-scrollbar-track { background: transparent; }
.ts-nav::-webkit-scrollbar-thumb {
  background: rgba(148,163,184,0.18);
  border-radius: 4px;
}
.ts-nav::-webkit-scrollbar-thumb:hover { background: rgba(148,163,184,0.32); }

/* ── Links ─────────────────────────────────────────────────────────── */
.ts-nav-link {
  display: flex; align-items: center; gap: 10px;
  padding: 7px 10px;
  margin: 1px 0;
  color: var(--side-fg);
  font-size: 13px;
  font-weight: 500;
  border-radius: var(--radius-sm);
  position: relative;
  transition: background var(--t-fast), color var(--t-fast), padding-left var(--t-fast);
}
.ts-nav-link i {
  font-size: 15px;
  opacity: 0.75;
  flex-shrink: 0;
  width: 18px; text-align: center;
  transition: opacity var(--t-fast);
}
.ts-nav-link > span { flex: 1; min-width: 0; }
.ts-nav-link:hover {
  background: var(--side-hover-bg);
  color: #fff;
  text-decoration: none;
}
.ts-nav-link:hover i { opacity: 1; }
.ts-nav-link.active {
  background: linear-gradient(90deg, rgba(96,165,250,0.18), rgba(96,165,250,0.06));
  color: var(--side-fg-active);
  font-weight: 600;
  /* Left accent bar — distinctive active state without screaming */
  padding-left: 14px;
}
.ts-nav-link.active::before {
  content: '';
  position: absolute;
  left: 4px; top: 6px; bottom: 6px;
  width: 3px;
  background: #60a5fa;
  border-radius: 2px;
  box-shadow: 0 0 8px rgba(96,165,250,0.5);
}
.ts-nav-link.active i { opacity: 1; color: #93c5fd; }

/* Pinned items (Today / Inbox / SPPD) sit at the top, slightly heavier
   so they read as the user's go-to entry points. */
.ts-nav-link.is-pinned {
  font-weight: 600;
  background: rgba(255,255,255,0.02);
}
.ts-nav-link.is-pinned:not(.active) i { color: #93c5fd; opacity: 0.9; }

/* Sub-nav — indented children inside an expanded group */
.ts-nav-link.ts-nav-sub {
  padding-left: 30px;
  font-size: 12.5px;
  position: relative;
}
.ts-nav-link.ts-nav-sub::after {
  content: '';
  position: absolute;
  left: 20px; top: 50%;
  width: 4px; height: 1px;
  background: rgba(255,255,255,0.18);
}
.ts-nav-link.ts-nav-sub i { font-size: 13px; opacity: 0.65; }
.ts-nav-link.ts-nav-sub.active { font-weight: 600; padding-left: 30px; }
.ts-nav-link.ts-nav-sub.active::before { left: 6px; }

/* ── Collapsible groups (details / summary) ────────────────────────── */
.ts-nav-group {
  margin: 4px 0;
  border-radius: var(--radius-sm);
}
.ts-nav-group > summary {
  display: flex; align-items: center; gap: 8px;
  padding: 7px 10px 7px 6px;
  cursor: pointer;
  list-style: none;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: #64748b;
  user-select: none;
  border-radius: var(--radius-sm);
  transition: color var(--t-fast), background var(--t-fast);
}
.ts-nav-group > summary::-webkit-details-marker { display: none; }
.ts-nav-group > summary > span { flex: 1; line-height: 1.2; }
.ts-nav-group > summary:hover {
  color: #cbd5e1;
  background: rgba(255,255,255,0.025);
}
.ts-chev {
  font-size: 12px !important;
  opacity: 0.7;
  width: 14px !important;
  transition: transform 0.18s cubic-bezier(0.4,0,0.2,1);
}
.ts-nav-group[open] > summary .ts-chev { transform: rotate(90deg); }
.ts-nav-group[open] > summary { color: #93c5fd; }
.ts-nav-group-body {
  padding: 2px 0 6px 6px;
  /* fade-in body on open — keeps perceived motion smooth */
  animation: navGroupOpen 0.18s cubic-bezier(0.4,0,0.2,1);
}
@keyframes navGroupOpen {
  from { opacity: 0; transform: translateY(-2px); }
  to   { opacity: 1; transform: translateY(0); }
}

/* Animasi tinggi buka-tutup grup (details) — butuh interpolate-size +
   ::details-content (Chrome/Edge modern). Browser lain fallback instan. */
.ts-nav-group { interpolate-size: allow-keywords; }
.ts-nav-group::details-content {
  height: 0;
  overflow: clip;
  transition: height 0.26s cubic-bezier(0.33, 0, 0.15, 1),
              content-visibility 0.26s allow-discrete;
}
.ts-nav-group[open]::details-content { height: auto; }
@media (prefers-reduced-motion: reduce) {
  .ts-nav-group::details-content { transition: none; }
}

/* Active group accent — when group contains active link */
.ts-nav-group:has(.ts-nav-link.active) > summary {
  color: #cbd5e1;
}
.ts-nav-group:has(.ts-nav-link.active) > summary::before {
  content: '';
  display: block;
  width: 2px; height: 12px;
  background: rgba(96,165,250,0.6);
  border-radius: 2px;
  margin-left: -2px;
  margin-right: 4px;
}

/* ── Filter hides unrelated items ──────────────────────────────────── */
.is-hidden-by-filter { display: none !important; }
.ts-nav-group.is-filtering > summary { color: #93c5fd; }

.ts-sidebar-footer {
  border-top: 1px solid rgba(255,255,255,0.06);
  padding: 10px 14px 12px;
  flex-shrink: 0;
  background: rgba(0,0,0,0.18);
}
.ts-user { display: flex; align-items: center; gap: 10px; margin-bottom: 10px; color: #fff; }
.ts-user-name { font-size: 13px; font-weight: 600; line-height: 1.1; }
.ts-user .text-muted { font-size: 11px; text-transform: uppercase; letter-spacing: 0.05em; color: #64748b !important; }
.ts-logout button {
  width: 100%;
  background: transparent;
  border: 1px solid rgba(255,255,255,0.12);
  color: var(--side-fg);
  padding: 6px 10px;
  border-radius: var(--radius-sm);
  font-size: 12px;
  cursor: pointer;
  transition: var(--t-fast);
}
.ts-logout button:hover { background: rgba(255,255,255,0.06); color: #fff; border-color: rgba(255,255,255,0.2); }

.ts-main {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  background: var(--bg-app);
}

.ts-topbar {
  height: var(--topbar-h);
  background: var(--bg-card);
  border-bottom: 1px solid var(--line);
  display: flex;
  align-items: center;
  padding: 0 24px;
  position: sticky;
  top: 0;
  z-index: 20;
  gap: 12px;
}
.ts-mobile-toggle {
  display: none;
  background: transparent;
  border: 1px solid var(--line);
  color: var(--fg);
  width: 36px; height: 36px;
  border-radius: var(--radius-sm);
  font-size: 18px;
  cursor: pointer;
  align-items: center; justify-content: center;
}
.ts-page-title {
  flex: 1;
  font-size: 15px;
  font-weight: 600;
  margin: 0;
  letter-spacing: -0.01em;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.ts-topbar-actions { display: flex; gap: 8px; align-items: center; }

/* ────── Notification badge (top-right bell) ────── */
.ts-notif-badge {
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--line);
  background: var(--bg-card);
  color: var(--fg-muted);
  font-size: 16px;
  transition: var(--t-fast);
  text-decoration: none;
}
.ts-notif-badge:hover {
  background: #fff5f5;
  border-color: #fecaca;
  color: var(--hot);
  text-decoration: none;
}
.ts-notif-badge .bi-bell-fill { color: var(--hot); }
.ts-notif-count {
  position: absolute;
  top: -4px;
  right: -4px;
  min-width: 16px;
  height: 16px;
  padding: 0 4px;
  background: var(--hot);
  color: #fff;
  font-size: 11px;
  font-weight: 700;
  line-height: 16px;
  border-radius: 999px;
  border: 2px solid #fff;
  box-shadow: 0 0 0 1px var(--hot);
  font-variant-numeric: tabular-nums;
  letter-spacing: -0.02em;
}
@keyframes ts-notif-pulse {
  0%   { box-shadow: 0 0 0 1px var(--hot), 0 0 0 0 rgba(220,38,38,0.55); }
  70%  { box-shadow: 0 0 0 1px var(--hot), 0 0 0 8px rgba(220,38,38,0); }
  100% { box-shadow: 0 0 0 1px var(--hot), 0 0 0 0 rgba(220,38,38,0); }
}
.ts-notif-count.is-fresh { animation: ts-notif-pulse 1.5s ease-out 2; }

/* ────── Notification popup stack (top-right, sticky until X'd) ────── */
.ts-notif-popup-stack {
  position: fixed;
  top: calc(var(--topbar-h) + 12px);
  right: 16px;
  z-index: 60;
  display: flex;
  flex-direction: column;
  gap: 10px;
  max-width: min(360px, calc(100vw - 32px));
  pointer-events: none;
}
.ts-notif-popup {
  pointer-events: auto;
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 12px 14px;
  background: var(--bg-card);
  border: 1px solid var(--line);
  border-left: 4px solid var(--hot);
  border-radius: var(--radius);
  box-shadow: 0 14px 32px -10px rgba(15,23,42,0.22), 0 4px 10px -4px rgba(15,23,42,0.12);
  animation: ts-notif-popup-in 0.22s cubic-bezier(0.4, 0, 0.2, 1);
  position: relative;
}
.ts-notif-popup.hue-warning   { border-left-color: #d97706; }
.ts-notif-popup.hue-danger    { border-left-color: #dc2626; }
.ts-notif-popup.hue-success   { border-left-color: #16a34a; }
.ts-notif-popup.hue-info      { border-left-color: #0ea5e9; }
.ts-notif-popup.hue-primary   { border-left-color: var(--pri); }
.ts-notif-popup.hue-secondary { border-left-color: var(--fg-muted); }
@keyframes ts-notif-popup-in {
  from { transform: translateX(18px); opacity: 0; }
  to   { transform: translateX(0);     opacity: 1; }
}
.ts-notif-popup.is-leaving {
  animation: ts-notif-popup-out 0.18s ease-in forwards;
}
@keyframes ts-notif-popup-out {
  to { transform: translateX(18px); opacity: 0; }
}
.ts-notif-popup-icon {
  width: 32px; height: 32px; min-width: 32px;
  border-radius: 50%;
  display: inline-flex; align-items: center; justify-content: center;
  font-size: 14px; color: #fff;
  background: var(--fg-muted);
  flex-shrink: 0;
}
.ts-notif-popup-icon.hue-warning   { background: #d97706; }
.ts-notif-popup-icon.hue-danger    { background: #dc2626; }
.ts-notif-popup-icon.hue-success   { background: #16a34a; }
.ts-notif-popup-icon.hue-info      { background: #0ea5e9; }
.ts-notif-popup-icon.hue-primary   { background: var(--pri); }
.ts-notif-popup-body { flex: 1; min-width: 0; padding-right: 18px; }
.ts-notif-popup-title {
  font-size: 12.5px; font-weight: 600; color: var(--fg);
  margin: 0 0 2px; line-height: 1.3;
}
.ts-notif-popup-msg {
  font-size: 12px; color: var(--fg-muted);
  line-height: 1.45; margin: 0 0 6px;
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.ts-notif-popup-foot {
  display: flex; align-items: center; gap: 8px;
  font-size: 11px; color: var(--fg-muted);
}
.ts-notif-popup-foot a {
  color: var(--pri); text-decoration: none; font-weight: 600;
}
.ts-notif-popup-foot a:hover { text-decoration: underline; }
.ts-notif-popup-x {
  position: absolute; top: 6px; right: 6px;
  width: 22px; height: 22px;
  background: transparent; border: 0;
  color: var(--fg-muted); cursor: pointer;
  border-radius: 4px; font-size: 13px;
  display: inline-flex; align-items: center; justify-content: center;
}
.ts-notif-popup-x:hover { background: var(--bg-soft); color: var(--fg); }
@media (max-width: 480px) {
  .ts-notif-popup-stack { left: 12px; right: 12px; max-width: none; }
}

.ts-content {
  padding: 20px 24px 64px;
  flex: 1;
  min-width: 0;
}

.ts-breadcrumb {
  font-size: 12px;
  color: var(--fg-muted);
  margin-bottom: 8px;
}
.ts-breadcrumb a { color: var(--fg-muted); }
.ts-breadcrumb a:hover { color: var(--fg); text-decoration: none; }
.ts-breadcrumb .sep { margin: 0 6px; color: var(--fg-subtle); }

/* ════════════════════════════════════════════════════════════════════════
   BUTTONS (Bootstrap overrides — clean, calm)
   ════════════════════════════════════════════════════════════════════════ */
.btn {
  font-size: 13px;
  font-weight: 500;
  padding: 7px 14px;
  border-radius: var(--radius-sm);
  border: 1px solid transparent;
  transition: var(--t-fast);
  display: inline-flex;
  align-items: center;
  gap: 6px;
  white-space: nowrap;
  line-height: 1.2;
}
.btn:focus, .btn:active { outline: none; box-shadow: 0 0 0 3px rgba(37,99,235,0.18); }
.btn-sm { padding: 5px 10px; font-size: 12px; }
.btn-lg { padding: 10px 20px; font-size: 14px; }

.btn-primary { background: var(--pri); color: #fff; border-color: var(--pri); }
.btn-primary:hover { background: var(--pri-hover); border-color: var(--pri-hover); color: #fff; }

.btn-light { background: #fff; color: var(--fg); border-color: var(--line); }
.btn-light:hover { background: var(--bg-hover); }

.btn-outline-secondary { background: #fff; color: var(--fg); border-color: var(--line); }
.btn-outline-secondary:hover { background: var(--bg-hover); color: var(--fg); }

.btn-outline-primary { background: #fff; color: var(--pri); border-color: var(--pri); }
.btn-outline-primary:hover { background: var(--pri); color: #fff; }

.btn-warning, .btn-outline-warning { background: var(--warn-soft); color: var(--warn); border-color: var(--warn-soft); }
.btn-warning:hover, .btn-outline-warning:hover { background: #fde68a; color: var(--warn); }

.btn-danger { background: var(--err); color: #fff; border-color: var(--err); }
.btn-block { display: flex; width: 100%; justify-content: center; }

.btn i { font-size: 14px; }

/* ════════════════════════════════════════════════════════════════════════
   FORMS — fix text truncation, proper spacing
   ════════════════════════════════════════════════════════════════════════ */
.form-control,
.form-control-sm {
  display: block;
  width: 100%;
  padding: 8px 12px;
  font-size: 13px;
  font-family: var(--font-sans);
  line-height: 1.45;
  color: var(--fg);
  background: var(--bg-card);
  border: 1px solid var(--line-dark);
  border-radius: var(--radius-sm);
  transition: var(--t-fast);
  height: auto;       /* override Bootstrap's fixed height that crops descenders */
  min-height: 36px;   /* keeps clickable target consistent */
}
.form-control-sm { padding: 6px 10px; font-size: 12.5px; min-height: 32px; }

.form-control::placeholder { color: var(--fg-subtle); }
.form-control:focus, .form-control-sm:focus {
  border-color: var(--pri);
  outline: none;
  box-shadow: 0 0 0 3px rgba(37,99,235,0.14);
}

textarea.form-control { min-height: 64px; line-height: 1.5; }

/* native dropdown arrow refresh */
select.form-control,
select.form-control-sm {
  appearance: none;
  -webkit-appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16' fill='%2364748b'%3E%3Cpath d='M4 6l4 4 4-4'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 10px center;
  background-size: 14px;
  padding-right: 28px;
}

label {
  font-size: 12px;
  font-weight: 500;
  color: var(--fg-muted);
  margin-bottom: 4px;
  display: block;
  letter-spacing: 0.01em;
}

.form-row {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  margin-bottom: 12px;
  margin-left: 0; margin-right: 0;
}
.form-row > [class*="col-"] {
  padding: 0;
  flex: 1 1 0;
}
.form-group { margin-bottom: 12px; min-width: 0; }
.form-row .form-group { margin-bottom: 0; }

/* Bootstrap col-md-* support inside our form-rows */
.form-row .col-md-3 { flex-basis: calc(25% - 9px); }
.form-row .col-md-4 { flex-basis: calc(33.333% - 8px); }
.form-row .col-md-5 { flex-basis: calc(41.666% - 7px); }
.form-row .col-md-6 { flex-basis: calc(50% - 6px); }
.form-row .col-md-7 { flex-basis: calc(58.333% - 5px); }
.form-row .col-md-8 { flex-basis: calc(66.666% - 4px); }
@media (max-width: 768px) {
  .form-row > [class*="col-"] { flex-basis: 100%; }
}

.ts-check { display: inline-flex; align-items: center; gap: 6px; font-size: 13px; cursor: pointer; user-select: none; }
.ts-check input[type=checkbox] { margin: 0; }

/* ════════════════════════════════════════════════════════════════════════
   FILTER BAR
   ════════════════════════════════════════════════════════════════════════ */
.ts-filterbar {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
  background: var(--bg-card);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  padding: 10px 12px;
  margin-bottom: 14px;
}
.ts-filterbar input[type="search"] {
  flex: 1 1 220px;
  min-width: 180px;
}
.ts-filterbar select { width: auto; min-width: 132px; flex: 0 0 auto; }
.ts-filterbar .ts-check { margin-left: 4px; }

/* Pills group for compact filters */
.ts-filter-pills { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }
.ts-pill {
  display: inline-flex; align-items: center; gap: 4px;
  padding: 4px 10px;
  font-size: 12px;
  font-weight: 500;
  border-radius: 999px;
  background: var(--bg-soft);
  color: var(--fg-muted);
  cursor: pointer;
  border: 1px solid transparent;
  transition: var(--t-fast);
}
.ts-pill:hover { background: var(--neutral-soft); color: var(--fg); }
.ts-pill.active { background: var(--pri); color: #fff; }
.ts-pill .count { font-size: 11px; font-weight: 600; opacity: 0.9; }

/* ════════════════════════════════════════════════════════════════════════
   DATA TABLE — fix truncation issue, sortable headers
   ════════════════════════════════════════════════════════════════════════ */
.ts-grid {
  background: var(--bg-card);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  overflow: hidden;
}
.ts-grid-scroll {
  width: 100%;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}

.ts-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
  table-layout: auto;       /* let columns size naturally */
}
.ts-table thead th {
  text-align: left;
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--fg-muted);
  background: var(--bg-stripe);
  padding: 9px 12px;
  border-bottom: 1px solid var(--line);
  white-space: nowrap;
  vertical-align: middle;
  position: sticky;
  top: 0;
  z-index: 1;
}
.ts-table thead th.text-right { text-align: right; }
.ts-table thead th a {
  color: inherit;
  display: inline-flex;
  align-items: center;
  gap: 4px;
  cursor: pointer;
}
.ts-table thead th a:hover { color: var(--fg); text-decoration: none; }
.ts-table thead th.sorted { color: var(--pri); }
.ts-table thead th .ts-sort-icon { font-size: 11px; opacity: 0.5; }
.ts-table thead th.sorted .ts-sort-icon { opacity: 1; }

.ts-table tbody td {
  padding: 10px 12px;
  border-bottom: 1px solid var(--line-soft);
  vertical-align: middle;
  /* CRITICAL FIX: do not aggressively truncate — let cells size to content,
     and only truncate where we explicitly opt in via .ts-cell-clip */
  white-space: nowrap;
}
.ts-table tbody tr:last-child td { border-bottom: none; }
.ts-table tbody tr.ts-row { cursor: pointer; transition: background var(--t-fast); }
.ts-table tbody tr.ts-row:hover { background: var(--bg-hover); }
.ts-table tbody tr.ts-row td:first-child { position: relative; }

.ts-table .text-right, .ts-table .text-end { text-align: right; }

/* Cell variants — opt-in clipping for known-overflowing fields */
.ts-cell-clip {
  max-width: 220px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.ts-cell-clip-sm { max-width: 140px; }
.ts-cell-wrap { white-space: normal; max-width: 320px; }
.ts-cell-mono { font-family: var(--font-mono); font-size: 12px; color: var(--fg-muted); }
.ts-cell-num { font-variant-numeric: tabular-nums; }

.ts-row-hot { background: linear-gradient(90deg, rgba(220,38,38,0.05), transparent 80%); }
.ts-row-hot td:first-child { box-shadow: inset 3px 0 0 var(--hot); }
.ts-row-platform td:first-child { box-shadow: inset 3px 0 0 var(--pri); }
.ts-row-overdue td:first-child { box-shadow: inset 3px 0 0 var(--err); }

/* Priority-1 row spotlight — dominates over hot when both apply */
.ts-row-p1 {
  background: linear-gradient(90deg, rgba(245,158,11,0.10), transparent 70%);
}
.ts-row-p1 td:first-child {
  box-shadow: inset 4px 0 0 #f59e0b;
}
.ts-row-p1:hover { background: linear-gradient(90deg, rgba(245,158,11,0.16), var(--bg-hover) 60%); }

/* Drag handle (row reorder grip) */
.ts-row-grip {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 18px;
  height: 22px;
  cursor: grab;
  color: var(--fg-subtle);
  opacity: 0;
  transition: opacity var(--t-fast), color var(--t-fast);
  font-size: 14px;
  vertical-align: middle;
}
.ts-row:hover .ts-row-grip { opacity: 1; }
.ts-row-grip:hover { color: var(--pri); }
.ts-row-grip:active { cursor: grabbing; }
.ts-row.ts-dragging {
  opacity: 0.5;
  background: var(--pri-soft);
}
.ts-row.ts-drop-above {
  box-shadow: inset 0 3px 0 0 var(--pri);
}
.ts-row.ts-drop-below {
  box-shadow: inset 0 -3px 0 0 var(--pri);
}
.ts-cell-handle {
  white-space: nowrap;
  vertical-align: middle;
}
.ts-cell-handle > * { vertical-align: middle; }

.ts-row-empty td {
  text-align: center;
  padding: 48px 16px;
  color: var(--fg-muted);
  font-size: 13px;
}

/* Stale styling on last_activity column */
.text-warning { color: var(--warn) !important; font-weight: 600; }
.text-danger  { color: var(--err)  !important; font-weight: 600; }
.text-muted   { color: var(--fg-muted) !important; }
.text-subtle  { color: var(--fg-subtle); }

/* ════════════════════════════════════════════════════════════════════════
   BADGES — refined pills
   ════════════════════════════════════════════════════════════════════════ */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 3px 8px;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.01em;
  border-radius: 5px;
  line-height: 1.4;
  white-space: nowrap;
}
.badge-secondary { background: var(--neutral-soft); color: var(--neutral); }
.badge-info      { background: var(--info-soft);    color: var(--info); }
.badge-primary   { background: var(--pri-soft);     color: var(--pri); }
.badge-warning   { background: var(--warn-soft);    color: var(--warn); }
.badge-success   { background: var(--ok-soft);      color: var(--ok); }
.badge-danger    { background: var(--err-soft);     color: var(--err); }
.badge-dark      { background: #1f2937;             color: #fff; }
.badge-muted     { background: var(--bg-soft);      color: var(--fg-muted); }

.ts-prio {
  display: inline-block;
  font-size: 11px;
  font-weight: 800;
  background: #94a3b8;
  color: white;
  padding: 2px 6px;
  border-radius: 4px;
  letter-spacing: 0.04em;
  margin-left: 4px;
  text-transform: uppercase;
}
/* Prioritas 1 = vivid amber pill with subtle glow (so it pops in tables) */
.ts-prio.ts-prio-p1 {
  background: linear-gradient(135deg, #f59e0b, #ea580c);
  color: #fff;
  box-shadow: 0 0 0 1px rgba(245, 158, 11, 0.25), 0 1px 4px rgba(245, 158, 11, 0.45);
  animation: ts-prio-pulse 2.4s ease-in-out infinite;
}
.ts-prio.ts-prio-p2 {
  background: #fde68a;
  color: #92400e;
}
.ts-prio.ts-prio-p3 {
  background: var(--neutral-soft);
  color: var(--neutral);
}
@keyframes ts-prio-pulse {
  0%, 100% { box-shadow: 0 0 0 1px rgba(245, 158, 11, 0.25), 0 1px 4px rgba(245, 158, 11, 0.45); }
  50%      { box-shadow: 0 0 0 2px rgba(245, 158, 11, 0.45), 0 1px 8px rgba(245, 158, 11, 0.6); }
}
.ts-hot-flag { font-size: 13px; line-height: 1; }

/* Priority filter chip group — visually echoes .ts-prio so the active chip
   looks like the pill in the row, but inactive chips stay outlined+subdued. */
.ts-prio-filter {
  display: inline-flex; gap: 4px; align-items: center;
  margin-left: 4px;
}
.ts-prio-chip {
  display: inline-flex; align-items: center; justify-content: center;
  min-width: 30px; height: 26px; padding: 0 8px;
  border-radius: 6px;
  font-size: 11.5px; font-weight: 700; letter-spacing: .04em;
  text-decoration: none;
  border: 1px solid var(--line);
  background: var(--bg-card); color: var(--fg-muted);
  transition: background .12s ease, color .12s ease, border-color .12s ease, transform .12s ease;
}
.ts-prio-chip:hover { transform: translateY(-1px); text-decoration: none; }
.ts-prio-chip-p1 { color: #b45309; border-color: rgba(245, 158, 11, 0.45); }
.ts-prio-chip-p1:hover { background: #fef3c7; color: #92400e; border-color: #f59e0b; }
.ts-prio-chip-p2 { color: #92400e; border-color: rgba(253, 230, 138, 0.85); }
.ts-prio-chip-p2:hover { background: #fef9e8; color: #78350f; border-color: #fde68a; }
.ts-prio-chip-p3 { color: var(--neutral); border-color: var(--line-dark); }
.ts-prio-chip-p3:hover { background: var(--neutral-soft); color: #1e293b; }
.ts-prio-chip.active {
  color: #fff; border-color: transparent;
  box-shadow: 0 1px 3px rgba(15, 23, 42, 0.12);
}
.ts-prio-chip-p1.active {
  background: linear-gradient(135deg, #f59e0b, #ea580c);
  box-shadow: 0 0 0 2px rgba(245, 158, 11, 0.18), 0 1px 4px rgba(245, 158, 11, 0.4);
}
.ts-prio-chip-p2.active { background: #fde68a; color: #92400e; box-shadow: 0 1px 3px rgba(146, 64, 14, 0.18); }
.ts-prio-chip-p3.active { background: var(--neutral); color: #fff; }

/* ════════════════════════════════════════════════════════════════════════
   CARDS / SECTIONS
   ════════════════════════════════════════════════════════════════════════ */
.ts-card {
  background: var(--bg-card);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  overflow: hidden;
}
.ts-card-head {
  padding: 12px 16px;
  border-bottom: 1px solid var(--line);
  font-weight: 600;
  font-size: 13px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  background: var(--bg-card);
}
.ts-card-head .text-muted { font-weight: 400; font-size: 12px; }
.ts-card-body { padding: 16px; }

/* ────── Stat cards ────── */
.ts-stats {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 12px;
  margin-bottom: 16px;
}
.ts-stat-card {
  display: flex;
  flex-direction: column;
  gap: 2px;
  background: var(--bg-card);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  padding: 14px 16px;
  color: var(--fg);
  text-decoration: none;
  position: relative;
  overflow: hidden;
  transition: var(--t-fast);
}
.ts-stat-card::before {
  content: "";
  position: absolute;
  inset: 0 auto 0 0;
  width: 3px;
  background: var(--pri);
}
.ts-stat-card:hover { border-color: var(--line-dark); box-shadow: var(--sh); text-decoration: none; color: var(--fg); }
.ts-stat-card.ts-stat-success::before { background: var(--ok); }
.ts-stat-card.ts-stat-warn::before    { background: var(--warn); }
.ts-stat-card.ts-stat-info::before    { background: var(--info); }
.ts-stat-card.ts-stat-hot::before     { background: var(--hot); }

.ts-stat-eyebrow {
  font-size: 11px;
  color: var(--fg-muted);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  font-weight: 600;
  display: flex;
  align-items: center;
  gap: 5px;
}
.ts-stat-value {
  font-size: 1.4rem;
  font-weight: 700;
  line-height: 1.15;
  letter-spacing: -0.02em;
  font-variant-numeric: tabular-nums;
  margin-top: 2px;
}
.ts-stat-foot {
  font-size: 12px;
  color: var(--fg-muted);
  margin-top: 4px;
}

/* ────── Status & leaderboard rows ────── */
.ts-status-list { display: flex; flex-direction: column; }
.ts-status-row {
  display: flex; align-items: center; justify-content: space-between;
  padding: 9px 14px;
  border-bottom: 1px solid var(--line-soft);
  color: var(--fg);
  text-decoration: none;
  transition: background var(--t-fast);
  gap: 8px;
}
.ts-status-row:last-child { border-bottom: none; }
.ts-status-row:hover { background: var(--bg-hover); text-decoration: none; color: var(--fg); }
.ts-status-row .ts-status-count { font-weight: 700; font-variant-numeric: tabular-nums; }

/* ────── Anomaly compact list (used in dashboard) ────── */
.ts-anom-list {
  list-style: none;
  padding: 0;
  margin: 0;
  max-height: 360px;
  overflow-y: auto;
}
.ts-anom-list li { border-bottom: 1px solid var(--line-soft); }
.ts-anom-list li:last-child { border-bottom: none; }
.ts-anom-row {
  display: grid;
  grid-template-columns: 1fr auto;
  align-items: center;
  gap: 4px 10px;
  padding: 9px 14px;
  text-decoration: none;
  color: var(--fg);
  transition: background var(--t-fast);
}
.ts-anom-row:hover { background: var(--bg-hover); text-decoration: none; }
.ts-anom-name {
  font-weight: 600;
  font-size: 13px;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.ts-anom-row .badge { justify-self: end; align-self: center; }
.ts-anom-meta {
  grid-column: 1 / 2;
  font-size: 11px;
  color: var(--fg-muted);
}
.ts-anom-empty {
  padding: 24px 16px;
  text-align: center;
  color: var(--fg-muted);
  font-size: 13px;
}

/* Daily-log compact form (no type selector) */
.ts-log-input {
  display: flex;
  align-items: stretch;
  gap: 8px;
}
.ts-log-input textarea {
  flex: 1;
  resize: vertical;
  min-height: 40px;
}
.ts-log-input button {
  flex-shrink: 0;
  align-self: stretch;
}

/* Resizable column handle */
.ts-table th { position: relative; }
.ts-table th .ts-resizer {
  position: absolute;
  top: 0;
  right: 0;
  bottom: 0;
  width: 4px;
  cursor: col-resize;
  user-select: none;
  background: transparent;
  transition: background var(--t-fast);
}
.ts-table th .ts-resizer:hover,
.ts-table th .ts-resizer.dragging { background: var(--pri); }
.ts-table.is-resizing { cursor: col-resize !important; user-select: none; }
.ts-table.is-resizing tbody tr { pointer-events: none; }

/* ════════════════════════════════════════════════════════════════════════
   LEAD / PROJECT DETAIL PAGE
   ════════════════════════════════════════════════════════════════════════ */
.ts-detail {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 320px;
  gap: 20px;
  align-items: start;
}
@media (max-width: 1024px) { .ts-detail { grid-template-columns: 1fr; } }

.ts-detail-head {
  background: #fff;
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  padding: 16px 20px;
  margin-bottom: 16px;
  display: flex;
  flex-wrap: wrap;
  gap: 16px;
  align-items: center;
  justify-content: space-between;
}
.ts-detail-head .meta {
  font-size: 12px;
  color: var(--fg-muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  font-weight: 600;
}
.ts-detail-head h1 {
  font-size: 1.4rem;
  font-weight: 700;
  letter-spacing: -0.02em;
  margin: 4px 0;
  word-break: break-word;
}
.ts-detail-head .summary { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; font-size: 13px; }
.ts-detail-head .summary .sep { color: var(--fg-subtle); }
.ts-detail-head .actions { display: flex; gap: 8px; flex-wrap: wrap; }

.ts-detail-stats {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: 12px;
  margin-bottom: 16px;
}
.ts-detail-stat {
  background: #fff;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 12px 14px;
}
.ts-detail-stat label {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  font-weight: 600;
  color: var(--fg-muted);
  margin-bottom: 2px;
}
.ts-detail-stat .v {
  font-size: 1.05rem;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  line-height: 1.2;
}
.ts-detail-stat .v.muted { color: var(--fg-muted); font-weight: 500; }
.ts-detail-stat .sub { font-size: 11px; color: var(--fg-muted); margin-top: 2px; }

.ts-tabs-bar {
  background: #fff;
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  display: flex;
  gap: 0;
  margin-bottom: 12px;
  overflow-x: auto;
}
.ts-tabs-bar a {
  padding: 10px 16px;
  font-size: 13px;
  font-weight: 500;
  color: var(--fg-muted);
  border-bottom: 2px solid transparent;
  white-space: nowrap;
}
.ts-tabs-bar a:hover { color: var(--fg); text-decoration: none; }
.ts-tabs-bar a.active { color: var(--pri); border-bottom-color: var(--pri); }

.ts-detail [data-tspane] { display: none; }
.ts-detail [data-tspane].active { display: block; }

/* Sidecar (contact info, related project, quick links) */
.ts-sidecar {
  display: flex;
  flex-direction: column;
  gap: 12px;
  position: sticky;
  top: calc(var(--topbar-h) + 16px);
}
.ts-sidecar .ts-card-head { padding: 12px 14px; }
.ts-sidecar .kv { padding: 10px 14px; border-bottom: 1px solid var(--line-soft); font-size: 13px; }
.ts-sidecar .kv:last-child { border-bottom: none; }
.ts-sidecar .kv label { font-size: 11px; color: var(--fg-muted); margin-bottom: 1px; text-transform: uppercase; letter-spacing: 0.04em; }
.ts-sidecar .kv .v { font-weight: 500; word-break: break-word; }
.ts-sidecar .kv .v.muted { color: var(--fg-muted); font-weight: 400; }

.ts-sidecar-actions { display: flex; flex-direction: column; gap: 6px; padding: 12px; }
.ts-sidecar-actions .btn { width: 100%; justify-content: center; }

/* DescriptionList — for static info panes */
.ts-dl {
  display: grid;
  grid-template-columns: 160px 1fr;
  row-gap: 8px;
  column-gap: 12px;
  margin: 0;
  padding: 12px 16px;
}
.ts-dl dt { color: var(--fg-muted); font-weight: 500; font-size: 12px; padding-top: 1px; }
.ts-dl dd { margin: 0; font-size: 13px; word-break: break-word; }
.ts-dl dd.muted { color: var(--fg-muted); }
@media (max-width: 600px) { .ts-dl { grid-template-columns: 1fr; row-gap: 0; }
  .ts-dl dt { padding-top: 8px; }
  .ts-dl dd { padding-bottom: 8px; border-bottom: 1px solid var(--line-soft); }
}

/* ────── Timeline (progress) ──────
   Single vertical rail at left = absolute line in parent <ul>.
   Markers and cards sit on top of the rail.

   Markup:
     <ul.ts-timeline>
       <li.ts-tl-day>...</li>                      ← optional day separator
       <li.ts-tl-item>
         <span.ts-tl-marker><i.bi></i></span>
         <div.ts-tl-card>
           <div.ts-tl-head> author · role · type · timestamp </div>
           <div.ts-tl-body>...</div>
         </div>
       </li>
*/
.ts-timeline {
  list-style: none;
  margin: 0;
  padding: 14px 14px 14px 44px;
  position: relative;
  /* Single continuous rail on the left, drawn as a background image so it
     never gets clipped by any child stacking context. */
  background-image: linear-gradient(var(--line), var(--line));
  background-size: 2px calc(100% - 28px);
  background-position: 25px 14px;
  background-repeat: no-repeat;
}
.ts-timeline li { padding: 0; margin: 0; }
.ts-timeline > li.ts-empty {
  list-style: none;
  color: var(--fg-muted);
  padding: 24px 0;
  text-align: center;
  font-size: 13px;
}

/* Day separator: small caps label, marker is a hollow dot on the rail. */
.ts-tl-day {
  position: relative;
  padding: 10px 0 6px 4px;
  margin-left: -22px;
  margin-top: 6px;
  font-size: 11px;
  font-weight: 700;
  color: var(--fg-muted);
  letter-spacing: 0.06em;
  text-transform: uppercase;
}
.ts-tl-day::before {
  content: "";
  display: inline-block;
  width: 8px; height: 8px;
  border-radius: 50%;
  background: var(--bg-card);
  border: 2px solid var(--line-dark);
  margin-right: 12px;
  margin-left: 9px;
  vertical-align: middle;
  position: relative; top: -1px;
}

/* Each entry */
.ts-tl-item {
  position: relative;
  display: flex;
  gap: 14px;
  padding: 0 0 14px 0;
  align-items: flex-start;
}
.ts-tl-item:last-child { padding-bottom: 4px; }

.ts-tl-marker {
  flex-shrink: 0;
  width: 28px; height: 28px;
  border-radius: 50%;
  background: var(--pri-soft);
  color: var(--pri);
  display: flex; align-items: center; justify-content: center;
  font-size: 13px;
  margin-left: -25px;          /* sit on top of the rail */
  margin-top: 1px;
  border: 2px solid var(--bg-card);
  box-shadow: 0 0 0 2px var(--line);
  z-index: 1;
}

.ts-tl-card {
  flex: 1 1 auto;
  min-width: 0;                 /* allow shrink so content can wrap */
  background: var(--bg-card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 10px 12px;
  transition: border-color var(--t-fast), box-shadow var(--t-fast);
  overflow: visible;            /* prevent any inner clipping */
}
.ts-tl-card:hover {
  border-color: var(--line-dark);
  box-shadow: var(--sh-sm);
}

.ts-tl-head {
  display: flex;
  flex-wrap: wrap;
  gap: 4px 10px;
  align-items: baseline;
  margin-bottom: 6px;
  font-size: 12px;
  line-height: 1.3;
}
.ts-tl-author { color: var(--fg); font-weight: 600; }
.ts-tl-role {
  color: var(--fg-muted);
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}
.ts-tl-type {
  background: var(--pri-soft);
  color: var(--pri);
  font-size: 11px;
  font-weight: 600;
  padding: 1px 6px;
  border-radius: 4px;
  text-transform: uppercase;
}
.ts-tl-time {
  margin-left: auto;
  color: var(--fg-muted);
  font-size: 11px;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}
.ts-tl-time .bi { font-size: 11px; opacity: 0.7; margin-right: 2px; }

.ts-tl-body {
  font-size: 13px;
  color: var(--fg);
  white-space: pre-wrap;
  word-break: break-word;
  overflow-wrap: anywhere;
  line-height: 1.55;
}
.ts-tl-body a { color: var(--acc); }

/* Inline auto-linkified URL inside body */
.ts-tl-link {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  padding: 1px 6px;
  background: var(--pri-soft);
  color: var(--pri);
  border-radius: 3px;
  font-size: 12px;
  text-decoration: none;
  border: 1px solid transparent;
  transition: border-color var(--t-fast);
  word-break: break-all;
  vertical-align: baseline;
}
.ts-tl-link:hover { border-color: var(--pri); text-decoration: none; }
.ts-tl-link .bi { font-size: 11px; opacity: 0.85; }

/* Action buttons row below the body when any URLs were detected */
.ts-tl-actions {
  display: flex; flex-wrap: wrap; gap: 6px;
  margin-top: 8px;
  padding-top: 8px;
  border-top: 1px dashed var(--line-soft);
}
.ts-tl-action-btn {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 4px 10px;
  background: var(--pri);
  color: #fff;
  border-radius: 4px;
  font-size: 11px;
  font-weight: 600;
  text-decoration: none;
  transition: background var(--t-fast);
}
.ts-tl-action-btn:hover { background: var(--pri-hover); color: #fff; text-decoration: none; }
.ts-tl-action-btn .bi { font-size: 11px; }

/* ────── Bulk action bar — compact, single-row, with dropdown menu ────── */
.ts-bulkbar {
  position: sticky;
  top: 8px;
  z-index: 5;
  background: #1e3a8a;
  color: #fff;
  border-radius: var(--radius);
  padding: 8px 14px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 12px;
  box-shadow: var(--sh-md);
}
/* CRITICAL: own `display: flex` declaration above wins over UA `[hidden]`
   selector specificity — must override explicitly. Same for the menu below. */
.ts-bulkbar[hidden],
.ts-bulkbar-menu[hidden] { display: none !important; }
.ts-bulkbar-info {
  display: flex; align-items: center; gap: 8px;
  font-size: 13px;
}
.ts-bulkbar-info strong { font-size: 18px; line-height: 1; }
.ts-bulkbar-info > .bi { font-size: 16px; opacity: 0.85; }

.ts-bulkbar-actions { display: flex; align-items: center; gap: 8px; }
.ts-bulkbar-menu-trigger {
  background: rgba(255,255,255,0.15);
  color: #fff;
  border: 1px solid rgba(255,255,255,0.25);
  border-radius: 6px;
  padding: 6px 12px;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  transition: background var(--t-fast);
}
.ts-bulkbar-menu-trigger:hover { background: rgba(255,255,255,0.25); }
.ts-bulkbar-menu-trigger .bi-chevron-down { font-size: 11px; opacity: 0.85; }

.ts-bulkbar-close {
  background: transparent;
  border: 0;
  color: rgba(255,255,255,0.85);
  cursor: pointer;
  font-size: 14px;
  padding: 6px 10px;
  border-radius: 6px;
  transition: background var(--t-fast);
}
.ts-bulkbar-close:hover { background: rgba(255,255,255,0.15); color: #fff; }

.ts-bulkbar-menu {
  position: absolute;
  top: 100%;
  right: 14px;
  margin-top: 6px;
  background: var(--bg-card);
  color: var(--fg);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--sh-md);
  padding: 12px;
  min-width: 240px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  z-index: 6;
}
.ts-bulkbar-menu-section { display: flex; flex-direction: column; gap: 4px; }
.ts-bulkbar-menu-section label {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--fg-muted);
  font-weight: 600;
}
.ts-bulkbar-row { display: flex; gap: 6px; }
.ts-bulkbar-row .btn { flex: 1; }

.ts-bulk-check { cursor: pointer; }

@media (max-width: 600px) {
  .ts-bulkbar { padding: 8px 10px; }
  .ts-bulkbar-menu { right: 6px; left: 6px; min-width: 0; }
}

/* ────── Row-level hover actions (quick log / inline edit) ────── */
.ts-row-act {
  display: inline-flex;
  gap: 4px;
  margin-left: 8px;
  opacity: 0;
  transition: opacity var(--t-fast);
  vertical-align: middle;
}
.ts-row:hover .ts-row-act { opacity: 1; }
.ts-row-act-btn {
  width: 24px; height: 24px;
  border-radius: 4px;
  border: 1px solid var(--line);
  background: var(--bg-card);
  color: var(--fg-muted);
  cursor: pointer;
  display: inline-flex; align-items: center; justify-content: center;
  font-size: 12px;
  transition: border-color var(--t-fast), color var(--t-fast), background var(--t-fast);
}
.ts-row-act-btn:hover {
  border-color: var(--pri);
  color: var(--pri);
  background: var(--pri-soft);
}

/* Quick popover (used for quick-log + inline-edit) */
.ts-quick-dialog {
  border: 0;
  background: transparent;
  padding: 0;
  max-width: 480px;
  width: 92vw;
  border-radius: var(--radius-lg);
}
.ts-quick-dialog::backdrop {
  background: rgba(15, 23, 42, 0.45);
  backdrop-filter: blur(2px);
}
/* .ts-quick-form is an alias for .ts-quick-card used by <form>-based
   quick dialogs (epc, scm, finance) — same white card surface. */
.ts-quick-card,
.ts-quick-form {
  background: #fff;
  border-radius: var(--radius-lg);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}
.ts-quick-head {
  display: flex; align-items: center; justify-content: space-between;
  padding: 14px 18px;
  border-bottom: 1px solid var(--line);
  font-size: 14px;
}
.ts-quick-head .btn-close {
  background: transparent;
  border: 0;
  color: var(--fg-muted);
  cursor: pointer;
  padding: 4px 8px;
  font-size: 14px;
}
.ts-quick-body { padding: 16px 18px; }
.ts-quick-hint {
  display: block;
  margin-top: 6px;
  padding: 6px 8px;
  background: var(--bg-soft);
  border-radius: 4px;
  font-size: 11px;
}
.ts-quick-body .form-label {
  display: block;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--fg-muted);
  margin-bottom: 4px;
}
.ts-quick-foot {
  display: flex; gap: 8px; justify-content: flex-end;
  padding: 12px 18px;
  border-top: 1px solid var(--line);
  background: var(--bg-stripe);
}

/* ────── Cmd+K omnibar ────── */
.ts-cmdk-trigger {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 5px 10px;
  border-radius: 6px;
  background: var(--bg-stripe);
  border: 1px solid var(--line);
  color: var(--fg-muted);
  font-size: 12px;
  cursor: pointer;
  transition: border-color var(--t-fast), background var(--t-fast);
  margin-left: auto;
  margin-right: 8px;
}
.ts-cmdk-trigger:hover { border-color: var(--line-dark); background: var(--bg-card); color: var(--fg); }
.ts-cmdk-trigger .ts-cmdk-kbd {
  background: var(--bg-card);
  border: 1px solid var(--line);
  border-radius: 4px;
  padding: 1px 5px;
  font-size: 11px;
  font-family: var(--font-mono);
  color: var(--fg-muted);
}

.ts-cmdk-dialog {
  border: 0;
  background: transparent;
  padding: 0;
  max-width: 640px;
  width: 92vw;
  margin-top: 12vh;
}
.ts-cmdk-dialog::backdrop {
  background: rgba(15, 23, 42, 0.55);
  backdrop-filter: blur(4px);
}
.ts-cmdk-shell {
  background: #fff;
  border-radius: var(--radius-lg);
  overflow: hidden;
  box-shadow: 0 25px 50px -12px rgba(0,0,0,0.25);
  display: flex;
  flex-direction: column;
  max-height: 70vh;
}
.ts-cmdk-search {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 14px 18px;
  border-bottom: 1px solid var(--line);
}
.ts-cmdk-search > .bi { font-size: 18px; color: var(--fg-muted); }
.ts-cmdk-search input {
  flex: 1;
  border: 0;
  outline: none;
  font-size: 16px;
  background: transparent;
  color: var(--fg);
}
.ts-cmdk-hint {
  background: var(--bg-soft);
  border: 1px solid var(--line);
  border-radius: 4px;
  padding: 2px 6px;
  font-size: 11px;
  font-family: var(--font-mono);
  color: var(--fg-muted);
}

.ts-cmdk-results {
  overflow-y: auto;
  flex: 1;
  min-height: 60px;
}
.ts-cmdk-help {
  padding: 18px 20px;
  color: var(--fg-muted);
  font-size: 13px;
}
.ts-cmdk-help p { margin: 0 0 8px 0; color: var(--fg); }
.ts-cmdk-help ul { padding-left: 18px; margin: 0; }
.ts-cmdk-help li { margin-bottom: 4px; }
.ts-cmdk-help kbd {
  background: var(--bg-soft);
  border: 1px solid var(--line);
  border-radius: 3px;
  padding: 1px 5px;
  font-size: 11px;
  font-family: var(--font-mono);
}
.ts-cmdk-empty {
  text-align: center;
  padding: 40px 20px;
  color: var(--fg-muted);
}
.ts-cmdk-empty i { font-size: 32px; display: block; margin-bottom: 8px; opacity: 0.5; }

.ts-cmdk-list { list-style: none; margin: 0; padding: 6px; }
.ts-cmdk-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 12px;
  border-radius: 6px;
  cursor: pointer;
  transition: background var(--t-fast);
}
.ts-cmdk-item.active { background: var(--pri-soft); }
.ts-cmdk-item:hover { background: var(--bg-hover); }
.ts-cmdk-kind-icon {
  width: 32px; height: 32px;
  border-radius: 6px;
  background: var(--bg-soft);
  color: var(--fg-muted);
  display: flex; align-items: center; justify-content: center;
  font-size: 14px;
  flex-shrink: 0;
}
.ts-cmdk-item.active .ts-cmdk-kind-icon { background: var(--pri); color: #fff; }
.ts-cmdk-text { flex: 1; min-width: 0; }
.ts-cmdk-label {
  font-weight: 600;
  color: var(--fg);
  font-size: 14px;
  white-space: nowrap;
  text-overflow: ellipsis;
  overflow: hidden;
}
.ts-cmdk-sub {
  font-size: 12px;
  color: var(--fg-muted);
  white-space: nowrap;
  text-overflow: ellipsis;
  overflow: hidden;
}
.ts-cmdk-badge {
  background: var(--bg-soft);
  color: var(--fg-muted);
  font-size: 11px;
  font-weight: 600;
  padding: 3px 8px;
  border-radius: 4px;
  flex-shrink: 0;
}
.ts-cmdk-item.active .ts-cmdk-badge { background: var(--pri); color: #fff; }

@media (max-width: 600px) {
  .ts-cmdk-dialog { margin-top: 6vh; max-width: 96vw; }
  .ts-cmdk-trigger .hide-sm { display: none; }
}

/* Reusable empty-state hero (no rows, no tasks, etc.) */
.ts-empty-state, .ts-today-empty {
  text-align: center;
  padding: 60px 20px;
  background: var(--bg-card);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
}
.ts-empty-state i, .ts-today-empty i {
  font-size: 56px;
  color: var(--ok);
  display: inline-block;
  margin-bottom: 12px;
}
.ts-empty-state h3, .ts-today-empty h3 { margin: 4px 0 8px 0; }
.ts-empty-state p, .ts-today-empty p { color: var(--fg-muted); margin-bottom: 16px; }

/* Company link in detail-head h1 — makes it clear the name is clickable */
.ts-company-link {
  color: inherit;
  text-decoration: none;
  border-bottom: 2px solid transparent;
  transition: border-color var(--t-fast), color var(--t-fast);
}
.ts-company-link:hover {
  color: var(--pri);
  border-bottom-color: var(--pri);
  text-decoration: none;
}

@media (max-width: 600px) {
  .ts-tl-time { margin-left: 0; flex-basis: 100%; }
  .ts-timeline { padding-left: 36px; background-position: 21px 14px; }
  .ts-tl-marker { margin-left: -24px; width: 24px; height: 24px; font-size: 11px; }
  .ts-tl-day { margin-left: -22px; }
  .ts-tl-day::before { margin-left: 7px; margin-right: 10px; }
}

/* The card that hosts the timeline must NOT clip — undo .ts-card's overflow */
.ts-card:has(.ts-timeline) { overflow: visible; }
/* Browsers without :has — guard via explicit class on the card */
.ts-card.ts-card-timeline { overflow: visible; }

/* Backwards compat for any caller still using old class names */
.ts-timeline-item { display: flex; gap: 10px; padding: 10px 0; border-bottom: 1px solid var(--line-soft); }
.ts-timeline-item:last-child { border-bottom: none; }
.ts-timeline-icon {
  width: 28px; height: 28px; flex-shrink: 0;
  border-radius: 50%; background: var(--pri-soft); color: var(--pri);
  display: flex; align-items: center; justify-content: center; font-size: 13px;
}
.ts-timeline-body { flex: 1; min-width: 0; }
.ts-timeline-meta { font-size: 11px; color: var(--fg-muted); margin-bottom: 2px; }
.ts-timeline-text { font-size: 13px; color: var(--fg); white-space: pre-wrap; word-break: break-word; line-height: 1.5; }

.ts-log-form { padding: 12px 16px; border-bottom: 1px solid var(--line-soft); background: var(--bg-stripe); }

/* ────── Documents ────── */
.ts-doc-uploader {
  padding: 12px 16px;
  background: var(--bg-stripe);
  border-bottom: 1px solid var(--line-soft);
}
.ts-doc-list { padding: 12px 16px; display: flex; flex-direction: column; gap: 6px; }
.ts-doc-item {
  display: flex; align-items: center; gap: 10px;
  padding: 8px 10px;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  font-size: 13px;
}
.ts-doc-name { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ts-doc-meta { font-size: 11px; color: var(--fg-muted); }

/* ════════════════════════════════════════════════════════════════════════
   MOBILE — table-to-cards, sidebar drawer
   ════════════════════════════════════════════════════════════════════════ */
.ts-sidebar-overlay { display: none; }

@media (max-width: 992px) {
  .ts-sidebar {
    position: fixed;
    left: 0; top: 0; bottom: 0;
    transform: translateX(-100%);
    transition: transform 0.24s ease;
    box-shadow: 4px 0 20px rgba(0,0,0,0.18);
  }
  .ts-sidebar.show { transform: translateX(0); }
  .ts-sidebar-overlay {
    display: block;
    position: fixed; inset: 0;
    background: rgba(15,23,42,0.4);
    backdrop-filter: blur(2px);
    z-index: 40;
    opacity: 0; pointer-events: none;
    transition: opacity 0.18s;
  }
  .ts-sidebar-overlay.show { opacity: 1; pointer-events: auto; }
  .ts-mobile-toggle { display: inline-flex; }
  .ts-content { padding: 16px 16px 64px; }
  .ts-topbar { padding: 0 16px; }
}

@media (max-width: 768px) {
  /* Switch tables to card layout for narrow viewports.
     Each <tr> becomes a card; <td>s become rows of "label : value" pairs. */
  .ts-table.ts-mobile-cards { border-collapse: separate; }
  .ts-table.ts-mobile-cards thead { display: none; }
  .ts-table.ts-mobile-cards tbody,
  .ts-table.ts-mobile-cards tbody tr,
  .ts-table.ts-mobile-cards tbody td { display: block; width: 100%; }

  .ts-table.ts-mobile-cards tbody tr {
    background: var(--bg-card);
    border: 1px solid var(--line);
    border-radius: var(--radius-lg);
    margin-bottom: 12px;
    padding: 14px 14px 8px 14px;
    position: relative;
    box-shadow: var(--sh-sm);
    transition: border-color var(--t-fast), box-shadow var(--t-fast);
    cursor: pointer;
  }
  .ts-table.ts-mobile-cards tbody tr:hover {
    border-color: var(--line-dark);
    box-shadow: var(--sh);
  }
  /* Hot / priority status pulled out of normal flow as a left edge ribbon */
  .ts-table.ts-mobile-cards tbody tr.ts-row-hot {
    border-left: 4px solid var(--hot);
    padding-left: 12px;
  }
  .ts-table.ts-mobile-cards tbody tr.ts-row-p1 {
    border-left: 4px solid #f59e0b;
    padding-left: 12px;
    background: linear-gradient(135deg, rgba(245,158,11,0.06), var(--bg-card) 60%);
  }
  .ts-table.ts-mobile-cards tbody tr.ts-row-platform {
    border-left: 4px solid var(--pri);
    padding-left: 12px;
  }
  .ts-table.ts-mobile-cards tbody tr.ts-row-overdue {
    border-left: 4px solid var(--err);
    padding-left: 12px;
  }

  /* Each cell becomes a label:value row */
  .ts-table.ts-mobile-cards tbody td {
    border-bottom: none;
    padding: 5px 0;
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 10px;
    white-space: normal;
    font-size: 13px;
  }
  .ts-table.ts-mobile-cards tbody td::before {
    content: attr(data-label);
    font-size: 11px;
    color: var(--fg-muted);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    font-weight: 600;
    flex-shrink: 0;
  }

  /* The first cell (badges / grip) and bulk-checkbox should be hidden, since
     that grouping makes no sense in a vertical card. The primary cell becomes
     the title at the top. */
  .ts-table.ts-mobile-cards tbody td.ts-cell-handle,
  .ts-table.ts-mobile-cards tbody td:has(> .ts-bulk-check) {
    position: absolute;
    top: 12px;
    right: 12px;
    width: auto;
    padding: 0;
    margin: 0;
  }
  .ts-table.ts-mobile-cards tbody td.ts-cell-handle::before,
  .ts-table.ts-mobile-cards tbody td:has(> .ts-bulk-check)::before { display: none; }
  .ts-table.ts-mobile-cards tbody td.ts-cell-handle .ts-row-grip { display: none; }

  /* Primary cell (Perusahaan): render as card title, full width, bold */
  .ts-table.ts-mobile-cards tbody td.ts-cell-primary {
    border-bottom: 1px solid var(--line-soft);
    padding: 0 0 8px 0;
    margin-bottom: 6px;
    font-size: 16px;
    font-weight: 700;
    flex-direction: column;
    align-items: flex-start;
    gap: 4px;
  }
  .ts-table.ts-mobile-cards tbody td.ts-cell-primary::before { display: none; }
  .ts-table.ts-mobile-cards tbody td.ts-cell-primary > .ts-row-act {
    opacity: 1;
    margin-left: 0;
  }
  .ts-table.ts-mobile-cards tbody td.ts-cell-primary strong {
    font-size: 16px;
    line-height: 1.3;
  }

  /* Hide a few low-value columns to declutter cards */
  .ts-table.ts-mobile-cards tbody td[data-label="Sourcing"],
  .ts-table.ts-mobile-cards tbody td[data-label="Material"],
  .ts-table.ts-mobile-cards tbody td[data-label="No SPH"],
  .ts-table.ts-mobile-cards tbody td[data-label="SPH No"] { display: none; }

  /* Don't show empty-value cells at all */
  .ts-table.ts-mobile-cards tbody td:empty,
  .ts-table.ts-mobile-cards tbody td:has(> :only-child:empty) { display: none; }

  /* Empty state still spans the row */
  .ts-table.ts-mobile-cards tbody tr.ts-row-empty {
    text-align: center; padding: 32px 16px;
  }
  .ts-table.ts-mobile-cards tbody tr.ts-row-empty td {
    text-align: center;
    justify-content: center;
  }
  .ts-table.ts-mobile-cards tbody tr.ts-row-empty td::before { display: none; }

  .ts-detail-head .actions { width: 100%; justify-content: stretch; }
  .ts-detail-head .actions .btn { flex: 1; justify-content: center; }
  .ts-sidecar { position: static; }

  /* Filter bar on mobile: stack vertically */
  .ts-filterbar { flex-wrap: wrap; }
  .ts-filterbar > * { flex: 1 1 calc(50% - 4px); min-width: 0; }
  .ts-filterbar input[type=search] { flex-basis: 100%; }

  /* Bulk bar wraps nicely */
  .ts-bulkbar { flex-direction: column; align-items: stretch; }
  .ts-bulkbar > span { margin-right: 0; }
}

/* ════════════════════════════════════════════════════════════════════════
   AUTH PAGE
   ════════════════════════════════════════════════════════════════════════ */
.ts-auth { min-height: 100vh; background: #0b1322; }
.ts-auth-shell {
  display: flex; align-items: center; justify-content: center;
  min-height: 100vh; padding: 24px;
  background: radial-gradient(circle at top right, rgba(30,58,138,0.25), transparent 60%),
              radial-gradient(circle at bottom left, rgba(30,58,138,0.2), transparent 60%);
}
.ts-auth-card {
  background: #fff;
  padding: 32px;
  border-radius: var(--radius-lg);
  box-shadow: 0 25px 50px -12px rgba(0,0,0,0.25);
  width: 100%; max-width: 400px;
}
.ts-auth-brand { text-align: center; margin-bottom: 28px; }
.ts-auth-brand img { width: 56px; height: 56px; border-radius: 12px; }
.ts-auth-brand h2 { margin: 12px 0 4px; font-weight: 700; letter-spacing: -0.02em; font-size: 1.3rem; }
.ts-auth-brand small { color: var(--fg-muted); font-size: 12px; }

/* Password visibility toggle (login + change-password) */
.ts-pw-wrap { position: relative; }
.ts-pw-wrap .form-control { padding-right: 48px; }
.ts-pw-toggle {
  position: absolute; top: 50%; right: 7px;
  transform: translateY(-50%);
  width: 34px; height: 34px;
  display: flex; align-items: center; justify-content: center;
  border: 0; border-radius: 8px;
  background: transparent;
  color: var(--fg-muted);
  cursor: pointer;
  transition: background-color .15s ease, color .15s ease;
}
.ts-pw-toggle:hover { background: rgba(11,19,34,0.07); color: #0b1322; }
.ts-pw-toggle:active { transform: translateY(-50%) scale(0.9); }
.ts-pw-toggle:focus-visible { outline: 2px solid #2563eb; outline-offset: 1px; }
.ts-pw-toggle i { font-size: 16px; line-height: 1; }

/* ════════════════════════════════════════════════════════════════════════
   UTILITIES
   ════════════════════════════════════════════════════════════════════════ */
.ts-empty { text-align: center; padding: 48px 16px; color: var(--fg-muted); font-size: 13px; }
.ts-empty i { font-size: 28px; opacity: 0.4; display: block; margin-bottom: 8px; }

.ts-flex { display: flex; gap: 8px; align-items: center; }
.ts-flex-1 { flex: 1; min-width: 0; }
.ts-stack { display: flex; flex-direction: column; gap: 10px; }
.ts-divider { height: 1px; background: var(--line-soft); margin: 12px 0; }

.ts-pip {
  display: inline-block;
  width: 6px; height: 6px;
  border-radius: 50%;
  background: var(--fg-subtle);
  margin-right: 4px;
}
.ts-pip.warn { background: var(--warn); }
.ts-pip.err  { background: var(--err); }
.ts-pip.ok   { background: var(--ok); }

.text-uppercase { text-transform: uppercase; letter-spacing: 0.05em; }
.text-tight     { line-height: 1.25; }
.text-tabular   { font-variant-numeric: tabular-nums; }
.fs-11 { font-size: 11px; } .fs-12 { font-size: 12px; } .fs-13 { font-size: 13px; }
.mt-0 { margin-top: 0; }   .mb-0 { margin-bottom: 0; }
.mt-1 { margin-top: 4px; } .mb-1 { margin-bottom: 4px; }
.mt-2 { margin-top: 8px; } .mb-2 { margin-bottom: 8px; }
.mt-3 { margin-top: 12px;} .mb-3 { margin-bottom: 12px; }
.mt-4 { margin-top: 16px;} .mb-4 { margin-bottom: 16px; }
.ml-1 { margin-left: 4px; } .mr-1 { margin-right: 4px; }
.ml-2 { margin-left: 8px; } .mr-2 { margin-right: 8px; }
.py-1 { padding-top: 4px; padding-bottom: 4px; }
.py-2 { padding-top: 8px; padding-bottom: 8px; }
.py-3 { padding-top: 12px; padding-bottom: 12px; }
.d-block { display: block; }
.d-flex { display: flex; }
.align-items-center { align-items: center; }
.justify-content-between { justify-content: space-between; }
.gap-1 { gap: 4px; } .gap-2 { gap: 8px; } .gap-3 { gap: 12px; }
.flex-wrap { flex-wrap: wrap; }
.w-100 { width: 100%; }

@media (max-width: 600px) {
  .hide-sm { display: none !important; }
}
@media (min-width: 601px) {
  .show-sm-only { display: none !important; }
}

/* ════════════════════════════════════════════════════════════════════════
   WEEKLY REPORT (web view + PDF print)
   ════════════════════════════════════════════════════════════════════════ */
.ts-report { display: flex; justify-content: center; }
.ts-report-doc {
  max-width: 980px;
  width: 100%;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  padding: 32px 40px;
  font-size: 13px;
}

.ts-report-head {
  display: flex;
  justify-content: space-between;
  align-items: flex-end;
  gap: 16px;
  padding-bottom: 18px;
  border-bottom: 2px solid var(--fg);
  margin-bottom: 28px;
}
.ts-report-eyebrow {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  color: var(--fg-muted);
}
.ts-report-title {
  font-size: 1.6rem;
  font-weight: 800;
  letter-spacing: -0.02em;
  line-height: 1.15;
  margin: 4px 0 6px;
}
.ts-report-period {
  font-size: 14px;
  color: var(--fg);
  font-weight: 500;
}
.ts-report-brand {
  display: flex;
  align-items: center;
  gap: 10px;
}
.ts-report-brand img {
  width: 40px;
  height: 40px;
  border-radius: 6px;
}
.ts-report-brand strong { display: block; font-size: 14px; line-height: 1.1; }
.ts-report-brand small { color: var(--fg-muted); font-size: 11px; }

.ts-report-section { margin-bottom: 32px; page-break-inside: avoid; }
.ts-report-section-title {
  font-size: 13px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--fg-muted);
  margin-bottom: 12px;
  padding-bottom: 6px;
  border-bottom: 1px solid var(--line);
}

.ts-report-stats {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 12px;
}
.ts-report-stat {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 12px 14px;
}
.ts-report-stat-label {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--fg-muted);
  font-weight: 600;
}
.ts-report-stat-value {
  font-size: 1.5rem;
  font-weight: 700;
  letter-spacing: -0.02em;
  line-height: 1.15;
  margin-top: 2px;
}
.ts-report-stat-sub { font-size: 11px; color: var(--fg-muted); margin-top: 2px; }

.ts-report-cols {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 24px;
}
.ts-report-h3 {
  font-size: 13px;
  font-weight: 700;
  margin-bottom: 8px;
  display: flex;
  align-items: center;
  gap: 6px;
}

.ts-report-list { list-style: none; padding: 0; margin: 0; }
.ts-report-list li { border-bottom: 1px dashed var(--line-soft); }
.ts-report-list li:last-child { border-bottom: none; }
.ts-report-list-row {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 4px 12px;
  padding: 7px 0;
  text-decoration: none;
  color: var(--fg);
}
.ts-report-list-row strong { font-size: 13px; grid-column: 1; }
.ts-report-list-row .text-tabular { grid-column: 2; align-self: start; font-weight: 600; }
.ts-report-list-row .text-muted { grid-column: 1 / -1; font-size: 11px; }

.ts-report-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 12px;
}
.ts-report-table th {
  background: var(--bg-stripe);
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--fg-muted);
  padding: 7px 10px;
  border-bottom: 2px solid var(--line);
  text-align: left;
}
.ts-report-table th.text-right { text-align: right; }
.ts-report-table td {
  padding: 7px 10px;
  border-bottom: 1px solid var(--line-soft);
  vertical-align: top;
}
.ts-report-table .text-right { text-align: right; }
.ts-report-table tr:last-child td { border-bottom: none; }

.ts-report-activity { list-style: none; padding: 0; margin: 0; }
.ts-report-activity li {
  display: grid;
  grid-template-columns: 130px 90px auto 1fr;
  gap: 10px;
  padding: 8px 0;
  border-bottom: 1px dashed var(--line-soft);
  font-size: 12px;
  align-items: baseline;
}
.ts-report-activity li:last-child { border-bottom: none; }
.ts-report-activity-when { color: var(--fg-muted); font-family: var(--font-mono); font-size: 11px; }
.ts-report-activity-user { font-weight: 600; }
.ts-report-activity-target { color: var(--fg); text-decoration: none; display: inline-flex; align-items: center; gap: 4px; }
.ts-report-activity-target:hover { color: var(--pri); text-decoration: underline; }
.ts-report-activity-body { white-space: pre-wrap; word-break: break-word; }
@media (max-width: 720px) {
  .ts-report-activity li { grid-template-columns: 1fr; gap: 2px; }
}

.ts-report-empty {
  padding: 16px;
  text-align: center;
  font-size: 12px;
  color: var(--fg-muted);
  background: var(--bg-stripe);
  border-radius: var(--radius);
  margin: 0;
}

.ts-report-footer {
  display: flex;
  justify-content: space-between;
  margin-top: 32px;
  padding-top: 16px;
  border-top: 1px solid var(--line);
  font-size: 11px;
  color: var(--fg-muted);
}

/* ────── SCM dashboard to-do queue (role-scoped) ────── */
.ts-queue {
  background: var(--bg-card); border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  margin-bottom: 18px; overflow: hidden;
}
.ts-queue-head {
  display: flex; align-items: center; justify-content: space-between;
  padding: 12px 16px; border-bottom: 1px solid var(--line);
  background: var(--bg-stripe);
}
.ts-queue-head h3 {
  margin: 0; font-size: 14px; font-weight: 700;
  display: flex; align-items: center; gap: 8px;
  color: var(--fg);
}
.ts-queue-head h3 .bi { color: var(--pri); }
.ts-queue-count {
  font-size: 11px; color: var(--fg-muted);
  background: var(--bg-soft); padding: 3px 10px; border-radius: 999px;
  font-weight: 600;
}
.ts-queue-list { list-style: none; margin: 0; padding: 0; max-height: 360px; overflow-y: auto; }
.ts-queue-item { border-bottom: 1px solid var(--line-soft); }
.ts-queue-item:last-child { border-bottom: none; }
.ts-queue-link {
  display: flex; align-items: center; gap: 12px;
  padding: 10px 16px; text-decoration: none; color: var(--fg);
  transition: background .12s;
}
.ts-queue-link:hover { background: var(--bg-hover); }
.ts-queue-kind {
  flex-shrink: 0; min-width: 38px; text-align: center;
  font-size: 10.5px; font-weight: 700; letter-spacing: .04em;
  padding: 3px 7px; border-radius: 4px;
  background: var(--bg-soft); color: var(--fg-muted);
}
.ts-queue-item.is-high .ts-queue-kind { background: var(--err-soft); color: var(--err); }
.ts-queue-item.is-med  .ts-queue-kind { background: var(--warn-soft); color: var(--warn); }
.ts-queue-item.is-low  .ts-queue-kind { background: var(--bg-soft); color: var(--fg-muted); }
.ts-queue-text { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.ts-queue-text strong { font-size: 13px; font-weight: 600; }
.ts-queue-sub { font-size: 11.5px; color: var(--fg-muted); }
.ts-queue-go { color: var(--fg-subtle); font-size: 14px; flex-shrink: 0; }

/* ────── Flash toast (server redirect side-effects callout) ────── */
.ts-flash {
  position: fixed; bottom: 24px; left: 50%; transform: translateX(-50%);
  z-index: 9998; min-width: 280px; max-width: min(640px, calc(100vw - 32px));
  display: flex; align-items: center; gap: 10px;
  padding: 12px 16px;
  border-radius: var(--radius-lg);
  box-shadow: 0 12px 32px rgba(15, 23, 42, 0.22);
  font-size: 13px; line-height: 1.5;
  animation: ts-flash-in .3s cubic-bezier(0.16, 1, 0.3, 1);
  background: var(--bg-card); border: 1px solid var(--line);
}
.ts-flash.is-ok      { background: var(--ok-soft);   border-color: var(--ok);   color: #064e2c; }
.ts-flash.is-warning { background: var(--warn-soft); border-color: var(--warn); color: #78350f; }
.ts-flash.is-err     { background: var(--err-soft);  border-color: var(--err);  color: #7f1d1d; }
.ts-flash.is-info    { background: var(--pri-soft);  border-color: var(--pri);  color: var(--pri); }
.ts-flash.is-leaving { opacity: 0; transform: translateX(-50%) translateY(10px); transition: all .3s ease; }
.ts-flash-link {
  margin-left: 8px; font-weight: 700; text-decoration: underline;
  color: inherit; flex-shrink: 0;
}
.ts-flash-x {
  margin-left: auto; background: none; border: 0;
  font-size: 18px; line-height: 1; cursor: pointer;
  color: inherit; opacity: .6; padding: 0 4px;
}
.ts-flash-x:hover { opacity: 1; }
@keyframes ts-flash-in {
  from { opacity: 0; transform: translateX(-50%) translateY(20px); }
  to   { opacity: 1; transform: translateX(-50%) translateY(0); }
}

/* ────── In-app modal (appConfirm/appPrompt + ad-hoc dialogs) ────── */
.ts-modal {
  position: fixed; inset: 0; z-index: 9999;
  display: none;
  align-items: flex-start; justify-content: center;
  padding: 10vh 16px 16px;
}
.ts-modal.is-open { display: flex; }
.ts-modal-backdrop {
  position: absolute; inset: 0;
  background: rgba(15, 23, 42, 0.5);
  backdrop-filter: blur(2px);
  -webkit-backdrop-filter: blur(2px);
}
.ts-modal-shell {
  position: relative; background: var(--bg-card);
  border-radius: var(--radius-lg);
  box-shadow: 0 24px 64px rgba(15, 23, 42, 0.28);
  width: min(460px, 100%);
  overflow: hidden;
  animation: ts-modal-pop 140ms cubic-bezier(0.16, 1, 0.3, 1);
  display: flex; flex-direction: column;
  max-height: calc(100vh - 14vh);
}
@keyframes ts-modal-pop {
  from { transform: translateY(-10px) scale(0.98); opacity: 0; }
  to   { transform: none;                          opacity: 1; }
}
.ts-modal-head {
  display: flex; align-items: center; justify-content: space-between;
  gap: 12px;
  padding: 14px 18px 10px;
  border-bottom: 1px solid var(--line-soft);
}
.ts-modal-title {
  margin: 0; font-size: 15px; font-weight: 600;
  line-height: 1.3; color: var(--fg);
  display: flex; align-items: center; gap: 8px;
}
.ts-modal-title .bi { color: var(--pri); font-size: 16px; }
.ts-modal-x {
  background: none; border: 0; padding: 6px;
  color: var(--fg-muted); cursor: pointer; border-radius: 6px;
  line-height: 1;
}
.ts-modal-x:hover { background: var(--bg-soft); color: var(--fg); }
.ts-modal-body {
  padding: 14px 18px;
  color: var(--fg); font-size: 13.5px; line-height: 1.5;
  overflow-y: auto;
}
.ts-modal-body .ts-modal-text { white-space: pre-wrap; margin-bottom: 10px; color: var(--fg-muted); }
.ts-modal-body label {
  font-size: 11.5px; font-weight: 600;
  color: var(--fg-muted); text-transform: uppercase; letter-spacing: .04em;
  margin-bottom: 4px; display: block;
}
.ts-modal-body .ts-modal-input,
.ts-modal-body .ts-modal-select,
.ts-modal-body .ts-modal-area,
.ts-modal-body .form-control {
  width: 100%; padding: 9px 11px;
  border: 1px solid var(--line); border-radius: var(--radius-sm);
  font: inherit; color: var(--fg); background: var(--bg-card);
  transition: border-color .12s ease, box-shadow .12s ease;
}
.ts-modal-body .ts-modal-area { min-height: 72px; resize: vertical; }
.ts-modal-body .ts-modal-input:focus,
.ts-modal-body .ts-modal-select:focus,
.ts-modal-body .ts-modal-area:focus,
.ts-modal-body .form-control:focus {
  outline: none; border-color: var(--pri);
  box-shadow: 0 0 0 3px var(--pri-soft);
}
.ts-modal-body .ts-modal-hint {
  font-size: 11.5px; color: var(--fg-muted);
  background: var(--bg-soft); border-radius: var(--radius-sm);
  padding: 8px 10px; margin-bottom: 12px; line-height: 1.5;
}
.ts-modal-body .ts-modal-hint code,
.ts-modal-body .ts-modal-hint strong { color: var(--fg); font-weight: 600; }
.ts-modal-body .ts-modal-err {
  font-size: 12px; color: var(--err);
  background: var(--err-soft); border-radius: var(--radius-sm);
  padding: 7px 10px; margin-top: 8px;
}
.ts-modal-body .ts-modal-req { color: var(--err); }
.ts-modal-foot {
  display: flex; justify-content: flex-end; gap: 8px;
  padding: 12px 18px; border-top: 1px solid var(--line-soft);
  background: var(--bg-stripe);
}
.ts-modal.is-danger .ts-modal-shell { border-top: 3px solid var(--err); }
.ts-modal.is-danger .ts-modal-title .bi { color: var(--err); }
.ts-modal.is-danger #app-modal-ok { background: var(--err); border-color: var(--err); }
.ts-modal.is-danger #app-modal-ok:hover { background: #b91c1c; }
@media (max-width: 520px) {
  .ts-modal { padding: 4vh 8px 8px; }
  .ts-modal-shell { width: 100%; max-height: calc(100vh - 6vh); }
  .ts-modal-head, .ts-modal-foot { padding-left: 14px; padding-right: 14px; }
  .ts-modal-body { padding: 12px 14px; }
}

/* ─── Print stylesheet (Save as PDF target) ─────────────────────────── */
@media print {
  @page { size: A4; margin: 14mm 12mm; }
  body { background: #fff !important; font-size: 11px; }
  .ts-sidebar, .ts-topbar, .ts-mobile-toggle { display: none !important; }
  .ts-app { display: block; }
  .ts-main, .ts-content { padding: 0 !important; background: #fff !important; }
  .ts-report-doc { border: none !important; padding: 0 !important; max-width: 100% !important; }
  .ts-report-section-title { font-size: 11px; }
  .ts-report-table th, .ts-report-table td { padding: 4px 6px; font-size: 10.5px; }
  .ts-report-stat-value { font-size: 1.2rem; }
  a { color: inherit; text-decoration: none; }
  .ts-report-section { page-break-inside: auto; break-inside: auto; }
}
