/* ==========================================================================
   TOOLBEHEER — Tool/Equipment Management Module for Bridge
   Dark theme · Yellow (#FFD600) primary · Blue (#2196F3) secondary
   All selectors namespaced with .tb- to avoid Bridge conflicts
   ========================================================================== */

/* ---------- CSS Custom Properties ---------- */
:root {
  --tb-bg: #0a0a0a;
  --tb-card: #141414;
  --tb-card-hover: #1a1a1a;
  --tb-border: #2a2a2a;
  --tb-text: #ffffff;
  --tb-text-secondary: #888888;
  --tb-text-muted: #555555;
  --tb-primary: #ffffff;
  --tb-primary-dark: #cccccc;
  --tb-secondary: #888888;
  --tb-secondary-dark: #666666;
  --tb-success: #4caf50;
  --tb-warning: #ff9800;
  --tb-danger: #f44336;
  --tb-font: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  --tb-radius: 8px;
  --tb-radius-sm: 4px;
  --tb-radius-lg: 12px;
  --tb-shadow: 0 2px 8px rgba(0, 0, 0, 0.3);
  --tb-shadow-lg: 0 8px 32px rgba(0, 0, 0, 0.5);
  --tb-shadow-glow: 0 0 20px rgba(255, 255, 255, 0.05);
  --tb-transition: 0.2s ease;
}

/* ---------- Keyframes ---------- */
@keyframes tb-fadeIn {
  from { opacity: 0; }
  to   { opacity: 1; }
}

@keyframes tb-slideUp {
  from { opacity: 0; transform: translateY(24px) scale(0.98); }
  to   { opacity: 1; transform: translateY(0) scale(1); }
}

@keyframes tb-slideInRight {
  from { opacity: 0; transform: translateX(100%); }
  to   { opacity: 1; transform: translateX(0); }
}

@keyframes tb-slideOutRight {
  from { opacity: 1; transform: translateX(0); }
  to   { opacity: 0; transform: translateX(100%); }
}

@keyframes tb-pulseExpired {
  0%, 100% { box-shadow: 0 0 4px rgba(244, 67, 54, 0.3); }
  50%      { box-shadow: 0 0 12px rgba(244, 67, 54, 0.6); }
}

@keyframes tb-spin {
  to { transform: rotate(360deg); }
}

/* ==========================================================================
   PAGE LAYOUT
   ========================================================================== */

.tb-page {
  min-height: 100vh;
  background: var(--tb-bg);
  color: var(--tb-text);
  font-family: var(--tb-font);
  font-size: 14px;
  line-height: 1.5;
  padding: 24px 32px;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

/* ---------- Header ---------- */

.tb-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 24px;
  flex-wrap: wrap;
  gap: 16px;
}

.tb-header h1,
.tb-header-title {
  font-size: 28px;
  font-weight: 700;
  color: var(--tb-text);
  letter-spacing: -0.02em;
  margin: 0;
}

.tb-header-actions {
  display: flex;
  align-items: center;
  gap: 10px;
}

/* ==========================================================================
   SEARCH
   ========================================================================== */

.tb-search-wrapper {
  position: relative;
  width: 100%;
  margin-bottom: 24px;
}

.tb-search-icon {
  position: absolute;
  left: 18px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--tb-text-muted);
  font-size: 20px;
  pointer-events: none;
  transition: color var(--tb-transition);
}

.tb-search-input {
  width: 100%;
  height: 48px;
  padding: 0 20px 0 52px;
  font-family: var(--tb-font);
  font-size: 18px;
  font-weight: 400;
  color: var(--tb-text);
  background: var(--tb-card);
  border: 2px solid var(--tb-border);
  border-radius: var(--tb-radius-lg);
  outline: none;
  transition: border-color var(--tb-transition), box-shadow var(--tb-transition), background var(--tb-transition);
  box-sizing: border-box;
}

.tb-search-input::placeholder {
  color: var(--tb-text-muted);
  font-weight: 400;
}

.tb-search-input:hover {
  border-color: #3a3a3a;
  background: var(--tb-card-hover);
}

.tb-search-input:focus {
  border-color: var(--tb-primary);
  box-shadow: 0 0 0 3px rgba(255, 255, 255, 0.1), var(--tb-shadow-glow);
  background: var(--tb-card-hover);
}

.tb-search-input:focus + .tb-search-icon,
.tb-search-wrapper:focus-within .tb-search-icon {
  color: var(--tb-primary);
}

/* ==========================================================================
   DASHBOARD & KPI
   ========================================================================== */

.tb-dashboard {
  display: flex;
  flex-direction: column;
  gap: 24px;
}

.tb-kpi-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 16px;
}

.tb-kpi-card {
  background: var(--tb-card);
  border: 1px solid var(--tb-border);
  border-radius: var(--tb-radius);
  padding: 20px 24px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  position: relative;
  overflow: hidden;
  transition: transform var(--tb-transition), box-shadow var(--tb-transition), background var(--tb-transition);
  cursor: default;
}

.tb-kpi-clickable {
  cursor: pointer;
}

.tb-kpi-clickable:active {
  transform: scale(0.97);
}

/* KPI Detail Modal */
.tb-kpi-modal {
  max-width: 800px;
}

.tb-kpi-table {
  width: 100%;
}

.tb-kpi-card::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 2px;
  background: linear-gradient(90deg, var(--tb-primary), transparent);
  opacity: 0;
  transition: opacity var(--tb-transition);
}

.tb-kpi-card:hover {
  transform: translateY(-2px);
  box-shadow: var(--tb-shadow-lg);
  background: var(--tb-card-hover);
}

.tb-kpi-card:hover::before {
  opacity: 1;
}

/* SVG icon base */
.tb-icon {
  width: 1em;
  height: 1em;
  vertical-align: -0.125em;
  display: inline-block;
  flex-shrink: 0;
}

.tb-kpi-icon {
  font-size: 22px;
  color: var(--tb-primary);
  margin-bottom: 4px;
}

.tb-kpi-icon .tb-icon {
  width: 22px;
  height: 22px;
}

.tb-nav-tab .tb-icon {
  width: 16px;
  height: 16px;
}

.tb-btn .tb-icon {
  width: 14px;
  height: 14px;
}

.tb-btn-icon .tb-icon {
  width: 16px;
  height: 16px;
}

.tb-badge .tb-icon {
  width: 12px;
  height: 12px;
}

.tb-kpi-value {
  font-size: 36px;
  font-weight: 700;
  color: var(--tb-text);
  line-height: 1.1;
  letter-spacing: -0.03em;
}

.tb-kpi-label {
  font-size: 14px;
  color: var(--tb-text-secondary);
  font-weight: 500;
  letter-spacing: 0.01em;
}

/* ==========================================================================
   CHART SECTION
   ========================================================================== */

.tb-chart-section {
  background: var(--tb-card);
  border: 1px solid var(--tb-border);
  border-radius: var(--tb-radius);
  padding: 24px;
}

.tb-chart-section h3,
.tb-chart-title {
  font-size: 16px;
  font-weight: 600;
  color: var(--tb-text);
  margin: 0 0 20px 0;
}

.tb-bar-chart {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.tb-bar-row {
  display: grid;
  grid-template-columns: 140px 1fr 48px;
  align-items: center;
  gap: 12px;
}

.tb-bar-clickable {
  cursor: pointer;
  border-radius: 6px;
  padding: 4px 8px;
  margin: -4px -8px;
  transition: background 0.15s;
}

.tb-bar-clickable:hover {
  background: rgba(255, 255, 255, 0.06);
}

.tb-bar-label {
  font-size: 13px;
  color: var(--tb-text-secondary);
  font-weight: 500;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.tb-bar-fill {
  height: 24px;
  border-radius: var(--tb-radius-sm);
  background: linear-gradient(90deg, var(--tb-primary), #999999);
  position: relative;
  min-width: 4px;
  transition: width 0.6s cubic-bezier(0.22, 1, 0.36, 1);
}

.tb-bar-fill::after {
  content: '';
  position: absolute;
  inset: 0;
  border-radius: inherit;
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.1) 0%, transparent 100%);
}

.tb-bar-value {
  font-size: 13px;
  font-weight: 600;
  color: var(--tb-text);
  text-align: right;
  font-variant-numeric: tabular-nums;
}

/* ==========================================================================
   NAV TABS
   ========================================================================== */

.tb-nav-tabs {
  display: flex;
  align-items: center;
  gap: 0;
  border-bottom: 1px solid var(--tb-border);
  margin-bottom: 20px;
}

.tb-nav-tab {
  position: relative;
  padding: 12px 20px;
  font-size: 14px;
  font-weight: 500;
  color: var(--tb-text-secondary);
  background: none;
  border: none;
  cursor: pointer;
  font-family: var(--tb-font);
  transition: color var(--tb-transition);
  white-space: nowrap;
}

.tb-nav-tab::after {
  content: '';
  position: absolute;
  bottom: -1px;
  left: 20px;
  right: 20px;
  height: 2px;
  background: var(--tb-primary);
  border-radius: 2px 2px 0 0;
  transform: scaleX(0);
  transition: transform 0.25s cubic-bezier(0.22, 1, 0.36, 1);
}

.tb-nav-tab:hover {
  color: var(--tb-text);
}

.tb-nav-tab.active {
  color: var(--tb-primary);
  font-weight: 600;
}

.tb-nav-tab.active::after {
  transform: scaleX(1);
}

/* ==========================================================================
   TOOLBAR & FILTERS
   ========================================================================== */

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

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

.tb-select {
  height: 36px;
  padding: 0 36px 0 12px;
  font-family: var(--tb-font);
  font-size: 13px;
  font-weight: 500;
  color: var(--tb-text);
  background: var(--tb-card);
  border: 1px solid var(--tb-border);
  border-radius: var(--tb-radius-sm);
  outline: none;
  cursor: pointer;
  appearance: none;
  -webkit-appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg width='10' height='6' viewBox='0 0 10 6' fill='none' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath d='M1 1L5 5L9 1' stroke='%23888888' stroke-width='1.5' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 12px center;
  transition: border-color var(--tb-transition), box-shadow var(--tb-transition);
}

.tb-select:hover {
  border-color: #3a3a3a;
}

.tb-select:focus {
  border-color: var(--tb-primary);
  box-shadow: 0 0 0 2px rgba(255, 255, 255, 0.1);
}

/* ==========================================================================
   BUTTONS
   ========================================================================== */

.tb-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  height: 36px;
  padding: 0 16px;
  font-family: var(--tb-font);
  font-size: 13px;
  font-weight: 600;
  border-radius: var(--tb-radius-sm);
  border: 1px solid transparent;
  cursor: pointer;
  white-space: nowrap;
  transition: all var(--tb-transition);
  text-decoration: none;
  line-height: 1;
  outline: none;
}

.tb-btn:active {
  transform: scale(0.97);
}

.tb-btn:focus-visible {
  box-shadow: 0 0 0 2px var(--tb-bg), 0 0 0 4px var(--tb-primary);
}

/* Primary — yellow, black text */
.tb-btn-primary {
  background: var(--tb-primary);
  color: #000000;
  border-color: var(--tb-primary);
}

.tb-btn-primary:hover {
  background: #cccccc;
  border-color: #cccccc;
  box-shadow: 0 4px 16px rgba(255, 255, 255, 0.1);
}

.tb-btn-primary:active {
  background: var(--tb-primary-dark);
  border-color: var(--tb-primary-dark);
  box-shadow: none;
}

/* Secondary — outlined */
.tb-btn-secondary {
  background: transparent;
  color: var(--tb-text);
  border-color: var(--tb-border);
}

.tb-btn-secondary:hover {
  border-color: var(--tb-text-secondary);
  background: rgba(255, 255, 255, 0.04);
}

.tb-btn-secondary:active {
  background: rgba(255, 255, 255, 0.08);
}

/* Danger — red */
.tb-btn-danger {
  background: var(--tb-danger);
  color: #ffffff;
  border-color: var(--tb-danger);
}

.tb-btn-danger:hover {
  background: #e53935;
  box-shadow: 0 4px 16px rgba(136, 136, 136, 0.3);
}

.tb-btn-danger:active {
  background: #c62828;
  box-shadow: none;
}

/* Icon button */
.tb-btn-icon {
  width: 36px;
  height: 36px;
  padding: 0;
  background: transparent;
  color: var(--tb-text-secondary);
  border-color: var(--tb-border);
}

.tb-btn-icon:hover {
  color: var(--tb-text);
  background: rgba(255, 255, 255, 0.06);
  border-color: var(--tb-text-secondary);
}

/* Small variant */
.tb-btn-sm {
  height: 28px;
  padding: 0 10px;
  font-size: 12px;
  gap: 5px;
}

.tb-btn-sm.tb-btn-icon {
  width: 28px;
  height: 28px;
}

/* ==========================================================================
   TABLE
   ========================================================================== */

.tb-table-wrapper {
  overflow-x: auto;
  border: 1px solid var(--tb-border);
  border-radius: var(--tb-radius);
  background: var(--tb-card);
  -webkit-overflow-scrolling: touch;
}

.tb-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}

.tb-table thead {
  position: sticky;
  top: 0;
  z-index: 2;
}

.tb-table th {
  padding: 12px 16px;
  text-align: left;
  font-weight: 600;
  font-size: 12px;
  color: var(--tb-text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  background: #111111;
  border-bottom: 1px solid var(--tb-border);
  white-space: nowrap;
  cursor: default;
  user-select: none;
  position: relative;
}

.tb-table th[data-sortable] {
  cursor: pointer;
}

.tb-table th[data-sortable]:hover {
  color: var(--tb-text);
}

.tb-table th[data-sortable]::after {
  content: '⇅';
  margin-left: 6px;
  opacity: 0.3;
  font-size: 11px;
}

.tb-table th[data-sorted="asc"]::after {
  content: '↑';
  opacity: 1;
  color: var(--tb-primary);
}

.tb-table th[data-sorted="desc"]::after {
  content: '↓';
  opacity: 1;
  color: var(--tb-primary);
}

.tb-table td {
  padding: 12px 16px;
  border-bottom: 1px solid rgba(42, 42, 42, 0.5);
  color: var(--tb-text);
  vertical-align: middle;
}

.tb-table tbody tr {
  transition: background var(--tb-transition);
}

.tb-table tbody tr:hover {
  background: var(--tb-card-hover);
}

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

.tb-table .tb-checkbox {
  width: 16px;
  height: 16px;
  accent-color: var(--tb-primary);
  cursor: pointer;
}

/* ==========================================================================
   BADGES
   ========================================================================== */

.tb-badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 3px 10px;
  font-size: 11px;
  font-weight: 600;
  border-radius: 100px;
  letter-spacing: 0.02em;
  text-transform: uppercase;
  white-space: nowrap;
  line-height: 1.4;
}

.tb-badge-good {
  background: rgba(76, 175, 80, 0.12);
  color: var(--tb-success);
  border: 1px solid rgba(76, 175, 80, 0.25);
}

.tb-badge-fair {
  background: rgba(255, 152, 0, 0.12);
  color: var(--tb-warning);
  border: 1px solid rgba(255, 152, 0, 0.25);
}

.tb-badge-poor {
  background: rgba(244, 67, 54, 0.12);
  color: var(--tb-danger);
  border: 1px solid rgba(244, 67, 54, 0.25);
}

.tb-badge-approved {
  background: rgba(76, 175, 80, 0.12);
  color: var(--tb-success);
  border: 1px solid rgba(76, 175, 80, 0.25);
}

.tb-badge-expired {
  background: rgba(244, 67, 54, 0.15);
  color: var(--tb-danger);
  border: 1px solid rgba(244, 67, 54, 0.3);
  animation: tb-pulseExpired 2s ease-in-out infinite;
}

.tb-badge-pending {
  background: rgba(255, 152, 0, 0.12);
  color: var(--tb-warning);
  border: 1px solid rgba(255, 152, 0, 0.25);
}

.tb-badge-tracker {
  background: rgba(136, 136, 136, 0.12);
  color: var(--tb-secondary);
  border: 1px solid rgba(136, 136, 136, 0.25);
}

/* ==========================================================================
   MODAL
   ========================================================================== */

.tb-modal-overlay {
  position: fixed;
  inset: 0;
  z-index: 9000;
  background: rgba(0, 0, 0, 0.7);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  animation: tb-fadeIn 0.2s ease;
}

.tb-modal {
  width: 100%;
  max-width: 640px;
  max-height: 85vh;
  background: var(--tb-card);
  border: 1px solid var(--tb-border);
  border-radius: var(--tb-radius-lg);
  box-shadow: var(--tb-shadow-lg);
  display: flex;
  flex-direction: column;
  animation: tb-slideUp 0.3s cubic-bezier(0.22, 1, 0.36, 1);
}

.tb-modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 20px 24px;
  border-bottom: 1px solid var(--tb-border);
  flex-shrink: 0;
}

.tb-modal-header h2,
.tb-modal-title {
  font-size: 18px;
  font-weight: 600;
  color: var(--tb-text);
  margin: 0;
}

.tb-modal-close {
  width: 32px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: none;
  border: none;
  color: var(--tb-text-secondary);
  cursor: pointer;
  border-radius: var(--tb-radius-sm);
  font-size: 20px;
  transition: color var(--tb-transition), background var(--tb-transition);
}

.tb-modal-close:hover {
  color: var(--tb-text);
  background: rgba(255, 255, 255, 0.06);
}

.tb-modal-body {
  padding: 24px;
  overflow-y: auto;
  flex: 1;
  -webkit-overflow-scrolling: touch;
}

.tb-modal-footer {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 10px;
  padding: 16px 24px;
  border-top: 1px solid var(--tb-border);
  flex-shrink: 0;
}

/* ==========================================================================
   FORMS
   ========================================================================== */

.tb-form-group {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-bottom: 18px;
}

.tb-form-group:last-child {
  margin-bottom: 0;
}

.tb-form-label {
  font-size: 13px;
  font-weight: 600;
  color: var(--tb-text-secondary);
  letter-spacing: 0.01em;
}

.tb-form-input {
  height: 40px;
  padding: 0 12px;
  font-family: var(--tb-font);
  font-size: 14px;
  color: var(--tb-text);
  background: var(--tb-bg);
  border: 1px solid var(--tb-border);
  border-radius: var(--tb-radius-sm);
  outline: none;
  transition: border-color var(--tb-transition), box-shadow var(--tb-transition);
  box-sizing: border-box;
}

.tb-form-input::placeholder {
  color: var(--tb-text-muted);
}

.tb-form-input:hover {
  border-color: #3a3a3a;
}

.tb-form-input:focus {
  border-color: var(--tb-primary);
  box-shadow: 0 0 0 2px rgba(255, 255, 255, 0.12);
}

.tb-form-select {
  height: 40px;
  padding: 0 36px 0 12px;
  font-family: var(--tb-font);
  font-size: 14px;
  color: var(--tb-text);
  background: var(--tb-bg);
  border: 1px solid var(--tb-border);
  border-radius: var(--tb-radius-sm);
  outline: none;
  cursor: pointer;
  appearance: none;
  -webkit-appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg width='10' height='6' viewBox='0 0 10 6' fill='none' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath d='M1 1L5 5L9 1' stroke='%23888888' stroke-width='1.5' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 12px center;
  transition: border-color var(--tb-transition), box-shadow var(--tb-transition);
  box-sizing: border-box;
}

.tb-form-select:focus {
  border-color: var(--tb-primary);
  box-shadow: 0 0 0 2px rgba(255, 255, 255, 0.12);
}

.tb-form-textarea {
  padding: 10px 12px;
  font-family: var(--tb-font);
  font-size: 14px;
  color: var(--tb-text);
  background: var(--tb-bg);
  border: 1px solid var(--tb-border);
  border-radius: var(--tb-radius-sm);
  outline: none;
  resize: vertical;
  min-height: 80px;
  transition: border-color var(--tb-transition), box-shadow var(--tb-transition);
  box-sizing: border-box;
}

.tb-form-textarea:focus {
  border-color: var(--tb-primary);
  box-shadow: 0 0 0 2px rgba(255, 255, 255, 0.12);
}

.tb-form-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
}

/* Toggle switch */
.tb-form-toggle {
  position: relative;
  display: inline-flex;
  align-items: center;
  gap: 10px;
  cursor: pointer;
  font-size: 14px;
  color: var(--tb-text);
  user-select: none;
}

.tb-form-toggle input {
  position: absolute;
  opacity: 0;
  width: 0;
  height: 0;
}

.tb-form-toggle .tb-toggle-track {
  position: relative;
  width: 40px;
  height: 22px;
  background: #333333;
  border-radius: 11px;
  transition: background var(--tb-transition);
  flex-shrink: 0;
}

.tb-form-toggle .tb-toggle-track::after {
  content: '';
  position: absolute;
  top: 3px;
  left: 3px;
  width: 16px;
  height: 16px;
  background: #ffffff;
  border-radius: 50%;
  transition: transform var(--tb-transition);
}

.tb-form-toggle input:checked + .tb-toggle-track {
  background: var(--tb-primary);
}

.tb-form-toggle input:checked + .tb-toggle-track::after {
  transform: translateX(18px);
}

.tb-form-toggle input:focus-visible + .tb-toggle-track {
  box-shadow: 0 0 0 2px var(--tb-bg), 0 0 0 4px var(--tb-primary);
}

/* ==========================================================================
   ACTIVITY FEED
   ========================================================================== */

.tb-activity-feed {
  display: flex;
  flex-direction: column;
  gap: 0;
}

.tb-activity-item {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  padding: 12px 0;
  border-bottom: 1px solid rgba(42, 42, 42, 0.5);
}

.tb-activity-item:last-child {
  border-bottom: none;
}

.tb-activity-time {
  font-size: 12px;
  color: var(--tb-text-muted);
  white-space: nowrap;
  min-width: 72px;
  padding-top: 1px;
  font-variant-numeric: tabular-nums;
}

.tb-activity-text {
  font-size: 13px;
  color: var(--tb-text-secondary);
  line-height: 1.5;
}

.tb-activity-text strong {
  color: var(--tb-text);
  font-weight: 600;
}

/* ==========================================================================
   EMPTY STATE
   ========================================================================== */

.tb-empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 64px 24px;
  text-align: center;
}

.tb-empty-state-icon {
  font-size: 48px;
  color: var(--tb-text-muted);
  margin-bottom: 16px;
  opacity: 0.5;
}

.tb-empty-state-title {
  font-size: 18px;
  font-weight: 600;
  color: var(--tb-text-secondary);
  margin: 0 0 8px 0;
}

.tb-empty-state-text {
  font-size: 14px;
  color: var(--tb-text-muted);
  max-width: 360px;
  margin: 0;
}

/* ==========================================================================
   INLINE EDIT
   ========================================================================== */

.tb-inline-edit {
  position: relative;
  cursor: text;
  padding: 2px 4px;
  border-radius: var(--tb-radius-sm);
  transition: background var(--tb-transition);
}

.tb-inline-edit:hover {
  background: rgba(255, 255, 255, 0.04);
}

.tb-inline-edit:hover::after {
  content: '✎';
  position: absolute;
  right: -18px;
  top: 50%;
  transform: translateY(-50%);
  font-size: 11px;
  color: var(--tb-text-muted);
  pointer-events: none;
}

.tb-inline-edit:focus-within {
  background: rgba(255, 255, 255, 0.06);
  outline: 1px solid var(--tb-primary);
}

.tb-inline-edit:focus-within::after {
  display: none;
}

/* ==========================================================================
   TOAST NOTIFICATIONS
   ========================================================================== */

.tb-toast {
  position: fixed;
  bottom: 24px;
  right: 24px;
  z-index: 9500;
  min-width: 320px;
  max-width: 440px;
  padding: 14px 20px;
  background: #1e1e1e;
  border: 1px solid var(--tb-border);
  border-radius: var(--tb-radius);
  border-left: 3px solid var(--tb-text-secondary);
  box-shadow: var(--tb-shadow-lg);
  font-size: 13px;
  color: var(--tb-text);
  animation: tb-slideInRight 0.35s cubic-bezier(0.22, 1, 0.36, 1);
  display: flex;
  align-items: center;
  gap: 10px;
}

.tb-toast.tb-toast-exit {
  animation: tb-slideOutRight 0.25s ease forwards;
}

.tb-toast-success {
  border-left-color: var(--tb-success);
}

.tb-toast-error {
  border-left-color: var(--tb-danger);
}

/* ==========================================================================
   UTILITY & HELPERS
   ========================================================================== */

.tb-text-primary   { color: var(--tb-primary) !important; }
.tb-text-secondary { color: var(--tb-secondary) !important; }
.tb-text-success   { color: var(--tb-success) !important; }
.tb-text-warning   { color: var(--tb-warning) !important; }
.tb-text-danger    { color: var(--tb-danger) !important; }
.tb-text-muted     { color: var(--tb-text-muted) !important; }

.tb-mt-0  { margin-top: 0 !important; }
.tb-mb-0  { margin-bottom: 0 !important; }
.tb-mt-sm { margin-top: 8px !important; }
.tb-mt-md { margin-top: 16px !important; }
.tb-mt-lg { margin-top: 24px !important; }
.tb-mb-sm { margin-bottom: 8px !important; }
.tb-mb-md { margin-bottom: 16px !important; }
.tb-mb-lg { margin-bottom: 24px !important; }

.tb-flex       { display: flex; }
.tb-flex-col   { flex-direction: column; }
.tb-items-center { align-items: center; }
.tb-justify-between { justify-content: space-between; }
.tb-gap-sm     { gap: 8px; }
.tb-gap-md     { gap: 16px; }
.tb-gap-lg     { gap: 24px; }

.tb-truncate {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.tb-sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  border: 0;
}

/* Scrollbar styling within tb- scoped elements */
.tb-modal-body::-webkit-scrollbar,
.tb-table-wrapper::-webkit-scrollbar {
  width: 6px;
  height: 6px;
}

.tb-modal-body::-webkit-scrollbar-track,
.tb-table-wrapper::-webkit-scrollbar-track {
  background: transparent;
}

.tb-modal-body::-webkit-scrollbar-thumb,
.tb-table-wrapper::-webkit-scrollbar-thumb {
  background: #333333;
  border-radius: 3px;
}

.tb-modal-body::-webkit-scrollbar-thumb:hover,
.tb-table-wrapper::-webkit-scrollbar-thumb:hover {
  background: #444444;
}

/* ==========================================================================
   RESPONSIVE — Tablet (≤ 1024px)
   ========================================================================== */

@media (max-width: 1024px) {
  .tb-page {
    padding: 20px;
  }

  .tb-kpi-grid {
    grid-template-columns: repeat(2, 1fr);
  }

  .tb-form-row {
    grid-template-columns: 1fr 1fr;
  }

  .tb-bar-row {
    grid-template-columns: 110px 1fr 40px;
  }
}

/* ==========================================================================
   RESPONSIVE — Mobile (≤ 640px)
   ========================================================================== */

@media (max-width: 640px) {
  .tb-page {
    padding: 16px;
  }

  .tb-header {
    flex-direction: column;
    align-items: flex-start;
  }

  .tb-header h1,
  .tb-header-title {
    font-size: 22px;
  }

  .tb-kpi-grid {
    grid-template-columns: 1fr;
  }

  .tb-kpi-card {
    padding: 16px;
  }

  .tb-kpi-value {
    font-size: 28px;
  }

  .tb-search-input {
    height: 44px;
    font-size: 16px;
    padding-left: 44px;
  }

  .tb-search-icon {
    left: 14px;
    font-size: 18px;
  }

  .tb-nav-tabs {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
  }

  .tb-nav-tabs::-webkit-scrollbar {
    display: none;
  }

  .tb-toolbar {
    flex-direction: column;
    align-items: stretch;
  }

  .tb-filter-group {
    flex-wrap: wrap;
  }

  .tb-select {
    flex: 1;
    min-width: 0;
  }

  /* Table card layout on mobile */
  .tb-table-wrapper {
    border: none;
    background: transparent;
  }

  .tb-table,
  .tb-table thead,
  .tb-table tbody,
  .tb-table th,
  .tb-table td,
  .tb-table tr {
    display: block;
  }

  .tb-table thead {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    border: 0;
  }

  .tb-table tbody tr {
    background: var(--tb-card);
    border: 1px solid var(--tb-border);
    border-radius: var(--tb-radius);
    margin-bottom: 10px;
    padding: 12px 16px;
  }

  .tb-table tbody tr:hover {
    background: var(--tb-card-hover);
  }

  .tb-table td {
    padding: 6px 0;
    border-bottom: none;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
  }

  .tb-table td::before {
    content: attr(data-label);
    font-size: 11px;
    font-weight: 600;
    color: var(--tb-text-muted);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    flex-shrink: 0;
  }

  .tb-bar-row {
    grid-template-columns: 100px 1fr 36px;
    gap: 8px;
  }

  .tb-bar-label {
    font-size: 12px;
  }

  /* Modal full-width on mobile */
  .tb-modal-overlay {
    padding: 0;
    align-items: flex-end;
  }

  .tb-modal {
    max-width: 100%;
    max-height: 92vh;
    border-radius: var(--tb-radius-lg) var(--tb-radius-lg) 0 0;
  }

  .tb-modal-header {
    padding: 16px 20px;
  }

  .tb-modal-body {
    padding: 20px;
  }

  .tb-modal-footer {
    padding: 14px 20px;
  }

  .tb-form-row {
    grid-template-columns: 1fr;
  }

  .tb-toast {
    left: 16px;
    right: 16px;
    bottom: 16px;
    min-width: 0;
    max-width: none;
  }
}

/* ==========================================================================
   APP LAYOUT (used by frontend JS)
   ========================================================================== */

.tb-app {
  max-width: 1400px;
  margin: 0 auto;
}

.tb-content {
  min-height: 400px;
}

/* Page loader */
.tb-page-loader {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 60px;
}

.tb-spinner {
  width: 32px;
  height: 32px;
  border: 3px solid var(--tb-border);
  border-top-color: var(--tb-primary);
  border-radius: 50%;
  animation: tb-spin 0.8s linear infinite;
}

/* ---------- Nav tabs (override for JS class names) ---------- */
.tb-nav {
  display: flex;
  gap: 0;
  border-bottom: 1px solid var(--tb-border);
  margin-bottom: 24px;
}

.tb-nav .tb-nav-tab {
  position: relative;
  padding: 12px 20px;
  font-size: 14px;
  font-weight: 500;
  color: var(--tb-text-secondary);
  background: none;
  border: none;
  cursor: pointer;
  font-family: var(--tb-font);
  transition: color 0.2s ease;
  white-space: nowrap;
}

.tb-nav .tb-nav-tab::after {
  content: '';
  position: absolute;
  bottom: -1px;
  left: 20px;
  right: 20px;
  height: 2px;
  background: var(--tb-primary);
  border-radius: 2px 2px 0 0;
  transform: scaleX(0);
  transition: transform 0.25s cubic-bezier(0.22, 1, 0.36, 1);
}

.tb-nav .tb-nav-tab:hover {
  color: var(--tb-text);
}

.tb-nav .tb-nav-tab.active {
  color: var(--tb-primary);
  font-weight: 600;
}

.tb-nav .tb-nav-tab.active::after {
  transform: scaleX(1);
}

/* ==========================================================================
   SEARCH BAR
   ========================================================================== */

.tb-search-bar {
  margin-bottom: 16px;
}

/* ==========================================================================
   FILTER BAR
   ========================================================================== */

.tb-filter-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 16px;
  flex-wrap: wrap;
}

.tb-filter-dropdowns {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.tb-filter-select {
  height: 36px;
  padding: 0 32px 0 10px;
  font-family: var(--tb-font);
  font-size: 13px;
  font-weight: 500;
  color: var(--tb-text);
  background: var(--tb-card);
  border: 1px solid var(--tb-border);
  border-radius: 4px;
  outline: none;
  cursor: pointer;
  appearance: none;
  -webkit-appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg width='10' height='6' viewBox='0 0 10 6' fill='none' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath d='M1 1L5 5L9 1' stroke='%23888888' stroke-width='1.5' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 10px center;
  transition: border-color 0.2s ease;
}

.tb-filter-select:focus {
  border-color: var(--tb-primary);
}

.tb-filter-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

/* ==========================================================================
   BULK BAR
   ========================================================================== */

.tb-bulk-bar {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 16px;
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid rgba(255, 255, 255, 0.2);
  border-radius: 8px;
  margin-bottom: 12px;
  flex-wrap: wrap;
}

.tb-bulk-count {
  font-size: 13px;
  font-weight: 600;
  color: var(--tb-primary);
  margin-right: 8px;
}

/* ==========================================================================
   TABLE EXTRAS
   ========================================================================== */

.tb-th-check,
.tb-td-check {
  width: 40px;
  text-align: center;
}

.tb-td-actions {
  width: 80px;
  white-space: nowrap;
}

.tb-td-actions .tb-btn-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 30px;
  height: 30px;
  padding: 0;
  background: none;
  border: 1px solid transparent;
  border-radius: 4px;
  cursor: pointer;
  font-size: 14px;
  transition: background 0.15s ease, border-color 0.15s ease;
}

.tb-td-actions .tb-btn-icon:hover {
  background: rgba(255, 255, 255, 0.06);
  border-color: var(--tb-border);
}

.tb-empty {
  text-align: center;
  padding: 48px 16px !important;
  color: var(--tb-text-muted);
  font-size: 14px;
}

.tb-tool-name {
  font-weight: 600;
  color: var(--tb-text);
}

.tb-row {
  cursor: pointer;
}

/* ==========================================================================
   DASHBOARD CHARTS GRID
   ========================================================================== */

.tb-dashboard-charts {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
}

@media (max-width: 768px) {
  .tb-dashboard-charts {
    grid-template-columns: 1fr;
  }
}

.tb-chart-card {
  background: var(--tb-card);
  border: 1px solid var(--tb-border);
  border-radius: 8px;
  padding: 24px;
}

.tb-chart-title {
  font-size: 16px;
  font-weight: 600;
  color: var(--tb-text);
  margin: 0 0 20px 0;
}

.tb-bar-track {
  flex: 1;
  height: 24px;
  background: rgba(255, 255, 255, 0.04);
  border-radius: 4px;
  overflow: hidden;
}

.tb-bar-count {
  font-size: 13px;
  font-weight: 600;
  color: var(--tb-text);
  text-align: right;
  min-width: 32px;
  font-variant-numeric: tabular-nums;
}

/* ==========================================================================
   ACTIVITY CARD
   ========================================================================== */

.tb-activity-card {
  background: var(--tb-card);
  border: 1px solid var(--tb-border);
  border-radius: 8px;
  padding: 24px;
}

.tb-activity-date {
  font-size: 12px;
  color: var(--tb-text-muted);
  white-space: nowrap;
  margin-left: auto;
  font-variant-numeric: tabular-nums;
}

.tb-activity-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 0;
  border-bottom: 1px solid rgba(42, 42, 42, 0.5);
}

.tb-activity-item:last-child {
  border-bottom: none;
}

.tb-muted {
  color: var(--tb-text-muted);
  font-size: 14px;
}

/* ==========================================================================
   BEHEER (Management) SECTION
   ========================================================================== */

.tb-beheer {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.tb-beheer-tabs {
  display: flex;
  gap: 0;
  border-bottom: 1px solid var(--tb-border);
  margin-bottom: 16px;
}

.tb-beheer-tab {
  padding: 10px 18px;
  font-size: 14px;
  font-weight: 500;
  color: var(--tb-text-secondary);
  background: none;
  border: none;
  cursor: pointer;
  font-family: var(--tb-font);
  border-bottom: 2px solid transparent;
  transition: color 0.2s ease, border-color 0.2s ease;
}

.tb-beheer-tab:hover {
  color: var(--tb-text);
}

.tb-beheer-tab-active {
  color: var(--tb-primary) !important;
  border-bottom-color: var(--tb-primary) !important;
  font-weight: 600;
}

.tb-beheer-section {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.tb-beheer-add-form {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 16px;
  background: var(--tb-card);
  border: 1px solid var(--tb-border);
  border-radius: 8px;
  flex-wrap: wrap;
}

.tb-beheer-add-form .tb-form-input {
  flex: 1;
  min-width: 120px;
}

.tb-form-input-small {
  max-width: 120px !important;
  flex: 0 0 120px !important;
}

.tb-beheer-list {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.tb-beheer-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 16px;
  background: var(--tb-card);
  border: 1px solid var(--tb-border);
  border-radius: 8px;
  transition: background 0.15s ease;
}

.tb-beheer-item:hover {
  background: var(--tb-card-hover);
}

.tb-beheer-item-content {
  display: flex;
  align-items: center;
  gap: 10px;
  flex: 1;
  min-width: 0;
}

.tb-beheer-item-icon {
  font-size: 18px;
  flex-shrink: 0;
}

.tb-beheer-item-name {
  font-weight: 600;
  color: var(--tb-text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.tb-beheer-item-desc {
  font-size: 13px;
  color: var(--tb-text-secondary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.tb-beheer-item-meta {
  font-size: 12px;
  color: var(--tb-text-muted);
  white-space: nowrap;
}

.tb-beheer-item-actions {
  display: flex;
  align-items: center;
  gap: 4px;
  flex-shrink: 0;
  margin-left: 12px;
}

.tb-beheer-item-actions .tb-btn-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 30px;
  height: 30px;
  padding: 0;
  background: none;
  border: 1px solid transparent;
  border-radius: 4px;
  cursor: pointer;
  font-size: 14px;
  transition: background 0.15s ease;
}

.tb-beheer-item-actions .tb-btn-icon:hover {
  background: rgba(255, 255, 255, 0.06);
  border-color: var(--tb-border);
}

.tb-beheer-edit-form {
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
  flex-wrap: wrap;
}

.tb-beheer-edit-form .tb-form-input {
  flex: 1;
  min-width: 100px;
}

/* ==========================================================================
   TOOL LIST WRAPPER
   ========================================================================== */

.tb-tool-list {
  display: flex;
  flex-direction: column;
  gap: 0;
}

/* ==========================================================================
   N.V.T. BADGE (not_required — neutral style)
   ========================================================================== */

.tb-badge:not([class*="tb-badge-"]),
.tb-badge-neutral {
  background: rgba(128, 128, 128, 0.12);
  color: var(--tb-text-muted);
  border: 1px solid rgba(128, 128, 128, 0.25);
}

/* ==========================================================================
   RESPONSIVE FILTER BAR
   ========================================================================== */

@media (max-width: 768px) {
  .tb-filter-bar {
    flex-direction: column;
    align-items: stretch;
  }

  .tb-filter-dropdowns {
    flex-wrap: wrap;
  }

  .tb-filter-select {
    flex: 1;
    min-width: 0;
  }

  .tb-filter-actions {
    justify-content: stretch;
  }

  .tb-filter-actions .tb-btn {
    flex: 1;
  }

  .tb-bulk-bar {
    flex-direction: column;
    align-items: stretch;
  }

  .tb-beheer-add-form {
    flex-direction: column;
    align-items: stretch;
  }

  .tb-beheer-add-form .tb-form-input,
  .tb-form-input-small {
    max-width: none !important;
    flex: 1 1 auto !important;
  }
}

/* ==========================================================================
   PRINT
   ========================================================================== */

@media print {
  .tb-page {
    background: #ffffff;
    color: #000000;
    padding: 0;
  }

  .tb-modal-overlay,
  .tb-toast,
  .tb-btn,
  .tb-search-wrapper,
  .tb-toolbar {
    display: none !important;
  }

  .tb-table th,
  .tb-table td {
    border: 1px solid #cccccc;
    color: #000000;
  }

  .tb-kpi-card {
    border: 1px solid #cccccc;
    background: #ffffff;
  }

  .tb-kpi-value {
    color: #000000;
  }
}

/* ==========================================================================
   NOTIFICATION BELL & PANEL
   ========================================================================== */

/* Bell button in nav */
.tb-notif-bell {
  position: relative;
  margin-left: 8px;
}

.tb-notif-bell .tb-icon {
  width: 18px;
  height: 18px;
}

.tb-notif-count {
  position: absolute;
  top: 6px;
  right: 10px;
  min-width: 18px;
  height: 18px;
  padding: 0 5px;
  font-size: 10px;
  font-weight: 700;
  line-height: 18px;
  text-align: center;
  color: #fff;
  background: var(--tb-danger);
  border-radius: 9px;
  pointer-events: none;
}

/* Slide-in panel */
.tb-notif-panel {
  position: fixed;
  top: 0;
  right: 0;
  bottom: 0;
  width: 400px;
  max-width: 90vw;
  background: var(--tb-card);
  border-left: 1px solid var(--tb-border);
  box-shadow: -8px 0 32px rgba(0, 0, 0, 0.5);
  z-index: 8000;
  display: flex;
  flex-direction: column;
  transform: translateX(100%);
  transition: transform 0.25s cubic-bezier(0.22, 1, 0.36, 1);
  overflow: hidden;
}

.tb-notif-panel-open {
  transform: translateX(0);
}

.tb-notif-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 20px 20px 16px;
  border-bottom: 1px solid var(--tb-border);
  flex-shrink: 0;
}

.tb-notif-title {
  font-size: 16px;
  font-weight: 600;
  color: var(--tb-text);
  margin: 0;
  display: flex;
  align-items: center;
  gap: 8px;
}

.tb-notif-title .tb-icon {
  width: 18px;
  height: 18px;
}

.tb-notif-close {
  width: 32px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: none;
  border: none;
  color: var(--tb-text-secondary);
  cursor: pointer;
  border-radius: 4px;
  font-size: 20px;
  transition: color 0.15s, background 0.15s;
}

.tb-notif-close:hover {
  color: var(--tb-text);
  background: rgba(255, 255, 255, 0.06);
}

.tb-notif-list {
  flex: 1;
  overflow-y: auto;
  padding: 12px 16px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.tb-notif-list::-webkit-scrollbar { width: 4px; }
.tb-notif-list::-webkit-scrollbar-track { background: transparent; }
.tb-notif-list::-webkit-scrollbar-thumb { background: #333; border-radius: 2px; }

.tb-notif-empty {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 48px 24px;
}

/* Notification item */
.tb-notif-item {
  background: var(--tb-bg);
  border: 1px solid var(--tb-border);
  border-radius: 10px;
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  transition: background 0.15s;
  animation: tb-slideUp 0.3s ease backwards;
}

.tb-notif-item:nth-child(2) { animation-delay: 0.05s; }
.tb-notif-item:nth-child(3) { animation-delay: 0.1s; }
.tb-notif-item:nth-child(4) { animation-delay: 0.15s; }

.tb-notif-item:hover {
  background: #111;
}

.tb-notif-item-danger {
  border-left: 3px solid var(--tb-danger);
}

.tb-notif-item-warning {
  border-left: 3px solid var(--tb-warning);
}

.tb-notif-item-info {
  border-left: 3px solid var(--tb-text-secondary);
}

.tb-notif-item-header {
  display: flex;
  align-items: center;
  gap: 8px;
}

.tb-notif-item-icon {
  flex-shrink: 0;
}

.tb-notif-item-danger .tb-notif-item-icon {
  color: var(--tb-danger);
}

.tb-notif-item-warning .tb-notif-item-icon {
  color: var(--tb-warning);
}

.tb-notif-item-info .tb-notif-item-icon {
  color: var(--tb-text-secondary);
}

.tb-notif-item-icon .tb-icon {
  width: 16px;
  height: 16px;
}

.tb-notif-item-title {
  font-size: 14px;
  font-weight: 600;
  color: var(--tb-text);
}

.tb-notif-item-desc {
  font-size: 13px;
  color: var(--tb-text-secondary);
  line-height: 1.5;
  margin: 0;
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.tb-notif-chat-btn {
  align-self: flex-start;
  background: rgba(255, 255, 255, 0.06) !important;
  border: 1px solid var(--tb-border) !important;
  color: var(--tb-text) !important;
  gap: 6px;
}

.tb-notif-chat-btn:hover {
  background: rgba(255, 255, 255, 0.12) !important;
  border-color: var(--tb-text-secondary) !important;
}

.tb-notif-chat-btn .tb-icon {
  width: 14px;
  height: 14px;
}

@media (max-width: 640px) {
  .tb-notif-panel {
    width: 100%;
    max-width: 100%;
  }
}

/* ─── Chat ─────────────────────────────────────────────────────────── */

.tb-chat {
  display: flex;
  flex-direction: column;
  height: calc(100vh - 140px);
  max-width: 720px;
  margin: 0 auto;
}

.tb-chat-messages {
  flex: 1;
  overflow-y: auto;
  padding: 24px 8px;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.tb-chat-msg {
  display: flex;
  max-width: 85%;
  animation: tb-chat-fadein 0.25s ease;
}

@keyframes tb-chat-fadein {
  from { opacity: 0; transform: translateY(8px); }
  to   { opacity: 1; transform: translateY(0); }
}

.tb-chat-msg-bot {
  align-self: flex-start;
  flex-direction: column;
  gap: 12px;
}

.tb-chat-msg-user {
  align-self: flex-end;
}

.tb-chat-bubble {
  padding: 12px 16px;
  border-radius: 16px;
  font-size: 14px;
  line-height: 1.6;
}

.tb-chat-msg-bot .tb-chat-bubble {
  background: #1a1a1a;
  color: #e0e0e0;
  border-bottom-left-radius: 4px;
}

.tb-chat-msg-user .tb-chat-bubble {
  background: #ffffff;
  color: #000000;
  border-bottom-right-radius: 4px;
}

.tb-chat-bubble strong {
  color: #ffffff;
  font-weight: 600;
}

.tb-chat-msg-user .tb-chat-bubble strong {
  color: #000000;
}

/* Chat input bar */
.tb-chat-input-bar {
  display: flex;
  gap: 8px;
  padding: 16px 8px;
  border-top: 1px solid #1a1a1a;
}

.tb-chat-input {
  flex: 1;
  background: #141414;
  border: 1px solid #2a2a2a;
  border-radius: 12px;
  padding: 12px 16px;
  color: #ffffff;
  font-size: 14px;
  outline: none;
  transition: border-color 0.2s ease;
}

.tb-chat-input:focus {
  border-color: #444;
}

.tb-chat-input::placeholder {
  color: #555;
}

.tb-chat-mic {
  background: transparent;
  border: 1px solid #333;
  border-radius: 12px;
  width: 44px;
  height: 44px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all 0.2s ease;
  flex-shrink: 0;
}

.tb-chat-mic .tb-icon {
  width: 18px;
  height: 18px;
  stroke: #888;
}

.tb-chat-mic:hover {
  border-color: #555;
}

.tb-chat-mic:hover .tb-icon {
  stroke: #fff;
}

.tb-chat-mic-active {
  background: #ff3b30;
  border-color: #ff3b30;
  animation: tb-mic-pulse 1.5s ease-in-out infinite;
}

.tb-chat-mic-active .tb-icon {
  stroke: #fff;
}

@keyframes tb-mic-pulse {
  0%, 100% { box-shadow: 0 0 0 0 rgba(255, 59, 48, 0.4); }
  50% { box-shadow: 0 0 0 8px rgba(255, 59, 48, 0); }
}

.tb-chat-send {
  background: #ffffff;
  border: none;
  border-radius: 12px;
  width: 44px;
  height: 44px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: opacity 0.2s ease;
  flex-shrink: 0;
}

.tb-chat-send:hover {
  opacity: 0.8;
}

.tb-chat-send .tb-icon {
  width: 18px;
  height: 18px;
  stroke: #000000;
}

/* Wizard option buttons */
.tb-chat-options {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  padding: 4px 0;
}

.tb-chat-option {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 16px;
  background: #141414;
  border: 1px solid #2a2a2a;
  border-radius: 10px;
  color: #e0e0e0;
  font-size: 13px;
  cursor: pointer;
  transition: all 0.2s ease;
  white-space: nowrap;
}

.tb-chat-option:hover {
  background: #1f1f1f;
  border-color: #444;
  color: #ffffff;
}

.tb-chat-option:active {
  transform: scale(0.97);
}

.tb-chat-option-icon {
  font-size: 16px;
  width: 22px;
  text-align: center;
  flex-shrink: 0;
}

.tb-chat-option-sub {
  font-size: 11px;
  color: #666;
  margin-left: 4px;
}

/* Thinking indicator */
.tb-thinking-bubble {
  padding: 12px 18px !important;
  min-width: 60px;
}
.tb-thinking-dots {
  display: flex;
  gap: 5px;
  align-items: center;
}
.tb-thinking-dots span {
  display: block;
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: #666;
  animation: tb-thinking-bounce 1.2s infinite;
}
.tb-thinking-dots span:nth-child(2) { animation-delay: 0.2s; }
.tb-thinking-dots span:nth-child(3) { animation-delay: 0.4s; }
@keyframes tb-thinking-bounce {
  0%, 60%, 100% { opacity: 0.3; transform: translateY(0); }
  30% { opacity: 1; transform: translateY(-4px); }
}

/* Streaming indicator */
.tb-chat-streaming {
  position: relative;
}

.tb-chat-streaming::after {
  content: '';
  display: inline-block;
  width: 6px;
  height: 14px;
  background: #666;
  margin-left: 2px;
  animation: tb-blink 0.8s infinite;
  vertical-align: text-bottom;
}

@keyframes tb-blink {
  0%, 50% { opacity: 1; }
  51%, 100% { opacity: 0; }
}

.tb-chat-bubble code {
  background: #0d0d0d;
  padding: 2px 6px;
  border-radius: 4px;
  font-size: 12px;
  font-family: monospace;
}

.tb-chat-send:disabled {
  opacity: 0.3;
  cursor: not-allowed;
}

.tb-chat-input:disabled {
  opacity: 0.5;
}

/* Scrollbar */
.tb-chat-messages::-webkit-scrollbar {
  width: 4px;
}
.tb-chat-messages::-webkit-scrollbar-track {
  background: transparent;
}
.tb-chat-messages::-webkit-scrollbar-thumb {
  background: #333;
  border-radius: 2px;
}

/* Mobile */
@media (max-width: 640px) {
  .tb-chat {
    height: calc(100vh - 120px);
  }
  .tb-chat-msg {
    max-width: 92%;
  }
  .tb-chat-options {
    gap: 6px;
  }
  .tb-chat-option {
    padding: 8px 12px;
    font-size: 12px;
  }
}

/* ==========================================================================
   QR CODE — Scanner, Preview, Scan Button
   ========================================================================== */

/* Scan button in nav */
.tb-scan-btn {
  margin-left: auto;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  white-space: nowrap;
  flex-shrink: 0;
}

/* QR section in tool modal */
.tb-qr-section {
  margin-top: 20px;
  padding-top: 20px;
  border-top: 1px solid var(--tb-border);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
}

.tb-qr-label {
  font-size: 13px;
  font-weight: 600;
  color: var(--tb-text-secondary);
  align-self: flex-start;
}

.tb-qr-preview {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
  background: #ffffff;
  border-radius: var(--tb-radius);
}

.tb-qr-img {
  display: block;
  width: 150px;
  height: 150px;
  image-rendering: pixelated;
}

.tb-qr-actions {
  display: flex;
  gap: 8px;
}

/* Scanner modal */
.tb-scanner-modal {
  max-width: 480px;
}

.tb-scanner-body {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 16px;
  padding: 16px 24px !important;
}

.tb-scanner-viewport {
  position: relative;
  width: 100%;
  max-width: 400px;
  aspect-ratio: 1;
  overflow: hidden;
  border-radius: var(--tb-radius-lg);
  background: #000;
}

.tb-scanner-viewport video {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

/* Crosshair overlay */
.tb-scanner-crosshair {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: 60%;
  height: 60%;
  pointer-events: none;
}

.tb-scanner-crosshair::before,
.tb-scanner-crosshair::after {
  content: '';
  position: absolute;
  border-color: rgba(255, 255, 255, 0.7);
  border-style: solid;
}

.tb-scanner-crosshair::before {
  top: 0;
  left: 0;
  width: 24px;
  height: 24px;
  border-width: 3px 0 0 3px;
  border-radius: 4px 0 0 0;
}

.tb-scanner-crosshair::after {
  top: 0;
  right: 0;
  width: 24px;
  height: 24px;
  border-width: 3px 3px 0 0;
  border-radius: 0 4px 0 0;
}

/* Bottom corners via the viewport pseudo-elements */
.tb-scanner-viewport::before,
.tb-scanner-viewport::after {
  content: '';
  position: absolute;
  z-index: 2;
  width: calc(60% * 0.15);
  height: calc(60% * 0.15);
  border-color: rgba(255, 255, 255, 0.7);
  border-style: solid;
  pointer-events: none;
}

.tb-scanner-viewport::before {
  bottom: 20%;
  left: 20%;
  border-width: 0 0 3px 3px;
  border-radius: 0 0 0 4px;
}

.tb-scanner-viewport::after {
  bottom: 20%;
  right: 20%;
  border-width: 0 3px 3px 0;
  border-radius: 0 0 4px 0;
}

.tb-scanner-status {
  font-size: 13px;
  color: var(--tb-text-secondary);
  text-align: center;
  margin: 0;
}

/* Mobile scanner */
@media (max-width: 640px) {
  .tb-scanner-modal {
    max-width: 100%;
  }

  .tb-scanner-viewport {
    max-width: 100%;
    border-radius: var(--tb-radius);
  }
}

/* ==========================================================================
   KOSTEN & AFSCHRIJVING — Cost & Depreciation Tracker
   ========================================================================== */

.tb-kosten {
  padding: 0;
}

/* 5-column KPI grid for costs */
.tb-kpi-grid-5 {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 16px;
  margin-bottom: 24px;
}

/* Text color helpers */
.tb-text-warning {
  color: var(--tb-warning) !important;
}

.tb-text-danger {
  color: var(--tb-danger) !important;
}

/* Progress card */
.tb-cost-progress-card {
  background: var(--tb-card);
  border: 1px solid var(--tb-border);
  border-radius: var(--tb-radius-lg);
  padding: 20px 24px;
  margin-bottom: 24px;
}

.tb-cost-progress-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 12px;
  font-size: 14px;
  color: var(--tb-text-secondary);
}

.tb-cost-progress-header span:last-child {
  color: var(--tb-text);
  font-weight: 600;
}

.tb-cost-progress-bar {
  width: 100%;
  height: 8px;
  background: #1a1a1a;
  border-radius: 4px;
  overflow: hidden;
  margin-bottom: 8px;
}

.tb-cost-progress-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--tb-warning), var(--tb-danger));
  border-radius: 4px;
  transition: width 0.6s ease;
}

.tb-cost-progress-labels {
  display: flex;
  justify-content: space-between;
  font-size: 12px;
  color: var(--tb-text-muted);
}

/* Two-column card layout */
.tb-cost-columns {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
  margin-bottom: 16px;
}

.tb-cost-card {
  background: var(--tb-card);
  border: 1px solid var(--tb-border);
  border-radius: var(--tb-radius-lg);
  padding: 20px 24px;
}

.tb-cost-card-full {
  margin-bottom: 16px;
}

.tb-cost-card .tb-chart-title {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 16px;
}

.tb-cost-card .tb-chart-title .tb-icon {
  width: 18px;
  height: 18px;
}

/* Cost list items */
.tb-cost-list {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.tb-cost-list-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 12px;
  border-radius: var(--tb-radius);
  transition: background var(--tb-transition);
}

.tb-cost-list-item:hover {
  background: var(--tb-card-hover);
}

.tb-cost-list-warn {
  border-left: 3px solid var(--tb-warning);
  padding-left: 9px;
}

.tb-cost-list-info {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
  flex: 1;
}

.tb-cost-list-name {
  font-size: 14px;
  font-weight: 500;
  color: var(--tb-text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.tb-cost-list-sub {
  font-size: 12px;
  color: var(--tb-text-muted);
}

.tb-cost-list-value {
  font-size: 14px;
  font-weight: 600;
  color: var(--tb-text);
  white-space: nowrap;
  margin-left: 12px;
}

.tb-cost-list-values {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 2px;
}

/* Cost table */
.tb-cost-table th {
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--tb-text-muted);
}

.tb-cost-table td {
  font-size: 13px;
}

/* Responsive */
@media (max-width: 1024px) {
  .tb-kpi-grid-5 {
    grid-template-columns: repeat(3, 1fr);
  }
}

@media (max-width: 768px) {
  .tb-kpi-grid-5 {
    grid-template-columns: repeat(2, 1fr);
  }

  .tb-cost-columns {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 480px) {
  .tb-kpi-grid-5 {
    grid-template-columns: 1fr;
  }
}

/* ─── Kaart (Map) ────────────────────────────────────────────────────────── */

.tb-kaart {
  display: flex;
  flex-direction: column;
  gap: 12px;
  height: calc(100vh - 180px);
  min-height: 480px;
}

.tb-leaflet-map {
  flex: 1;
  width: 100%;
  border: 1px solid #2a2a2a;
  border-radius: 8px;
  background: #0a0a0a;
  overflow: hidden;
}

.tb-map-warning {
  background: #1a1a1a;
  border: 1px solid #2a2a2a;
  border-left: 3px solid #888;
  padding: 10px 14px;
  border-radius: 6px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  color: #ccc;
  font-size: 13px;
}

.tb-map-empty {
  color: #888;
  text-align: center;
  padding: 16px;
  font-size: 13px;
}

/* Custom pin */
.tb-map-pin-wrapper { background: transparent; border: none; }

.tb-map-pin {
  width: 40px;
  height: 40px;
  background: #fff;
  color: #000;
  border-radius: 50% 50% 50% 0;
  transform: rotate(-45deg);
  display: flex;
  align-items: center;
  justify-content: center;
  border: 2px solid #000;
  box-shadow: 0 4px 10px rgba(0,0,0,0.6);
  position: relative;
  top: -4px;
  left: -2px;
}

.tb-map-pin-count {
  transform: rotate(45deg);
  font-weight: 700;
  font-size: 13px;
  color: #000;
  font-family: inherit;
}

/* Popup styling — override Leaflet defaults to match zwart-wit-grijs */
.tb-map-popup .leaflet-popup-content-wrapper {
  background: #0d0d0d;
  color: #eee;
  border: 1px solid #2a2a2a;
  border-radius: 8px;
  box-shadow: 0 8px 24px rgba(0,0,0,0.6);
  padding: 0;
}

.tb-map-popup .leaflet-popup-content {
  margin: 0;
  padding: 14px 16px;
  font-family: inherit;
  font-size: 13px;
  line-height: 1.4;
}

.tb-map-popup .leaflet-popup-tip {
  background: #0d0d0d;
  border: 1px solid #2a2a2a;
}

.tb-map-popup .leaflet-popup-close-button {
  color: #888;
  font-size: 18px;
  padding: 6px 8px;
}
.tb-map-popup .leaflet-popup-close-button:hover {
  color: #fff;
}

.tb-map-popup-title {
  font-weight: 700;
  font-size: 15px;
  color: #fff;
  margin-bottom: 4px;
}

.tb-map-popup-address {
  color: #888;
  font-size: 12px;
  margin-bottom: 8px;
}

.tb-map-popup-count {
  color: #ccc;
  font-size: 12px;
  margin-bottom: 8px;
  padding-bottom: 8px;
  border-bottom: 1px solid #222;
}

.tb-map-popup-list {
  list-style: none;
  margin: 0;
  padding: 0;
  max-height: 220px;
  overflow-y: auto;
}

.tb-map-popup-item {
  padding: 6px 8px;
  border-radius: 4px;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  gap: 2px;
  transition: background 0.15s;
}

.tb-map-popup-item:hover {
  background: #1a1a1a;
}

.tb-map-popup-tool-name {
  color: #fff;
  font-size: 12px;
  font-weight: 500;
}

.tb-map-popup-tool-person {
  color: #777;
  font-size: 11px;
}

.tb-map-popup-more {
  color: #777;
  font-size: 11px;
  text-align: center;
  padding-top: 6px;
  border-top: 1px solid #222;
  margin-top: 6px;
}

/* Leaflet UI controls — donker thema */
.leaflet-control-zoom a {
  background: #1a1a1a !important;
  color: #fff !important;
  border-color: #2a2a2a !important;
}
.leaflet-control-zoom a:hover {
  background: #2a2a2a !important;
}
.leaflet-control-attribution {
  background: rgba(0,0,0,0.6) !important;
  color: #888 !important;
}
.leaflet-control-attribution a {
  color: #aaa !important;
}

/* Beheer locatie form — extra velden voor kaart */
.tb-beheer-add-form-loc,
.tb-beheer-edit-form-loc {
  flex-wrap: wrap;
}

.tb-form-input-sm {
  max-width: 110px;
}

.tb-beheer-item-coords {
  font-size: 11px;
  color: #888;
  font-family: monospace;
  margin-top: 2px;
}

.tb-beheer-item-coords-missing {
  color: #555;
  font-style: italic;
  font-family: inherit;
}
