/* ---- Auto-Dialer Admin Console styles ---- */
:root {
  --bg: #0f172a;
  --bg-soft: #1e293b;
  --panel: #ffffff;
  --panel-bg: #f1f5f9;
  --text: #0f172a;
  --muted: #64748b;
  --border: #e2e8f0;
  --primary: #2563eb;
  --primary-dark: #1d4ed8;
  --green: #16a34a;
  --red: #dc2626;
  --amber: #d97706;
  --shadow: 0 1px 3px rgba(0,0,0,.08), 0 1px 2px rgba(0,0,0,.06);
  --radius: 10px;
}

* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; }
body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  color: var(--text);
  background: var(--panel-bg);
  font-size: 14px;
}
.hidden { display: none !important; }
.muted { color: var(--muted); }
.small { font-size: 12px; }
code { background: #eef2ff; padding: 1px 5px; border-radius: 4px; font-size: 12px; }

/* ---- Login ---- */
.login-view {
  min-height: 100vh;
  display: flex; align-items: center; justify-content: center;
  background: radial-gradient(1200px 600px at 50% -10%, #1e3a8a 0%, var(--bg) 55%);
  padding: 20px;
}
.login-card {
  background: var(--panel);
  width: 100%; max-width: 360px;
  padding: 32px 28px;
  border-radius: 16px;
  box-shadow: 0 20px 60px rgba(0,0,0,.35);
  display: flex; flex-direction: column; gap: 12px;
  text-align: center;
}
.brand-mark { font-size: 40px; }
.login-card h1 { margin: 0; font-size: 24px; }
.login-card p { margin: 0; }
.login-card label { text-align: left; display: flex; flex-direction: column; gap: 4px; font-size: 13px; color: var(--muted); }
.login-card input { margin-top: 2px; }
.login-card .hint { margin-top: 6px; font-size: 11px; }

/* ---- App shell ---- */
.app-view { display: flex; min-height: 100vh; }
.sidebar {
  width: 230px; flex-shrink: 0;
  background: var(--bg); color: #cbd5e1;
  display: flex; flex-direction: column;
  padding: 18px 14px;
}
.logo { font-size: 18px; font-weight: 700; color: #fff; display: flex; align-items: center; gap: 8px; padding: 6px 8px 18px; }
.logo-mark { font-size: 22px; }
.nav { display: flex; flex-direction: column; gap: 4px; flex: 1; }
.nav-item {
  color: #cbd5e1; text-decoration: none;
  padding: 10px 12px; border-radius: 8px; font-weight: 500;
  transition: background .15s, color .15s;
}
.nav-item:hover { background: #1e293b; color: #fff; }
.nav-item.active { background: var(--primary); color: #fff; }
.sidebar-footer { margin-top: 14px; border-top: 1px solid #1e293b; padding-top: 12px; }
.who { font-size: 12px; margin-bottom: 8px; word-break: break-all; }

.content { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.topbar {
  display: flex; align-items: center; justify-content: space-between;
  padding: 16px 24px; background: var(--panel); border-bottom: 1px solid var(--border);
  position: sticky; top: 0; z-index: 5;
}
.topbar h2 { margin: 0; font-size: 18px; }

.tab { display: none; padding: 22px 24px; }
.tab.active { display: block; }
.section-title { margin: 22px 0 10px; font-size: 14px; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); }
.section-title:first-child { margin-top: 0; }

/* ---- Cards ---- */
.cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: 14px; }
.card {
  background: var(--panel); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 16px; box-shadow: var(--shadow);
}
.card .k { font-size: 12px; color: var(--muted); text-transform: uppercase; letter-spacing: .03em; }
.card .v { font-size: 26px; font-weight: 700; margin-top: 6px; }

/* ---- Troubleshoot ---- */
.card.diag-ok { border-left: 4px solid #16a34a; }
.card.diag-warn { border-left: 4px solid #d97706; }
.card.diag-err { border-left: 4px solid #dc2626; }
.card.diag-ok .k, .card.diag-warn .k, .card.diag-err .k {
  font-size: 14px; font-weight: 700; color: var(--text); text-transform: none; letter-spacing: 0;
}
.card .diag-msg { font-size: 12.5px; color: var(--muted); margin-top: 6px; word-break: break-word; }
.diag-key { font-weight: 600; width: 42%; }
.diag-steps { margin: 8px 0 0 18px; line-height: 2; }
.diag-steps code { background: #eef2f7; padding: 1px 6px; border-radius: 5px; font-size: 12px; }

/* ---- Panels ---- */
.panel {
  background: var(--panel); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 16px; box-shadow: var(--shadow); margin-bottom: 16px;
}

/* ---- Tables ---- */
.table-wrap { background: var(--panel); border: 1px solid var(--border); border-radius: var(--radius); overflow: auto; box-shadow: var(--shadow); margin-bottom: 16px; }
table { width: 100%; border-collapse: collapse; font-size: 13px; }
thead th { text-align: left; background: #f8fafc; color: var(--muted); font-weight: 600; padding: 10px 12px; border-bottom: 1px solid var(--border); white-space: nowrap; }
thead th.sortable { cursor: pointer; user-select: none; }
thead th.sortable:hover { color: var(--primary); }
tbody td { padding: 10px 12px; border-bottom: 1px solid var(--border); }
tbody tr:last-child td { border-bottom: none; }
tbody tr:hover { background: #f8fafc; }
.empty-row td { text-align: center; color: var(--muted); padding: 22px; }

/* ---- Forms ---- */
input, select, button { font: inherit; }
input, select {
  padding: 9px 11px; border: 1px solid var(--border); border-radius: 8px;
  background: #fff; color: var(--text); outline: none;
}
input:focus, select:focus { border-color: var(--primary); box-shadow: 0 0 0 3px rgba(37,99,235,.15); }
.form-row { display: flex; flex-wrap: wrap; gap: 10px; align-items: end; }
.form-row > input, .form-row > select { flex: 1; min-width: 140px; }
label.inline { display: flex; flex-direction: column; gap: 4px; font-size: 12px; color: var(--muted); }

/* ---- Buttons ---- */
.btn {
  padding: 9px 14px; border: 1px solid var(--border); border-radius: 8px;
  background: #fff; color: var(--text); cursor: pointer; font-weight: 600;
  transition: background .15s, border-color .15s, opacity .15s;
}
.btn:hover { background: #f1f5f9; }
.btn.primary { background: var(--primary); border-color: var(--primary); color: #fff; }
.btn.primary:hover { background: var(--primary-dark); }
.btn.ghost { background: transparent; color: #cbd5e1; border-color: #334155; }
.btn.ghost:hover { background: #1e293b; color: #fff; }
.btn.block { width: 100%; }
.btn.tiny { padding: 5px 9px; font-size: 12px; }
.btn.danger { background: #dc2626; border-color: #dc2626; color: #fff; }
.btn.danger:hover { background: #b91c1c; }
.btn:disabled { opacity: .55; cursor: not-allowed; }

/* ---- Badges ---- */
.badge { display: inline-block; padding: 2px 9px; border-radius: 999px; font-size: 11px; font-weight: 600; text-transform: capitalize; }
.badge.new { background: #e0f2fe; color: #0369a1; }
.badge.assigned { background: #ede9fe; color: #6d28d9; }
.badge.in_progress { background: #fef3c7; color: #92400e; }
.badge.done { background: #dcfce7; color: #166534; }
.badge.picked { background: #dcfce7; color: #166534; }
.badge.not_picked { background: #fee2e2; color: #991b1b; }
.badge.busy, .badge.rejected, .badge.failed { background: #f1f5f9; color: #475569; }

/* ---- Toggle switch ---- */
.switch { position: relative; display: inline-block; width: 40px; height: 22px; }
.switch input { opacity: 0; width: 0; height: 0; }
.slider { position: absolute; cursor: pointer; inset: 0; background: #cbd5e1; border-radius: 999px; transition: .2s; }
.slider:before { content: ""; position: absolute; height: 16px; width: 16px; left: 3px; bottom: 3px; background: #fff; border-radius: 50%; transition: .2s; }
.switch input:checked + .slider { background: var(--green); }
.switch input:checked + .slider:before { transform: translateX(18px); }

/* ---- Dropzone ---- */
.dropzone {
  border: 2px dashed #cbd5e1; border-radius: var(--radius);
  padding: 28px; text-align: center; cursor: pointer; color: var(--muted);
  transition: border-color .15s, background .15s;
}
.dropzone:hover, .dropzone.drag { border-color: var(--primary); background: #eff6ff; color: var(--primary); }
.dropzone p { margin: 4px 0; }

/* ---- Toasts ---- */
.toasts { position: fixed; top: 18px; right: 18px; z-index: 1000; display: flex; flex-direction: column; gap: 10px; }
.toast {
  min-width: 240px; max-width: 360px; padding: 12px 14px; border-radius: 10px;
  color: #fff; box-shadow: 0 8px 24px rgba(0,0,0,.2); font-size: 13px;
  animation: slidein .2s ease;
}
.toast.success { background: var(--green); }
.toast.error { background: var(--red); }
.toast.info { background: var(--primary); }
@keyframes slidein { from { transform: translateX(20px); opacity: 0; } to { transform: translateX(0); opacity: 1; } }

/* ---- Responsive ---- */
@media (max-width: 760px) {
  .app-view { flex-direction: column; }
  .sidebar { width: 100%; flex-direction: row; flex-wrap: wrap; align-items: center; padding: 10px; }
  .nav { flex-direction: row; flex-wrap: wrap; }
  .sidebar-footer { margin: 0 0 0 auto; border: none; padding: 0; display: flex; align-items: center; gap: 10px; }
  .who { display: none; }
}
