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

:root {
  --primary: #0891b2;
  --primary-dark: #0e7490;
  --success: #16a34a;
  --warning: #f59e0b;
  --danger: #dc2626;
  --info: #3b82f6;
  --bg: #f0f9ff;
  --card: #ffffff;
  --text: #1e293b;
  --text-muted: #64748b;
  --border: #e2e8f0;
  --shadow: 0 1px 3px rgba(0,0,0,0.1);
  --shadow-lg: 0 4px 12px rgba(0,0,0,0.15);
  --radius: 8px;
}

body { font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif; background: var(--bg); color: var(--text); min-height: 100vh; }

/* ============ SIDEBAR ============ */
.has-sidebar { display: flex; }

.app-sidebar {
  width: 240px;
  min-height: 100vh;
  background: linear-gradient(180deg, #0c3547 0%, #134e4a 50%, #0c3547 100%);
  position: fixed;
  top: 0; left: 0; bottom: 0;
  z-index: 150;
  display: flex;
  flex-direction: column;
  overflow-y: auto;
}

.sidebar-brand {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 1.25rem 1.2rem;
  border-bottom: 1px solid rgba(255,255,255,0.08);
}

.sidebar-brand-icon { font-size: 2rem; }
.sidebar-brand-title { color: white; font-size: 1.05rem; font-weight: 700; line-height: 1.2; }
.sidebar-brand-sub { color: rgba(255,255,255,0.45); font-size: 0.7rem; }

.sidebar-menu { flex: 1; padding: 0.5rem 0; }

.sidebar-section-label {
  color: rgba(255,255,255,0.35);
  font-size: 0.65rem;
  font-weight: 700;
  text-transform: uppercase;
  padding: 0.5rem 1.2rem 0.2rem;
  letter-spacing: 0.05em;
}

.sidebar-item {
  display: flex;
  align-items: center;
  gap: 0.7rem;
  padding: 0.6rem 1.2rem;
  color: rgba(255,255,255,0.65);
  text-decoration: none;
  font-size: 0.82rem;
  font-weight: 500;
  transition: all 0.2s;
  border-left: 3px solid transparent;
}

.sidebar-item:hover {
  background: rgba(255,255,255,0.07);
  color: white;
}

.sidebar-item.active {
  background: rgba(8,145,178,0.35);
  color: white;
  border-left-color: #22d3ee;
  font-weight: 700;
}

.sidebar-icon { font-size: 1rem; width: 22px; text-align: center; flex-shrink: 0; }

.sidebar-divider {
  height: 1px;
  background: rgba(255,255,255,0.08);
  margin: 0.4rem 1rem;
}

.sidebar-item-admin {
  color: rgba(251,146,60,0.85);
}
.sidebar-item-admin:hover { color: #fb923c; background: rgba(251,146,60,0.1); }

.sidebar-footer {
  padding: 0.75rem 1.2rem;
  border-top: 1px solid rgba(255,255,255,0.08);
}

.main-content {
  margin-left: 240px;
  flex: 1;
  min-width: 0;
  max-width: 1400px;
  padding: 1.5rem;
}

/* Mobile top bar */
.mobile-topbar {
  display: none;
  position: sticky; top: 0; z-index: 120;
  background: linear-gradient(135deg, #0c3547 0%, #134e4a 100%);
  color: white;
  padding: 0.75rem 1rem;
  align-items: center;
  gap: 0.75rem;
}
.mobile-menu-btn { background: none; border: none; color: white; font-size: 1.4rem; cursor: pointer; padding: 0.2rem 0.5rem; }
.mobile-title { font-weight: 700; font-size: 1rem; }
.sidebar-overlay { display: none; position: fixed; inset: 0; background: rgba(0,0,0,0.5); z-index: 140; }

@media (max-width: 768px) {
  .has-sidebar { display: block; }
  .app-sidebar { transform: translateX(-100%); transition: transform 0.3s ease; }
  .app-sidebar.open { transform: translateX(0); }
  .sidebar-overlay.open { display: block; }
  .mobile-topbar { display: flex; }
  .main-content { margin-left: 0; padding: 1rem; }
}

/* ============ LANGUAGE SWITCHER ============ */
.lang-switcher { display: flex; gap: 3px; flex-wrap: wrap; }
.lang-btn {
  padding: 0.2rem 0.4rem; border: 1px solid rgba(255,255,255,0.3);
  border-radius: 4px; background: transparent; color: rgba(255,255,255,0.7);
  cursor: pointer; font-size: 0.65rem; transition: all 0.2s;
}
.lang-btn:hover { background: rgba(255,255,255,0.15); color: white; }
.lang-btn.active { background: rgba(255,255,255,0.25); color: white; border-color: white; font-weight: 700; }

/* ============ BUTTONS ============ */
.btn { padding: 0.5rem 1rem; border: none; border-radius: 6px; cursor: pointer; font-size: 0.85rem; font-weight: 600; transition: all 0.2s; display: inline-flex; align-items: center; gap: 0.3rem; }
.btn-sm { padding: 0.3rem 0.6rem; font-size: 0.75rem; }
.btn-xs { padding: 0.2rem 0.4rem; font-size: 0.7rem; }
.btn-primary { background: var(--primary); color: white; }
.btn-primary:hover { background: var(--primary-dark); }
.btn-success { background: var(--success); color: white; }
.btn-success:hover { background: #15803d; }
.btn-warning { background: var(--warning); color: white; }
.btn-danger { background: var(--danger); color: white; }
.btn-danger:hover { background: #b91c1c; }
.btn-info { background: var(--info); color: white; }
.btn-outline { background: transparent; border: 1px solid var(--border); color: var(--text); }
.btn-outline:hover { background: var(--bg); }
.btn-full { width: 100%; justify-content: center; }

/* ============ LAYOUT ============ */
.page { display: none; }
.page.active { display: block; }
.page-title { font-size: 1.3rem; font-weight: 700; margin-bottom: 1.5rem; color: var(--text); border-bottom: 3px solid var(--primary); padding-bottom: 0.5rem; }

.stats-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 0.75rem; margin-bottom: 1.5rem; }
.stat-card { background: var(--card); border-radius: var(--radius); padding: 1.25rem; text-align: center; box-shadow: var(--shadow); border-left: 4px solid; }
.stat-blue { border-color: var(--primary); } .stat-green { border-color: var(--success); } .stat-yellow { border-color: var(--warning); } .stat-red { border-color: var(--danger); }
.stat-number { font-size: 1.8rem; font-weight: 800; }
.stat-blue .stat-number { color: var(--primary); } .stat-green .stat-number { color: var(--success); } .stat-yellow .stat-number { color: var(--warning); } .stat-red .stat-number { color: var(--danger); }
.stat-label { color: var(--text-muted); font-size: 0.8rem; margin-top: 0.25rem; }

.charts-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(350px, 1fr)); gap: 1rem; margin-bottom: 1.5rem; }
.chart-card { background: var(--card); border-radius: var(--radius); padding: 1.5rem; box-shadow: var(--shadow); }
.chart-card h3 { margin-bottom: 1rem; font-size: 0.9rem; color: var(--text-muted); }

.card { background: var(--card); border-radius: var(--radius); padding: 1.5rem; box-shadow: var(--shadow); margin-bottom: 1rem; }
.card h3 { margin-bottom: 1rem; font-size: 0.95rem; color: var(--text); border-bottom: 1px solid var(--border); padding-bottom: 0.5rem; }
.grid-2 { display: grid; grid-template-columns: repeat(auto-fit, minmax(350px, 1fr)); gap: 1rem; }

.filters { display: flex; gap: 0.75rem; flex-wrap: wrap; margin-bottom: 1.5rem; background: var(--card); padding: 0.75rem 1rem; border-radius: var(--radius); box-shadow: var(--shadow); align-items: flex-end; }
.filter-group { display: flex; flex-direction: column; gap: 0.2rem; }
.filter-group label { font-size: 0.7rem; color: var(--text-muted); font-weight: 600; }
.filter-group select, .filter-group input { padding: 0.35rem 0.5rem; border: 1px solid var(--border); border-radius: 5px; font-size: 0.8rem; min-width: 130px; }

/* ============ TABLES ============ */
table { width: 100%; border-collapse: collapse; background: var(--card); border-radius: var(--radius); overflow: hidden; box-shadow: var(--shadow); }
th { background: #f0fdfa; padding: 0.6rem; text-align: left; font-size: 0.72rem; color: var(--text-muted); font-weight: 700; text-transform: uppercase; border-bottom: 2px solid var(--border); white-space: nowrap; }
td { padding: 0.5rem 0.6rem; border-bottom: 1px solid var(--border); font-size: 0.8rem; }
tr:hover { background: #f0fdfa; }

.badge { display: inline-block; padding: 0.15rem 0.5rem; border-radius: 50px; font-size: 0.68rem; font-weight: 700; white-space: nowrap; }
.badge-type { color: white; } .badge-normal { background: #dcfce7; color: #166534; } .badge-warning { background: #fee2e2; color: #991b1b; } .badge-pending { background: #e0f2fe; color: #0369a1; }

/* ============ MATRIX ============ */
.matrix-table { border-collapse: collapse; font-size: 0.72rem; width: 100%; }
.matrix-table th, .matrix-table td { border: 1px solid #cbd5e1; padding: 0.35rem; text-align: center; }
.matrix-table th { background: #f0fdfa; font-size: 0.68rem; white-space: nowrap; }
.matrix-table td.cell-done { background: #dcfce7; } .matrix-table td.cell-partial { background: #fef3c7; } .matrix-table td.cell-missing { background: #fee2e2; } .matrix-table td.cell-future { background: #f1f5f9; color: #94a3b8; }
.matrix-table td.row-header { text-align: left; font-weight: 600; min-width: 80px; white-space: nowrap; background: #f8fafc; }

/* ============ OVERDUE ============ */
.urgency-critical { background: #991b1b; color: white; } .urgency-high { background: #dc2626; color: white; } .urgency-medium { background: #f59e0b; color: white; }
.countdown { font-size: 0.75rem; font-weight: 700; padding: 0.15rem 0.4rem; border-radius: 4px; display: inline-block; }
.countdown-overdue { background: #fee2e2; color: #991b1b; } .countdown-urgent { background: #fff7ed; color: #c2410c; }

/* ============ TABS / CHECKLIST ============ */
.tab-group { display: flex; gap: 0.4rem; margin-bottom: 1.5rem; flex-wrap: wrap; }
.tab-btn { padding: 0.4rem 0.8rem; border: 2px solid var(--border); border-radius: 50px; background: var(--card); cursor: pointer; font-size: 0.8rem; font-weight: 600; transition: all 0.2s; }
.tab-btn:hover { border-color: var(--primary); color: var(--primary); } .tab-btn.active { background: var(--primary); color: white; border-color: var(--primary); }

.check-status-select { padding: 0.25rem; border: 1px solid var(--border); border-radius: 4px; font-size: 0.78rem; }
.check-notes-input { padding: 0.25rem; border: 1px solid var(--border); border-radius: 4px; font-size: 0.75rem; width: 100%; }

.temp-legend { display: flex; gap: 0.75rem; flex-wrap: wrap; padding: 0.6rem; background: #f0fdfa; border-radius: 6px; font-size: 0.75rem; margin-bottom: 1rem; }
.temp-legend-item { display: flex; align-items: center; gap: 0.25rem; }
.temp-legend-dot { width: 10px; height: 10px; border-radius: 50%; }

.section-link { color: var(--primary); cursor: pointer; text-decoration: underline; font-size: 0.8rem; }
.section-link:hover { color: var(--primary-dark); }

/* ============ FORMS / MODALS ============ */
.form-group { margin-bottom: 0.75rem; }
.form-group label { display: block; font-size: 0.75rem; font-weight: 600; margin-bottom: 0.2rem; color: var(--text-muted); }
.form-group input, .form-group select, .form-group textarea { width: 100%; padding: 0.4rem 0.6rem; border: 1px solid var(--border); border-radius: 5px; font-size: 0.85rem; }
.form-group textarea { resize: vertical; }
.form-row { display: flex; gap: 0.75rem; flex-wrap: wrap; align-items: flex-end; }
.form-row .form-group { flex: 1; min-width: 130px; }

.empty-state { text-align: center; padding: 2rem; color: var(--text-muted); }
.empty-state .icon { font-size: 2.5rem; margin-bottom: 0.75rem; }

/* ============ TOAST ============ */
.toast-container { position: fixed; bottom: 1.5rem; right: 1.5rem; z-index: 300; display: flex; flex-direction: column; gap: 0.5rem; }
.toast { padding: 0.6rem 1rem; border-radius: 8px; color: white; font-size: 0.8rem; font-weight: 600; box-shadow: var(--shadow-lg); animation: slideIn 0.3s ease; }
.toast-success { background: var(--success); } .toast-error { background: var(--danger); } .toast-info { background: var(--info); }
@keyframes slideIn { from { transform: translateX(100%); opacity: 0; } to { transform: translateX(0); opacity: 1; } }

/* ============ ADMIN (navbar style) ============ */
.navbar {
  background: linear-gradient(135deg, #0c3547 0%, #134e4a 100%);
  color: white; padding: 0 1.5rem; display: flex; align-items: center; height: 56px;
  position: sticky; top: 0; z-index: 100; box-shadow: var(--shadow-lg);
}
.nav-brand { font-size: 1.1rem; font-weight: 700; display: flex; align-items: center; gap: 0.5rem; min-width: 160px; }
.nav-icon { font-size: 1.3rem; }
.nav-links { display: flex; gap: 0.25rem; flex: 1; justify-content: center; }
.nav-link { color: rgba(255,255,255,0.8); text-decoration: none; padding: 0.4rem 0.6rem; border-radius: 5px; font-size: 0.8rem; transition: all 0.2s; }
.nav-link:hover, .nav-link.active { background: rgba(255,255,255,0.2); color: white; }
.nav-actions { display: flex; gap: 0.3rem; min-width: 80px; justify-content: flex-end; }

.admin-header { background: linear-gradient(135deg, #991b1b 0%, #dc2626 100%); color: white; padding: 1.5rem; border-radius: var(--radius); margin-bottom: 1.5rem; }
.admin-header h1 { font-size: 1.3rem; } .admin-header p { opacity: 0.8; font-size: 0.85rem; }
.admin-tabs { display: flex; gap: 0.4rem; margin-bottom: 1.5rem; flex-wrap: wrap; }
.admin-tab { padding: 0.5rem 1rem; border: 2px solid var(--border); border-radius: 6px; background: var(--card); cursor: pointer; font-weight: 600; font-size: 0.8rem; transition: all 0.2s; }
.admin-tab:hover { border-color: var(--danger); color: var(--danger); } .admin-tab.active { background: var(--danger); color: white; border-color: var(--danger); }
.admin-section { display: none; } .admin-section.active { display: block; }
.admin-form { background: var(--card); border-radius: var(--radius); padding: 1.5rem; box-shadow: var(--shadow); margin-bottom: 1.5rem; }
.admin-form h3 { margin-bottom: 0.75rem; }
.admin-table-wrap { background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow); overflow-x: auto; }

/* ============ RESPONSIVE ============ */
@media (max-width: 768px) {
  .charts-grid { grid-template-columns: 1fr; }
  .grid-2 { grid-template-columns: 1fr; }
  .filters { flex-direction: column; }
  .filter-group select, .filter-group input { min-width: 100%; }
  .admin-tabs { overflow-x: auto; }
}
