/* Thème clair "Serene Blue" soft UI, aligné sur la palette et les ombres du site vitrine
   (Site_Vitrine/css/styles.css) — mêmes noms de variables qu'avant pour que le reste du
   fichier reste valide, seules les valeurs changent (sombre/violet -> clair/bleu soft UI). */
:root {
  --dusk-blue: #274c77;
  --steel-blue: #6096ba;
  --icy-blue: #a3cef1;

  --bg: #e3edf5;
  --surface: #ffffff;
  --surface-alt: #dbe7f0;
  --border: hsl(206 32% 85%);
  --border-strong: hsl(206 30% 72%);
  --text: #16232f;
  --text-muted: #55636d;
  --text-faint: #6b7880;

  --accent: var(--dusk-blue);
  --accent-dark: #1b3a5c;
  --accent-ink: #2f6690;
  --accent-soft: color-mix(in oklab, var(--icy-blue) 42%, white);

  --ok: #1e7a42;
  --ok-soft: color-mix(in oklab, var(--ok) 14%, white);
  --warn: #a15c00;
  --warn-soft: color-mix(in oklab, var(--warn) 14%, white);
  --danger: #c0392b;
  --danger-soft: color-mix(in oklab, var(--danger) 14%, white);

  --sidebar-bg: #ffffff;
  --sidebar-border: var(--border);
  --sidebar-text: var(--text-muted);
  --sidebar-text-dim: var(--text-faint);
  --sidebar-active: var(--accent);

  --radius: 14px;
  --radius-lg: 20px;
  --ease-soft: cubic-bezier(0.22, 1, 0.36, 1);
  --shadow-soft: 6px 6px 12px rgba(150, 173, 196, 0.4), -6px -6px 12px rgba(255, 255, 255, 0.85);
  --shadow-soft-sm: 4px 4px 8px rgba(150, 173, 196, 0.35), -4px -4px 8px rgba(255, 255, 255, 0.85);
  --shadow-soft-hover: 8px 8px 16px rgba(150, 173, 196, 0.45), -8px -8px 16px rgba(255, 255, 255, 0.9);
  --shadow-soft-inset: inset 4px 4px 8px rgba(150, 173, 196, 0.35), inset -4px -4px 8px rgba(255, 255, 255, 0.7);
  --shadow-sm: var(--shadow-soft-sm);
  --shadow-md: 0 20px 44px -20px rgba(22, 41, 58, 0.35), 0 4px 10px -4px rgba(22, 41, 58, 0.12);

  --font: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  --font-mono: "Roboto Mono", "SFMono-Regular", Consolas, monospace;
}

* { box-sizing: border-box; }

html, body {
  height: 100%;
  margin: 0;
  padding: 0;
}

body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  -webkit-font-smoothing: antialiased;
}

.app-shell {
  display: flex;
  height: 100vh;
  gap: 2px;
  padding: 8px;
  background: var(--bg);
}

.app-shell[hidden] {
  display: none;
}

/* Sidebar */

.sidebar {
  width: 264px;
  flex-shrink: 0;
  height: 100%;
  background: transparent;
  color: var(--sidebar-text);
  display: flex;
  flex-direction: column;
  padding: 10px 10px 6px;
  overflow-y: auto;
  transition: width 0.16s ease, padding 0.16s ease;
}

.sidebar-brand {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 6px 8px 14px;
  margin-bottom: 8px;
  border-bottom: 1px solid var(--sidebar-border);
}

.brand-mark {
  width: 34px;
  height: 34px;
  border-radius: 7px;
  background: var(--accent);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 13px;
  letter-spacing: 0.5px;
  flex-shrink: 0;
}

.brand-text {
  display: flex;
  flex-direction: column;
  line-height: 1.25;
  min-width: 0;
}

.brand-name {
  color: var(--text);
  font-weight: 600;
  font-size: 14.5px;
  white-space: nowrap;
}

.brand-sub {
  font-family: var(--font-mono);
  font-size: 10.5px;
  letter-spacing: 0.03em;
  text-transform: uppercase;
  color: var(--text-faint);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.sidebar-nav {
  display: flex;
  flex-direction: column;
  gap: 12px;
  flex: 1;
  padding-top: 4px;
}

.nav-group {
  display: flex;
  flex-direction: column;
  gap: 1px;
}

.nav-group[hidden] {
  display: none;
}

.nav-group-label {
  margin: 4px 10px 4px;
  font-size: 10.5px;
  font-weight: 600;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  color: var(--text-faint);
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  padding: 8px 10px;
  background: transparent;
  border: none;
  border-radius: var(--radius);
  color: var(--sidebar-text);
  font-family: inherit;
  font-size: 13px;
  font-weight: 500;
  text-align: left;
  cursor: pointer;
  transition: background 0.12s ease, color 0.12s ease;
}

.nav-item:hover {
  background: var(--surface-alt);
  color: var(--text);
}

.nav-item.is-active {
  background: var(--accent-soft);
  color: var(--accent-ink);
  font-weight: 600;
}

.nav-item[hidden] {
  display: none;
}

.nav-item span {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.nav-icon {
  width: 17px;
  height: 17px;
  flex-shrink: 0;
  color: var(--text-faint);
}

.nav-item.is-active .nav-icon,
.nav-item:hover .nav-icon {
  color: currentColor;
}

.sidebar-footer {
  border-top: 1px solid var(--sidebar-border);
  padding-top: 14px;
  margin-top: 10px;
  flex-shrink: 0;
}

.sidebar-footer .status-pill {
  display: flex;
  width: 100%;
  justify-content: center;
  white-space: normal;
  text-align: center;
  margin-bottom: 10px;
}

.user-chip {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 38px 8px 10px;
  border-radius: 8px;
  position: relative;
}

.user-avatar {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: var(--accent-soft);
  color: var(--accent-ink);
  font-size: 12px;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.user-meta {
  display: flex;
  flex-direction: column;
  line-height: 1.25;
  min-width: 0;
}

.user-name {
  color: var(--text);
  font-size: 13px;
  font-weight: 600;
}

.user-role {
  font-family: var(--font-mono);
  font-size: 10.5px;
  letter-spacing: 0.02em;
  text-transform: uppercase;
  color: var(--text-faint);
}

/* Collapsible sidebar */

.app-shell.sidebar-collapsed .sidebar {
  width: 62px;
  padding-left: 8px;
  padding-right: 8px;
}

.app-shell.sidebar-collapsed .brand-text,
.app-shell.sidebar-collapsed .nav-group-label,
.app-shell.sidebar-collapsed .nav-item span,
.app-shell.sidebar-collapsed .user-meta,
.app-shell.sidebar-collapsed .logout-btn,
.app-shell.sidebar-collapsed .sidebar-footer #status-text {
  display: none;
}

.app-shell.sidebar-collapsed .sidebar-brand,
.app-shell.sidebar-collapsed .nav-item,
.app-shell.sidebar-collapsed .user-chip {
  justify-content: center;
}

.app-shell.sidebar-collapsed .user-chip {
  padding-right: 10px;
}

/* Main */

.main {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-width: 0;
  min-height: 0;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-md);
  overflow: hidden;
}

.topbar {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 18px 28px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}

.icon-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 34px;
  height: 34px;
  flex-shrink: 0;
  border-radius: var(--radius);
  border: none;
  background: transparent;
  color: var(--text-muted);
  cursor: pointer;
  transition: background 0.12s ease, color 0.12s ease;
}

.icon-btn svg {
  width: 18px;
  height: 18px;
}

.icon-btn:hover {
  background: var(--surface-alt);
  color: var(--text);
}

.topbar-title {
  flex: 1;
  min-width: 0;
}

.topbar-title h1 {
  margin: 0;
  font-size: 20px;
  font-weight: 600;
  letter-spacing: -0.01em;
}

.topbar-title p {
  margin: 4px 0 0 0;
  font-size: 13px;
  color: var(--text-muted);
}

.status-pill {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 7px 14px;
  border-radius: 999px;
  background: var(--bg);
  border: none;
  box-shadow: var(--shadow-soft-sm);
  font-family: var(--font-mono);
  font-size: 11.5px;
  letter-spacing: 0.01em;
  color: var(--text-muted);
  white-space: nowrap;
}

.status-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--warn);
  flex-shrink: 0;
}

.status-dot-connecting { background: var(--warn); }
.status-dot-ok { background: var(--ok); }
.status-dot-error { background: var(--danger); }

.content {
  flex: 1;
  padding: 32px;
  overflow-y: auto;
}

.panel {
  display: none;
  height: 100%;
}

.panel.is-active {
  display: block;
}

.panel[data-panel="database"].is-active {
  display: flex;
  flex-direction: column;
}

/* Sub-tabs (within a panel, e.g. Database) */

.subtabs {
  display: flex;
  gap: 4px;
  border-bottom: 1px solid var(--border);
  margin-bottom: 20px;
  flex-shrink: 0;
}

.subtab-item {
  padding: 10px 14px;
  background: transparent;
  border: none;
  border-bottom: 2px solid transparent;
  margin-bottom: -1px;
  color: var(--text-muted);
  font-family: inherit;
  font-size: 13.5px;
  font-weight: 500;
  cursor: pointer;
  transition: color 0.12s ease, border-color 0.12s ease;
}

.subtab-item:hover {
  color: var(--text);
}

.subtab-item.is-active {
  color: var(--accent-dark);
  border-bottom-color: var(--accent);
  font-weight: 600;
}

.subpanel {
  display: none;
  flex: 1;
  min-height: 0;
}

.subpanel.is-active {
  display: flex;
  flex-direction: column;
}

.subpanel .empty-state {
  flex: 1;
}

.empty-state {
  height: 100%;
  min-height: 420px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  background: var(--surface);
  border: none;
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-soft);
  padding: 48px 24px;
}

.empty-state[hidden] {
  display: none;
}

.empty-icon {
  width: 60px;
  height: 60px;
  border-radius: var(--radius);
  background: var(--accent-soft);
  border: none;
  box-shadow: var(--shadow-soft-sm);
  color: var(--accent-ink);
  display: flex;
  align-items: center;
  justify-content: center;
  margin-bottom: 20px;
}

.empty-icon svg {
  width: 28px;
  height: 28px;
}

.empty-state h2 {
  margin: 0 0 8px 0;
  font-size: 17px;
  font-weight: 600;
  color: var(--text);
}

.empty-state p {
  margin: 0 0 22px 0;
  font-size: 13.5px;
  color: var(--text-muted);
  max-width: 360px;
  line-height: 1.5;
}

.btn {
  font-family: inherit;
  font-size: 13.5px;
  font-weight: 600;
  padding: 10px 18px;
  border-radius: var(--radius);
  border: 1px solid transparent;
  cursor: pointer;
  transition: background 0.15s ease, border-color 0.15s ease, box-shadow 0.3s var(--ease-soft), transform 0.05s ease;
}

.btn-primary {
  background-color: var(--accent);
  background-image: linear-gradient(180deg, color-mix(in oklab, var(--accent) 88%, white), transparent 65%);
  color: #fff;
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.16),
    0 1px 2px rgba(39, 76, 119, 0.25),
    0 4px 8px -2px rgba(39, 76, 119, 0.3);
}

.btn-primary:hover:not(:disabled) {
  background-color: var(--accent-dark);
  background-image: linear-gradient(180deg, color-mix(in oklab, var(--accent-dark) 88%, white), transparent 65%);
}

.btn-primary:active:not(:disabled) {
  box-shadow: var(--shadow-soft-inset);
}

.btn:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

/* Gate screens (connect / login / unsupported) */

.gate-screen {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  background: var(--bg);
  padding: 24px;
}

.gate-screen[hidden] {
  display: none;
}

.gate-brand {
  font-family: var(--font-mono);
  font-size: 11px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--text-faint);
  margin-bottom: 22px;
}

.gate-card {
  width: 100%;
  max-width: 400px;
  background: var(--surface);
  border: none;
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-soft);
  padding: 34px 30px;
  text-align: center;
}

.gate-icon {
  width: 48px;
  height: 48px;
  border-radius: var(--radius);
  background: var(--accent-soft);
  border: none;
  box-shadow: var(--shadow-soft-sm);
  color: var(--accent-ink);
  display: flex;
  align-items: center;
  justify-content: center;
  margin: 0 auto 18px auto;
}

.gate-icon svg {
  width: 24px;
  height: 24px;
}

.gate-icon-warn {
  background: var(--danger-soft);
  color: var(--danger);
}

.gate-card h1 {
  margin: 0 0 8px 0;
  font-size: 20px;
  font-weight: 600;
}

.gate-card > p {
  margin: 0 0 26px 0;
  font-size: 13.5px;
  color: var(--text-muted);
  line-height: 1.55;
}

.gate-actions {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.gate-actions .btn {
  width: 100%;
}

.gate-error {
  margin: 14px 0 0 0;
  font-size: 12.5px;
  color: var(--danger);
  background: var(--danger-soft);
  border-radius: 8px;
  padding: 8px 12px;
}

.btn-secondary {
  background: var(--bg);
  color: var(--text);
  border-color: transparent;
  box-shadow: var(--shadow-soft-sm);
}

.btn-secondary:hover {
  background: var(--surface);
  box-shadow: var(--shadow-soft);
}

.btn-secondary:active {
  box-shadow: var(--shadow-soft-inset);
}

.btn-link {
  background: transparent;
  color: var(--accent-ink);
  padding: 8px 12px;
  font-weight: 500;
}

.btn-link:hover {
  color: var(--accent);
  text-decoration: underline;
}

.gate-disconnect {
  margin-top: 18px;
  font-size: 12.5px;
}

/* Role list (login screen) */

.role-grid {
  display: flex;
  flex-direction: column;
  border-top: 1px solid var(--border);
  margin-bottom: 4px;
}

.role-grid[hidden] {
  display: none;
}

.role-btn {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 100%;
  padding: 15px 4px;
  border: none;
  border-bottom: 1px solid var(--border);
  border-left: 2px solid transparent;
  background: transparent;
  color: var(--text);
  font-family: inherit;
  font-size: 14.5px;
  font-weight: 500;
  text-align: left;
  cursor: pointer;
  transition: border-color 0.12s ease, color 0.12s ease, padding-left 0.12s ease;
}

.role-btn::after {
  content: "\2192";
  color: var(--text-faint);
  font-size: 14px;
  transition: color 0.12s ease, transform 0.12s ease;
}

.role-btn:hover {
  border-left-color: var(--accent);
  color: var(--accent-dark);
  padding-left: 10px;
}

.role-btn:hover::after {
  color: var(--accent);
  transform: translateX(2px);
}

.login-form {
  text-align: left;
}

.login-label {
  display: block;
  font-family: var(--font-mono);
  font-size: 11px;
  letter-spacing: 0.02em;
  text-transform: uppercase;
  font-weight: 500;
  color: var(--text-muted);
  margin-bottom: 8px;
}

.login-label span {
  color: var(--text);
  text-transform: none;
}

.login-input {
  width: 100%;
  padding: 11px 13px;
  border-radius: var(--radius);
  border: 1px solid transparent;
  font-family: inherit;
  font-size: 14px;
  margin-bottom: 4px;
  background: var(--bg);
  color: var(--text);
  box-shadow: var(--shadow-soft-inset);
  transition: box-shadow 0.15s ease;
}

.login-input:focus {
  outline: none;
  box-shadow: var(--shadow-soft-inset), 0 0 0 3px var(--accent-soft);
}

.login-form .gate-actions {
  margin-top: 16px;
}

/* Sidebar user chip / logout */

.logout-btn {
  position: absolute;
  right: 6px;
  top: 50%;
  transform: translateY(-50%);
  width: 28px;
  height: 28px;
  border-radius: 6px;
  border: none;
  background: transparent;
  color: var(--text-faint);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
}

.logout-btn svg {
  width: 15px;
  height: 15px;
}

.logout-btn:hover {
  background: var(--surface-alt);
  color: var(--text);
}

/* Production line switcher + station import toolbar */

.line-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 12px;
  margin-bottom: 16px;
  flex-shrink: 0;
}

.line-select-group {
  display: flex;
  align-items: center;
  gap: 10px;
}

.field-label-inline {
  font-family: var(--font-mono);
  font-size: 10.5px;
  letter-spacing: 0.03em;
  text-transform: uppercase;
  color: var(--text-muted);
  white-space: nowrap;
}

.line-select {
  padding: 9px 12px;
  border-radius: var(--radius);
  border: 1px solid transparent;
  font-family: inherit;
  font-size: 13.5px;
  font-weight: 600;
  background: var(--bg);
  color: var(--text);
  box-shadow: var(--shadow-soft-inset);
  min-width: 160px;
}

.line-select:focus {
  outline: none;
  box-shadow: var(--shadow-soft-inset), 0 0 0 3px var(--accent-soft);
}

.line-toolbar-actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.line-toolbar-hint {
  margin: 0;
  font-size: 12px;
  color: var(--text-faint);
}

.line-toolbar-hint strong {
  color: var(--text-muted);
  font-weight: 600;
}

.line-select-compact {
  min-width: 130px;
  padding: 7px 10px;
  font-size: 12.5px;
  font-weight: 500;
}

.table-toolbar-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.search-input {
  width: 220px;
  padding: 7px 10px;
  font-size: 12.5px;
}

.search-input::-webkit-search-cancel-button {
  cursor: pointer;
}

.btn-small {
  padding: 7px 12px;
  font-size: 12.5px;
}

/* Admin tab */

.admin-grid {
  display: flex;
  flex-direction: column;
  gap: 24px;
}

.admin-card {
  background: var(--surface);
  border: none;
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-soft);
  padding: 18px 20px;
}

.admin-card-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 10px;
  margin-bottom: 14px;
}

.admin-card-head h3 {
  margin: 0;
  font-size: 14.5px;
  font-weight: 600;
}

.admin-card-head-title {
  display: flex;
  align-items: baseline;
  gap: 10px;
}

.admin-card-scope-hint {
  margin: 0;
  font-family: var(--font-mono);
  font-size: 11px;
  letter-spacing: 0.02em;
  color: var(--text-faint);
}

.admin-card-head-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.cell-id {
  font-family: var(--font-mono);
  font-size: 11.5px;
  color: var(--text-faint);
}

.admin-danger-card {
  border: 1px solid color-mix(in oklab, var(--danger) 40%, transparent);
}

.admin-danger-card .admin-card-head h3 {
  color: var(--danger);
}

.admin-danger-text {
  margin: 0 0 16px 0;
  font-size: 12.5px;
  color: var(--text-faint);
}

.admin-danger-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  padding: 14px 0;
  border-top: 1px solid var(--border);
}

.admin-danger-row:first-of-type {
  border-top: none;
}

.admin-danger-label {
  margin: 0 0 4px 0;
  font-size: 13.5px;
  font-weight: 600;
  color: var(--text);
}

.admin-danger-desc {
  margin: 0;
  font-size: 12.5px;
  color: var(--text-muted);
  max-width: 440px;
}

.btn-danger {
  background: var(--danger-soft);
  color: var(--danger);
  border-color: color-mix(in oklab, var(--danger) 32%, transparent);
  flex-shrink: 0;
}

.btn-danger:hover {
  background: var(--danger);
  color: #fff;
}

.admin-empty-row td {
  color: var(--text-faint);
  font-size: 13px;
  padding: 16px;
  text-align: center;
}

/* Dynamic per-product time fields (task modal) */

.task-times-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-bottom: 8px;
}

.task-time-row {
  display: flex;
  align-items: center;
  gap: 8px;
}

.task-time-row .task-time-label {
  width: 110px;
  flex-shrink: 0;
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--text-muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.task-time-row .field-input {
  flex: 1;
}

.task-time-check {
  flex-shrink: 0;
  width: 16px;
  height: 16px;
  accent-color: var(--accent);
  cursor: pointer;
}

.task-time-row .task-time-input:disabled {
  opacity: 0.5;
  background: var(--surface-alt);
  cursor: not-allowed;
}

.task-time-row.is-unconcerned .task-time-label {
  color: var(--text-faint);
}

/* Visual separator row in the task table */

.task-docs-list {
  display: flex;
  flex-direction: column;
  gap: 2px;
  max-height: 180px;
  overflow-y: auto;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 4px;
  margin-bottom: 8px;
}

.task-doc-row {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 8px;
  border-radius: 6px;
  cursor: pointer;
}

.task-doc-row[hidden] {
  display: none;
}

.task-doc-row:hover {
  background: var(--surface-alt);
}

.task-doc-check {
  flex-shrink: 0;
  width: 16px;
  height: 16px;
  accent-color: var(--accent);
  cursor: pointer;
}

.task-doc-meta {
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.task-doc-name {
  font-size: 13px;
  color: var(--text);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.task-doc-location {
  font-family: var(--font-mono);
  font-size: 10.5px;
  color: var(--text-faint);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.task-doc-badge {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  margin-left: 6px;
  padding: 1px 6px;
  border: 1px solid var(--border);
  border-radius: 999px;
  font-family: var(--font-mono);
  font-size: 10.5px;
  color: var(--text-muted);
  vertical-align: middle;
}

.task-doc-badge svg {
  width: 11px;
  height: 11px;
}

.workflow-badge {
  display: inline-flex;
  align-items: center;
  margin-left: 6px;
  padding: 1px 8px;
  border-radius: 999px;
  font-family: var(--font-mono);
  font-size: 10.5px;
  font-weight: 600;
  vertical-align: middle;
  white-space: nowrap;
}

.workflow-badge.is-pending {
  background: rgba(224, 148, 47, 0.15);
  color: #b3730f;
}

.workflow-badge.is-approved {
  background: rgba(47, 168, 94, 0.15);
  color: #1f7a42;
}

.workflow-badge.is-rejected {
  background: rgba(224, 72, 62, 0.15);
  color: #b3261e;
}

.bal-station-workflow-row {
  display: flex;
  align-items: center;
  margin-top: 8px;
}

.workflow-type-icon {
  display: inline-flex;
  margin-right: 6px;
  color: var(--text-faint);
  vertical-align: middle;
}

.workflow-type-icon svg {
  width: 15px;
  height: 15px;
}

.row-separator td {
  background: var(--surface-alt);
  font-family: var(--font-mono);
  font-size: 11px;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--text-faint);
  padding: 8px 16px;
}

/* Data tables (Database sub-tabs) */

.table-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 14px;
  flex-shrink: 0;
}

.table-count-group {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.table-count {
  margin: 0;
  font-family: var(--font-mono);
  font-size: 11.5px;
  letter-spacing: 0.02em;
  text-transform: uppercase;
  color: var(--text-faint);
}

.table-count-warn {
  margin: 0;
  font-family: var(--font-mono);
  font-size: 11px;
  letter-spacing: 0.02em;
  text-transform: uppercase;
  color: var(--warn);
  background: var(--warn-soft);
  border-radius: 999px;
  padding: 3px 9px;
}

.table-count-warn[hidden] { display: none; }

.toolbar-filter {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 12.5px;
  color: var(--text-muted);
  cursor: pointer;
  user-select: none;
}

.toolbar-filter input {
  accent-color: var(--warn);
}

/* Missing-times panel: one card per vehicle/product, listing tasks that are
   confirmed-concerned but still untimed for it. */

.missing-panel {
  margin-bottom: 14px;
  flex-shrink: 0;
  max-height: 320px;
  overflow-y: auto;
}

.missing-panel[hidden] { display: none; }

.missing-cards {
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding-right: 4px; /* keeps content clear of the scrollbar */
}

.missing-panel-empty {
  margin: 0;
  padding: 14px;
  font-size: 13px;
  color: var(--text-faint);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
}

/* Each card is a single compact button — clicking it opens the "missing times"
   modal for that vehicle instead of expanding in place. */
.missing-card {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  padding: 9px 14px;
  background: var(--warn-soft);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  font: inherit;
  cursor: pointer;
  text-align: left;
}

.missing-card:hover {
  border-color: var(--warn);
}

.missing-card-chevron {
  display: flex;
  color: var(--warn);
  flex-shrink: 0;
}

.missing-card-chevron svg { width: 13px; height: 13px; }

.missing-card-title {
  font-weight: 600;
  font-size: 13.5px;
  color: var(--text);
  flex: 1;
}

.missing-card-count {
  font-family: var(--font-mono);
  font-size: 11px;
  letter-spacing: 0.02em;
  text-transform: uppercase;
  color: var(--warn);
  flex-shrink: 0;
}

/* The per-vehicle task list, rendered inside the "missing times" modal. */
.missing-list-rows {
  max-height: 360px;
  overflow-y: auto;
  border: 1px solid var(--border);
  border-radius: 8px;
}

.missing-card-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 14px;
  border-top: 1px solid var(--border);
}

.missing-card-row:first-child {
  border-top: none;
}

.missing-card-station {
  font-size: 12px;
  color: var(--text-muted);
  min-width: 110px;
  flex-shrink: 0;
}

.missing-card-name {
  font-size: 13px;
  color: var(--text);
  flex: 1;
}

.table-scroll-top {
  overflow-x: auto;
  overflow-y: hidden;
  height: 14px;
  flex-shrink: 0;
}

.table-scroll-top[hidden] {
  display: none;
}

.table-scroll-top-inner {
  height: 1px;
}

.table-wrap {
  overflow: auto;
  max-height: calc(100vh - 340px);
  min-height: 240px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-soft-sm);
}

.table-wrap[hidden] {
  display: none;
}

/* Sticky header — stays visible while scrolling through many rows. */
.data-table thead th {
  position: sticky;
  top: 0;
  z-index: 2;
  background: var(--surface);
  box-shadow: 0 1px 0 var(--border);
}

/* Frozen columns: Station / Task name / Type / Option % / People.
   Columns size naturally from their content (no forced width, no ellipsis) —
   their `left` offset is computed in JS from each column's real rendered width,
   since CSS sticky positioning needs a concrete pixel value, not "auto".
   Header cells that are both column- and row-frozen (the top-left corner) need
   the highest z-index so they render above the plain sticky header row too. */

.data-table th.col-sticky,
.data-table td.col-sticky {
  position: sticky;
  background: var(--surface);
  white-space: nowrap;
}

.data-table td.col-sticky {
  z-index: 1;
}

.data-table th.col-sticky {
  z-index: 3;
}

.col-sticky-people {
  box-shadow: 4px 0 8px -4px rgba(22, 41, 58, 0.25);
}

.data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13.5px;
}

.data-table th {
  text-align: left;
  font-family: var(--font-mono);
  font-size: 10.5px;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--text-faint);
  font-weight: 500;
  padding: 12px 16px;
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}

.data-table td {
  padding: 12px 16px;
  border-bottom: 1px solid var(--border);
  color: var(--text);
  vertical-align: top;
}

.data-table tr:last-child td {
  border-bottom: none;
}

.data-table td.cell-time {
  font-family: var(--font-mono);
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.time-missing {
  color: var(--warn);
  font-weight: 700;
}

.time-na {
  color: var(--text-faint);
}

.data-table td.cell-comment {
  color: var(--text-muted);
  max-width: 260px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.col-actions {
  width: 1%;
  white-space: nowrap;
}

.row-actions {
  display: flex;
  gap: 4px;
  justify-content: flex-end;
}

.row-action-btn {
  width: 28px;
  height: 28px;
  border-radius: 6px;
  border: none;
  background: transparent;
  color: var(--text-faint);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
}

.row-action-btn svg { width: 15px; height: 15px; }

.row-action-btn:hover {
  background: var(--surface-alt);
  color: var(--text);
}

.row-action-btn.danger:hover {
  background: var(--danger-soft);
  color: var(--danger);
}

.row-action-btn:disabled {
  cursor: not-allowed;
  opacity: 0.5;
}

.row-action-btn:disabled:hover {
  background: transparent;
  color: var(--text-faint);
}

.pagination {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  margin-top: 12px;
}

.pagination[hidden] {
  display: none;
}

.pagination-info {
  font-family: var(--font-mono);
  font-size: 11.5px;
  letter-spacing: 0.02em;
  color: var(--text-muted);
}

.supervision-total-row td {
  border-top: 2px solid var(--border);
  background: var(--surface-alt);
}

.type-color-input {
  width: 32px;
  height: 24px;
  padding: 0;
  border: 1px solid var(--border);
  border-radius: 4px;
  background: none;
  cursor: pointer;
}

.type-color-input::-webkit-color-swatch-wrapper {
  padding: 2px;
}

.type-color-input::-webkit-color-swatch {
  border: none;
  border-radius: 2px;
}

/* Supervision breakdown charts */

.supervision-legend {
  display: flex;
  flex-wrap: wrap;
  gap: 14px;
  margin: 16px 0 4px;
}

.supervision-legend-item {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 12.5px;
  color: var(--text-muted);
}

.supervision-legend-swatch {
  width: 10px;
  height: 10px;
  border-radius: 2px;
  flex-shrink: 0;
}

.supervision-product-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 16px;
  margin-top: 12px;
}

.supervision-product-card {
  flex: 1 1 380px;
  min-width: 320px;
  background: var(--surface);
  border: none;
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-soft);
  padding: 16px 18px;
}

.supervision-product-card h4 {
  margin: 0 0 12px;
  font-size: 13.5px;
  font-weight: 600;
  color: var(--text);
}

.supervision-product-body {
  display: flex;
  gap: 18px;
}

.supervision-empty-note {
  font-size: 12.5px;
  color: var(--text-faint);
}

.stacked-bar-col {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  flex-shrink: 0;
}

.stacked-bar-total {
  font-family: var(--font-mono);
  font-size: 11px;
  font-weight: 600;
  color: var(--text);
  white-space: nowrap;
}

.stacked-bar {
  width: 34px;
  height: 150px;
  display: flex;
  flex-direction: column-reverse;
  border-radius: 6px;
  overflow: hidden;
  background: var(--surface-alt);
  border: 1px solid var(--border);
}

.stacked-bar-segment {
  width: 100%;
}

.hbar-list {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 8px;
  justify-content: center;
}

.hbar-row {
  display: flex;
  align-items: center;
  gap: 8px;
}

.hbar-label {
  width: 110px;
  flex-shrink: 0;
  font-size: 12px;
  color: var(--text-muted);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.hbar-track {
  flex: 1;
  min-width: 0;
  height: 14px;
  background: var(--surface-alt);
  border-radius: 4px;
  overflow: hidden;
}

.hbar-fill {
  height: 100%;
  border-radius: 4px;
}

.hbar-value {
  width: 56px;
  flex-shrink: 0;
  text-align: right;
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--text-muted);
}

.supervision-station-card {
  flex: 1 1 100%;
  width: 100%;
  margin-top: 4px;
}

.supervision-station-card .hbar-list {
  justify-content: flex-start;
}

.pie-block {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
  flex-shrink: 0;
  width: 190px;
}

.pie-wrap {
  position: relative;
  width: 130px;
  height: 130px;
}

.pie-chart {
  width: 100%;
  height: 100%;
  border-radius: 50%;
  background: var(--surface-alt);
}

.pie-hole {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: 74px;
  height: 74px;
  border-radius: 50%;
  background: var(--surface);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 1px;
}

.pie-hole-total {
  font-family: var(--font-mono);
  font-size: 11.5px;
  font-weight: 600;
  color: var(--text);
}

.pie-hole-label {
  font-size: 9px;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--text-faint);
}

.chart-legend {
  display: flex;
  flex-direction: column;
  gap: 6px;
  width: 100%;
}

.chart-legend-row {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
}

.chart-legend-swatch {
  width: 9px;
  height: 9px;
  border-radius: 2px;
  flex-shrink: 0;
}

.chart-legend-name {
  flex: 1;
  min-width: 0;
  color: var(--text-muted);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.chart-legend-pct {
  font-family: var(--font-mono);
  font-size: 10.5px;
  color: var(--text-faint);
  width: 34px;
  text-align: right;
  flex-shrink: 0;
}

.chart-legend-time {
  font-family: var(--font-mono);
  font-size: 10.5px;
  color: var(--text-muted);
  width: 52px;
  text-align: right;
  flex-shrink: 0;
}

/* Time by product and type — grouped horizontal bars, one section per product,
   all sharing one global scale (set inline per bar) so magnitudes are
   comparable across products, not just within one product's own breakdown. */

.supervision-bargroup {
  margin-bottom: 18px;
}

.supervision-bargroup:last-child {
  margin-bottom: 0;
}

.supervision-bargroup-title {
  font-size: 12.5px;
  font-weight: 600;
  color: var(--text);
  margin-bottom: 8px;
}

/* Total time per product — one column per product, bar height itself
   proportional to that product's total (shared scale across columns), each
   column split into colored segments by task type. */

.vstack-chart {
  display: flex;
  align-items: flex-end;
  gap: 28px;
  flex-wrap: wrap;
  padding-top: 8px;
}

.vstack-col {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
}

.vstack-value {
  font-family: var(--font-mono);
  font-size: 11px;
  font-weight: 600;
  color: var(--text);
  white-space: nowrap;
}

.vstack-bar-wrap {
  height: 200px;
  display: flex;
  align-items: flex-end;
}

.vstack-bar {
  width: 42px;
  display: flex;
  flex-direction: column-reverse;
  border-radius: 6px 6px 0 0;
  overflow: hidden;
  background: var(--surface-alt);
}

.vstack-segment {
  width: 100%;
}

.vstack-label {
  font-size: 12px;
  color: var(--text-muted);
  max-width: 80px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* Time breakdown for one product — vertical bar chart (one column per task
   type) next to a full pie chart with inline percentage labels. */

.vbar-chart {
  display: flex;
  align-items: flex-end;
  gap: 18px;
  flex-wrap: wrap;
  padding-top: 8px;
}

.vbar-col {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
}

.vbar-value {
  font-family: var(--font-mono);
  font-size: 10.5px;
  color: var(--text-muted);
  white-space: nowrap;
}

.vbar-bar-wrap {
  height: 160px;
  display: flex;
  align-items: flex-end;
}

.vbar-bar {
  width: 30px;
  border-radius: 4px 4px 0 0;
}

.vbar-label {
  font-size: 11.5px;
  color: var(--text-muted);
  max-width: 70px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.supervision-decomp-total {
  font-size: 12.5px;
  color: var(--text-muted);
  margin-bottom: 14px;
}

.supervision-decomp-total strong {
  color: var(--text);
  font-family: var(--font-mono);
}

.supervision-decomp-grid {
  display: flex;
  gap: 28px;
  flex-wrap: wrap;
  align-items: flex-start;
}

.pie-full-wrap {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 14px;
  flex-shrink: 0;
}

.pie-full-container {
  position: relative;
  width: 150px;
  height: 150px;
}

.pie-full {
  width: 100%;
  height: 100%;
  border-radius: 50%;
}

.pie-slice-label {
  position: absolute;
  transform: translate(-50%, -50%);
  font-family: var(--font-mono);
  font-size: 10.5px;
  font-weight: 600;
  color: #fff;
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.35);
  pointer-events: none;
}

/* Documents tab */

.doc-name-cell {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 260px;
  max-width: 420px;
}

.doc-name-text {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.doc-icon {
  display: inline-flex;
  flex: none;
  color: var(--text-faint);
}

.doc-icon svg { width: 16px; height: 16px; }

.doc-category-badge {
  display: inline-block;
  padding: 2px 8px;
  border: 1px solid var(--border);
  border-radius: 999px;
  font-family: var(--font-mono);
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  color: var(--text-muted);
  white-space: nowrap;
}

.cell-mono {
  font-family: var(--font-mono);
  font-size: 12.5px;
  color: var(--text-muted);
  white-space: nowrap;
}

/* Hover "+" — insert a task or separator right below this row */

.row-plus-btn {
  opacity: 0;
  transition: opacity 0.1s ease, border-color 0.1s ease;
  border: 1px solid var(--border);
  background: var(--surface);
}

.row-plus-btn:hover {
  border-color: var(--accent);
  color: var(--accent);
}

tr:hover .row-plus-btn,
.row-plus-btn.is-open {
  opacity: 1;
}

.data-table td.col-sticky-gutter,
.data-table th.col-sticky-gutter {
  padding: 6px;
  text-align: center;
}

/* A single shared menu, kept outside the table and positioned via JS
   (getBoundingClientRect + position:fixed) — nesting it inside a sticky cell would
   trap it in that cell's own stacking context, unable to render above later rows. */
.row-plus-menu {
  position: fixed;
  min-width: 175px;
  background: var(--surface);
  border: none;
  border-radius: var(--radius);
  box-shadow: var(--shadow-md);
  z-index: 50;
  overflow: hidden;
}

.row-plus-menu[hidden] {
  display: none;
}

.row-plus-menu button {
  display: block;
  width: 100%;
  text-align: left;
  padding: 9px 14px;
  background: transparent;
  border: none;
  font-family: inherit;
  font-size: 13px;
  color: var(--text);
  cursor: pointer;
  white-space: nowrap;
}

.row-plus-menu button:hover {
  background: var(--surface-alt);
}

/* Modal (task add/edit) */

.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.62);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  z-index: 50;
}

.modal-overlay[hidden] {
  display: none;
}

.modal-card {
  width: 100%;
  max-width: 460px;
  max-height: calc(100vh - 48px);
  overflow-y: auto;
  background: var(--surface);
  border: none;
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-md);
  padding: 26px 26px 22px 26px;
}

.modal-card h3 {
  margin: 0 0 18px 0;
  font-size: 17px;
  font-weight: 600;
}

.field-label {
  display: block;
  font-family: var(--font-mono);
  font-size: 10.5px;
  letter-spacing: 0.03em;
  text-transform: uppercase;
  color: var(--text-muted);
  margin: 14px 0 6px 0;
}

.field-label:first-of-type {
  margin-top: 0;
}

.field-input {
  width: 100%;
  padding: 10px 12px;
  border-radius: var(--radius);
  border: 1px solid transparent;
  font-family: inherit;
  font-size: 13.5px;
  background: var(--bg);
  color: var(--text);
  box-shadow: var(--shadow-soft-inset);
  resize: vertical;
  transition: box-shadow 0.15s ease;
}

.field-input:focus {
  outline: none;
  box-shadow: var(--shadow-soft-inset), 0 0 0 3px var(--accent-soft);
}

.field-input:disabled {
  opacity: 0.5;
  background: var(--surface-alt);
  cursor: not-allowed;
}

.field-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
  margin-top: 14px;
}

.field-row .field-label {
  margin-top: 0;
}

.field-hint {
  margin: 6px 0 0 0;
  font-size: 11.5px;
  color: var(--text-faint);
  line-height: 1.4;
}

.modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  margin-top: 20px;
}

.modal-card-wide {
  max-width: 560px;
}

.modal-lead {
  margin: 0 0 16px 0;
  font-size: 13px;
  color: var(--text-muted);
}

.station-map-list {
  max-height: 320px;
  overflow-y: auto;
  border: 1px solid var(--border);
  border-radius: 8px;
}

.station-map-row {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 11px 14px;
  border-bottom: 1px solid var(--border);
}

.station-map-row:last-child {
  border-bottom: none;
}

.station-map-name {
  flex: 1;
  min-width: 0;
  font-size: 13.5px;
  font-weight: 500;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.station-map-status {
  font-family: var(--font-mono);
  font-size: 10.5px;
  letter-spacing: 0.02em;
  text-transform: uppercase;
  white-space: nowrap;
}

.station-map-status.is-existing { color: var(--text-faint); }
.station-map-status.is-new { color: var(--accent-ink); }

.station-map-action {
  padding: 7px 10px;
  border-radius: var(--radius);
  border: 1px solid transparent;
  font-family: inherit;
  font-size: 12.5px;
  background: var(--bg);
  color: var(--text);
  box-shadow: var(--shadow-soft-inset);
  max-width: 220px;
}

/* Column mapping (CSV import) */

.column-map-list {
  max-height: 340px;
  overflow-y: auto;
  border: 1px solid var(--border);
  border-radius: 8px;
}

.column-map-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 14px;
  border-bottom: 1px solid var(--border);
}

.column-map-row:last-child {
  border-bottom: none;
}

.column-map-header {
  flex: 1;
  min-width: 0;
  font-family: var(--font-mono);
  font-size: 12.5px;
  color: var(--text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.column-map-select {
  padding: 7px 10px;
  border-radius: var(--radius);
  border: 1px solid transparent;
  font-family: inherit;
  font-size: 12.5px;
  background: var(--bg);
  color: var(--text);
  box-shadow: var(--shadow-soft-inset);
  min-width: 150px;
  flex-shrink: 0;
}


/* Balancing Line tab */

.bal-stats-row {
  display: flex;
  flex-wrap: wrap;
  gap: 24px;
}

.bal-stat {
  display: flex;
  flex-direction: column;
  gap: 4px;
  min-width: 120px;
}

.bal-stat-label {
  font-family: var(--font-mono);
  font-size: 10.5px;
  letter-spacing: 0.03em;
  text-transform: uppercase;
  color: var(--text-faint);
}

.bal-stat-value {
  font-size: 16px;
  font-weight: 600;
  color: var(--text);
}

.hbar-fill {
  background: var(--accent);
}

.hbar-fill.is-over {
  background: var(--danger);
}

.bal-stations-grid {
  display: flex;
  flex-direction: column;
}

.bal-station-wrap {
  position: relative;
}

.bal-station-card {
  width: 100%;
  background: var(--surface);
  border: none;
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-soft);
  padding: 14px 16px;
  margin-bottom: 16px;
}

.bal-station-card.is-over {
  border: 1px solid var(--danger);
}

.bal-station-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 8px;
}

/* Hover strip glued to the bottom edge of a station card — invisible until
   the card (or the strip itself) is hovered, when it reveals a "+" button
   for adding another station. Placed inside .bal-station-wrap so it can
   overlap the card's bottom border without shifting layout below it. */
.bal-station-add-below {
  position: absolute;
  left: 50%;
  bottom: 0;
  transform: translate(-50%, 50%);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.12s;
  z-index: 1;
}

.bal-station-wrap:hover .bal-station-add-below,
.bal-station-add-below:hover {
  opacity: 1;
  pointer-events: auto;
}

.bal-station-add-below-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 26px;
  height: 26px;
  border-radius: 50%;
  border: 1px solid var(--accent);
  background: var(--surface);
  color: var(--accent);
  font-size: 16px;
  line-height: 1;
  cursor: pointer;
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.12);
}

.bal-station-add-below-btn:hover {
  background: var(--accent);
  color: #fff;
}

.bal-add-station-inline {
  display: flex;
  justify-content: center;
  padding: 10px 0;
}

.bal-station-name-input {
  flex: 1 1 0;
  min-width: 0;
  padding: 6px 8px;
  font-size: 13px;
  font-weight: 600;
}

.bal-station-personnel-select {
  flex: 1 1 0;
  min-width: 0;
  padding: 6px 8px;
  font-size: 12px;
}

.bal-personnel-name-input {
  max-width: 260px;
  padding: 6px 8px;
  font-size: 13px;
}

.bal-station-body {
  display: flex;
  align-items: flex-start;
  gap: 14px;
}

.bal-station-main {
  flex: 1;
  min-width: 0;
}

.bal-station-assign-row {
  margin-bottom: 10px;
}

.bal-assign-select {
  font-size: 12px;
  padding: 6px 8px;
}

.bal-task-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 12px;
  margin-bottom: 10px;
}

.bal-task-table th {
  text-align: left;
  font-family: var(--font-mono);
  font-size: 9.5px;
  letter-spacing: 0.03em;
  text-transform: uppercase;
  color: var(--text-faint);
  font-weight: 500;
  padding: 5px 6px;
  border-bottom: 1px solid var(--border);
}

.bal-task-table td {
  padding: 6px;
  border-bottom: 1px solid var(--border);
  color: var(--text);
}

.bal-task-table tr:last-child td {
  border-bottom: none;
}

.bal-task-table tr[draggable="true"] {
  cursor: grab;
}

.bal-task-table tr.is-dragging {
  opacity: 0.4;
}

.bal-task-drag-handle {
  width: 14px;
  padding-left: 2px !important;
  padding-right: 0 !important;
  color: var(--text-faint);
  font-size: 12px;
  user-select: none;
}

.bal-station-card[data-drop-station].is-drag-target {
  border: 1px solid var(--accent);
  background: var(--accent-soft);
}

.bal-task-name-cell {
  max-width: 160px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.bal-task-type-dot {
  display: inline-block;
  width: 7px;
  height: 7px;
  border-radius: 50%;
  margin-right: 6px;
}

.bal-station-donut-wrap {
  position: relative;
  width: 64px;
  height: 64px;
  flex-shrink: 0;
}

.bal-station-donut {
  width: 100%;
  height: 100%;
  border-radius: 50%;
  background: var(--surface-alt);
}

.bal-station-donut-hole {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: 42px;
  height: 42px;
  border-radius: 50%;
  background: var(--surface);
  display: flex;
  align-items: center;
  justify-content: center;
}

.bal-station-donut-pct {
  font-family: var(--font-mono);
  font-size: 10.5px;
  font-weight: 600;
  color: var(--text);
}

.bal-station-totals {
  display: flex;
  flex-wrap: wrap;
  gap: 4px 10px;
  margin-bottom: 8px;
  padding-bottom: 8px;
  border-bottom: 1px solid var(--border);
}

.bal-station-product {
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--text-muted);
  white-space: nowrap;
}

.bal-station-product.is-over {
  color: var(--danger);
  font-weight: 600;
}

.bal-cell-over {
  color: var(--danger);
  font-weight: 600;
}

.bal-station-empty {
  font-size: 12px;
  color: var(--text-faint);
  margin: 0 0 10px;
}

/* Database tab — Messages sub-tab */

.msg-composer {
  display: flex;
  gap: 10px;
  align-items: flex-start;
  margin-bottom: 16px;
}

.msg-composer textarea.field-input {
  flex: 1;
  resize: vertical;
  min-height: 44px;
}

.msg-feed {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.msg-feed[hidden] {
  display: none;
}

.msg-row {
  background: var(--surface);
  border: none;
  border-radius: var(--radius);
  box-shadow: var(--shadow-soft-sm);
  padding: 12px 14px;
}

.msg-row-head {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 10px;
  margin-bottom: 6px;
}

.msg-row-role {
  font-size: 12px;
  font-weight: 600;
  color: var(--accent-ink);
}

.msg-row-time {
  font-family: var(--font-mono);
  font-size: 10.5px;
  color: var(--text-faint);
  white-space: nowrap;
}

.msg-row-text {
  margin: 0;
  font-size: 13px;
  color: var(--text);
  white-space: pre-wrap;
  word-break: break-word;
}

/* Personnel tab — qualification matrix */

.qual-matrix-legend {
  display: flex;
  flex-wrap: wrap;
  gap: 8px 20px;
  margin-bottom: 14px;
}

.qual-matrix-wrap {
  min-height: 0;
}

.qual-cell {
  text-align: center;
  padding: 6px 8px;
}

.qual-cell-btn {
  width: 30px;
  height: 30px;
  border-radius: 6px;
  border: 1px solid var(--border);
  background: var(--surface-alt);
  color: var(--text);
  font-family: var(--font-mono);
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  transition: transform 0.1s ease;
}

.qual-cell-btn:hover {
  transform: scale(1.08);
}

/* Direction tab — factory overview gap badges */

.dir-gap-badge {
  display: inline-block;
  margin-left: 8px;
  padding: 2px 8px;
  border-radius: 999px;
  font-family: var(--font-mono);
  font-size: 10.5px;
  font-weight: 600;
  letter-spacing: 0.02em;
  vertical-align: middle;
}

.dir-gap-ok {
  background: var(--ok-soft);
  color: var(--ok);
}

.dir-gap-under {
  background: var(--warn-soft);
  color: var(--warn);
}

.dir-gap-over {
  background: var(--accent-soft);
  color: var(--accent-ink);
}

@media (max-width: 900px) {
  .sidebar {
    width: 62px;
    padding: 10px 8px 6px;
  }
  .brand-text,
  .nav-group-label,
  .nav-item span:not(.nav-icon),
  .user-meta,
  .logout-btn {
    display: none;
  }
  .sidebar-brand {
    justify-content: center;
  }
  .nav-item {
    justify-content: center;
  }
  .user-chip {
    justify-content: center;
    padding-right: 10px;
  }
  .sidebar-footer .status-pill {
    padding: 6px;
  }
  .sidebar-footer #status-text {
    display: none;
  }
  .topbar {
    padding: 18px 20px;
  }
  .content {
    padding: 20px;
  }
}

/* --- Showcase mode : ghost cursor for the looping embed demo --- */
.sc-cursor {
  position: fixed;
  left: 0;
  top: 0;
  z-index: 100000;
  pointer-events: none;
  margin: -2px 0 0 -2px;
  filter: drop-shadow(0 2px 5px rgba(0, 0, 0, 0.5));
  transition: transform 0.6s cubic-bezier(0.45, 0.05, 0.2, 1);
}
.sc-cursor svg { display: block; }
.sc-cursor-tap svg { animation: sc-tap-svg 0.24s ease; }
@keyframes sc-tap-svg {
  50% { transform: scale(0.72); }
}
.sc-ring {
  position: fixed;
  z-index: 99999;
  pointer-events: none;
  width: 16px;
  height: 16px;
  margin: -8px 0 0 -8px;
  border-radius: 50%;
  border: 2px solid var(--accent);
  animation: sc-ring 0.6s ease-out forwards;
}
@keyframes sc-ring {
  from { opacity: 0.75; transform: scale(0.3); }
  to { opacity: 0; transform: scale(3.4); }
}
@media (prefers-reduced-motion: reduce) {
  .sc-cursor, .sc-ring { display: none; }
}

/* --- Phantom tour (?phantom=1) : caption bubble that follows the ghost cursor --- */
.pt-caption {
  position: fixed;
  left: 0;
  top: 0;
  z-index: 100000;
  pointer-events: none;
  max-width: 260px;
  padding: 7px 12px;
  border-radius: 8px;
  background: var(--surface-alt);
  color: var(--text);
  border: 1px solid var(--accent-soft);
  font-family: var(--font);
  font-size: 12.5px;
  font-weight: 500;
  line-height: 1.35;
  box-shadow: var(--shadow-md);
  opacity: 0;
}
.pt-caption.is-visible { opacity: 1; }
@media (prefers-reduced-motion: reduce) {
  .pt-caption { display: none; }
}
