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

:root {
  --primary: #232f3e;
  --primary-light: #37475a;
  --accent: #ff9900;
  --accent-hover: #e88b00;
  --success: #067d62;
  --danger: #d13212;
  --warning: #f0ad4e;
  --info: #0073bb;
  --bg: #f4f6f8;
  --card-bg: #fff;
  --border: #d5dbdb;
  --text: #16191f;
  --text-secondary: #545b64;
  --radius: 6px;
  --shadow: 0 1px 3px rgba(0,0,0,0.12);
}

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
}

/* Header */
header {
  background: var(--primary);
  color: #fff;
  padding: 0 24px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 56px;
  position: sticky;
  top: 0;
  z-index: 100;
  box-shadow: 0 2px 4px rgba(0,0,0,0.2);
}

.header-left {
  display: flex;
  align-items: center;
  gap: 12px;
}

.header-logo {
  height: 44px;
  width: auto;
}

header h1 {
  font-size: 18px;
  font-weight: 600;
  color: var(--accent);
}

nav { display: flex; gap: 4px; }

.nav-btn {
  background: transparent;
  border: none;
  color: #d5dbdb;
  padding: 16px 16px;
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  border-bottom: 3px solid transparent;
  transition: all 0.2s;
}

.nav-btn:hover { color: #fff; background: var(--primary-light); }
.nav-btn.active { color: #fff; border-bottom-color: var(--accent); }

/* Nav dropdown */
.nav-dropdown {
  position: relative;
  display: inline-block;
}
.nav-dropdown-content {
  display: none;
  position: absolute;
  top: 100%;
  left: 0;
  background: #fff;
  min-width: 200px;
  box-shadow: 0 4px 12px rgba(0,0,0,0.2);
  border-radius: 0 0 var(--radius) var(--radius);
  z-index: 110;
  overflow: hidden;
}
.nav-dropdown-content.show { display: block; }
.nav-dropdown-content button {
  display: block;
  width: 100%;
  padding: 10px 16px;
  text-align: left;
  border: none;
  background: none;
  font-size: 13px;
  cursor: pointer;
  color: var(--text);
}
.nav-dropdown-content button:hover { background: #f5f5f5; }

/* Main */
main { padding: 20px 24px; max-width: 1600px; margin: 0 auto; }

/* Cards */
.card {
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  margin-bottom: 16px;
}

.card-header {
  padding: 12px 16px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: #fafafa;
  border-radius: var(--radius) var(--radius) 0 0;
}

.card-header h2 { font-size: 16px; font-weight: 600; }
.card-body { padding: 16px; }

/* Summary bar */
.summary-bar {
  display: flex;
  gap: 24px;
  padding: 12px 16px;
  background: var(--primary);
  color: #fff;
  border-radius: var(--radius);
  margin-bottom: 16px;
  flex-wrap: wrap;
}

.summary-item { font-size: 14px; }
.summary-item strong { color: var(--accent); margin-left: 4px; }

/* Filter bar */
.filter-bar {
  display: flex;
  gap: 12px;
  align-items: center;
  margin-bottom: 16px;
  flex-wrap: wrap;
}

.filter-bar input[type="text"],
.filter-bar select {
  padding: 8px 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  font-size: 14px;
  background: #fff;
}

.filter-bar input[type="text"] { min-width: 280px; }
.filter-bar select { min-width: 140px; }

/* Buttons */
.btn {
  padding: 8px 16px;
  border: none;
  border-radius: var(--radius);
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s;
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.btn-primary { background: var(--accent); color: #000; }
.btn-primary:hover { background: var(--accent-hover); }
.btn-success { background: var(--success); color: #fff; }
.btn-success:hover { opacity: 0.9; }
.btn-danger { background: var(--danger); color: #fff; }
.btn-danger:hover { opacity: 0.9; }
.btn-info { background: var(--info); color: #fff; }
.btn-info:hover { opacity: 0.9; }
.btn-secondary { background: #eee; color: var(--text); border: 1px solid var(--border); }
.btn-secondary:hover { background: #ddd; }
.btn-sm { padding: 4px 10px; font-size: 12px; }
.btn-xs { padding: 2px 8px; font-size: 11px; }

/* Tables */
.data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}

.data-table th {
  background: var(--primary);
  color: #fff;
  padding: 10px 12px;
  text-align: left;
  font-weight: 500;
  white-space: nowrap;
  cursor: pointer;
  user-select: none;
  position: sticky;
  top: 0;
}

.data-table th:hover { background: var(--primary-light); }
.data-table th .sort-arrow { margin-left: 4px; font-size: 10px; opacity: 0.6; }
.data-table th.sorted .sort-arrow { opacity: 1; }

.data-table td {
  padding: 8px 12px;
  border-bottom: 1px solid #eee;
  vertical-align: top;
}

.data-table tr:hover { background: #f5f8ff; }
.data-table tr.clickable { cursor: pointer; }

/* Status badges */
.badge {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 10px;
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
}

.badge-active { background: #d4edda; color: #155724; }
.badge-grounded { background: #fff3cd; color: #856404; }
.badge-amazon-grounded { background: #fce4ec; color: #b71c1c; }
.badge-inactive { background: #e2e3e5; color: #383d41; }

/* Alert badges */
.alert-tag {
  display: inline-block;
  padding: 2px 6px;
  border-radius: 3px;
  font-size: 10px;
  font-weight: 600;
  margin: 1px 2px;
  white-space: nowrap;
}

.alert-tag.inspection { background: #fce4ec; color: #c62828; }
.alert-tag.registration { background: #fff3e0; color: #e65100; }
.alert-tag.license { background: #e8eaf6; color: #283593; }
.alert-tag.contract { background: #fbe9e7; color: #bf360c; }
.alert-tag.issue-date { background: #f3e5f5; color: #6a1b9a; }
.alert-tag.afs { background: #e0f2f1; color: #004d40; }

/* Action buttons in grid */
.action-dropdown {
  position: relative;
  display: inline-block;
}

.action-dropdown-content {
  display: none;
  position: absolute;
  right: 0;
  background: #fff;
  min-width: 160px;
  box-shadow: 0 4px 12px rgba(0,0,0,0.15);
  border-radius: var(--radius);
  z-index: 50;
  overflow: hidden;
}

.action-dropdown-content.show { display: block; }

.action-dropdown-content button {
  display: block;
  width: 100%;
  padding: 8px 12px;
  text-align: left;
  border: none;
  background: none;
  font-size: 13px;
  cursor: pointer;
}

.action-dropdown-content button:hover { background: #f5f5f5; }

/* Modal */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.5);
  z-index: 200;
  display: flex;
  align-items: flex-start;
  justify-content: center;
  padding-top: 40px;
  overflow-y: auto;
}

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

.modal {
  background: #fff;
  border-radius: 8px;
  width: 90%;
  max-width: 900px;
  box-shadow: 0 8px 32px rgba(0,0,0,0.3);
  margin-bottom: 40px;
}

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

.modal-header h2 { font-size: 18px; }

.modal-close {
  background: none;
  border: none;
  font-size: 24px;
  cursor: pointer;
  color: var(--text-secondary);
  padding: 4px 8px;
}

.modal-body { padding: 20px; max-height: 70vh; overflow-y: auto; }
.modal-footer { padding: 12px 20px; border-top: 1px solid var(--border); display: flex; justify-content: flex-end; gap: 8px; }

/* Forms */
.form-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 16px;
}

.form-group { display: flex; flex-direction: column; gap: 4px; }
.form-group label { font-size: 12px; font-weight: 600; color: var(--text-secondary); text-transform: uppercase; }

.form-group input,
.form-group select,
.form-group textarea {
  padding: 8px 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  font-size: 14px;
  font-family: inherit;
}

.form-group textarea { resize: vertical; min-height: 60px; }
.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 2px rgba(255,153,0,0.2);
}

.form-group.full-width { grid-column: 1 / -1; }

/* Tabs inside detail */
.tab-bar {
  display: flex;
  border-bottom: 2px solid var(--border);
  margin-bottom: 16px;
}

.tab-btn {
  padding: 10px 20px;
  border: none;
  background: none;
  font-size: 14px;
  font-weight: 500;
  color: var(--text-secondary);
  cursor: pointer;
  border-bottom: 2px solid transparent;
  margin-bottom: -2px;
  transition: all 0.2s;
}

.tab-btn:hover { color: var(--text); }
.tab-btn.active { color: var(--accent); border-bottom-color: var(--accent); }

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

.detail-header h2 { font-size: 20px; }

.back-link {
  color: var(--info);
  cursor: pointer;
  font-size: 14px;
  display: flex;
  align-items: center;
  gap: 4px;
}

.back-link:hover { text-decoration: underline; }

/* Info grid */
.info-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 12px;
  margin-bottom: 16px;
}

.info-item label {
  display: block;
  font-size: 11px;
  font-weight: 600;
  color: var(--text-secondary);
  text-transform: uppercase;
  margin-bottom: 2px;
}

.info-item span { font-size: 14px; }

/* Daily workflow */
.workflow-grid {
  overflow-x: auto;
}

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

.workflow-grid th, .workflow-grid td {
  padding: 8px 12px;
  border: 1px solid var(--border);
  text-align: center;
  min-width: 100px;
}

.workflow-grid th {
  background: var(--primary);
  color: #fff;
  font-weight: 500;
}

.workflow-grid td input {
  width: 80px;
  padding: 4px;
  border: 1px solid var(--border);
  border-radius: 3px;
  text-align: center;
  font-size: 13px;
}

.workflow-grid .row-label {
  text-align: left;
  font-weight: 600;
  background: #f9f9f9;
  white-space: nowrap;
}

/* Maintenance coverage */
.coverage-yes { color: var(--success); font-weight: 600; }
.coverage-no { color: var(--danger); font-weight: 600; }

/* Supplemental report */
.report-field {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 10px 0;
  border-bottom: 1px solid #eee;
}

.report-field label { font-weight: 500; }

.report-field input {
  width: 150px;
  padding: 6px 10px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  text-align: right;
  font-size: 14px;
}

.report-field .computed {
  font-size: 16px;
  font-weight: 600;
  color: var(--info);
  min-width: 150px;
  text-align: right;
}

/* Week selector */
.week-selector {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 16px;
}

.week-selector button {
  padding: 6px 12px;
  border: 1px solid var(--border);
  background: #fff;
  border-radius: var(--radius);
  cursor: pointer;
}

.week-selector button:hover { background: #f5f5f5; }
.week-selector .week-label { font-size: 16px; font-weight: 600; }

/* ERO section */
.ero-entry {
  display: flex;
  gap: 8px;
  align-items: center;
  margin-bottom: 6px;
  padding: 6px;
  background: #f9f9f9;
  border-radius: var(--radius);
}

.ero-entry select, .ero-entry input {
  padding: 4px 8px;
  border: 1px solid var(--border);
  border-radius: 3px;
  font-size: 13px;
}

/* Responsive */
@media (max-width: 768px) {
  header { flex-direction: column; height: auto; padding: 12px; }
  nav { flex-wrap: wrap; }
  main { padding: 12px; }
  .filter-bar input[type="text"] { min-width: 100%; }
  .form-grid { grid-template-columns: 1fr; }
  .summary-bar { flex-direction: column; gap: 8px; }
}

/* Covered/Not covered indicators in maintenance table */
.data-table .covered-cell { text-align: center; }

/* Upload area */
.upload-area {
  border: 2px dashed var(--border);
  border-radius: var(--radius);
  padding: 20px;
  text-align: center;
  cursor: pointer;
  transition: all 0.2s;
}

.upload-area:hover { border-color: var(--accent); background: #fff8ef; }
.upload-area input[type="file"] { display: none; }

/* Empty state */
.empty-state {
  text-align: center;
  padding: 40px;
  color: var(--text-secondary);
}

.empty-state h3 { margin-bottom: 8px; }

/* Scrollable table wrapper */
.table-wrapper {
  overflow-x: auto;
  border: 1px solid var(--border);
  border-radius: var(--radius);
}

.table-wrapper .data-table th { position: sticky; top: 0; z-index: 10; }

/* Inline editable */
.editable {
  cursor: pointer;
  padding: 2px 4px;
  border-radius: 3px;
}

.editable:hover { background: #fff3cd; }

/* Section spacing for detail tabs */
.section { margin-bottom: 24px; }
.section-title {
  font-size: 15px;
  font-weight: 600;
  margin-bottom: 12px;
  padding-bottom: 6px;
  border-bottom: 2px solid var(--accent);
  display: flex;
  justify-content: space-between;
  align-items: center;
}

/* Notification toast */
.toast {
  position: fixed;
  bottom: 20px;
  right: 20px;
  padding: 12px 20px;
  background: var(--primary);
  color: #fff;
  border-radius: var(--radius);
  box-shadow: 0 4px 12px rgba(0,0,0,0.2);
  z-index: 300;
  animation: slideIn 0.3s ease;
}

.toast.success { background: var(--success); }
.toast.error { background: var(--danger); }

@keyframes slideIn {
  from { transform: translateX(100px); opacity: 0; }
  to { transform: translateX(0); opacity: 1; }
}

/* Notes tooltip */
.notes-cell {
  position: relative;
  cursor: default;
  max-width: 200px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.notes-cell:hover {
  overflow: visible;
  white-space: normal;
  background: #fffde7;
  z-index: 20;
  box-shadow: 0 2px 8px rgba(0,0,0,0.15);
  border-radius: 4px;
  padding: 8px 12px;
  max-width: 400px;
  position: relative;
}

/* Clickable summary items */
.clickable-summary {
  cursor: pointer;
  transition: opacity 0.2s;
}
.clickable-summary:hover {
  opacity: 0.8;
  text-decoration: underline;
}

/* View-only fields in forms */
.view-only-field {
  background: #f4f6f8;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 8px 12px;
  font-size: 14px;
  color: var(--text-secondary);
  min-height: 36px;
  display: flex;
  align-items: center;
}

/* Active contract required banner */
.contract-banner {
  background: #fce4ec;
  color: #c62828;
  padding: 10px 16px;
  border-radius: var(--radius);
  margin-bottom: 12px;
  font-weight: 600;
  text-align: center;
  border: 1px solid #ef9a9a;
}

/* Tab navigation in detail view */
.tab-nav {
  display: flex;
  gap: 0;
  border-bottom: 2px solid var(--border);
  margin-bottom: 16px;
}

.tab-btn {
  background: transparent;
  border: none;
  padding: 10px 20px;
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  color: var(--text-secondary);
  border-bottom: 3px solid transparent;
  margin-bottom: -2px;
  transition: all 0.2s;
}

.tab-btn:hover {
  color: var(--text);
  background: #f4f6f8;
}

.tab-btn.active {
  color: var(--accent);
  border-bottom-color: var(--accent);
  font-weight: 600;
}

/* Covered / Not Covered badges */
.covered-badge {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 10px;
  font-size: 12px;
  font-weight: 600;
}
.covered-badge.yes { background: #e8f5e9; color: #2e7d32; }
.covered-badge.no { background: #fce4ec; color: #c62828; }
.covered-badge.pending { background: #fff3e0; color: #e65100; }

/* Insurance upload area */
.upload-area {
  border: 2px dashed var(--border);
  border-radius: var(--radius);
  padding: 16px;
  text-align: center;
  cursor: pointer;
  transition: border-color 0.2s;
}
.upload-area:hover {
  border-color: var(--accent);
}

/* Service duration alert */
.alert-tag.service-duration { background: #fff8e1; color: #f57f17; }

/* Custom date input (mm-dd-yy) */
.date-input-wrap {
  position: relative;
  display: flex;
}
.date-input-wrap .date-text-input {
  width: 100%;
  padding-right: 36px;
}
.date-input-wrap .date-hidden-picker {
  position: absolute;
  top: 0; right: 0;
  width: 36px; height: 100%;
  opacity: 0;
  cursor: pointer;
}
.date-input-wrap .date-cal-icon {
  position: absolute;
  right: 10px;
  top: 50%;
  transform: translateY(-50%);
  pointer-events: none;
  font-size: 16px;
  color: var(--text-secondary);
}

/* File view links */
.view-file-link {
  color: var(--info);
  text-decoration: underline;
  cursor: pointer;
  font-weight: 500;
}
.view-file-link:hover {
  color: var(--accent);
}

/* Print */
@media print {
  header { display: none; }
  .no-print { display: none; }
  .data-table th { background: #333 !important; -webkit-print-color-adjust: exact; }
}
