/* ===================================================
   STYLE.CSS – FactoryFlow Design System
   =================================================== */

/* ===== DARK THEME (default) ===== */
:root {
  --bg: #0f172a;
  --bg2: #1e293b;
  --bg3: #263249;
  --surface: #1e293b;
  --surface2: #263249;
  --border: #334155;
  --text: #f1f5f9;
  --text2: #94a3b8;
  --text3: #64748b;
  --blue: #3b82f6;
  --green: #22c55e;
  --yellow: #f59e0b;
  --red: #ef4444;
  --orange: #f97316;
  --purple: #8b5cf6;
  --cyan: #06b6d4;
  --sidebar-w: 240px;
  --radius: 10px;
  --shadow: 0 4px 24px rgba(0,0,0,0.4);
}

/* ===== LIGHT THEME ===== */
[data-theme="light"] {
  --bg: #f1f5f9;
  --bg2: #ffffff;
  --bg3: #e2e8f0;
  --surface: #ffffff;
  --surface2: #f8fafc;
  --border: #cbd5e1;
  --text: #0f172a;
  --text2: #475569;
  --text3: #94a3b8;
  --shadow: 0 4px 24px rgba(0,0,0,0.10);
}

[data-theme="light"] .login-page {
  background: linear-gradient(135deg, #e2e8f0 0%, #f1f5f9 50%, #e2e8f0 100%);
}

[data-theme="light"] .sidebar { border-right-color: var(--border); }
[data-theme="light"] .nav-item.active { background: rgba(59,130,246,.1); }
[data-theme="light"] .data-table th { background: var(--bg3); }
[data-theme="light"] .kanban-card { background: var(--bg3); }
[data-theme="light"] .topbar { background: var(--surface); }

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

body {
  font-family: 'Inter', sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
}

a { text-decoration: none; color: inherit; }

/* ===== SCROLLBAR ===== */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: var(--bg2); }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 3px; }

/* ===== LOGIN ===== */
.login-page {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  background: linear-gradient(135deg, #0f172a 0%, #1e293b 50%, #0f172a 100%);
}

.login-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 2.5rem;
  width: 100%;
  max-width: 420px;
  box-shadow: var(--shadow);
}

.login-logo {
  text-align: center;
  margin-bottom: 2rem;
}

.login-logo i {
  font-size: 3rem;
  color: var(--blue);
  margin-bottom: .5rem;
}

.login-logo h1 {
  font-size: 2rem;
  font-weight: 800;
  color: var(--text);
}

.login-logo p { color: var(--text2); margin-top: .25rem; }

.login-error {
  background: rgba(239,68,68,.15);
  border: 1px solid var(--red);
  color: var(--red);
  padding: .75rem 1rem;
  border-radius: var(--radius);
  margin-bottom: 1rem;
  font-size: .875rem;
}

.login-hint { text-align: center; margin-top: 1.5rem; color: var(--text3); }

/* ===== LAYOUT ===== */
#appPage { display: flex; min-height: 100vh; }

.sidebar {
  width: var(--sidebar-w);
  background: var(--surface);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  position: fixed;
  top: 0; left: 0;
  height: 100vh;
  z-index: 100;
  transition: width .3s ease;
}

.sidebar.collapsed { width: 60px; }
.sidebar.collapsed .sidebar-header span,
.sidebar.collapsed .nav-item span,
.sidebar.collapsed .user-name,
.sidebar.collapsed .user-role { display: none; }
.sidebar.collapsed .sidebar-footer { padding: .75rem .5rem; }
.sidebar.collapsed .sidebar-header { justify-content: center; }
.sidebar.collapsed .nav-item { justify-content: center; padding: .75rem; }

.sidebar-header {
  display: flex;
  align-items: center;
  gap: .75rem;
  padding: 1.25rem 1rem;
  font-size: 1.1rem;
  font-weight: 700;
  color: var(--blue);
  border-bottom: 1px solid var(--border);
}
.sidebar-header i { font-size: 1.5rem; }

.sidebar-nav { flex: 1; overflow-y: auto; padding: .5rem 0; }

.nav-item {
  display: flex;
  align-items: center;
  gap: .75rem;
  padding: .75rem 1rem;
  color: var(--text2);
  transition: background .2s, color .2s;
  border-radius: 0;
  cursor: pointer;
  font-size: .9rem;
}

.nav-item:hover { background: var(--bg3); color: var(--text); }
.nav-item.active { background: rgba(59,130,246,.15); color: var(--blue); border-right: 3px solid var(--blue); }
.nav-item i { width: 20px; text-align: center; }

.sidebar-footer {
  padding: 1rem;
  border-top: 1px solid var(--border);
}

.user-info { display: flex; align-items: center; gap: .75rem; margin-bottom: .75rem; }
.user-avatar i { font-size: 2rem; color: var(--text3); }
.user-name { font-size: .875rem; font-weight: 600; }
.user-role { font-size: .75rem; color: var(--text2); }

.btn-logout {
  width: 100%;
  background: rgba(239,68,68,.1);
  border: 1px solid rgba(239,68,68,.3);
  color: var(--red);
  padding: .5rem;
  border-radius: var(--radius);
  cursor: pointer;
  font-size: .875rem;
  transition: background .2s;
}
.btn-logout:hover { background: rgba(239,68,68,.2); }

/* ===== MAIN CONTENT ===== */
.main-content {
  margin-left: var(--sidebar-w);
  flex: 1;
  display: flex;
  flex-direction: column;
  min-height: 100vh;
  transition: margin-left .3s ease;
}

.sidebar.collapsed ~ .main-content { margin-left: 60px; }

.topbar {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  padding: .875rem 1.5rem;
  display: flex;
  align-items: center;
  gap: 1rem;
  position: sticky;
  top: 0;
  z-index: 90;
}

.sidebar-toggle {
  background: none;
  border: none;
  color: var(--text2);
  cursor: pointer;
  font-size: 1.2rem;
  padding: .25rem;
}
.sidebar-toggle:hover { color: var(--text); }

.topbar-title {
  flex: 1;
  font-size: 1.1rem;
  font-weight: 600;
}

.topbar-actions { display: flex; align-items: center; gap: 1rem; }

.alert-bell {
  position: relative;
  cursor: pointer;
  color: var(--text2);
  font-size: 1.2rem;
  padding: .5rem;
  border-radius: 50%;
  transition: background .2s;
}
.alert-bell:hover { background: var(--bg3); color: var(--text); }
.alert-bell .badge {
  position: absolute;
  top: 2px; right: 2px;
  background: var(--red);
  color: white;
  font-size: .65rem;
  font-weight: 700;
  min-width: 16px;
  height: 16px;
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0 3px;
}

.alert-dropdown {
  position: fixed;
  top: 60px; right: 20px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  width: 320px;
  max-height: 400px;
  overflow-y: auto;
  z-index: 200;
  box-shadow: var(--shadow);
}

.alert-header {
  padding: .875rem 1rem;
  font-weight: 600;
  border-bottom: 1px solid var(--border);
  color: var(--yellow);
}

/* ===== PAGES ===== */
.page { display: none; padding: 1.5rem; }
.page.active { display: block; }

.page-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 1.5rem;
  flex-wrap: wrap;
  gap: 1rem;
}

.page-header h2 {
  font-size: 1.4rem;
  font-weight: 700;
  display: flex;
  align-items: center;
  gap: .5rem;
}
.page-header h2 i { color: var(--blue); }

.header-actions { display: flex; align-items: center; gap: .75rem; flex-wrap: wrap; }

/* ===== BUTTONS ===== */
.btn {
  display: inline-flex;
  align-items: center;
  gap: .4rem;
  padding: .625rem 1.25rem;
  border-radius: var(--radius);
  font-size: .875rem;
  font-weight: 500;
  cursor: pointer;
  border: none;
  transition: opacity .2s, transform .1s;
}
.btn:hover { opacity: .85; }
.btn:active { transform: scale(.97); }
.btn-block { width: 100%; justify-content: center; }

.btn-primary { background: var(--blue); color: white; }
.btn-success { background: var(--green); color: white; }
.btn-warning { background: var(--yellow); color: #1e293b; }
.btn-danger  { background: var(--red); color: white; }
.btn-secondary { background: var(--bg3); color: var(--text2); border: 1px solid var(--border); }
.btn-outline  { background: transparent; color: var(--text2); border: 1px solid var(--border); }
.btn-sm { padding: .375rem .75rem; font-size: .8rem; }

/* ===== FORMS ===== */
.form-group { margin-bottom: 1rem; }
.form-group label {
  display: block;
  font-size: .8rem;
  font-weight: 500;
  color: var(--text2);
  margin-bottom: .375rem;
  text-transform: uppercase;
  letter-spacing: .04em;
}

.form-group input,
.form-group select,
.form-group textarea {
  width: 100%;
  background: var(--bg);
  border: 1px solid var(--border);
  color: var(--text);
  padding: .625rem .875rem;
  border-radius: var(--radius);
  font-size: .9rem;
  transition: border-color .2s;
}

.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus {
  outline: none;
  border-color: var(--blue);
}

.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: .75rem; }

.search-input {
  background: var(--bg2);
  border: 1px solid var(--border);
  color: var(--text);
  padding: .5rem 1rem;
  border-radius: var(--radius);
  font-size: .875rem;
  width: 220px;
}

/* ===== METRICS ===== */
.metrics-row {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: 1rem;
  margin-bottom: 1.5rem;
}

.metric-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.25rem;
  text-align: center;
  cursor: default;
  transition: transform .2s, box-shadow .2s;
  position: relative;
  overflow: hidden;
}
.metric-card:hover { transform: translateY(-2px); box-shadow: var(--shadow); }

.metric-icon { font-size: 1.5rem; margin-bottom: .5rem; opacity: .7; }
.metric-num  { font-size: 2rem; font-weight: 800; }
.metric-label { font-size: .75rem; color: var(--text2); margin-top: .25rem; text-transform: uppercase; letter-spacing: .04em; }

.metric-blue   { border-top: 3px solid var(--blue);   } .metric-blue .metric-num   { color: var(--blue); }
.metric-green  { border-top: 3px solid var(--green);  } .metric-green .metric-num  { color: var(--green); }
.metric-yellow { border-top: 3px solid var(--yellow); } .metric-yellow .metric-num { color: var(--yellow); }
.metric-red    { border-top: 3px solid var(--red);    } .metric-red .metric-num    { color: var(--red); }
.metric-orange { border-top: 3px solid var(--orange); } .metric-orange .metric-num { color: var(--orange); }
.metric-purple { border-top: 3px solid var(--purple); } .metric-purple .metric-num { color: var(--purple); }

/* ===== FILTER TABS ===== */
.filter-tabs, .section-tabs {
  display: flex;
  gap: .5rem;
  margin-bottom: 1.25rem;
  flex-wrap: wrap;
}

.tab-btn {
  background: var(--bg2);
  border: 1px solid var(--border);
  color: var(--text2);
  padding: .5rem 1rem;
  border-radius: 20px;
  font-size: .8rem;
  cursor: pointer;
  transition: all .2s;
}
.tab-btn:hover { background: var(--bg3); color: var(--text); }
.tab-btn.active { background: var(--blue); color: white; border-color: var(--blue); }

/* ===== LOT CARDS ===== */
.lots-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 1rem;
}

.lot-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.25rem;
  cursor: pointer;
  transition: transform .2s, box-shadow .2s, border-color .2s;
  position: relative;
}
.lot-card:hover { transform: translateY(-2px); box-shadow: var(--shadow); border-color: var(--blue); }
.lot-card.late { border-color: var(--red) !important; }
.lot-card.alert-lot { border-color: var(--yellow) !important; }

.lot-card-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: .75rem; }
.lot-number { font-size: 1rem; font-weight: 700; color: var(--blue); }

.priority-badge {
  font-size: .7rem;
  font-weight: 600;
  padding: .25rem .6rem;
  border-radius: 12px;
  color: white;
  text-transform: uppercase;
  letter-spacing: .04em;
}

.lot-client { font-weight: 600; margin-bottom: .375rem; font-size: .9rem; }
.lot-paint  { color: var(--text2); font-size: .85rem; margin-bottom: .5rem; }

.lot-sector-badge {
  display: inline-flex;
  align-items: center;
  gap: .35rem;
  font-size: .75rem;
  font-weight: 600;
  padding: .3rem .75rem;
  border-radius: 12px;
  color: white;
  margin-bottom: .5rem;
}

.lot-meta { display: flex; justify-content: space-between; font-size: .78rem; color: var(--text2); margin-bottom: .375rem; flex-wrap: wrap; gap: .25rem; }
.lot-city { font-size: .78rem; color: var(--text3); margin-bottom: .5rem; }
.lot-actions { display: flex; gap: .5rem; margin-top: .75rem; }

.alert-banner {
  background: rgba(245,158,11,.1);
  border: 1px solid rgba(245,158,11,.3);
  color: var(--yellow);
  padding: .375rem .625rem;
  border-radius: 6px;
  font-size: .75rem;
  margin-bottom: .5rem;
}

/* ===== KANBAN ===== */
.kanban-board {
  display: flex;
  gap: 1rem;
  overflow-x: auto;
  padding-bottom: 1rem;
  min-height: calc(100vh - 200px);
}

.kanban-col {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  min-width: 240px;
  max-width: 260px;
  flex-shrink: 0;
  display: flex;
  flex-direction: column;
}

.kanban-col-header {
  padding: 1rem;
  border-bottom: 1px solid var(--border);
}
.kanban-col-title { display: flex; justify-content: space-between; align-items: center; margin-bottom: .25rem; font-weight: 600; font-size: .9rem; }
.kanban-count { background: var(--bg3); border-radius: 10px; padding: .1rem .5rem; font-size: .8rem; }

.kanban-cards { flex: 1; overflow-y: auto; padding: .75rem; display: flex; flex-direction: column; gap: .75rem; }
.kanban-empty { color: var(--text3); font-size: .8rem; text-align: center; padding: 1rem; }

.kanban-card {
  background: var(--bg3);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: .875rem;
  cursor: pointer;
  transition: all .2s;
}
.kanban-card:hover { border-color: var(--blue); transform: translateY(-1px); }
.kanban-card.late-card  { border-color: var(--red); }
.kanban-card.alert-card { border-color: var(--yellow); }

.kanban-card-top { display: flex; justify-content: space-between; align-items: center; margin-bottom: .5rem; }
.kanban-lot-num { font-weight: 700; color: var(--blue); font-size: .875rem; }
.priority-dot { width: 10px; height: 10px; border-radius: 50%; flex-shrink: 0; }

.kanban-card-client { font-weight: 600; font-size: .85rem; margin-bottom: .25rem; }
.kanban-card-paint  { color: var(--text2); font-size: .8rem; margin-bottom: .25rem; }
.kanban-card-qty    { color: var(--text3); font-size: .78rem; margin-bottom: .25rem; }
.kanban-card-date   { font-size: .78rem; color: var(--text2); margin-bottom: .25rem; }
.kanban-card-city   { font-size: .75rem; color: var(--text3); margin-bottom: .25rem; }
.kanban-card-time   { font-size: .75rem; color: var(--text3); margin-bottom: .5rem; }
.kanban-alert { font-size: .72rem; color: var(--yellow); margin-bottom: .5rem; }
.kanban-advance-btn { width: 100%; margin-top: .25rem; }

/* ===== ROUTES ===== */
.route-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.25rem;
  margin-bottom: 1rem;
}

.route-card-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  margin-bottom: 1rem;
  gap: 1rem;
  flex-wrap: wrap;
}
.route-card-header h4 { font-size: 1rem; font-weight: 600; margin-bottom: .25rem; }

.route-progress {
  height: 6px;
  background: var(--bg3);
  border-radius: 3px;
  margin-bottom: .5rem;
  overflow: hidden;
}
.route-progress-bar { height: 100%; background: var(--green); border-radius: 3px; transition: width .5s; }
.route-meta { font-size: .8rem; color: var(--text2); margin-bottom: 1rem; }

.route-stops { display: flex; flex-direction: column; gap: .5rem; }
.route-stop {
  display: flex;
  align-items: flex-start;
  gap: .75rem;
  padding: .75rem;
  background: var(--bg3);
  border-radius: 8px;
  transition: opacity .2s;
}
.route-stop.stop-delivered { opacity: .6; }
.stop-num {
  background: var(--blue);
  color: white;
  width: 24px; height: 24px;
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-size: .75rem; font-weight: 700; flex-shrink: 0;
}
.stop-info { flex: 1; font-size: .85rem; line-height: 1.5; }
.stop-info small { color: var(--text2); }

.route-preview {
  display: flex;
  flex-direction: column;
  gap: .5rem;
  margin-top: .75rem;
}
.route-step {
  display: flex;
  align-items: flex-start;
  gap: .75rem;
  padding: .75rem;
  background: var(--bg3);
  border-radius: 8px;
}
.route-step-num {
  background: var(--orange);
  color: white;
  width: 28px; height: 28px;
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-weight: 700; font-size: .8rem; flex-shrink: 0;
}
.route-step-info { font-size: .875rem; line-height: 1.5; }
.route-step-info small { color: var(--text2); }

/* ===== DETAIL MODAL ===== */
.detail-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 1.5rem; }
.detail-col h4 { font-size: 1rem; font-weight: 600; margin-bottom: 1rem; color: var(--blue); }

.detail-table { width: 100%; font-size: .875rem; border-collapse: collapse; }
.detail-table td { padding: .4rem .5rem; border-bottom: 1px solid var(--border); }
.detail-table td:first-child { color: var(--text2); white-space: nowrap; width: 40%; }

/* ===== TIMELINE ===== */
.timeline { display: flex; flex-direction: column; gap: 0; position: relative; }
.timeline::before {
  content: '';
  position: absolute;
  left: 10px; top: 0; bottom: 0;
  width: 2px;
  background: var(--border);
}

.timeline-item {
  display: flex;
  gap: 1rem;
  padding-bottom: 1rem;
  position: relative;
}

.timeline-dot {
  width: 20px; height: 20px;
  border-radius: 50%;
  flex-shrink: 0;
  margin-top: 2px;
  z-index: 1;
  border: 2px solid var(--bg2);
}

.timeline-content { flex: 1; }
.timeline-action { font-size: .875rem; font-weight: 500; margin-bottom: .25rem; }
.timeline-meta { font-size: .75rem; color: var(--text2); }

/* ===== SECTION CARDS ===== */
.section-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.25rem;
  margin-bottom: 1.5rem;
}
.section-card h3 { font-size: 1rem; font-weight: 600; margin-bottom: 1rem; display: flex; align-items: center; gap: .5rem; }

/* ===== CHARTS ===== */
.charts-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1rem;
  margin-bottom: 1.5rem;
}

.chart-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.25rem;
}
.chart-card h4 { font-size: .9rem; font-weight: 600; margin-bottom: 1rem; color: var(--text2); }

/* ===== SECTOR BREAKDOWN ===== */
.sector-breakdown { display: flex; flex-direction: column; gap: .75rem; }
.sector-row { display: flex; align-items: center; gap: .75rem; flex-wrap: wrap; }
.sector-row-label { width: 120px; font-size: .85rem; font-weight: 600; flex-shrink: 0; }
.sector-row-bar-wrap { flex: 1; min-width: 80px; background: var(--bg3); border-radius: 3px; height: 8px; overflow: hidden; }
.sector-row-bar { height: 100%; border-radius: 3px; transition: width .5s; }
.sector-row-count { width: 24px; text-align: right; font-weight: 700; font-size: .85rem; }
.sector-row-detail { display: flex; flex-wrap: wrap; gap: .25rem; }

.lot-chip {
  background: var(--bg3);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: .15rem .5rem;
  font-size: .72rem;
  cursor: pointer;
  transition: background .2s;
}
.lot-chip:hover { background: var(--blue); border-color: var(--blue); }

/* ===== FACTORY PANEL ===== */
.factory-grid { display: grid; grid-template-columns: 2fr 1fr; gap: 1.5rem; margin-bottom: 1.5rem; }
.factory-section h3 { font-size: .9rem; font-weight: 600; margin-bottom: 1rem; color: var(--text2); text-transform: uppercase; letter-spacing: .04em; }

.factory-sectors { display: flex; flex-direction: column; gap: .625rem; }
.factory-sector-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: .875rem;
}
.factory-sector-top { display: flex; justify-content: space-between; align-items: center; margin-bottom: .5rem; }
.factory-sector-name { font-weight: 600; font-size: .875rem; }
.factory-sector-count {
  color: white;
  font-size: .75rem;
  font-weight: 700;
  padding: .2rem .6rem;
  border-radius: 10px;
}
.factory-sector-lots { display: flex; flex-wrap: wrap; gap: .35rem; }
.factory-sector-empty { color: var(--text3); font-size: .8rem; }

.factory-lot-chip {
  padding: .2rem .6rem;
  border-radius: 6px;
  font-size: .72rem;
  font-weight: 600;
  cursor: pointer;
  background: var(--bg3);
  border: 1px solid var(--border);
  transition: background .2s;
}
.factory-lot-chip:hover { background: var(--blue); }
.factory-lot-chip.chip-late    { background: rgba(239,68,68,.2); border-color: var(--red); }
.factory-lot-chip.chip-sameday { background: rgba(239,68,68,.2); border-color: var(--red); }
.factory-lot-chip.chip-urgent  { background: rgba(245,158,11,.2); border-color: var(--yellow); }

.factory-alert-item {
  padding: .625rem .75rem;
  background: var(--bg3);
  border-radius: 8px;
  margin-bottom: .5rem;
  font-size: .85rem;
  cursor: pointer;
  transition: background .2s;
}
.factory-alert-item:hover { background: var(--bg); }
.factory-alert-item.item-delivered { opacity: .6; }

/* ===== PRIORITY ITEMS ===== */
.priority-item {
  padding: .75rem 1rem;
  background: var(--bg3);
  border-radius: 8px;
  margin-bottom: .5rem;
  cursor: pointer;
  border-left: 4px solid transparent;
  transition: background .2s;
  font-size: .875rem;
}
.priority-item:hover { background: var(--bg); }
.priority-item small { color: var(--text2); }
.priority-sameday { border-left-color: var(--red); background: rgba(239,68,68,.07); }
.priority-urgent  { border-left-color: var(--yellow); background: rgba(245,158,11,.07); }

/* ===== TOP LIST ===== */
.top-list { display: flex; flex-direction: column; gap: .5rem; }
.top-item { display: flex; align-items: center; gap: .75rem; padding: .625rem .75rem; background: var(--bg3); border-radius: 8px; font-size: .875rem; }
.top-rank { background: var(--blue); color: white; width: 24px; height: 24px; border-radius: 50%; display: flex; align-items: center; justify-content: center; font-size: .75rem; font-weight: 700; flex-shrink: 0; }
.top-name { flex: 1; font-weight: 500; }
.top-count { color: var(--text2); font-size: .8rem; }

/* ===== STATUS BADGES ===== */
.status-badge {
  padding: .3rem .75rem;
  border-radius: 12px;
  font-size: .75rem;
  font-weight: 600;
  color: white;
  white-space: nowrap;
}

.sector-tag {
  display: inline-block;
  padding: .2rem .6rem;
  border-radius: 6px;
  color: white;
  font-size: .78rem;
  font-weight: 600;
}

/* ===== TABLE ===== */
.table-container { overflow-x: auto; }
.data-table { width: 100%; border-collapse: collapse; font-size: .875rem; }
.data-table th { background: var(--bg3); padding: .75rem 1rem; text-align: left; font-size: .75rem; text-transform: uppercase; letter-spacing: .04em; color: var(--text2); white-space: nowrap; }
.data-table td { padding: .75rem 1rem; border-bottom: 1px solid var(--border); vertical-align: middle; }
.data-table tr:hover td { background: var(--bg3); }

/* ===== DRIVERS ===== */
.cards-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 1rem; }

.driver-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.5rem;
  text-align: center;
}
.driver-avatar { font-size: 3rem; color: var(--text3); margin-bottom: .75rem; }
.driver-card h3 { font-size: 1rem; font-weight: 600; margin-bottom: .25rem; }
.driver-login { color: var(--text2); font-size: .8rem; margin-bottom: 1rem; }
.driver-stats { display: flex; justify-content: center; gap: 1.5rem; }
.driver-stat .stat-num { font-size: 1.5rem; font-weight: 700; }
.driver-stat .stat-label { font-size: .7rem; color: var(--text2); }

/* ===== ROLE BADGES ===== */
.role-badge { padding: .2rem .6rem; border-radius: 8px; font-size: .75rem; font-weight: 600; }
.role-admin   { background: rgba(239,68,68,.2); color: var(--red); }
.role-pcp     { background: rgba(59,130,246,.2); color: var(--blue); }
.role-manager { background: rgba(139,92,246,.2); color: var(--purple); }
.role-sector  { background: rgba(34,197,94,.2); color: var(--green); }
.role-driver  { background: rgba(249,115,22,.2); color: var(--orange); }
.role-viewer  { background: rgba(148,163,184,.2); color: var(--text2); }

/* ===== MODAL ===== */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.6);
  z-index: 300;
  display: none;
  align-items: center;
  justify-content: center;
  padding: 1rem;
  backdrop-filter: blur(2px);
}

.modal {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 14px;
  width: 100%;
  max-width: 600px;
  max-height: 90vh;
  overflow-y: auto;
  box-shadow: var(--shadow);
  display: none;
}

.modal-large { max-width: 800px; }

.modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 1.25rem 1.5rem;
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  background: var(--surface);
  z-index: 1;
}

.modal-header h3 { font-size: 1.1rem; font-weight: 600; display: flex; align-items: center; gap: .5rem; }
.modal-header h3 i { color: var(--blue); }

.modal-close {
  background: none;
  border: none;
  color: var(--text2);
  cursor: pointer;
  font-size: 1.1rem;
  padding: .375rem;
  border-radius: 6px;
}
.modal-close:hover { background: var(--bg3); color: var(--text); }

.modal-body { padding: 1.5rem; }
.modal-footer { display: flex; justify-content: flex-end; gap: .75rem; padding-top: 1rem; }

/* ===== RADIO / CHECKBOX OPTIONS ===== */
.radio-option, .checkbox-option {
  display: flex;
  align-items: center;
  gap: .75rem;
  padding: .75rem 1rem;
  background: var(--bg3);
  border-radius: 8px;
  margin-bottom: .5rem;
  cursor: pointer;
  font-size: .875rem;
  border: 2px solid transparent;
  transition: border-color .2s;
}
.radio-option:hover, .checkbox-option:hover { border-color: var(--blue); }
.radio-option input, .checkbox-option input { cursor: pointer; }
.checkbox-option.checked { border-color: var(--blue); background: rgba(59,130,246,.1); }

.checkbox-list { display: flex; flex-direction: column; gap: .375rem; max-height: 250px; overflow-y: auto; }

/* ===== ALERT ITEMS ===== */
.alert-item {
  padding: .75rem 1rem;
  font-size: .875rem;
  border-bottom: 1px solid var(--border);
  cursor: pointer;
}
.alert-item:hover { background: var(--bg3); }
.alert-item.alert-warning { border-left: 3px solid var(--yellow); }

.alert-section {
  background: rgba(245,158,11,.07);
  border: 1px solid rgba(245,158,11,.25);
  border-radius: var(--radius);
  padding: 1rem 1.25rem;
  margin-bottom: 1.5rem;
}
.alert-section h3 { font-size: .9rem; margin-bottom: .75rem; }
.alert-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: .5rem; }

/* ===== EMPTY STATE ===== */
.empty-state {
  text-align: center;
  padding: 3rem;
  color: var(--text3);
}
.empty-state i { font-size: 3rem; margin-bottom: 1rem; opacity: .4; }
.empty-state p { font-size: .9rem; }

/* ===== UTILITIES ===== */
.text-danger  { color: var(--red) !important; }
.text-success { color: var(--green) !important; }
.text-warning { color: var(--yellow) !important; }
.text-muted   { color: var(--text2) !important; }
.text-blue    { color: var(--blue) !important; }
.text-orange  { color: var(--orange) !important; }
.text-green   { color: var(--green) !important; }

/* ===== TOAST ===== */
.toast {
  position: fixed;
  bottom: 2rem; right: 2rem;
  background: var(--surface);
  border: 1px solid var(--green);
  color: var(--text);
  padding: .875rem 1.25rem;
  border-radius: var(--radius);
  font-size: .875rem;
  z-index: 9999;
  box-shadow: var(--shadow);
  transform: translateY(100px);
  opacity: 0;
  transition: all .3s ease;
}
.toast.show { transform: translateY(0); opacity: 1; }

/* ===== RESPONSIVE ===== */
@media (max-width: 1024px) {
  .charts-row { grid-template-columns: 1fr; }
  .detail-grid { grid-template-columns: 1fr; }
  .factory-grid { grid-template-columns: 1fr; }
}

@media (max-width: 768px) {
  .sidebar {
    transform: translateX(-100%);
    transition: transform .3s ease;
  }
  .sidebar.open { transform: translateX(0); }
  .main-content { margin-left: 0 !important; }
  .kanban-board { overflow-x: auto; }
  .form-grid { grid-template-columns: 1fr; }
  .metrics-row { grid-template-columns: repeat(2, 1fr); }
  .page { padding: 1rem; }

  /* Mobile sidebar overlay */
  .sidebar-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,.6);
    z-index: 99;
  }
  .sidebar-overlay.visible { display: block; }
}

@media (max-width: 480px) {
  .login-card { padding: 1.5rem; }
  .metrics-row { grid-template-columns: 1fr 1fr; }
  .lots-grid { grid-template-columns: 1fr; }
}

/* ===== THEME TOGGLE / RESET BUTTONS in Sidebar ===== */
.btn-theme-toggle {
  width: 100%;
  background: rgba(59,130,246,.1);
  border: 1px solid rgba(59,130,246,.3);
  color: var(--blue);
  padding: .5rem;
  border-radius: var(--radius);
  cursor: pointer;
  font-size: .8rem;
  font-weight: 600;
  margin-bottom: .5rem;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: .4rem;
  transition: background .2s;
}
.btn-theme-toggle:hover { background: rgba(59,130,246,.2); }

.btn-reset {
  width: 100%;
  background: rgba(239,68,68,.08);
  border: 1px solid rgba(239,68,68,.25);
  color: var(--red);
  padding: .5rem;
  border-radius: var(--radius);
  cursor: pointer;
  font-size: .8rem;
  font-weight: 600;
  margin-bottom: .5rem;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: .4rem;
  transition: background .2s;
}
.btn-reset:hover { background: rgba(239,68,68,.18); }

/* ===== ROUTE LIVE PANEL (Dashboard) ===== */
.route-live-panel {
  background: rgba(249,115,22,.07);
  border: 1px solid rgba(249,115,22,.3);
  border-radius: var(--radius);
  padding: 1.25rem;
  margin-bottom: 1.5rem;
}
.route-live-panel h3 { font-size: .95rem; font-weight: 700; margin-bottom: 1rem; color: var(--orange); display: flex; align-items: center; gap: .5rem; }

.route-live-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
  gap: .875rem;
}

.route-live-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 1rem;
  cursor: pointer;
  transition: border-color .2s, transform .2s;
}
.route-live-card:hover { border-color: var(--orange); transform: translateY(-2px); }

.route-live-top { display: flex; justify-content: space-between; align-items: center; margin-bottom: .5rem; }
.route-live-driver { font-weight: 700; font-size: .9rem; }
.route-live-badge {
  background: var(--orange);
  color: white;
  font-size: .65rem;
  font-weight: 800;
  padding: .2rem .6rem;
  border-radius: 10px;
  letter-spacing: .04em;
  animation: pulseBadge 2s infinite;
}
@keyframes pulseBadge {
  0%, 100% { opacity: 1; }
  50% { opacity: .6; }
}

.route-live-saida { font-size: .78rem; color: var(--text2); margin-bottom: .625rem; }
.route-live-stops { display: flex; flex-wrap: wrap; gap: .3rem; margin-bottom: .625rem; }
.route-live-stop {
  background: var(--bg3);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: .15rem .5rem;
  font-size: .72rem;
}
.route-live-stop.stop-ok {
  background: rgba(34,197,94,.1);
  border-color: rgba(34,197,94,.4);
  color: var(--green);
  text-decoration: line-through;
  opacity: .7;
}

.route-live-progress {
  height: 5px;
  background: var(--bg3);
  border-radius: 3px;
  overflow: hidden;
  margin-bottom: .375rem;
}
.route-live-bar { height: 100%; background: var(--orange); border-radius: 3px; transition: width .5s; }
.route-live-meta { font-size: .75rem; color: var(--text2); }

/* ===== AUTO-UPDATE INDICATOR ===== */
.live-dot {
  display: inline-block;
  width: 8px; height: 8px;
  background: var(--green);
  border-radius: 50%;
  margin-right: .4rem;
  animation: pulseBadge 2s infinite;
}

