/* Inventory Management System */
* {
  box-sizing: border-box;
}

body {
  font-family: system-ui, -apple-system, sans-serif;
  margin: 0;
  padding: 0;
  background: #f5f5f5;
}

/* App Layout with Sidebar */
.app-layout {
  display: flex;
  min-height: 100vh;
}

.sidebar {
  width: 220px;
  background: #1e3a5f;
  color: #fff;
  flex-shrink: 0;
}

@media (max-width: 768px) {
  .app-layout { flex-direction: column; }
  .sidebar {
    width: 100%;
    display: flex;
    flex-wrap: wrap;
  }
  .sidebar-nav {
    flex-direction: row;
    flex-wrap: wrap;
  }
  .nav-link { padding: 0.5rem; font-size: 0.9rem; }
  .main-content { padding: 1rem; }
}

.sidebar-header {
  padding: 1rem;
  border-bottom: 1px solid rgba(255,255,255,0.2);
}

.sidebar-header h2 {
  margin: 0 0 0.5rem 0;
  font-size: 1.1rem;
}

.btn-logout {
  background: transparent;
  color: #fff;
  border: 1px solid rgba(255,255,255,0.5);
  padding: 0.35rem 0.75rem;
  font-size: 0.85rem;
}

.btn-logout:hover {
  background: rgba(255,255,255,0.1);
}

.sidebar-nav {
  display: flex;
  flex-direction: column;
  padding: 0.5rem 0;
}

.nav-link {
  color: rgba(255,255,255,0.9);
  text-decoration: none;
  padding: 0.6rem 1rem;
  font-size: 0.95rem;
}

.nav-link:hover {
  background: rgba(255,255,255,0.1);
}

.nav-link.active {
  background: rgba(255,255,255,0.2);
  font-weight: 600;
}

.main-content {
  flex: 1;
  padding: 1.5rem;
  overflow-x: hidden;
}

.main-content h1 {
  margin-top: 0;
  margin-bottom: 1rem;
  color: #1e3a5f;
}

.container {
  max-width: 900px;
  margin: 0 auto;
}

h1 {
  margin-top: 0;
  color: #333;
}

.card {
  background: #fff;
  border-radius: 8px;
  padding: 1.25rem;
  margin-bottom: 1rem;
  box-shadow: 0 1px 3px rgba(0,0,0,0.08);
}

.card h2 {
  margin-top: 0;
  font-size: 1.1rem;
  color: #444;
}

.form-column-group {
  display: flex;
  flex-direction: column;
  max-width: 400px;
  margin-bottom: 0.5rem;
}

.form-row,
.filter-row {
  margin-bottom: 0.75rem;
}

.form-row label,
.filter-row label {
  display: block;
  font-weight: 500;
  margin-bottom: 0.25rem;
  color: #333;
}

input[type="text"],
select {
  width: 100%;
  max-width: 400px;
  padding: 0.5rem;
  border: 1px solid #ccc;
  border-radius: 4px;
  font-size: 1rem;
}

.filter-row {
  display: flex;
  flex-wrap: wrap;
  gap: 1rem;
  align-items: flex-end;
}

.filter-row label { margin-bottom: 0.25rem; }
.filter-row select { max-width: 200px; }
.filter-row input { max-width: 200px; }

.form-actions {
  margin-top: 1rem;
  display: flex;
  gap: 0.5rem;
  flex-wrap: wrap;
}

button {
  padding: 0.5rem 1rem;
  border: none;
  border-radius: 4px;
  font-size: 0.95rem;
  cursor: pointer;
  background: #2563eb;
  color: #fff;
}

button:hover {
  background: #1d4ed8;
}

button:focus-visible,
input:focus-visible,
select:focus-visible,
textarea:focus-visible,
.nav-link:focus-visible {
  outline: 2px solid #2563eb;
  outline-offset: 2px;
}

button:disabled {
  opacity: 0.6;
  cursor: not-allowed;
}

button[type="button"]#btn-clear {
  background: #64748b;
}

button[type="button"]#btn-clear:hover {
  background: #475569;
}

.status {
  min-height: 1.5rem;
  padding: 0.5rem;
  margin-bottom: 1rem;
  border-radius: 4px;
  font-size: 0.9rem;
}

.status.success {
  background: #dcfce7;
  color: #166534;
}

.status.error {
  background: #fee2e2;
  color: #991b1b;
}

.status.info {
  background: #e0f2fe;
  color: #0369a1;
}

.data-table,
.stations-table {
  width: 100%;
  border-collapse: collapse;
}

.data-table th,
.data-table td,
.stations-table th,
.stations-table td {
  padding: 0.5rem 0.75rem;
  text-align: left;
  border-bottom: 1px solid #e2e8f0;
}

.data-table th,
.stations-table th {
  background: #f8fafc;
  font-weight: 600;
  color: #334155;
}

.data-table tbody tr:hover,
.stations-table tbody tr:hover {
  background: #f8fafc;
}

.btn-row {
  display: flex;
  gap: 0.25rem;
  flex-wrap: wrap;
}

.inventory-action-select {
  max-width: 180px;
}

.btn-small {
  padding: 0.25rem 0.5rem;
  font-size: 0.85rem;
}

.btn-secondary { background: #64748b; }
.btn-secondary:hover { background: #475569; }
.btn-danger { background: #dc2626; }
.btn-danger:hover { background: #b91c1c; }

.dashboard-filters {
  margin-bottom: 1rem;
}

.dashboard-filters .filter-controls {
  display: flex;
  flex-wrap: wrap;
  gap: 1rem;
  align-items: flex-end;
  margin-bottom: 0.75rem;
}

.dashboard-filters .filter-controls label {
  display: flex;
  flex-direction: column;
  font-weight: 500;
  margin-bottom: 0;
}

.dashboard-filters .filter-controls select,
.dashboard-filters .filter-controls input[type="date"] {
  max-width: 160px;
  padding: 0.4rem 0.5rem;
}

.dashboard-filters .filter-controls .filter-checkbox-label {
  flex-direction: row;
  align-items: center;
}

.dashboard-filters .filter-controls input[type="checkbox"] {
  margin-right: 0.5rem;
}

.filter-pills {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  align-items: center;
  margin-bottom: 0.5rem;
}

.filter-pill {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  padding: 0.25rem 0.5rem;
  background: #e2e8f0;
  border-radius: 9999px;
  font-size: 0.9rem;
}

.filter-pill:focus {
  outline: 2px solid #2563eb;
  outline-offset: 2px;
}

.filter-pill-remove {
  padding: 0 0.25rem;
  margin: 0;
  background: transparent;
  border: none;
  font-size: 1.1rem;
  line-height: 1;
  cursor: pointer;
  color: #64748b;
}

.filter-pill-remove:hover {
  color: #334155;
}

#dashboard-reset-filters,
#dashboard-refresh {
  margin-top: 0.25rem;
  margin-right: 0.5rem;
}

.dashboard-kpis {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: 0.75rem;
  margin-bottom: 1rem;
}

.kpi-card {
  background: #fff;
  border-radius: 8px;
  padding: 1rem;
  box-shadow: 0 1px 3px rgba(0,0,0,0.08);
  text-align: center;
}

.kpi-card .kpi-value {
  font-size: 1.5rem;
  font-weight: 700;
  color: #1e3a5f;
}

.kpi-card .kpi-label {
  font-size: 0.85rem;
  color: #64748b;
  margin-top: 0.25rem;
}

.dashboard-charts-layout {
  display: grid;
  grid-template-columns: 220px minmax(0, 1fr);
  gap: 1rem;
  align-items: flex-start;
  margin-bottom: 1rem;
}

.dashboard-chart-tabs {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.dashboard-chart-tab {
  width: 100%;
  text-align: left;
  background: #e5e7eb;
  color: #111827;
  border-radius: 6px;
  padding: 0.5rem 0.75rem;
  font-size: 0.9rem;
}

.dashboard-chart-tab:hover {
  background: #d1d5db;
}

.dashboard-chart-tab.active {
  background: #2563eb;
  color: #fff;
}

.dashboard-charts {
  display: block;
}

.chart-card {
  min-height: 280px;
}

.chart-card .chart-container {
  position: relative;
  min-height: 200px;
}

.chart-card canvas {
  max-height: 250px;
  min-height: 200px;
  width: 100% !important;
}

.chart-empty {
  color: #64748b;
  font-style: italic;
  padding: 2rem 1rem;
  text-align: center;
  margin: 0;
}

.chart-card .chart-empty[hidden] {
  display: none !important;
}

/* Condition / cost severity badges */
.badge {
  display: inline-block;
  padding: 0.2rem 0.5rem;
  border-radius: 4px;
  font-size: 0.85rem;
  font-weight: 500;
}

.badge.severity-positive {
  background: #dcfce7;
  color: #166534;
}

.badge.severity-warning {
  background: #fef9c3;
  color: #854d0e;
}

.badge.severity-critical {
  background: #fee2e2;
  color: #991b1b;
}

.badge.cost-exception {
  background: #fef2f2;
  color: #b91c1c;
  border: 1px solid #fecaca;
}

.badge:not(.severity-positive):not(.severity-warning):not(.severity-critical):not(.cost-exception) {
  background: #f1f5f9;
  color: #64748b;
}

/* Forecasting replacement schedule row highlights */
.data-table tbody tr.row-overdue {
  background: #fef2f2;
}
.data-table tbody tr.row-due-soon {
  background: #fefce8;
}
.row-sample { padding: 0 0.25rem; border-radius: 2px; }
.row-overdue-sample { background: #fef2f2; }
.row-due-soon-sample { background: #fefce8; }
.hint { font-size: 0.9rem; color: #64748b; margin-bottom: 0.5rem; }

.forecasting-overdue-card {
  border-left: 4px solid #dc2626;
  background: linear-gradient(180deg, #fffafa 0%, #fff 100%);
}
.forecasting-overdue-total-value {
  font-size: 2rem;
  font-weight: 700;
  color: #b91c1c;
  letter-spacing: -0.02em;
}

/* Fiscal summary */
.fiscal-summary {
  display: flex;
  flex-wrap: wrap;
  gap: 1.5rem;
}
.fiscal-summary-item {
  padding: 0.75rem 1rem;
  background: #f8fafc;
  border-radius: 6px;
  min-width: 200px;
}
.fiscal-summary-item .label { font-size: 0.9rem; color: #64748b; }
.fiscal-summary-item .value { font-size: 1.25rem; font-weight: 600; }
.fiscal-summary-item--past {
  background: #fef2f2;
  border-left: 3px solid #dc2626;
}

/* Legend card */
.legend-card {
  margin-bottom: 1rem;
}

.legend-card h3 {
  margin-top: 0;
  font-size: 0.95rem;
  color: #475569;
}

.legend-row {
  display: flex;
  flex-wrap: wrap;
  gap: 1rem;
  align-items: center;
}

.legend-item {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  font-size: 0.9rem;
  color: #64748b;
}

.notifications-list {
  min-height: 80px;
}

.notification-item {
  padding: 0.5rem 0;
  border-bottom: 1px solid #e2e8f0;
}

.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.5);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 2000;
}

/* Must override display:flex when hidden - otherwise modal blocks page */
.modal-overlay[hidden],
#modal-overlay[hidden] {
  display: none !important;
  visibility: hidden !important;
  pointer-events: none !important;
}

.modal-content {
  background: #fff;
  padding: 1.5rem;
  border-radius: 8px;
  max-width: 500px;
  width: 90%;
  max-height: 90vh;
  overflow-y: auto;
}

textarea {
  width: 100%;
  max-width: 400px;
  padding: 0.5rem;
  border: 1px solid #ccc;
  border-radius: 4px;
  font-family: inherit;
}

.empty-message {
  color: #64748b;
  font-style: italic;
}

#stations-table[data-empty="true"] {
  display: none;
}

#stations-table[data-empty="true"] ~ #stations-empty {
  display: block !important;
}

#stations-empty[hidden] {
  display: none !important;
}

/* Autocomplete */
.autocomplete-container {
  position: relative;
  display: inline-block;
  width: 100%;
  max-width: 400px;
}

.autocomplete-wrap {
  position: absolute;
  top: 100%;
  left: 0;
  right: 0;
  z-index: 1000;
  display: none;
}

.autocomplete-container.autocomplete-open .autocomplete-wrap {
  display: block;
}

.autocomplete-list {
  margin: 0;
  padding: 0;
  list-style: none;
  background: #fff;
  border: 1px solid #ccc;
  border-top: none;
  border-radius: 0 0 4px 4px;
  max-height: 200px;
  overflow-y: auto;
  box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
}

.autocomplete-item {
  padding: 0.5rem 0.75rem;
  cursor: pointer;
}

.autocomplete-item:hover,
.autocomplete-item.autocomplete-selected {
  background: #e0f2fe;
}

.autocomplete-item.autocomplete-empty {
  color: #64748b;
  cursor: default;
}

