/* ────────────────────────────────────────────────────────────────────────
   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;
}

.ts-brand {
  display: flex; align-items: center; gap: 10px;
  padding: 16px 20px;
  border-bottom: 1px solid rgba(255,255,255,0.06);
}
.ts-brand img { width: 32px; height: 32px; border-radius: 6px; }
.ts-brand-text strong { color: #fff; display: block; font-size: 14px; font-weight: 600; line-height: 1.1; }
.ts-brand-text small { color: #64748b; font-size: 11px; }

.ts-nav {
  flex: 1;
  padding: 12px 8px;
  overflow-y: auto;
}
.ts-nav-link {
  display: flex; align-items: center; gap: 10px;
  padding: 8px 12px;
  margin: 1px 0;
  color: var(--side-fg);
  font-size: 13px;
  font-weight: 500;
  border-radius: var(--radius-sm);
  transition: background var(--t-fast), color var(--t-fast);
}
.ts-nav-link i { font-size: 16px; opacity: 0.85; }
.ts-nav-link:hover { background: var(--side-hover-bg); color: #fff; text-decoration: none; }
.ts-nav-link.active {
  background: var(--side-active-bg);
  color: var(--side-fg-active);
}
.ts-nav-link.active i { opacity: 1; }
.ts-nav-section {
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: #475569;
  margin: 14px 12px 4px;
}

.ts-sidebar-footer {
  border-top: 1px solid rgba(255,255,255,0.06);
  padding: 12px 16px;
}
.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: 10px; 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: #fff;
  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; }

.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: #fff;
  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: #fff;
  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: #fff;
  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: 10px; 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: 10px;
  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; }

/* ════════════════════════════════════════════════════════════════════════
   CARDS / SECTIONS
   ════════════════════════════════════════════════════════════════════════ */
.ts-card {
  background: #fff;
  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: #fff;
}
.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: #fff;
  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: 10px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}
.ts-tl-type {
  background: var(--pri-soft);
  color: var(--pri);
  font-size: 10px;
  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: 10px; 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: 10px; 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: 10px; }

/* ────── 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-card {
  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: 10px;
  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; }

/* ════════════════════════════════════════════════════════════════════════
   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: 10.5px;
  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);
}

/* ─── 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; }
}
