/* ============================================================
   TSF OPS   Light Theme (Jadmark-inspired)
   Technology Solutions | tsfresno.com
   Uses original header.php class names
   ============================================================ */

@import url('https://fonts.googleapis.com/css2?family=DM+Sans:wght@300;400;500;600;700&family=DM+Mono:wght@400;500&display=swap');

/* -- CSS Variables ------------------------------------------- */
:root {
  --tsf-blue:        #2a8fc4;
  --tsf-blue-dark:   #1c6fa0;
  --tsf-blue-light:  #e8f4fb;
  --tsf-navy:        #1a2338;
  --sidebar-bg:      #1a2535;
  --sidebar-hover:   #243044;
  --sidebar-active:  #2a3d55;
  --sidebar-border:  #263447;
  --sidebar-text:    #dde6f0;
  --sidebar-muted:   #7a94ad;
  --sidebar-accent:  #f5a623;
  --sidebar-width:   220px;
  --bg-page:         #e8ecf2;
  --bg-card:         #ffffff;
  --bg-card-alt:     #f4f6f9;
  --border:          #c8d0dc;
  --border-light:    #dde3eb;
  --text-primary:    #0f1923;
  --text-secondary:  #2d3748;
  --text-muted:      #64748b;
  --accent-blue:     #2a8fc4;
  --accent-amber:    #f5a623;
  --accent-green:    #27ae60;
  --accent-red:      #e74c3c;
  --accent-purple:   #7b68ee;
  --accent-teal:     #17a589;
  --shadow-sm:       0 1px 3px rgba(0,0,0,0.07), 0 1px 2px rgba(0,0,0,0.04);
  --shadow-md:       0 4px 12px rgba(0,0,0,0.08), 0 2px 4px rgba(0,0,0,0.04);
  --shadow-lg:       0 10px 30px rgba(0,0,0,0.10);
  --radius-sm:       6px;
  --radius-md:       10px;
  --radius-lg:       14px;
  --font-body:       'DM Sans', system-ui, sans-serif;
  --font-mono:       'DM Mono', monospace;

  /* -- Legacy variable aliases (used throughout tab files) -- */
  --ts-blue:         #2a8fc4;
  --ts-navy:         #1a2338;
  --ts-navy-2:       #243044;
  --ts-navy-3:       #f4f6f9;
  --navy:            #1a2338;
  --navy2:           #243044;
  --navy3:           #f4f6f9;
  --text:            #0f1923;
  --text2:           #2d3748;
  --text3:           #64748b;
  --border2:         #c8d0dc;
  --radius:          10px;
  --green:           #27ae60;
  --red:             #e74c3c;
  --gold:            #f5a623;
  --blue:            #2a8fc4;
  --accent:          #2a8fc4;
  --sans:            'DM Sans', system-ui, sans-serif;
  --mono:            'DM Mono', monospace;
  --bg:              #e8ecf2;
  --bg2:             #f4f6f9;
  --bg3:             #ffffff;
  --white:           #ffffff;
  --blue-bg:         #e8f4fb;
  --blue-border:     #b8d9f5;
  --green-bg:        #d4f5e3;
  --green-border:    #a8e6c2;
  --gold-border:     #f5d98a;
}

/* -- Reset & Base -------------------------------------------- */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html, body {
  height: 100%;
  font-family: var(--font-body);
  font-size: 14px;
  line-height: 1.5;
  color: #0f1923;
  background: var(--bg-page);
  -webkit-font-smoothing: antialiased;
}

a { color: var(--tsf-blue); text-decoration: none; }
a:hover { text-decoration: none; }

/* -- Sidebar ------------------------------------------------- */
.sidebar {
  width: var(--sidebar-width);
  min-height: 100vh;
  background: var(--sidebar-bg);
  display: flex;
  flex-direction: column;
  position: fixed;
  top: 0;
  left: 0;
  z-index: 100;
  overflow-x: hidden;
  border-right: 1px solid var(--sidebar-border);
  transition: transform 0.25s ease;
}

.sidebar-logo {
  padding: 16px 14px 12px;
  border-bottom: 1px solid var(--sidebar-border);
}

.sidebar-logo img {
  width: 100%;
  max-width: 160px;
  height: auto;
  display: block;
}

.sidebar-location {
  padding: 10px 14px 6px;
}

.loc-badge {
  display: inline-block;
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.10em;
  padding: 3px 8px;
  border-radius: 20px;
}

.loc-all    { background: #2d3d52; color: #c8d6e5; }
.loc-ca     { background: #1a4a7a; color: #a8d4f5; }
.loc-tx     { background: #7a3a1a; color: #f5c8a8; }

.sidebar-filter {
  display: flex;
  gap: 4px;
  padding: 4px 14px 8px;
}

.filter-btn {
  font-size: 11px;
  font-weight: 600;
  padding: 3px 10px;
  border-radius: 20px;
  color: var(--sidebar-muted);
  background: transparent;
  border: 1px solid var(--sidebar-border);
  transition: all 0.15s;
}

.filter-btn:hover,
.filter-btn.active {
  background: var(--tsf-blue);
  color: #fff;
  border-color: var(--tsf-blue);
}

.sidebar-nav {
  flex: 1;
  padding: 8px 0;
  overflow-y: auto;
}

.sidebar-nav::-webkit-scrollbar { width: 4px; }
.sidebar-nav::-webkit-scrollbar-track { background: transparent; }
.sidebar-nav::-webkit-scrollbar-thumb { background: var(--sidebar-border); border-radius: 2px; }

.sidebar-link {
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 8px 14px;
  color: var(--sidebar-text);
  font-size: 13px;
  font-weight: 400;
  cursor: pointer;
  transition: background 0.15s, color 0.15s;
  text-decoration: none;
  position: relative;
  border-left: 3px solid transparent;
}

.sidebar-link:hover {
  background: var(--sidebar-hover);
  color: #fff;
}

.sidebar-link.active {
  background: var(--sidebar-active);
  color: #fff;
  font-weight: 500;
  border-left-color: var(--sidebar-accent);
}

.sidebar-link.gold {
  color: #f5c842;
}

.sidebar-link.gold:hover,
.sidebar-link.gold.active {
  color: #fff;
  background: var(--sidebar-active);
  border-left-color: #f5c842;
}

.sidebar-footer {
  padding: 12px 14px;
  border-top: 1px solid var(--sidebar-border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.sidebar-user {
  display: flex;
  align-items: center;
  gap: 8px;
  flex: 1;
  min-width: 0;
}

.sidebar-avatar {
  width: 30px;
  height: 30px;
  border-radius: 50%;
  background: var(--tsf-blue);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 12px;
  font-weight: 700;
  flex-shrink: 0;
}

.sidebar-user-info {
  min-width: 0;
}

.sidebar-user-name {
  font-size: 12.5px;
  font-weight: 600;
  color: var(--sidebar-text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.sidebar-user-role {
  font-size: 10.5px;
  color: var(--sidebar-muted);
}

.sidebar-logout {
  color: var(--sidebar-muted);
  font-size: 16px;
  flex-shrink: 0;
  transition: color 0.15s;
  padding: 4px;
}

.sidebar-logout:hover { color: var(--accent-red); }

/* -- Main Content -------------------------------------------- */
.main-wrap {
  margin-left: var(--sidebar-width);
  min-height: 100vh;
  padding: 24px;
  background: var(--bg-page);
}

/* -- Mobile bar ---------------------------------------------- */
.mobile-bar {
  display: none;
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  height: 52px;
  background: var(--sidebar-bg);
  z-index: 101;
  align-items: center;
  justify-content: space-between;
  padding: 0 16px;
  border-bottom: 1px solid var(--sidebar-border);
}

.hamburger {
  background: none;
  border: none;
  color: var(--sidebar-text);
  font-size: 20px;
  cursor: pointer;
  padding: 4px;
}

.sidebar-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.45);
  z-index: 99;
}

/* -- Cards --------------------------------------------------- */
.card {
  background: var(--bg-card);
  border: 1px solid #d0d7e2;
  border-radius: var(--radius-md);
  box-shadow: 0 2px 8px rgba(0,0,0,0.08), 0 1px 3px rgba(0,0,0,0.05);
  margin-bottom: 16px;
}

.card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 18px 12px;
  border-bottom: 1px solid var(--border-light);
}

.card-title {
  font-size: 14px;
  font-weight: 600;
  color: var(--text-primary);
}

.card-body { padding: 18px; }

/* Stat cards */
.stat-card {
  background: var(--bg-card);
  border: 1px solid #d0d7e2;
  border-radius: var(--radius-md);
  box-shadow: 0 2px 8px rgba(0,0,0,0.08), 0 1px 3px rgba(0,0,0,0.05);
  padding: 16px 18px 14px;
  border-top: 3px solid var(--accent-blue);
  transition: box-shadow 0.2s;
}

.stat-card:hover { box-shadow: 0 4px 16px rgba(0,0,0,0.12); }
.stat-card.amber  { border-top-color: var(--accent-amber); }
.stat-card.green  { border-top-color: var(--accent-green); }
.stat-card.red    { border-top-color: var(--accent-red); }
.stat-card.purple { border-top-color: var(--accent-purple); }
.stat-card.teal   { border-top-color: var(--accent-teal); }

.stat-label {
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.10em;
  text-transform: uppercase;
  color: var(--text-muted);
  margin-bottom: 6px;
}

.stat-value {
  font-size: 26px;
  font-weight: 700;
  color: var(--text-primary);
  line-height: 1;
  letter-spacing: -0.02em;
}

.stat-sub {
  font-size: 11.5px;
  color: var(--text-muted);
  margin-top: 4px;
}

/* Stat grid */
.stat-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
  gap: 14px;
  margin-bottom: 20px;
}

/* -- Tables -------------------------------------------------- */
.table-wrap {
  overflow-x: auto;
  border-radius: var(--radius-md);
  border: 1px solid #d0d7e2;
  background: var(--bg-card);
  box-shadow: 0 2px 8px rgba(0,0,0,0.08), 0 1px 3px rgba(0,0,0,0.05);
}

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

thead th {
  font-size: 10.5px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: #4a5568;
  padding: 10px 14px;
  border-bottom: 2px solid #c8d0dc;
  text-align: left;
  background: #f4f6f9;
  white-space: nowrap;
}

tbody tr {
  border-bottom: 1px solid #dde3eb;
  transition: background 0.12s;
}

tbody tr:last-child { border-bottom: none; }
tbody tr:hover { background: var(--tsf-blue-light); }

tbody td {
  padding: 10px 14px;
  color: #0f1923;
  vertical-align: middle;
}

/* -- Buttons ------------------------------------------------- */
.btn, button.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 7px 14px;
  border-radius: var(--radius-sm);
  font-family: var(--font-body);
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  border: none;
  transition: background 0.15s, box-shadow 0.15s, transform 0.1s;
  line-height: 1;
  white-space: nowrap;
  text-decoration: none;
}

.btn:active { transform: translateY(1px); }

.btn-primary  { background: var(--tsf-blue); color: #fff; }
.btn-primary:hover { background: var(--tsf-blue-dark); }

.btn-secondary { background: var(--bg-card); color: var(--text-secondary); border: 1px solid var(--border); }
.btn-secondary:hover { background: var(--bg-card-alt); }

.btn-danger { background: #fff0f0; color: #c0392b; border: 1px solid #f5b8b5; }
.btn-danger:hover { background: var(--accent-red); color: #fff; border-color: var(--accent-red); }

.btn-ghost { background: transparent; color: var(--text-secondary); border: 1px solid var(--border); }
.btn-ghost:hover { background: var(--bg-card-alt); }

.btn-sm { padding: 5px 10px; font-size: 12px; }
.btn-lg { padding: 10px 20px; font-size: 14px; }

/* -- Badges -------------------------------------------------- */
.badge {
  display: inline-flex;
  align-items: center;
  padding: 2px 8px;
  border-radius: 20px;
  font-size: 11px;
  font-weight: 600;
  white-space: nowrap;
}

.badge-blue    { background: #dbeeff; color: #1a6fa0; }
.badge-amber   { background: #fff3d6; color: #a06c00; }
.badge-green   { background: #d4f5e3; color: #1a7a45; }
.badge-red     { background: #ffe0de; color: #b0281a; }
.badge-gray    { background: #edf2f7; color: #4a5568; }
.badge-purple  { background: #eae8fd; color: #5147c7; }
.badge-gold    { background: #fff3d6; color: #a06c00; }

/* Status */
.badge-open        { background: #dbeeff; color: #1a6fa0; }
.badge-assigned    { background: #fff3d6; color: #a06c00; }
.badge-in_progress { background: #d4f5e3; color: #1a7a45; }
.badge-resolved    { background: #edf2f7; color: #4a5568; }
.badge-pending     { background: #eae8fd; color: #5147c7; }

/* Priority */
.badge-critical { background: #ffe0de; color: #b0281a; }
.badge-high     { background: #ffe8d6; color: #a04010; }
.badge-medium   { background: #fff3d6; color: #a06c00; }
.badge-low      { background: #d4f5e3; color: #1a7a45; }

/* Location pill */
.location-pill {
  display: inline-flex;
  align-items: center;
  padding: 2px 8px;
  background: #dbeeff;
  color: var(--tsf-blue-dark);
  border-radius: 20px;
  font-size: 11px;
  font-weight: 600;
}

/* -- Forms --------------------------------------------------- */
.form-group { margin-bottom: 14px; }

label, .form-label {
  display: block;
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.04em;
  color: var(--text-secondary);
  margin-bottom: 4px;
}

input, select, textarea,
input[type="text"], input[type="email"],
input[type="number"], input[type="date"],
input[type="time"], input[type="password"] {
  width: 100%;
  padding: 8px 10px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-family: var(--font-body);
  font-size: 13.5px;
  color: var(--text-primary);
  background: var(--bg-card);
  transition: border-color 0.15s, box-shadow 0.15s;
  outline: none;
}

input:focus, select:focus, textarea:focus {
  border-color: var(--tsf-blue);
  box-shadow: 0 0 0 3px rgba(42,143,196,0.15);
}

input::placeholder, textarea::placeholder { color: var(--text-muted); }
textarea { resize: vertical; min-height: 80px; }
select { cursor: pointer; }

.form-row {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
  gap: 12px;
}

/* -- Alerts -------------------------------------------------- */
.alert {
  padding: 10px 14px;
  border-radius: var(--radius-sm);
  font-size: 13.5px;
  margin-bottom: 14px;
  border: 1px solid transparent;
}

.alert-success { background: #d4f5e3; border-color: #a8e6c2; color: #155a35; }
.alert-warn    { background: #fff3d6; border-color: #f5d98a; color: #7a5200; }
.alert-error   { background: #ffe0de; border-color: #f5b8b5; color: #8a1a15; }
.alert-info    { background: #dbeeff; border-color: #b8d9f5; color: #1a5f8a; }

/* -- Modals -------------------------------------------------- */
.modal-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(15,23,42,0.45);
  backdrop-filter: blur(2px);
  z-index: 200;
  align-items: center;
  justify-content: center;
  padding: 20px;
}

.modal-overlay.active,
.modal-overlay.open,
.modal-overlay[style*="display: flex"],
.modal-overlay[style*="display:flex"] {
  display: flex !important;
}

.modal-backdrop {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(15,23,42,0.45);
  backdrop-filter: blur(2px);
  z-index: 200;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
}

.modal-backdrop.active,
.modal-backdrop.show,
.modal-backdrop[style*="display: flex"],
.modal-backdrop[style*="display:flex"] {
  display: flex !important;
}

.modal {
  background: var(--bg-card);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg), 0 0 0 1px rgba(0,0,0,0.05);
  width: 100%;
  max-width: 560px;
  max-height: 90vh;
  display: flex;
  flex-direction: column;
}

.modal-lg { max-width: 780px; }
.modal-xl { max-width: 1000px; }

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

.modal-title {
  font-size: 15px;
  font-weight: 600;
  color: var(--text-primary);
}

.modal-close {
  width: 28px;
  height: 28px;
  border-radius: 6px;
  border: none;
  background: none;
  cursor: pointer;
  color: var(--text-muted);
  font-size: 18px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.15s;
}

.modal-close:hover { background: var(--border-light); color: var(--text-primary); }

.modal-body {
  padding: 18px 20px;
  overflow-y: auto;
  flex: 1;
}

.modal-footer {
  padding: 12px 20px;
  border-top: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 8px;
  background: var(--bg-card-alt);
  border-radius: 0 0 var(--radius-lg) var(--radius-lg);
}

/* -- Tabs ---------------------------------------------------- */
.tab-bar {
  display: flex;
  border-bottom: 2px solid var(--border);
  margin-bottom: 18px;
  gap: 0;
}

.tab-btn {
  padding: 8px 14px;
  font-size: 13px;
  font-weight: 500;
  color: var(--text-muted);
  border: none;
  background: none;
  cursor: pointer;
  border-bottom: 2px solid transparent;
  margin-bottom: -2px;
  transition: color 0.15s, border-color 0.15s;
}

.tab-btn:hover { color: var(--text-primary); }
.tab-btn.active { color: var(--tsf-blue); border-bottom-color: var(--tsf-blue); font-weight: 600; }

/* -- Page header --------------------------------------------- */
.page-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 20px;
}

.page-title {
  font-size: 20px;
  font-weight: 700;
  color: var(--text-primary);
  letter-spacing: -0.01em;
}

/* -- Utility ------------------------------------------------- */
.text-muted   { color: var(--text-muted); }
.text-blue    { color: var(--tsf-blue); }
.text-success { color: var(--accent-green); }
.text-danger  { color: var(--accent-red); }
.text-warning { color: var(--accent-amber); }
.text-sm  { font-size: 12px; }
.text-xs  { font-size: 11px; }
.fw-500 { font-weight: 500; }
.fw-600 { font-weight: 600; }
.fw-700 { font-weight: 700; }
.d-flex { display: flex; }
.align-center { align-items: center; }
.justify-between { justify-content: space-between; }
.gap-8  { gap: 8px; }
.gap-12 { gap: 12px; }
.gap-16 { gap: 16px; }
.mt-8   { margin-top: 8px; }
.mt-16  { margin-top: 16px; }
.mt-24  { margin-top: 24px; }
.mb-8   { margin-bottom: 8px; }
.mb-16  { margin-bottom: 16px; }
.mb-24  { margin-bottom: 24px; }

.divider { height: 1px; background: var(--border); margin: 14px 0; }

.empty-state {
  text-align: center;
  padding: 40px 20px;
  color: var(--text-muted);
}

.empty-state-icon { font-size: 32px; margin-bottom: 10px; opacity: 0.4; }
.empty-state-text { font-size: 14px; font-weight: 500; color: var(--text-secondary); }
.empty-state-sub  { font-size: 12.5px; color: var(--text-muted); margin-top: 4px; }

/* Font mono for ticket numbers etc */
.mono { font-family: var(--font-mono); font-size: 12px; }

/* Scrollbar */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: #c5d0de; border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: #a0aec0; }

/* -- Schedule ------------------------------------------------ */
.section-label {
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.10em;
  text-transform: uppercase;
  color: var(--text-muted);
  padding: 18px 0 8px;
  border-bottom: 2px solid #c8d0dc;
  margin-bottom: 12px;
}

/* Each job row becomes its own lifted card */
.card-row {
  background: #fff;
  border: 1px solid #d0d7e2;
  border-radius: var(--radius-md);
  box-shadow: 0 2px 6px rgba(0,0,0,0.06);
  padding: 14px 16px;
  margin-bottom: 10px;
  display: flex;
  align-items: flex-start;
  gap: 14px;
  transition: box-shadow 0.15s;
}

.card-row:hover {
  box-shadow: 0 4px 14px rgba(0,0,0,0.10);
}

/* Remove the outer card wrapper's border when it contains job rows */
.card:has(.card-row) {
  background: transparent;
  border: none;
  box-shadow: none;
  padding: 0;
}

/* Job title */
.card-row > div:first-child > div:first-child span[style*="font-weight:600"],
.card-row [style*="font-weight:600"]:first-child {
  font-size: 14px;
  color: #0f1923;
}

/* Date header grouping */
.history-job-row {
  border-left: 3px solid var(--tsf-blue);
}

.history-job-row[data-type="service"]  { border-left-color: var(--accent-amber); }
.history-job-row[data-type="survey"]   { border-left-color: var(--accent-purple); }
.history-job-row[data-type="followup"] { border-left-color: var(--accent-teal); }
.history-job-row[data-type="roughin"]  { border-left-color: var(--accent-green); }
.history-job-row[data-type="trimout"]  { border-left-color: var(--accent-red); }

/* Pills / badges used in schedule */
.pill {
  display: inline-flex;
  align-items: center;
  padding: 2px 8px;
  border-radius: 20px;
  font-size: 11px;
  font-weight: 600;
  white-space: nowrap;
}

.pill-blue   { background: #dbeeff; color: #1a6fa0; }
.pill-green  { background: #d4f5e3; color: #1a7a45; }
.pill-gold   { background: #fff3d6; color: #a06c00; }
.pill-orange { background: #ffe8d6; color: #a04010; }
.pill-gray   { background: #edf2f7; color: #4a5568; }
.pill-red    { background: #ffe0de; color: #b0281a; }

/* Empty state in schedule */
.empty {
  text-align: center;
  padding: 36px 20px;
  color: var(--text-muted);
}

.empty-icon {
  font-size: 30px;
  margin-bottom: 10px;
  opacity: 0.4;
}

/* Flex layout helpers used in schedule */
.flex-between {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
}

/* -- Flight Control overrides -------------------------------- */
/* Flight control uses dark cards with its own inline styles   normalize */
.fc-card, .flight-card, [class*="fc-"] {
  border-radius: var(--radius-sm) !important;
  box-shadow: 0 2px 6px rgba(0,0,0,0.15) !important;
}

/* Ensure delete/danger icon buttons in schedules aren't too jarring */
button[style*="background:#e74"], 
button[style*="background: #e74"],
button[style*="background:red"],
button[style*="background:#dc"] {
  background: #fff0f0 !important;
  color: #c0392b !important;
  border: 1px solid #f5b8b5 !important;
}

button[style*="background:#e74"]:hover,
button[style*="background: #e74"]:hover,
button[style*="background:red"]:hover,
button[style*="background:#dc"]:hover {
  background: #e74c3c !important;
  color: #fff !important;
}

/* -- Flight Control light theme overrides -------------------- */
#fc-wrap {
  --ts-navy-2:   #ffffff;
  --ts-navy-3:   #f4f6f9;
  --text:        #0f1923;
  --text2:       #2d3748;
  --text3:       #64748b;
  --border:      #c8d0dc;
  --border2:     #c8d0dc;
}

#fc-wrap .fc-bcard,
#fc-wrap .fc-today-strip,
#fc-wrap .fc-lane,
#fc-wrap .fc-card,
#fc-wrap .fc-stat,
#fc-wrap .fc-add-row {
  background: #ffffff !important;
  border-color: #c8d0dc !important;
  box-shadow: 0 2px 6px rgba(0,0,0,0.06);
}

#fc-wrap .fc-card {
  background: #f8fafc !important;
}

#fc-wrap .fc-card:hover {
  background: #ffffff !important;
  border-color: var(--tsf-blue) !important;
  box-shadow: 0 4px 12px rgba(0,0,0,0.10) !important;
}

#fc-wrap .fc-lane {
  background: #f0f3f7 !important;
}

#fc-wrap .fc-bval { color: #0f1923 !important; }
#fc-wrap .fc-card-title { color: #0f1923 !important; }
#fc-wrap .fc-tj-title { color: #0f1923 !important; }
#fc-wrap .fc-lane-badge { background: #e8ecf2 !important; }
#fc-wrap .fc-fbtn.active { background: #dbeeff !important; color: var(--tsf-blue) !important; }
#fc-wrap .fc-add-input { background: #ffffff !important; color: #0f1923 !important; border-color: #c8d0dc !important; }

#fc-wrap .fc-chip.it  { background: #dbeeff !important; color: #1a6fa0 !important; border-color: #b8d9f5 !important; }
#fc-wrap .fc-chip.biz { background: #fff3d6 !important; color: #a06c00 !important; border-color: #f5d98a !important; }
#fc-wrap .fc-chip.lv  { background: #d4f5e3 !important; color: #1a7a45 !important; border-color: #a8e6c2 !important; }
#fc-wrap .fc-chip.ca  { background: #eae8fd !important; color: #5147c7 !important; border-color: #c4b5fd !important; }
#fc-wrap .fc-chip.tx  { background: #ffe0de !important; color: #b0281a !important; border-color: #f5b8b5 !important; }
#fc-wrap .fc-chip.urg { background: #ffe0de !important; color: #b0281a !important; border-color: #f5b8b5 !important; }

/* -- Responsive ---------------------------------------------- */
@media (max-width: 900px) {
  /* Hide sidebar off-screen by default on mobile */
  .sidebar {
    transform: translateX(-100%);
    position: fixed;
    z-index: 200;
    width: 260px;
  }

  .sidebar.open {
    transform: translateX(0);
    box-shadow: 4px 0 20px rgba(0,0,0,0.3);
  }

  /* Show overlay when sidebar open */
  .sidebar-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.5);
    z-index: 199;
  }

  .sidebar-overlay.open {
    display: block;
  }

  /* Show mobile top bar */
  .mobile-bar {
    display: flex;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    height: 52px;
    background: var(--sidebar-bg);
    z-index: 101;
    align-items: center;
    justify-content: space-between;
    padding: 0 16px;
    border-bottom: 1px solid var(--sidebar-border);
  }

  /* Main content takes full width, pushed down for mobile bar */
  .main-wrap {
    margin-left: 0;
    padding: 64px 14px 20px;
    width: 100%;
  }

  /* Stat grid 2 columns on mobile */
  .stat-grid {
    grid-template-columns: repeat(2, 1fr);
    gap: 10px;
  }

  /* User grid on login   1 column on small screens */
  .user-grid {
    grid-template-columns: 1fr;
    max-width: 360px;
  }

  /* Login push up on mobile */
  .login-wrap {
    justify-content: flex-start;
    padding-top: 48px;
  }

  /* Tables scroll horizontally */
  table {
    display: block;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
  }

  /* Card rows stack better */
  .card-row {
    flex-direction: column;
    gap: 10px;
  }

  .card-row > div:last-child {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
  }

  /* Page title smaller */
  .page-title {
    font-size: 17px;
  }

  /* Modals full screen on mobile */
  .modal-overlay {
    align-items: flex-end;
    padding: 0;
  }

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

/* -- Login Page ---------------------------------------------- */
.login-wrap {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 32px 16px;
  background: var(--bg-page);
}

.login-logo {
  margin-bottom: 8px;
}

.login-logo img {
  height: 56px;
  width: auto;
  display: block;
}

.login-subtitle {
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--text-muted);
  margin-bottom: 28px;
}

/* User grid */
.user-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 10px;
  width: 100%;
  max-width: 680px;
}

.user-tile {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 14px;
  background: var(--bg-card);
  border: 1px solid #d0d7e2;
  border-radius: var(--radius-md);
  box-shadow: 0 2px 6px rgba(0,0,0,0.06);
  cursor: pointer;
  transition: box-shadow 0.15s, border-color 0.15s, transform 0.1s;
  font-family: var(--font-body);
}

.user-tile:hover {
  box-shadow: 0 4px 14px rgba(0,0,0,0.12);
  border-color: var(--tsf-blue);
  transform: translateY(-1px);
}

.user-tile:active { transform: translateY(0); }

.manager-tile { border-color: var(--sidebar-accent); }
.manager-tile:hover {
  border-color: var(--sidebar-accent);
  box-shadow: 0 4px 14px rgba(245,166,35,0.2);
}

.user-avatar {
  width: 40px;
  height: 40px;
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 14px;
  font-weight: 700;
  flex-shrink: 0;
}

.user-info { flex: 1; min-width: 0; text-align: left; }

.user-name {
  font-size: 13.5px;
  font-weight: 600;
  color: var(--text-primary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.user-role {
  font-size: 11.5px;
  color: var(--text-muted);
  margin-top: 1px;
}

/* PIN pad */
.pin-wrap {
  display: flex;
  flex-direction: column;
  align-items: center;
  width: 100%;
  max-width: 320px;
}

.pin-title {
  font-size: 20px;
  font-weight: 700;
  color: var(--text-primary);
  margin-bottom: 4px;
}

.pin-sub {
  font-size: 13px;
  color: var(--text-muted);
  margin-bottom: 20px;
}

.pin-error-msg {
  font-size: 12.5px;
  color: var(--accent-red);
  background: #ffe0de;
  border: 1px solid #f5b8b5;
  border-radius: var(--radius-sm);
  padding: 6px 14px;
  margin-bottom: 14px;
}

.pin-dots {
  display: flex;
  gap: 14px;
  margin-bottom: 24px;
}

.pin-dot {
  width: 14px;
  height: 14px;
  border-radius: 50%;
  border: 2px solid #c8d0dc;
  background: transparent;
  transition: background 0.15s, border-color 0.15s;
}

.pin-dot.filled { background: var(--tsf-blue); border-color: var(--tsf-blue); }
.pin-dot.error  { background: var(--accent-red); border-color: var(--accent-red); }

.pin-grid {
  display: grid;
  grid-template-columns: repeat(3, 72px);
  gap: 10px;
  margin-bottom: 20px;
}

.pin-key {
  width: 72px;
  height: 72px;
  border-radius: 50%;
  border: 1px solid #d0d7e2;
  background: var(--bg-card);
  box-shadow: 0 2px 6px rgba(0,0,0,0.07);
  font-family: var(--font-body);
  font-size: 22px;
  font-weight: 500;
  color: var(--text-primary);
  cursor: pointer;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  line-height: 1;
  transition: background 0.12s, box-shadow 0.12s, transform 0.1s;
}

.pin-key:hover {
  background: var(--tsf-blue-light);
  border-color: var(--tsf-blue);
  box-shadow: 0 4px 10px rgba(42,143,196,0.15);
}

.pin-key:active {
  transform: scale(0.94);
  background: var(--tsf-blue);
  color: #fff;
}

.pin-key-sub {
  font-size: 8px;
  letter-spacing: 0.12em;
  color: var(--text-muted);
  margin-top: 2px;
  font-weight: 600;
}

.pin-back {
  font-size: 13px;
  color: var(--tsf-blue);
  background: none;
  border: none;
  cursor: pointer;
  padding: 6px 12px;
  border-radius: var(--radius-sm);
  font-family: var(--font-body);
  transition: background 0.12s;
  margin-bottom: 8px;
}

.pin-back:hover { background: var(--tsf-blue-light); }

.pin-hint {
  font-size: 11.5px;
  color: var(--text-muted);
  text-align: center;
}



/* -- Accordion Nav ------------------------------------------- */
.nav-group-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 7px 14px;
  cursor: pointer;
  user-select: none;
  transition: background 0.15s;
}

.nav-group-header:hover {
  background: var(--sidebar-hover);
}

.nav-group-header.open {
  background: var(--sidebar-hover);
}

.nav-group-label {
  font-size: 10.5px;
  font-weight: 700;
  letter-spacing: 0.10em;
  text-transform: uppercase;
  color: var(--sidebar-muted);
  transition: color 0.15s;
}

.nav-group-header:hover .nav-group-label,
.nav-group-header.open .nav-group-label {
  color: var(--sidebar-text);
}

.nav-group-header.has-active .nav-group-label {
  color: var(--sidebar-text);
}

.nav-chevron {
  font-size: 14px;
  color: var(--sidebar-muted);
  transform: rotate(0deg);
  transition: transform 0.2s ease, color 0.15s;
  line-height: 1;
}

.nav-group-header.open .nav-chevron {
  transform: rotate(90deg);
  color: var(--sidebar-text);
}

.nav-group-body {
  overflow: hidden;
  max-height: 0;
  transition: max-height 0.25s ease;
}

.nav-group-body.open {
  max-height: 400px;
}

.sidebar-link-child {
  padding-left: 22px;
  font-size: 12.5px;
}

/* -- Dark Theme ------------------------------------------------ */
[data-theme="dark"] {
  --bg-page:         #111827;
  --bg-card:         #1a2535;
  --bg-card-alt:     #1e2d42;
  --border:          #2a3d58;
  --border-light:    #233452;
  --text-primary:    #e2eaf5;
  --text-secondary:  #c0d0e5;
  --text-muted:      #6e8aab;
  --shadow-sm:       0 1px 3px rgba(0,0,0,0.30), 0 1px 2px rgba(0,0,0,0.20);
  --shadow-md:       0 4px 12px rgba(0,0,0,0.35), 0 2px 4px rgba(0,0,0,0.20);
  --shadow-lg:       0 10px 30px rgba(0,0,0,0.45);
  /* Legacy aliases */
  --ts-navy-2:       #1a2535;
  --ts-navy-3:       #1e2d42;
  --text:            #e2eaf5;
  --text2:           #c0d0e5;
  --text3:           #6e8aab;
  --border2:         #2a3d58;
  --bg:              #111827;
  --bg2:             #1a2535;
  --bg3:             #1e2d42;
  --white:           #1a2535;
  --blue-bg:         #0d2138;
  --blue-border:     #1a3d5c;
  --green-bg:        #0a2318;
  --green-border:    #1a4a2e;
  --gold-border:     #4a3a00;
}

[data-theme="dark"] body { background: var(--bg-page); color: var(--text-primary); }

[data-theme="dark"] .card,
[data-theme="dark"] .stat-card,
[data-theme="dark"] .table-wrap,
[data-theme="dark"] .card-row {
  background: var(--bg-card);
  border-color: var(--border);
}

[data-theme="dark"] thead th { background: var(--bg-card-alt); color: var(--text-muted); border-bottom-color: var(--border); }
[data-theme="dark"] tbody tr:hover { background: rgba(42,143,196,0.08); }
[data-theme="dark"] tbody td { color: var(--text-primary); }
[data-theme="dark"] tbody tr { border-bottom-color: var(--border-light); }

[data-theme="dark"] input,
[data-theme="dark"] select,
[data-theme="dark"] textarea {
  background: var(--bg-card-alt);
  border-color: var(--border);
  color: var(--text-primary);
}

[data-theme="dark"] .btn-secondary { background: var(--bg-card-alt); border-color: var(--border); color: var(--text-secondary); }
[data-theme="dark"] .btn-ghost { border-color: var(--border); color: var(--text-muted); }
[data-theme="dark"] .modal { background: var(--bg-card); }
[data-theme="dark"] .modal-footer { background: var(--bg-card-alt); }
[data-theme="dark"] .modal-header { border-bottom-color: var(--border); }

/* -- Theme Toggle Button --------------------------------------- */
.theme-toggle {
  width: 28px;
  height: 28px;
  border-radius: 6px;
  border: none;
  background: none;
  cursor: pointer;
  color: var(--sidebar-muted);
  font-size: 15px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.15s, color 0.15s;
  flex-shrink: 0;
}
.theme-toggle:hover { background: var(--sidebar-hover); color: var(--sidebar-text); }

/* -- Mobile force overrides (must be last) ------------------- */
@media (max-width: 900px) {
  .sidebar {
    transform: translateX(-100%) !important;
    z-index: 300 !important;
  }
  .sidebar.open {
    transform: translateX(0) !important;
  }
  .main-wrap {
    margin-left: 0 !important;
    padding-top: 64px !important;
  }
  .mobile-bar {
    display: flex !important;
    z-index: 299 !important;
  }
}