/* ===== CSS Variables ===== */
:root {
  --primary: #1a73e8;
  --primary-dark: #1557b0;
  --primary-light: #e8f0fe;
  --success: #0d9488;
  --success-light: #ccfbf1;
  --warning: #f59e0b;
  --warning-light: #fef3c7;
  --danger: #dc2626;
  --danger-light: #fee2e2;
  --purple: #8b5cf6;
  --purple-light: #ede9fe;
  --bg: #f5f7fa;
  --sidebar-bg: #1e293b;
  --sidebar-text: #94a3b8;
  --sidebar-active: #3b82f6;
  --sidebar-hover: #334155;
  --card-bg: #fff;
  --text: #1e293b;
  --text-secondary: #64748b;
  --text-muted: #94a3b8;
  --border: #e2e8f0;
  --radius: 8px;
  --radius-sm: 4px;
  --shadow: 0 1px 3px rgba(0,0,0,.1);
  --shadow-md: 0 4px 12px rgba(0,0,0,.1);
  --shadow-lg: 0 8px 24px rgba(0,0,0,.15);
  --sidebar-width: 240px;
  --topbar-height: 56px;
  --transition: 0.2s ease;
}

/* ===== Reset ===== */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html, body { height: 100%; }
body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'PingFang SC', 'Microsoft YaHei', sans-serif;
  font-size: 14px;
  color: var(--text);
  background: var(--bg);
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}
a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }
ul, ol { list-style: none; }
img { max-width: 100%; }

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

/* ===== Sidebar ===== */
.sidebar {
  width: var(--sidebar-width);
  background: var(--sidebar-bg);
  color: var(--sidebar-text);
  display: flex;
  flex-direction: column;
  position: fixed;
  top: 0;
  left: 0;
  bottom: 0;
  z-index: 100;
  transition: transform var(--transition);
}

.sidebar-brand {
  padding: 20px;
  display: flex;
  align-items: center;
  gap: 10px;
  border-bottom: 1px solid rgba(255,255,255,.06);
}
.sidebar-brand .brand-icon {
  width: 32px; height: 32px;
  background: var(--sidebar-active);
  border-radius: var(--radius-sm);
  display: flex; align-items: center; justify-content: center;
  color: #fff; font-size: 16px; font-weight: 700;
}
.sidebar-brand .brand-name {
  color: #fff;
  font-size: 16px;
  font-weight: 600;
}

.sidebar-user {
  padding: 14px 20px;
  border-bottom: 1px solid rgba(255,255,255,.06);
  display: flex;
  align-items: center;
  gap: 10px;
}
.sidebar-user .user-avatar {
  width: 36px; height: 36px;
  border-radius: 50%;
  background: var(--sidebar-active);
  display: flex; align-items: center; justify-content: center;
  color: #fff; font-weight: 600; font-size: 14px;
}
.sidebar-user .user-info { flex: 1; min-width: 0; }
.sidebar-user .user-name {
  color: #e2e8f0; font-size: 13px; font-weight: 500;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.sidebar-user .user-role {
  color: var(--sidebar-text); font-size: 11px;
}

.sidebar-nav {
  flex: 1;
  padding: 12px 0;
  overflow-y: auto;
}
.sidebar-nav .nav-section {
  padding: 8px 20px 4px;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--sidebar-text);
  opacity: .5;
}
.sidebar-nav a {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 20px;
  color: var(--sidebar-text);
  font-size: 14px;
  transition: all var(--transition);
  border-left: 3px solid transparent;
  text-decoration: none;
}
.sidebar-nav a:hover {
  background: var(--sidebar-hover);
  color: #e2e8f0;
}
.sidebar-nav a.active {
  background: rgba(59,130,246,.15);
  color: #fff;
  border-left-color: var(--sidebar-active);
}
.sidebar-nav a .nav-icon {
  width: 20px;
  text-align: center;
  font-size: 16px;
}

.sidebar-footer {
  padding: 12px 20px;
  border-top: 1px solid rgba(255,255,255,.06);
}
.sidebar-footer a {
  display: flex; align-items: center; gap: 8px;
  color: var(--sidebar-text); font-size: 13px;
  padding: 6px 0;
  cursor: pointer;
  text-decoration: none;
}
.sidebar-footer a:hover { color: #e2e8f0; }

/* ===== Main Content ===== */
.main-content {
  flex: 1;
  margin-left: var(--sidebar-width);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}
.main-content.login-mode {
  margin-left: 0;
}

/* ===== Topbar ===== */
.topbar {
  height: var(--topbar-height);
  background: var(--card-bg);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  padding: 0 24px;
  gap: 16px;
  position: sticky;
  top: 0;
  z-index: 50;
}
.topbar .sidebar-toggle {
  display: none;
  background: none; border: none;
  font-size: 22px; cursor: pointer;
  color: var(--text-secondary);
  padding: 4px;
}
.topbar .breadcrumb {
  font-size: 13px;
  color: var(--text-secondary);
}
.topbar .breadcrumb span { color: var(--text); font-weight: 500; }

/* ===== Page Container ===== */
.page-container {
  flex: 1;
  padding: 24px;
}

.page-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 20px;
  flex-wrap: wrap;
  gap: 12px;
}
.page-header h2 {
  font-size: 20px;
  font-weight: 600;
  color: var(--text);
}
.page-header-actions {
  display: flex;
  gap: 8px;
}

/* ===== Cards ===== */
.card {
  background: var(--card-bg);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 20px;
  margin-bottom: 20px;
}
.card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 16px;
}
.card-header h3 {
  font-size: 16px;
  font-weight: 600;
  color: var(--text);
}
.card-header .card-subtitle {
  font-size: 12px;
  color: var(--text-muted);
}

/* ===== Stat Cards ===== */
.stat-cards {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 16px;
  margin-bottom: 24px;
}
.stat-card {
  background: var(--card-bg);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 20px;
  display: flex;
  align-items: flex-start;
  gap: 14px;
  transition: box-shadow var(--transition);
}
.stat-card:hover { box-shadow: var(--shadow-md); }
.stat-card .stat-icon {
  width: 44px; height: 44px;
  border-radius: var(--radius);
  display: flex; align-items: center; justify-content: center;
  font-size: 20px;
  flex-shrink: 0;
}
.stat-card .stat-icon.blue { background: var(--primary-light); color: var(--primary); }
.stat-card .stat-icon.green { background: var(--success-light); color: var(--success); }
.stat-card .stat-icon.orange { background: var(--warning-light); color: var(--warning); }
.stat-card .stat-icon.red { background: var(--danger-light); color: var(--danger); }
.stat-card .stat-icon.purple { background: var(--purple-light); color: var(--purple); }
.stat-card .stat-body { flex: 1; min-width: 0; }
.stat-card .stat-label {
  font-size: 12px; color: var(--text-secondary);
  margin-bottom: 4px;
}
.stat-card .stat-value {
  font-size: 26px; font-weight: 700; color: var(--text);
  line-height: 1.2;
}
.stat-card .stat-sub {
  font-size: 11px; color: var(--text-muted);
  margin-top: 2px;
}

/* ===== Tables ===== */
.data-table-wrapper {
  overflow-x: auto;
}
.data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}
.data-table thead th {
  background: var(--bg);
  padding: 10px 12px;
  text-align: left;
  font-weight: 600;
  color: var(--text-secondary);
  border-bottom: 2px solid var(--border);
  white-space: nowrap;
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.3px;
}
.data-table tbody td {
  padding: 10px 12px;
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
}
.data-table tbody tr:hover { background: #f8fafc; }
.data-table .text-right { text-align: right; }
.data-table .text-center { text-align: center; }
.data-table .text-mono { font-family: 'SF Mono', 'Fira Code', monospace; font-size: 12px; }
.data-table .actions {
  display: flex; gap: 4px;
  white-space: nowrap;
}

/* ===== Badges ===== */
.badge {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 10px;
  font-size: 11px;
  font-weight: 500;
  line-height: 1.6;
}
.badge-green { background: var(--success-light); color: var(--success); }
.badge-blue { background: var(--primary-light); color: var(--primary); }
.badge-orange { background: var(--warning-light); color: #d97706; }
.badge-purple { background: var(--purple-light); color: var(--purple); }
.badge-red { background: var(--danger-light); color: var(--danger); }
.badge-gray { background: #f1f5f9; color: #64748b; }
.badge-gold { background: #fef9c3; color: #a16207; }

/* ===== Buttons ===== */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 8px 16px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  background: var(--card-bg);
  color: var(--text);
  transition: all var(--transition);
  white-space: nowrap;
  line-height: 1.4;
  text-decoration: none;
}
.btn:hover { background: #f8fafc; border-color: #cbd5e1; }
.btn:active { transform: scale(0.98); }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn-primary {
  background: var(--primary);
  color: #fff;
  border-color: var(--primary);
}
.btn-primary:hover { background: var(--primary-dark); border-color: var(--primary-dark); }
.btn-success {
  background: var(--success);
  color: #fff;
  border-color: var(--success);
}
.btn-success:hover { background: #0f766e; border-color: #0f766e; }
.btn-danger {
  background: var(--danger);
  color: #fff;
  border-color: var(--danger);
}
.btn-danger:hover { background: #b91c1c; border-color: #b91c1c; }
.btn-warning {
  background: var(--warning);
  color: #fff;
  border-color: var(--warning);
}
.btn-warning:hover { background: #d97706; border-color: #d97706; }
.btn-sm { padding: 4px 10px; font-size: 12px; }
.btn-lg { padding: 10px 24px; font-size: 15px; }
.btn-icon { padding: 6px; width: 32px; height: 32px; }
.btn-link {
  background: none; border: none;
  color: var(--primary); padding: 4px 8px;
  cursor: pointer; font-size: 13px;
}
.btn-link:hover { text-decoration: underline; background: none; }
.btn-link.danger { color: var(--danger); }

/* ===== Forms ===== */
.form-group {
  margin-bottom: 16px;
}
.form-group label {
  display: block;
  margin-bottom: 4px;
  font-size: 13px;
  font-weight: 500;
  color: var(--text);
}
.form-group .required::after {
  content: ' *';
  color: var(--danger);
}
.form-group .form-hint {
  font-size: 11px; color: var(--text-muted);
  margin-top: 2px;
}
.form-control {
  width: 100%;
  padding: 8px 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 13px;
  color: var(--text);
  background: var(--card-bg);
  transition: border-color var(--transition);
  outline: none;
  font-family: inherit;
}
.form-control:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(26,115,232,.1);
}
.form-control::placeholder { color: var(--text-muted); }
textarea.form-control { min-height: 80px; resize: vertical; }
select.form-control { cursor: pointer; appearance: none; background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath d='M6 8L1 3h10z' fill='%2364748b'/%3E%3C/svg%3E"); background-repeat: no-repeat; background-position: right 10px center; padding-right: 30px; }
.form-checkbox {
  display: flex; align-items: center; gap: 6px;
  font-size: 13px; cursor: pointer;
}
.form-checkbox input[type="checkbox"] {
  width: 16px; height: 16px; accent-color: var(--primary);
}
.form-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
}
.form-row.three { grid-template-columns: 1fr 1fr 1fr; }
.form-actions {
  display: flex;
  gap: 8px;
  justify-content: flex-end;
  margin-top: 20px;
  padding-top: 16px;
  border-top: 1px solid var(--border);
}

/* ===== Search Box ===== */
.search-box {
  display: flex;
  align-items: center;
  gap: 8px;
}
.search-box .form-control {
  width: 240px;
  padding-left: 34px;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%2394a3b8' stroke-width='2'%3E%3Ccircle cx='11' cy='11' r='8'/%3E%3Cpath d='m21 21-4.35-4.35'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: 10px center;
}

/* ===== Pagination ===== */
.pagination {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 4px;
  padding: 16px 0;
}
.pagination button {
  width: 32px; height: 32px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--card-bg);
  color: var(--text);
  font-size: 13px;
  cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  transition: all var(--transition);
}
.pagination button:hover { background: #f1f5f9; }
.pagination button.active {
  background: var(--primary);
  color: #fff;
  border-color: var(--primary);
}
.pagination button:disabled { opacity: .5; cursor: not-allowed; }
.pagination .page-info {
  font-size: 12px; color: var(--text-secondary);
  margin: 0 8px;
}

/* ===== Modal ===== */

/* Modal */
.modal-wrapper {
  position: fixed; top: 0; left: 0; right: 0; bottom: 0;
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(0,0,0,.5);
  animation: fadeIn .15s ease;
}
.modal-wrapper .modal-overlay {
  /* inside modal-wrapper, overlay is just a transparent spacer */
  position: absolute;
  top: 0; left: 0; right: 0; bottom: 0;
  background: transparent;
  z-index: 1;
}
.modal-wrapper .modal {
  position: relative;
  z-index: 2;
}
.modal-overlay {
  position: fixed;
  top: 0; left: 0; right: 0; bottom: 0;
  background: rgba(0,0,0,.5);
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
  animation: fadeIn .15s ease;
  overflow-y: auto;
}
.modal {
  background: var(--card-bg);
  border-radius: var(--radius);
  box-shadow: var(--shadow-lg);
  width: 90%;
  max-width: 640px;
  max-height: 85vh;
  display: flex;
  flex-direction: column;
  animation: slideUp .2s ease;
  margin: auto;
}
.modal.wide { max-width: 800px; }
.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 20px;
  border-bottom: 1px solid var(--border);
}
.modal-header h3 { font-size: 16px; font-weight: 600; }
.modal-close {
  background: none; border: none;
  font-size: 20px; cursor: pointer;
  color: var(--text-muted);
  padding: 4px; line-height: 1;
}
.modal-close:hover { color: var(--text); }
.modal-body {
  padding: 20px;
  overflow-y: auto;
  flex: 1;
}
.modal-footer {
  padding: 12px 20px;
  border-top: 1px solid var(--border);
  display: flex;
  gap: 8px;
  justify-content: flex-end;
}

@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }
@keyframes slideUp { from { opacity: 0; transform: translateY(20px); } to { opacity: 1; transform: translateY(0); } }

/* ===== Toast ===== */
.toast-container {
  position: fixed;
  top: 20px;
  right: 20px;
  z-index: 300;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.toast {
  padding: 12px 20px;
  border-radius: var(--radius-sm);
  box-shadow: var(--shadow-md);
  font-size: 13px;
  color: #fff;
  display: flex;
  align-items: center;
  gap: 8px;
  animation: slideIn .25s ease;
  min-width: 200px;
  max-width: 380px;
}
.toast-success { background: var(--success); }
.toast-error { background: var(--danger); }
.toast-warning { background: #d97706; }
.toast-info { background: var(--primary); }
.toast-close {
  background: none; border: none;
  color: inherit; cursor: pointer;
  margin-left: auto; opacity: .7;
  font-size: 16px;
}
.toast-close:hover { opacity: 1; }

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

/* ===== Confirm Dialog ===== */
.confirm-overlay {
  position: fixed;
  top: 0; left: 0; right: 0; bottom: 0;
  background: rgba(0,0,0,.5);
  z-index: 2; /* above overlay */
  display: flex;
  align-items: center;
  justify-content: center;
}
.confirm-dialog {
  background: var(--card-bg);
  border-radius: var(--radius);
  box-shadow: var(--shadow-lg);
  padding: 24px;
  max-width: 400px;
  width: 90%;
  text-align: center;
}
.confirm-dialog .confirm-icon {
  font-size: 40px; margin-bottom: 12px;
}
.confirm-dialog .confirm-icon.warn { color: var(--warning); }
.confirm-dialog .confirm-icon.danger { color: var(--danger); }
.confirm-dialog .confirm-title {
  font-size: 16px; font-weight: 600;
  margin-bottom: 8px;
}
.confirm-dialog .confirm-message {
  font-size: 13px; color: var(--text-secondary);
  margin-bottom: 20px;
}
.confirm-dialog .confirm-actions {
  display: flex; gap: 8px; justify-content: center;
}

/* ===== Loading ===== */
.loading {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 40px;
  color: var(--text-muted);
  font-size: 14px;
}
.loading::before {
  content: '';
  width: 20px; height: 20px;
  border: 2px solid var(--border);
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: spin .6s linear infinite;
  margin-right: 8px;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ===== Empty State ===== */
.empty-state {
  text-align: center;
  padding: 60px 20px;
  color: var(--text-muted);
}
.empty-state .empty-icon { font-size: 48px; margin-bottom: 12px; }
.empty-state .empty-title { font-size: 16px; color: var(--text-secondary); margin-bottom: 4px; }
.empty-state .empty-desc { font-size: 13px; }

/* ===== Charts (Simple CSS) ===== */
.chart-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 20px;
  margin-bottom: 20px;
}
.chart-card {
  background: var(--card-bg);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 20px;
}
.chart-card h4 {
  font-size: 14px; font-weight: 600;
  margin-bottom: 16px;
  color: var(--text);
}

/* ===== Period Stats ===== */
.period-stats-row {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 16px;
  margin-bottom: 20px;
}
.period-card {
  background: var(--card-bg);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 16px;
  border-left: 3px solid var(--primary);
}
.period-card:nth-child(2) { border-left-color: #0d9488; }
.period-card:nth-child(3) { border-left-color: #8b5cf6; }
.period-title {
  font-weight: 600;
  font-size: 14px;
  margin-bottom: 10px;
  color: var(--text);
}
.period-metrics { display: flex; flex-direction: column; gap: 6px; }
.period-metric {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
}
.pm-label { color: var(--text-muted); min-width: 60px; }
.pm-value { font-weight: 600; color: var(--text); min-width: 36px; }
.pm-sub { color: var(--text-muted); font-size: 12px; }

/* ===== Triple Grid ===== */
.triple-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 20px;
}

/* ===== Compact Table ===== */
.data-table.compact { font-size: 12px; }
.data-table.compact th,
.data-table.compact td { padding: 6px 10px; }

/* Bar chart */
.bar-chart {
  display: flex;
  align-items: flex-end;
  gap: 6px;
  height: 160px;
  padding-bottom: 20px;
  border-bottom: 1px solid var(--border);
}
.bar-chart .bar-item {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  min-width: 0;
}
.bar-chart .bar-value {
  font-size: 10px;
  color: var(--text-muted);
}
.bar-chart .bar-fill {
  width: 100%;
  max-width: 32px;
  border-radius: 3px 3px 0 0;
  background: var(--primary);
  transition: height .3s ease;
  min-height: 2px;
}
.bar-chart .bar-label {
  font-size: 10px;
  color: var(--text-muted);
  margin-top: 4px;
  white-space: nowrap;
}

/* Horizontal bar chart */
.hbar-chart {
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.hbar-item {
  display: flex;
  align-items: center;
  gap: 8px;
}
.hbar-label {
  width: 80px;
  font-size: 12px;
  color: var(--text-secondary);
  text-align: right;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  flex-shrink: 0;
}
.hbar-track {
  flex: 1;
  height: 20px;
  background: var(--bg);
  border-radius: 3px;
  overflow: hidden;
}
.hbar-fill {
  height: 100%;
  border-radius: 3px;
  transition: width .3s ease;
  min-width: 2px;
}
.hbar-value {
  width: 48px;
  font-size: 12px;
  color: var(--text);
  text-align: right;
  flex-shrink: 0;
}

/* ===== Toolbar ===== */
.toolbar {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
  margin-bottom: 16px;
  padding-bottom: 16px;
  border-bottom: 1px solid var(--border);
}
.toolbar .toolbar-spacer { flex: 1; }

/* ===== Login Page ===== */
.login-page {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(135deg, #1e293b 0%, #334155 50%, #1e293b 100%);
}
.login-card {
  background: var(--card-bg);
  border-radius: var(--radius);
  box-shadow: var(--shadow-lg);
  padding: 40px;
  width: 380px;
  max-width: 90%;
}
.login-card .login-logo {
  text-align: center;
  margin-bottom: 28px;
}
.login-card .login-logo .logo-icon {
  width: 56px; height: 56px;
  background: var(--primary);
  border-radius: 12px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: #fff; font-size: 24px; font-weight: 700;
  margin-bottom: 12px;
}
.login-card .login-logo h1 {
  font-size: 20px; font-weight: 600;
  color: var(--text);
}
.login-card .login-logo p {
  font-size: 13px; color: var(--text-muted);
  margin-top: 4px;
}
.login-card .login-error {
  background: var(--danger-light);
  color: var(--danger);
  padding: 8px 12px;
  border-radius: var(--radius-sm);
  font-size: 12px;
  margin-bottom: 16px;
  display: none;
}
.login-card .btn { width: 100%; padding: 10px; font-size: 14px; }

/* ===== Order Detail ===== */
.detail-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
  margin-bottom: 20px;
}
.detail-item label {
  font-size: 12px; color: var(--text-muted);
  display: block; margin-bottom: 2px;
}
.detail-item .detail-value {
  font-size: 14px; font-weight: 500;
  color: var(--text);
}

/* ===== Photo Gallery ===== */
.detail-section {
  margin: 16px 0;
  padding: 12px;
  background: var(--bg-subtle, #f8f9fa);
  border-radius: 8px;
}
.detail-section h5 {
  font-size: 13px; font-weight: 600;
  margin-bottom: 8px;
  color: var(--text);
}
.photo-gallery {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
}

/* ===== Order Lifecycle Timeline ===== */
.lifecycle-timeline { padding: 8px 0; }
.lifecycle-step {
  display: flex; align-items: flex-start; gap: 12px;
  position: relative; padding-bottom: 4px;
}
.lifecycle-dot {
  width: 32px; height: 32px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-size: 14px; flex-shrink: 0;
  border: 2px solid var(--border); background: #fff;
}
.lifecycle-done { border-color: var(--success); background: #f0fdf4; }
.lifecycle-pending { border-color: #e2e8f0; background: #f8fafc; opacity: 0.6; }
.lifecycle-info { padding-top: 4px; }
.lifecycle-label { font-size: 13px; font-weight: 600; color: var(--text); }
.lifecycle-date { font-size: 11px; color: var(--text-secondary); }
.lifecycle-line {
  width: 2px; height: 16px; background: var(--border);
  margin: 2px 0 2px 15px;
}
.lifecycle-line.done { background: var(--success); }

/* ===== Alert ===== */
.alert {
  padding: 10px 14px; border-radius: var(--radius-sm);
  font-size: 13px; margin-bottom: 12px;
}
.alert-danger { background: #fef2f2; color: #991b1b; border: 1px solid #fecaca; }
.alert-warning { background: #fffbeb; color: #92400e; border: 1px solid #fde68a; }
.alert-success { background: #f0fdf4; color: #166534; border: 1px solid #bbf7d0; }

/* ===== Status Timeline ===== */
.status-timeline {
  display: flex;
  align-items: center;
  gap: 0;
  padding: 16px 0;
}
.status-step {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  color: var(--text-muted);
}
.status-step .step-dot {
  width: 10px; height: 10px;
  border-radius: 50%;
  background: var(--border);
}
.status-step.active { color: var(--primary); }
.status-step.active .step-dot { background: var(--primary); }
.status-step.done { color: var(--success); }
.status-step.done .step-dot { background: var(--success); }
.status-line {
  flex: 1;
  height: 2px;
  background: var(--border);
  margin: 0 8px;
}
.status-line.done { background: var(--success); }

/* ===== Responsive ===== */
@media (max-width: 768px) {
  .sidebar {
    transform: translateX(-100%);
  }
  .sidebar.open {
    transform: translateX(0);
  }
  .main-content {
    margin-left: 0;
  }
  .topbar .sidebar-toggle {
    display: block;
  }
  .chart-grid {
    grid-template-columns: 1fr;
  }
  .period-stats-row,
  .triple-grid {
    grid-template-columns: 1fr;
  }
  .form-row, .form-row.three {
    grid-template-columns: 1fr;
  }
  .detail-grid {
    grid-template-columns: 1fr;
  }
  .stat-cards {
    grid-template-columns: 1fr 1fr;
  }
  .toolbar {
    flex-direction: column;
    align-items: stretch;
  }
  .search-box .form-control {
    width: 100%;
  }
  .modal { width: 95%; max-width: 95%; }
}

/* ===== Mobile overlay ===== */
.sidebar-overlay {
  display: none;
  position: fixed;
  top: 0; left: 0; right: 0; bottom: 0;
  background: rgba(0,0,0,.5);
  z-index: 99;
}
@media (max-width: 768px) {
  .sidebar-overlay.show { display: block; }
}

/* ===== Misc ===== */
.text-success { color: var(--success); }
.text-danger { color: var(--danger); }
.text-warning { color: #d97706; }
.text-muted { color: var(--text-muted); }
.mt-0 { margin-top: 0; }
.mb-0 { margin-bottom: 0; }
.mb-8 { margin-bottom: 8px; }
.mb-16 { margin-bottom: 16px; }
.mr-8 { margin-right: 8px; }
.text-sm { font-size: 12px; }
.text-xs { font-size: 11px; }
.font-mono { font-family: 'SF Mono', 'Fira Code', monospace; }
.truncate { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* ===== Multi-select for vehicle selection ===== */
.selected-vehicles {
  margin-top: 8px;
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
}
.selected-vehicle-tag {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 2px 8px;
  background: var(--primary-light);
  color: var(--primary);
  border-radius: 10px;
  font-size: 12px;
}
.selected-vehicle-tag .remove-tag {
  cursor: pointer;
  font-size: 14px;
  line-height: 1;
  opacity: .7;
}
.selected-vehicle-tag .remove-tag:hover { opacity: 1; }

.vehicle-list-picker {
  max-height: 200px;
  overflow-y: auto;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  margin-top: 4px;
}
.vehicle-list-picker .vehicle-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 10px;
  cursor: pointer;
  font-size: 13px;
  border-bottom: 1px solid var(--border);
  transition: background .15s;
}
.vehicle-list-picker .vehicle-item:last-child { border-bottom: none; }
.vehicle-list-picker .vehicle-item:hover { background: #f8fafc; }
.vehicle-list-picker .vehicle-item.selected { background: var(--primary-light); }

/* Vehicle search in order create */
.vehicle-search-row {
  display: flex;
  gap: 8px;
  margin-bottom: 6px;
}
.vehicle-search-row input { flex: 1; }

.veh-badge-green { background: #dcfce7; color: #166534; font-size: 11px; padding: 1px 6px; }
.veh-badge-blue { background: #dbeafe; color: #1e40af; font-size: 11px; padding: 1px 6px; }

/* ===== Filter bar ===== */
.filter-bar {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}
.filter-bar select.form-control {
  width: auto;
  min-width: 120px;
}

/* ===== NProgress-like top bar ===== */
#nprogress {
  position: fixed;
  top: 0; left: 0; right: 0;
  height: 2px;
  background: var(--primary);
  z-index: 999;
  display: none;
  transition: width .3s;
}
/* ===== NProgress-like top bar (deduplicated from top) ===== */
