:root {
  --primary: #16221d;
  --primary-light: #23342d;
  --primary-dark: #0d1512;
  --accent-gold: #c88a2c;
  --accent-gold-hover: #b37822;
  --accent-gold-light: #fdf6ec;
  --bg-page: #f8faf9;
  --surface: #ffffff;
  --border: #e2e8f0;
  --border-dark: #cbd5e1;
  --text-main: #1e293b;
  --text-muted: #64748b;
  --text-light: #94a3b8;
  --success: #16a34a;
  --warning: #d97706;
  --info: #0284c7;
  --danger: #dc2626;
  --radius: 8px;
  --shadow-sm: 0 1px 2px rgba(0,0,0,0.05);
  --shadow: 0 4px 6px -1px rgba(0,0,0,0.08), 0 2px 4px -2px rgba(0,0,0,0.04);
  --shadow-lg: 0 10px 15px -3px rgba(0,0,0,0.09), 0 4px 6px -4px rgba(0,0,0,0.04);
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html, body {
  max-width: 100vw;
  overflow-x: hidden;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  background-color: var(--bg-page);
  color: var(--text-main);
  line-height: 1.5;
  font-size: 14px;
  width: 100%;
}

/* ==================================================== */
/* TOP APP HEADER & NAVIGATION                         */
/* ==================================================== */
.app-header {
  background-color: var(--primary);
  color: #fff;
  padding: 8px 20px;
  border-bottom: 3px solid var(--accent-gold);
  position: sticky;
  top: 0;
  z-index: 50;
  box-shadow: 0 2px 10px rgba(0,0,0,0.2);
  width: 100%;
  max-width: 100vw;
  box-sizing: border-box;
}

.header-container {
  max-width: 1600px;
  margin: 0 auto;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 16px;
  width: 100%;
}

.brand {
  order: 1;
  display: flex;
  align-items: center;
  gap: 12px;
  flex-shrink: 0;
}

.brand img {
  height: 40px;
  object-fit: contain;
}

.brand-name {
  font-size: 1.15rem;
  font-weight: 700;
  color: #fff;
  letter-spacing: 0.5px;
  line-height: 1.2;
}

.brand-tag {
  font-size: 0.7rem;
  color: var(--accent-gold);
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.8px;
}

/* Nav Tabs */
.nav-tabs {
  order: 2;
  display: flex;
  align-items: center;
  gap: 4px;
  flex-shrink: 0;
}

.tab-label-short {
  display: none;
}

.tab-label-full {
  display: inline;
}

.nav-tab {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 8px 12px;
  font-size: 13px;
  font-weight: 600;
  color: #94a3b8;
  background: transparent;
  border: none;
  border-radius: 6px;
  cursor: pointer;
  transition: all 0.15s ease;
  white-space: nowrap;
}

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

.nav-tab:hover {
  color: #fff;
  background-color: rgba(255, 255, 255, 0.08);
}

.nav-tab.active {
  color: #fff;
  background-color: #243830;
  box-shadow: inset 0 -2px 0 var(--accent-gold);
}

.nav-badge {
  background-color: var(--accent-gold);
  color: #16221d;
  font-size: 10.5px;
  font-weight: 800;
  padding: 1px 6px;
  border-radius: 10px;
}

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

/* View Panels Switching */
.view-panel {
  display: none;
  animation: viewFadeIn 0.18s ease;
}

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

@keyframes viewFadeIn {
  from { opacity: 0; transform: translateY(3px); }
  to { opacity: 1; transform: translateY(0); }
}

/* ==================================================== */
/* BUTTONS & BADGES                                     */
/* ==================================================== */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 14px;
  font-size: 13px;
  font-weight: 600;
  border-radius: var(--radius);
  border: 1px solid transparent;
  cursor: pointer;
  transition: all 0.15s ease;
  text-decoration: none;
  white-space: nowrap;
}

.btn-sm {
  padding: 6px 10px;
  font-size: 12px;
}

.btn-block {
  width: 100%;
  justify-content: center;
}

.btn-primary {
  background-color: var(--accent-gold);
  color: #16221d;
  border-color: var(--accent-gold);
}
.btn-primary:hover {
  background-color: var(--accent-gold-hover);
  border-color: var(--accent-gold-hover);
}

.btn-accent {
  background-color: #15803d;
  color: #fff;
}
.btn-accent:hover {
  background-color: #166534;
}

.btn-secondary {
  background-color: #f1f5f9;
  color: var(--text-main);
  border-color: var(--border-dark);
}
.btn-secondary:hover {
  background-color: #e2e8f0;
}

.btn-dark {
  background-color: #243830;
  color: #fff;
  border-color: #243830;
}
.btn-dark:hover {
  background-color: #2e473e;
}

.btn-outline {
  background-color: transparent;
  color: #cbd5e1;
  border-color: #475569;
}
.btn-outline:hover {
  background-color: rgba(255,255,255,0.1);
  color: #fff;
}

.btn-danger {
  background-color: #fee2e2;
  color: var(--danger);
  border-color: #fca5a5;
}
.btn-danger:hover {
  background-color: #fecaca;
}

.btn-group {
  display: inline-flex;
  border-radius: var(--radius);
  overflow: hidden;
}
.btn-group .btn {
  border-radius: 0;
  border-right: 1px solid rgba(255,255,255,0.15);
}
.btn-group .btn:last-child {
  border-right: none;
}

/* Badges */
.badge {
  display: inline-flex;
  align-items: center;
  padding: 3px 8px;
  border-radius: 12px;
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
}

.badge-draft { background-color: #e2e8f0; color: #475569; }
.badge-sent { background-color: #dbeafe; color: #1d4ed8; }
.badge-scheduled { background-color: #e0e7ff; color: #4338ca; }
.badge-inprogress { background-color: #fef3c7; color: #b45309; }
.badge-approved { background-color: #dcfce7; color: #15803d; }
.badge-completed { background-color: #dcfce7; color: #15803d; }
.badge-invoiced { background-color: #f3e8ff; color: #7e22ce; }
.badge-paid { background-color: #dcfce7; color: #15803d; }

.priority-tag {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 2px 7px;
  border-radius: 4px;
  font-size: 10.5px;
  font-weight: 700;
  text-transform: uppercase;
}
.priority-normal { background: #e0f2fe; color: #0369a1; }
.priority-high { background: #fef3c7; color: #b45309; }
.priority-emergency { background: #fee2e2; color: #b91c1c; }

/* ==================================================== */
/* LAYOUTS & CARDS                                      */
/* ==================================================== */
.main-wrapper {
  max-width: 1480px;
  margin: 20px auto;
  padding: 0 20px;
  display: grid;
  grid-template-columns: 1fr 340px;
  gap: 20px;
}

.card {
  background: var(--surface);
  border-radius: var(--radius);
  border: 1px solid var(--border);
  box-shadow: var(--shadow);
  margin-bottom: 20px;
  overflow: hidden;
}

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

.card-header h3 {
  font-size: 14.5px;
  font-weight: 700;
  color: var(--primary);
  display: flex;
  align-items: center;
  gap: 8px;
}

.card-header h3 i { width: 18px; height: 18px; }

.card-body { padding: 18px; }
.card-body.p-0 { padding: 0; }

.section-divider-title {
  font-size: 12px;
  font-weight: 800;
  text-transform: uppercase;
  color: var(--primary);
  letter-spacing: 0.5px;
  border-bottom: 1px solid var(--border);
  padding-bottom: 6px;
  margin: 18px 0 12px 0;
  display: flex;
  align-items: center;
  gap: 6px;
}

/* Forms */
.form-row {
  display: flex;
  gap: 14px;
  margin-bottom: 14px;
}

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

.form-group label {
  font-size: 12px;
  font-weight: 600;
  color: var(--text-main);
}

.form-input,
.form-select,
.form-textarea {
  padding: 8px 10px;
  border: 1px solid var(--border);
  border-radius: 5px;
  font-size: 13px;
  font-family: inherit;
  background-color: #fff;
  transition: all 0.15s ease;
}

.form-input:focus,
.form-select:focus,
.form-textarea:focus {
  outline: none;
  border-color: var(--accent-gold);
  box-shadow: 0 0 0 2px rgba(200, 138, 44, 0.18);
}

.form-select-sm {
  padding: 5px 8px;
  font-size: 12px;
}

.checkbox-label {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  font-size: 12.5px;
  cursor: pointer;
}

/* ==================================================== */
/* CALCULATOR TABLES & SIDEBAR                          */
/* ==================================================== */
.calc-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}

.calc-table th {
  background-color: #f1f5f9;
  text-align: left;
  padding: 9px 12px;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--text-muted);
  border-bottom: 1px solid var(--border-dark);
}

.calc-table td {
  padding: 8px 12px;
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
}

.calc-table tr:hover td { background-color: #fafbfc; }

.calc-table .subheading-row td {
  background-color: #f8fafc;
  font-weight: 700;
  color: var(--primary);
  font-size: 12px;
  padding-top: 12px;
  padding-bottom: 6px;
  border-top: 1px solid var(--border);
}

.calc-table .subtotal-row td {
  background-color: #f1f5f9;
  font-weight: 700;
  color: var(--text-main);
}

.cell-num { text-align: right; }

.table-input {
  width: 100%;
  max-width: 105px;
  padding: 5px 8px;
  font-size: 12.5px;
  text-align: right;
  border: 1px solid var(--border);
  border-radius: 4px;
}

.table-note { font-size: 11px; color: var(--text-muted); font-style: italic; }
.tag-calc { font-size: 11px; color: var(--accent-gold-hover); font-weight: 600; }

/* Sticky Sidebar */
.sticky-sidebar {
  position: sticky;
  top: 76px;
}

.summary-card {
  background: #ffffff;
  border: 2px solid var(--primary);
  border-radius: var(--radius);
  box-shadow: var(--shadow-lg);
  overflow: hidden;
}

.summary-header {
  background: var(--primary);
  color: #fff;
  padding: 14px 18px;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.summary-header h4 { font-size: 15px; font-weight: 700; color: #fff; }
.summary-body { padding: 16px; }

.summary-line {
  display: flex;
  justify-content: space-between;
  padding: 5px 0;
  font-size: 13px;
  color: #475569;
}
.summary-line.bold { font-weight: 700; color: var(--text-main); }
.summary-line.highlight {
  font-size: 14px;
  font-weight: 700;
  color: var(--primary);
  border-top: 1px dashed var(--border);
  padding-top: 8px;
  margin-top: 4px;
}

.summary-grand-total {
  background-color: #f8fafc;
  border: 2px solid var(--accent-gold);
  border-radius: 6px;
  padding: 12px;
  margin-top: 14px;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.grand-label {
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
  color: var(--primary);
}

.grand-amount {
  font-size: 20px;
  font-weight: 800;
  color: var(--accent-gold-hover);
}

.sidebar-actions {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-top: 16px;
}

/* ==================================================== */
/* WORK ORDERS VIEW LAYOUT                              */
/* ==================================================== */
.wo-layout {
  max-width: 1480px;
  margin: 20px auto;
  padding: 0 20px;
  display: grid;
  grid-template-columns: 360px 1fr;
  gap: 20px;
  align-items: start;
}

.wo-list-panel {
  background: #fff;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  overflow: hidden;
  height: calc(100vh - 120px);
  display: flex;
  flex-direction: column;
}

.wo-list-header {
  padding: 14px 16px;
  background-color: #fafbfc;
  border-bottom: 1px solid var(--border);
}

.search-box {
  position: relative;
  display: flex;
  align-items: center;
}
.search-box i {
  position: absolute;
  left: 10px;
}
.search-box input {
  width: 100%;
  padding: 7px 10px 7px 32px;
  border: 1px solid var(--border);
  border-radius: 6px;
  font-size: 12.5px;
}

.filter-chips {
  display: flex;
  gap: 6px;
  margin-top: 10px;
  overflow-x: auto;
}

.filter-chip {
  padding: 4px 10px;
  font-size: 11px;
  font-weight: 600;
  border-radius: 12px;
  border: 1px solid var(--border);
  background: #fff;
  cursor: pointer;
  white-space: nowrap;
}
.filter-chip.active {
  background-color: var(--primary);
  color: #fff;
  border-color: var(--primary);
}

.wo-list-items {
  flex: 1;
  overflow-y: auto;
  padding: 10px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.wo-card {
  padding: 12px;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: #fff;
  cursor: pointer;
  transition: all 0.15s ease;
}
.wo-card:hover {
  border-color: var(--accent-gold);
  background: #fafbfc;
}
.wo-card.active {
  border-color: var(--accent-gold);
  background-color: #fdfbf7;
  box-shadow: 0 0 0 1px var(--accent-gold);
}

.wo-card-top {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 6px;
}
.wo-card-num {
  font-size: 13.5px;
  font-weight: 700;
  color: var(--primary);
}
.wo-card-client {
  font-size: 13px;
  font-weight: 600;
  color: var(--text-main);
  margin-bottom: 3px;
}
.wo-card-address {
  font-size: 11.5px;
  color: var(--text-muted);
  margin-bottom: 6px;
}
.wo-card-footer {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 11px;
  color: var(--text-muted);
  border-top: 1px solid #f1f5f9;
  padding-top: 6px;
  margin-top: 6px;
}

/* Right Editor Panel */
.wo-editor-card {
  background: #fff;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  overflow: hidden;
}

.wo-editor-header {
  padding: 16px 20px;
  background: #fafbfc;
  border-bottom: 1px solid var(--border);
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 12px;
}

.wo-header-actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.wo-editor-body {
  padding: 22px;
}

.tech-checkbox-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
  gap: 8px;
  padding: 10px;
  background: #f8fafc;
  border: 1px solid var(--border);
  border-radius: 6px;
}

/* Field Level Risk Assessment (FLRA) */
.flra-container {
  background: #f8fafc;
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 16px;
  margin-bottom: 20px;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.flra-block {
  background: #ffffff;
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 14px;
}

.flra-block-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 12px;
  padding-bottom: 8px;
  border-bottom: 1px solid #f1f5f9;
  flex-wrap: wrap;
  gap: 6px;
}

.flra-title {
  font-size: 13px;
  font-weight: 700;
  color: var(--primary);
  display: flex;
  align-items: center;
  gap: 6px;
}

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

.flra-checkbox-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(210px, 1fr));
  gap: 8px;
}

.flra-check-label {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 7px 10px;
  background: #f8fafc;
  border: 1px solid #e2e8f0;
  border-radius: 5px;
  font-size: 12px;
  color: #334155;
  cursor: pointer;
  transition: all 0.15s ease;
  user-select: none;
}

.flra-check-label:hover {
  background: #f1f5f9;
  border-color: #cbd5e1;
}

.flra-check-label input[type="checkbox"] {
  accent-color: var(--primary);
  width: 15px;
  height: 15px;
  cursor: pointer;
  margin: 0;
}

.flra-check-label.checked {
  background: #eff6ff;
  border-color: #93c5fd;
  color: #1e40af;
  font-weight: 600;
}

.flra-table-wrapper {
  overflow-x: auto;
}

.flra-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 12.5px;
}

.flra-table th {
  background: #f1f5f9;
  color: #475569;
  font-weight: 700;
  padding: 8px 10px;
  border: 1px solid #e2e8f0;
  text-align: left;
  font-size: 11px;
  text-transform: uppercase;
}

.flra-table td {
  padding: 6px 8px;
  border: 1px solid #e2e8f0;
  vertical-align: middle;
}

.flra-table .row-num {
  text-align: center;
  font-weight: 700;
  color: var(--primary);
  background: #f8fafc;
  width: 32px;
}

.flra-table input.form-input {
  width: 100%;
  padding: 7px 10px;
  font-size: 12.5px;
  border: 1px solid #cbd5e1;
  border-radius: 4px;
}

.flra-table input.form-input:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 2px rgba(22, 34, 29, 0.1);
  outline: none;
}

/* ==================================================== */
/* INTERACTIVE CALENDAR                                 */
/* ==================================================== */
.calendar-wrapper {
  max-width: 1480px;
  margin: 20px auto;
  padding: 0 20px;
}

.cal-controls-bar {
  background: #fff;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
  padding: 12px 18px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 16px;
  flex-wrap: wrap;
  gap: 12px;
}

.cal-nav-group {
  display: flex;
  align-items: center;
  gap: 12px;
}
.cal-title {
  font-size: 18px;
  font-weight: 800;
  color: var(--primary);
  margin-left: 6px;
}

.cal-filter-group {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
}
.cal-filter-item {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  font-weight: 600;
  color: var(--text-muted);
}

.calendar-grid-container {
  background: #fff;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  overflow: hidden;
}

.cal-day-header-row {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  background: #f1f5f9;
  border-bottom: 1px solid var(--border);
  text-align: center;
  font-size: 12px;
  font-weight: 700;
  color: var(--text-muted);
  text-transform: uppercase;
}
.cal-day-header-row div {
  padding: 10px 4px;
  border-right: 1px solid var(--border);
}
.cal-day-header-row div:last-child { border-right: none; }

.cal-days-grid {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
}

.cal-day-cell {
  min-height: 120px;
  border-right: 1px solid var(--border);
  border-bottom: 1px solid var(--border);
  padding: 6px;
  background: #fff;
  transition: background 0.15s ease;
  position: relative;
  cursor: pointer;
}
.cal-day-cell:nth-child(7n) { border-right: none; }
.cal-day-cell:hover { background-color: #fafbfc; }
.cal-day-cell.other-month {
  background-color: #f8fafc;
  opacity: 0.6;
}
.cal-day-cell.today {
  background-color: #fefcf6;
}

.cal-day-num {
  font-size: 12px;
  font-weight: 700;
  color: var(--text-muted);
  display: inline-block;
  width: 24px;
  height: 24px;
  line-height: 24px;
  text-align: center;
  border-radius: 50%;
  margin-bottom: 4px;
}
.cal-day-cell.today .cal-day-num {
  background-color: var(--accent-gold);
  color: #fff;
}

.cal-events-wrap {
  display: flex;
  flex-direction: column;
  gap: 3px;
  max-height: 90px;
  overflow-y: auto;
}

.cal-event-pill {
  font-size: 10.5px;
  font-weight: 600;
  padding: 3px 6px;
  border-radius: 4px;
  color: #fff;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 4px;
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.7);
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.15);
  transition: transform 0.1s ease, filter 0.1s ease;
}
.cal-event-pill:hover {
  filter: brightness(1.1);
  transform: translateY(-1px);
}

.cal-tech-dots {
  display: inline-flex;
  align-items: center;
  gap: 2px;
  margin-right: 2px;
  flex-shrink: 0;
}

.tech-color-dot {
  display: inline-block;
  width: 7px;
  height: 7px;
  border-radius: 50%;
  border: 1px solid rgba(255, 255, 255, 0.9);
  box-shadow: 0 0.5px 1.5px rgba(0, 0, 0, 0.4);
  flex-shrink: 0;
}

.tech-badge-pill {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 2px 8px;
  border-radius: 12px;
  font-size: 11.5px;
  font-weight: 700;
  color: #ffffff;
  text-shadow: 0 1px 1px rgba(0, 0, 0, 0.5);
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.1);
}

/* Alternate calendar view (Week / Agenda) */
.calendar-alternate-view {
  background: #fff;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
}

.agenda-item-card {
  padding: 14px 16px;
  border: 1px solid var(--border);
  border-radius: 6px;
  margin-bottom: 10px;
  background: #fff;
  display: flex;
  justify-content: space-between;
  align-items: center;
  border-left-width: 6px !important;
  transition: all 0.15s ease;
}
.agenda-item-card:hover {
  border-color: var(--accent-gold);
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.06);
}

.color-picker-input {
  height: 38px;
  padding: 2px 4px;
  cursor: pointer;
  border-radius: 4px;
}

.roster-color-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  cursor: pointer;
  border: 2px solid #ffffff;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.25);
  position: relative;
  overflow: hidden;
  flex-shrink: 0;
}
.roster-color-badge input[type="color"] {
  position: absolute;
  top: -10px;
  left: -10px;
  width: 40px;
  height: 40px;
  opacity: 0;
  cursor: pointer;
}

/* ==================================================== */
/* RECORDS & SETTINGS                                   */
/* ==================================================== */
.records-container,
.settings-page-wrapper {
  max-width: 1480px;
  margin: 20px auto;
  padding: 0 20px;
}

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

.records-tab-bar {
  display: flex;
  gap: 6px;
  border-bottom: 1px solid var(--border);
  padding-bottom: 6px;
}

.records-type-btn {
  padding: 6px 14px;
  font-size: 12.5px;
  font-weight: 600;
  background: transparent;
  border: 1px solid transparent;
  border-radius: 5px;
  cursor: pointer;
  color: var(--text-muted);
}
.records-type-btn.active {
  background: #fff;
  border-color: var(--border);
  color: var(--primary);
  font-weight: 700;
}

.records-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}
.records-table th {
  text-align: left;
  padding: 10px 12px;
  background: #f1f5f9;
  color: var(--text-muted);
  border-bottom: 1px solid var(--border-dark);
}
.records-table td {
  padding: 10px 12px;
  border-bottom: 1px solid var(--border);
}
.records-table tr:hover td { background: #fafbfc; }

/* Roster List in Settings */
.roster-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 10px;
}

.roster-card {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 10px 14px;
  background: #ffffff;
  border: 1px solid var(--border);
  border-radius: 6px;
  box-shadow: var(--shadow-sm);
  transition: border-color 0.15s ease;
}

.roster-card:hover {
  border-color: #cbd5e1;
}

.roster-card-info {
  display: flex;
  flex-direction: column;
  gap: 3px;
}

.roster-card-name {
  font-size: 13.5px;
  font-weight: 700;
  color: var(--primary);
  display: flex;
  align-items: center;
  gap: 6px;
}

.roster-card-email {
  font-size: 12px;
  color: var(--text-muted);
  display: flex;
  align-items: center;
  gap: 4px;
}

.roster-card-email.has-email {
  color: #2563eb;
  font-weight: 500;
}

.roster-del-btn {
  cursor: pointer;
  color: #94a3b8;
  border: none;
  background: none;
  font-size: 18px;
  line-height: 1;
  padding: 4px 6px;
  border-radius: 4px;
  transition: color 0.15s, background-color 0.15s;
}

.roster-del-btn:hover {
  color: var(--danger);
  background-color: #fee2e2;
}

/* ==================================================== */
/* MODALS                                               */
/* ==================================================== */
.modal-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background-color: rgba(15, 23, 20, 0.65);
  backdrop-filter: blur(2px);
  z-index: 100;
  align-items: center;
  justify-content: center;
  padding: 20px;
}
.modal-overlay.active { display: flex; }

.modal-container {
  background: #ffffff;
  border-radius: var(--radius);
  max-width: 650px;
  width: 100%;
  max-height: 90vh;
  display: flex;
  flex-direction: column;
  box-shadow: var(--shadow-lg);
  overflow: hidden;
  animation: modalFadeIn 0.2s ease;
}

@keyframes modalFadeIn {
  from { opacity: 0; transform: scale(0.97); }
  to { opacity: 1; transform: scale(1); }
}

.modal-header {
  padding: 14px 20px;
  background-color: var(--primary);
  color: #fff;
  display: flex;
  justify-content: space-between;
  align-items: center;
}
.modal-header h3 {
  font-size: 15px;
  font-weight: 700;
  display: flex;
  align-items: center;
  gap: 8px;
}
.close-btn {
  background: none;
  border: none;
  color: #cbd5e1;
  font-size: 22px;
  cursor: pointer;
  line-height: 1;
}
.close-btn:hover { color: #fff; }

.modal-body { padding: 20px; overflow-y: auto; }
.modal-footer {
  padding: 12px 20px;
  background-color: #f8fafc;
  border-top: 1px solid var(--border);
  display: flex;
  justify-content: flex-end;
  gap: 10px;
}

/* ==================================================== */
/* RESPONSIVE BREAKPOINTS (Mobile & Tablets)           */
/* ==================================================== */
@media (max-width: 1024px) {
  .main-wrapper {
    grid-template-columns: 1fr;
  }
  .wo-layout {
    grid-template-columns: 1fr;
  }
  .wo-list-panel {
    height: 380px;
  }
  .sticky-sidebar {
    position: static;
  }
}

@media (max-width: 1150px) {
  .brand-tag { display: none; }
  .nav-tab { padding: 6px 9px; font-size: 12px; gap: 5px; }
  .user-session-badge { padding: 3px 8px 3px 5px; margin-left: 8px; }
}

@media (max-width: 950px) {
  .tab-label-full { display: none; }
  .tab-label-short { display: inline; }
}

@media (max-width: 768px) {
  .hide-mobile { display: none !important; }
  
  .app-header {
    padding: 8px 10px;
    width: 100%;
    max-width: 100vw;
    overflow: hidden;
  }
  
  .header-container {
    display: flex;
    flex-wrap: wrap;
    justify-content: space-between;
    align-items: center;
    row-gap: 8px;
    width: 100%;
    max-width: 100%;
  }
  
  .brand {
    order: 1;
    gap: 8px;
    max-width: calc(100% - 135px);
  }
  
  .brand img {
    height: 32px;
  }
  
  .brand-name {
    font-size: 0.95rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
  }
  
  .brand-tag {
    display: none;
  }
  
  .user-session-badge {
    order: 2;
    margin-left: 0;
    padding: 3px 6px;
    gap: 4px;
  }
  
  .nav-tabs {
    order: 3;
    width: 100%;
    min-width: 0;
    max-width: 100%;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
    display: flex;
    gap: 4px;
    padding: 4px 0 2px 0;
    border-top: 1px solid rgba(255, 255, 255, 0.08);
  }
  
  .nav-tabs::-webkit-scrollbar {
    display: none;
  }
  
  .nav-tab {
    flex-shrink: 0;
    padding: 6px 10px;
    font-size: 12px;
    gap: 5px;
    background: rgba(255, 255, 255, 0.05);
  }
  
  .nav-tab.active {
    background: #243830;
  }
  
  .nav-tab i, .nav-tab svg {
    width: 14px;
    height: 14px;
  }
  
  .tab-label-full {
    display: none;
  }
  
  .tab-label-short {
    display: inline;
  }

  /* Page Wrappers on Mobile */
  .main-wrapper,
  .wo-layout,
  .calendar-wrapper,
  .records-container,
  .settings-layout {
    padding: 0 10px;
    margin: 12px auto;
    width: 100%;
    max-width: 100vw;
    box-sizing: border-box;
  }

  /* Work Order Header Actions on Mobile */
  .wo-editor-header {
    padding: 12px 14px;
    flex-direction: column;
    align-items: stretch;
    gap: 10px;
  }
  
  .wo-header-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
  }
  
  .wo-header-actions .btn {
    flex: 1 1 calc(50% - 6px);
    justify-content: center;
    padding: 7px 8px;
    font-size: 11.5px;
  }
  
  .wo-header-actions .btn#btn-wo-save {
    flex: 1 1 100%;
  }
  
  .wo-editor-body {
    padding: 14px;
  }

  /* Table Cards horizontal scroll on Mobile */
  .card-body.p-0 {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
  }
  
  .calc-table {
    min-width: 460px;
  }

  /* Calendar Controls Bar on Mobile */
  .cal-controls-bar {
    flex-direction: column;
    align-items: stretch;
    padding: 10px 12px;
    gap: 10px;
  }
  
  .cal-nav-group {
    justify-content: space-between;
    width: 100%;
  }
  
  .cal-title {
    font-size: 16px;
  }
  
  .cal-filter-group {
    flex-direction: column;
    align-items: stretch;
    gap: 8px;
    width: 100%;
  }
  
  .cal-filter-item {
    width: 100%;
    justify-content: space-between;
  }
  
  .cal-view-selector {
    display: flex;
    width: 100%;
  }
  
  .cal-view-selector .btn {
    flex: 1;
    justify-content: center;
    padding: 6px 4px;
    font-size: 11.5px;
  }
  
  .calendar-grid-container {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
  }
  
  .cal-day-header-row,
  .cal-days-grid {
    min-width: 480px;
  }
  
  .cal-day-cell {
    min-height: 75px;
    padding: 4px;
  }
  
  .cal-day-header-row div {
    font-size: 10px;
    padding: 6px 2px;
  }

  /* Form Row Stacking */
  .form-row {
    flex-direction: column;
    gap: 10px;
  }
}

@media (max-width: 480px) {
  .hide-mobile-sm {
    display: none !important;
  }
  .brand-name {
    font-size: 0.9rem;
  }
  .user-session-badge {
    padding: 2px 5px;
    gap: 3px;
  }
  .user-avatar {
    width: 24px;
    height: 24px;
    font-size: 10px;
  }
  .btn-icon-sm {
    padding: 3px 4px;
  }
}

/* ==================================================== */
/* PRINT MEDIA STYLES                                   */
/* ==================================================== */
#printable-area,
#printable-wo-area {
  display: none;
}

@page {
  size: letter portrait;
  margin: 0;
}

@media print {
  @page {
    size: letter portrait;
    margin: 0;
  }

  html, body {
    background: #fff;
    color: #000;
    font-size: 11.5px;
    margin: 0;
    padding: 0;
    -webkit-print-color-adjust: exact;
    print-color-adjust: exact;
  }

  .app-header,
  .main-wrapper,
  .view-panel,
  .modal-overlay,
  .no-print {
    display: none !important;
  }

  body.print-mode-estimate #printable-area {
    display: block !important;
  }

  body.print-mode-workorder #printable-wo-area {
    display: block !important;
  }

  .print-page {
    padding: 16mm 18mm 14mm 18mm;
    max-width: 800px;
    margin: 0 auto;
    box-sizing: border-box;
    page-break-after: always;
  }

  .print-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    border-bottom: 2px solid #16221d;
    padding-bottom: 16px;
    margin-bottom: 18px;
  }

  .print-logo {
    max-height: 60px;
    object-fit: contain;
  }

  .print-company-info {
    text-align: right;
    font-size: 11px;
    line-height: 1.4;
    color: #333;
  }

  .print-doc-title {
    font-size: 22px;
    font-weight: 800;
    color: #16221d;
    letter-spacing: 1px;
    margin-bottom: 2px;
  }

  .print-meta-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 16px;
    margin-bottom: 16px;
  }

  .print-box {
    border: 1px solid #ddd;
    border-radius: 4px;
    padding: 10px 12px;
    font-size: 11px;
  }

  .print-box-title {
    font-weight: bold;
    color: #16221d;
    text-transform: uppercase;
    font-size: 10px;
    letter-spacing: 0.5px;
    border-bottom: 1px solid #eee;
    padding-bottom: 3px;
    margin-bottom: 6px;
  }

  .print-table {
    width: 100%;
    border-collapse: collapse;
    margin-bottom: 18px;
    font-size: 11px;
  }

  .print-table th {
    background: #16221d;
    color: #fff;
    padding: 6px 10px;
    text-align: left;
    font-size: 10px;
    text-transform: uppercase;
  }

  .print-table td {
    padding: 6px 10px;
    border-bottom: 1px solid #e2e8f0;
  }

  .print-table .subtotal-row td {
    background: #f8fafc;
    font-weight: bold;
  }

  .print-totals-box {
    margin-left: auto;
    width: 260px;
    border: 1px solid #16221d;
    border-radius: 4px;
    overflow: hidden;
    margin-bottom: 20px;
  }

  .print-totals-line {
    display: flex;
    justify-content: space-between;
    padding: 5px 10px;
    font-size: 11px;
    border-bottom: 1px solid #eee;
  }

  .print-grand-total {
    background: #16221d;
    color: #fff;
    font-weight: bold;
    font-size: 13.5px;
    display: flex;
    justify-content: space-between;
    padding: 7px 10px;
  }

  .print-sign-line {
    margin-top: 35px;
    display: flex;
    justify-content: space-between;
    gap: 35px;
  }

  .sign-field {
    flex: 1;
    border-top: 1px solid #333;
    padding-top: 5px;
    font-size: 10.5px;
    text-align: center;
  }

  .print-flra-badge {
    display: inline-block;
    padding: 2px 6px;
    margin: 2px 4px 2px 0;
    background: #f1f5f9;
    border: 1px solid #cbd5e1;
    border-radius: 3px;
    font-size: 10px;
    font-weight: 500;
  }

  .print-flra-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 10.5px;
    margin-top: 4px;
  }

  .print-flra-table th {
    background: #f1f5f9;
    color: #1e293b;
    font-weight: bold;
    padding: 4px 6px;
    border: 1px solid #cbd5e1;
    font-size: 10px;
    text-transform: uppercase;
  }

  .print-flra-table td {
    padding: 4px 6px;
    border: 1px solid #cbd5e1;
    font-size: 10px;
    vertical-align: top;
  }

  .print-footer {
    border-top: 1px solid #e2e8f0;
    padding-top: 10px;
    margin-top: 20px;
    font-size: 10px;
    color: #64748b;
    display: flex;
    justify-content: flex-end;
  }
}

/* ==================================================== */
/* AUTHENTICATION & LOGIN GATE STYLES                   */
/* ==================================================== */
body.not-authenticated {
  background-color: #0f1714;
  overflow-y: auto;
}

body.not-authenticated .app-header,
body.not-authenticated .view-panel,
body.not-authenticated #printable-area,
body.not-authenticated #printable-workorder-area {
  display: none !important;
}

body.authenticated #auth-gate {
  display: none !important;
}

.auth-gate {
  display: flex;
  min-height: 100vh;
  width: 100%;
  align-items: center;
  justify-content: center;
  background: radial-gradient(circle at 50% 20%, #1c2b24 0%, #111a16 60%, #0a110e 100%);
  padding: 24px;
}

.auth-container {
  width: 100%;
  max-width: 440px;
  margin: 0 auto;
}

.auth-header {
  text-align: center;
  margin-bottom: 24px;
}

.auth-logo {
  height: 52px;
  width: auto;
  margin-bottom: 12px;
  filter: drop-shadow(0 4px 12px rgba(0, 0, 0, 0.4));
}

.auth-title {
  color: #ffffff;
  font-size: 24px;
  font-weight: 800;
  letter-spacing: 0.5px;
  margin: 0 0 4px 0;
}

.auth-subtitle {
  color: var(--accent-gold);
  font-size: 12.5px;
  font-weight: 600;
  letter-spacing: 0.75px;
  text-transform: uppercase;
  margin: 0;
  opacity: 0.9;
}

.auth-card {
  background: #ffffff;
  border-radius: 12px;
  padding: 32px 28px;
  box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.5), 0 0 0 1px rgba(255, 255, 255, 0.1);
  transition: transform 0.2s, box-shadow 0.2s;
}

.auth-card-title {
  margin-bottom: 20px;
}

.auth-card-title h3 {
  margin: 0 0 6px 0;
  font-size: 18px;
  font-weight: 700;
  color: var(--primary);
  display: flex;
  align-items: center;
  gap: 8px;
}

.auth-card-title p {
  margin: 0;
  font-size: 13px;
  color: #64748b;
  line-height: 1.4;
}

.auth-link {
  font-size: 12px;
  color: #2563eb;
  text-decoration: none;
  font-weight: 500;
  transition: color 0.15s;
}

.auth-link:hover {
  color: #1d4ed8;
  text-decoration: underline;
}

.input-with-icon {
  position: relative;
  display: flex;
  align-items: center;
}

.input-with-icon > svg,
.input-with-icon > i {
  position: absolute;
  left: 12px;
  color: #94a3b8;
  width: 16px;
  height: 16px;
  pointer-events: none;
}

.input-with-icon .form-input {
  padding-left: 38px;
  width: 100%;
}

.input-password-wrap .form-input {
  padding-right: 38px;
}

.btn-toggle-pw {
  position: absolute;
  right: 8px;
  background: none;
  border: none;
  color: #94a3b8;
  cursor: pointer;
  padding: 6px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 4px;
  transition: color 0.15s;
}

.btn-toggle-pw:hover {
  color: var(--primary);
}

.btn-auth {
  width: 100%;
  justify-content: center;
  padding: 12px 18px;
  font-size: 14.5px;
  font-weight: 700;
  letter-spacing: 0.25px;
  border-radius: 6px;
}

.auth-alert {
  padding: 10px 14px;
  border-radius: 6px;
  font-size: 13px;
  margin-bottom: 16px;
  line-height: 1.4;
}

.auth-alert.error {
  background-color: #fef2f2;
  border: 1px solid #fecaca;
  color: #991b1b;
}

.auth-alert.success {
  background-color: #ecfdf5;
  border: 1px solid #a7f3d0;
  color: #065f46;
}

.auth-footer {
  text-align: center;
  margin-top: 24px;
  font-size: 12px;
  color: #64748b;
  opacity: 0.8;
}

/* Header User Profile Badge */
.user-session-badge {
  order: 3;
  display: flex;
  align-items: center;
  gap: 8px;
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid rgba(255, 255, 255, 0.15);
  border-radius: 20px;
  padding: 4px 10px 4px 6px;
  margin-left: auto;
  flex-shrink: 0;
  white-space: nowrap;
}

.user-avatar {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 26px;
  height: 26px;
  background-color: var(--accent-gold);
  color: var(--primary);
  border-radius: 50%;
  font-size: 11px;
  font-weight: 800;
  letter-spacing: -0.5px;
}

.user-name {
  color: #ffffff;
  font-size: 13px;
  font-weight: 600;
}

.btn-icon-sm {
  background: none;
  border: none;
  color: #cbd5e1;
  cursor: pointer;
  padding: 4px 6px;
  border-radius: 4px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.15s;
}

.btn-icon-sm:hover {
  color: #ffffff;
  background: rgba(255, 255, 255, 0.12);
}

.btn-icon-sm.btn-logout:hover {
  color: #ef4444;
  background: rgba(239, 68, 68, 0.15);
}

.btn-icon-sm.btn-sync {
  color: var(--accent-gold);
}

.btn-icon-sm.btn-sync:hover {
  color: #ffffff;
  background: rgba(200, 138, 44, 0.25);
}

@keyframes spin {
  from { transform: rotate(0deg); }
  to { transform: rotate(360deg); }
}

.spinning i,
.spinning svg {
  animation: spin 0.75s linear infinite;
}

