/* =====================================================================
   DocTrack admin theme — sidebar dashboard layout (Bootstrap 5 based)
   ===================================================================== */
:root {
  --dt-primary: #2f5bea;
  --dt-primary-600: #2548c7;
  --dt-primary-soft: #eaf0ff;
  --dt-body: #f4f6fb;
  --dt-card: #ffffff;
  --dt-ink: #1d2433;
  --dt-ink-2: #5b6478;
  --dt-muted: #8e96a8;
  --dt-line: #e9ecf3;
  --dt-sidebar-w: 264px;
  --dt-header-h: 84px;
  --dt-radius: 16px;
  --dt-shadow: 0 6px 24px rgba(28, 39, 76, .06);

  --bs-primary: var(--dt-primary);
  --bs-primary-rgb: 47, 91, 234;
  --bs-body-font-family: 'Poppins', system-ui, -apple-system, 'Segoe UI', sans-serif;
  --bs-body-color: var(--dt-ink);
  --bs-body-bg: var(--dt-body);
  --bs-border-color: var(--dt-line);
}

[hidden] { display: none !important; }
body { background: var(--dt-body); font-size: .875rem; color: var(--dt-ink); }
a { color: var(--dt-primary); text-decoration: none; }
.text-muted { color: var(--dt-muted) !important; }
.fw-semibold { font-weight: 600 !important; }
.tabular { font-variant-numeric: tabular-nums; }

/* ---------------- Sidebar ---------------- */
.dt-sidebar {
  position: fixed; inset: 0 auto 0 0; width: var(--dt-sidebar-w); z-index: 1040;
  background: var(--dt-card); border-right: 1px solid var(--dt-line);
  display: flex; flex-direction: column; transition: transform .25s ease;
}
.dt-brand {
  height: var(--dt-header-h); display: flex; align-items: center; gap: .75rem;
  padding: 0 1.5rem; color: var(--dt-ink); flex-shrink: 0;
}
.dt-brand-mark {
  width: 44px; height: 44px; border-radius: 12px; display: grid; place-items: center;
  background: linear-gradient(135deg, var(--dt-primary), #6a8cff); color: #fff; font-size: 1.35rem;
  box-shadow: 0 8px 18px rgba(47, 91, 234, .35);
}
.dt-brand-name { font-weight: 700; font-size: 1.25rem; line-height: 1; }
.dt-brand-sub { font-size: .7rem; color: var(--dt-muted); letter-spacing: .02em; }

.dt-menu { flex: 1; overflow-y: auto; padding: .5rem 1.25rem 1.5rem; }
.dt-menu-label {
  font-size: .68rem; text-transform: uppercase; letter-spacing: .08em; color: var(--dt-muted);
  font-weight: 600; margin: 1.25rem .75rem .5rem;
}
.dt-menu a {
  display: flex; align-items: center; gap: .85rem; padding: .72rem 1rem; margin-bottom: .2rem;
  border-radius: 12px; color: var(--dt-ink-2); font-weight: 500; transition: background .15s, color .15s;
}
.dt-menu a i { font-size: 1.15rem; width: 1.25rem; text-align: center; }
.dt-menu a:hover { background: var(--dt-primary-soft); color: var(--dt-primary); }
.dt-menu a.active {
  background: var(--dt-primary); color: #fff; box-shadow: 0 8px 18px rgba(47, 91, 234, .28);
}
.dt-menu a .dt-count {
  margin-left: auto; min-width: 22px; height: 22px; padding: 0 6px; border-radius: 11px; font-size: .7rem;
  display: grid; place-items: center; background: #ff5b5b; color: #fff; font-weight: 600;
}
.dt-sidebar-card {
  margin: 0 1.25rem 1.25rem; padding: 1.1rem; border-radius: var(--dt-radius);
  background: linear-gradient(135deg, var(--dt-primary), #5b7cff); color: #fff;
}
.dt-sidebar-card p { font-size: .75rem; opacity: .85; margin: .35rem 0 .75rem; }
.dt-sidebar-card .btn { background: #fff; color: var(--dt-primary); font-weight: 600; border: 0; }

/* ---------------- Header ---------------- */
.dt-main { margin-left: var(--dt-sidebar-w); min-height: 100vh; display: flex; flex-direction: column; }
.dt-header {
  position: sticky; top: 0; z-index: 1030; height: var(--dt-header-h);
  background: rgba(244, 246, 251, .92); backdrop-filter: blur(8px);
  display: flex; align-items: center; gap: 1rem; padding: 0 2rem;
}
.dt-header h1 { font-size: 1.5rem; font-weight: 700; margin: 0; }
.dt-header .dt-crumb { font-size: .75rem; color: var(--dt-muted); }
.dt-search {
  position: relative; width: 320px; max-width: 40vw;
}
.dt-search input {
  border-radius: 12px; border: 1px solid var(--dt-line); background: var(--dt-card);
  padding: .65rem 1rem .65rem 2.6rem; font-size: .85rem;
}
.dt-search i { position: absolute; left: 1rem; top: 50%; transform: translateY(-50%); color: var(--dt-muted); }
.dt-icon-btn {
  width: 44px; height: 44px; border-radius: 12px; background: var(--dt-card); border: 1px solid var(--dt-line);
  display: grid; place-items: center; color: var(--dt-ink-2); position: relative; font-size: 1.15rem;
}
.dt-icon-btn:hover { color: var(--dt-primary); }
.dt-icon-btn .dot {
  position: absolute; top: 8px; right: 9px; min-width: 16px; height: 16px; padding: 0 4px; border-radius: 8px;
  background: #ff5b5b; color: #fff; font-size: .62rem; display: grid; place-items: center; font-weight: 600;
}
.dt-profile { display: flex; align-items: center; gap: .75rem; color: var(--dt-ink); }
.dt-profile .name { font-weight: 600; line-height: 1.1; }
.dt-profile .role { font-size: .72rem; color: var(--dt-muted); }
.avatar {
  width: 44px; height: 44px; border-radius: 12px; display: grid; place-items: center; flex-shrink: 0;
  background: var(--dt-primary-soft); color: var(--dt-primary); font-weight: 700;
}
.avatar-sm { width: 34px; height: 34px; border-radius: 10px; font-size: .75rem; }

.dropdown-menu { border: 1px solid var(--dt-line); border-radius: 14px; box-shadow: var(--dt-shadow); padding: .5rem; }
.dropdown-item { border-radius: 8px; padding: .5rem .75rem; font-size: .85rem; }
.dt-notif { width: 340px; }
.dt-notif .dropdown-item { white-space: normal; display: flex; gap: .65rem; }
.dt-notif .ic { width: 32px; height: 32px; border-radius: 10px; background: var(--dt-primary-soft);
  color: var(--dt-primary); display: grid; place-items: center; flex-shrink: 0; }

.dt-content { padding: .5rem 2rem 2rem; flex: 1; }
.dt-footer { padding: 1rem 2rem; font-size: .75rem; color: var(--dt-muted); }

/* ---------------- Cards ---------------- */
.card {
  border: 0; border-radius: var(--dt-radius); background: var(--dt-card); box-shadow: var(--dt-shadow);
}
.card-header {
  background: transparent; border-bottom: 1px solid var(--dt-line); padding: 1.15rem 1.5rem;
  display: flex; align-items: center; justify-content: space-between; gap: 1rem; flex-wrap: wrap;
}
.card-header h5, .card-title { font-size: 1.02rem; font-weight: 600; margin: 0; }
.card-header .sub { font-size: .75rem; color: var(--dt-muted); }
.card-body { padding: 1.5rem; }

/* KPI tiles */
.kpi { display: flex; flex-direction: row; align-items: center; gap: 1rem; padding: 1.35rem 1.5rem; }
.kpi-icon {
  width: 58px; height: 58px; border-radius: 50%; display: grid; place-items: center; font-size: 1.45rem; flex-shrink: 0;
}
.kpi-value { font-size: 1.75rem; font-weight: 700; line-height: 1.1; }
.kpi-label { color: var(--dt-muted); font-size: .8rem; }
.kpi-foot { font-size: .72rem; margin-top: .15rem; }
.tone-primary { background: #eaf0ff; color: #2f5bea; }
.tone-info    { background: #e3f6fd; color: #0f8fc0; }
.tone-warning { background: #fff4df; color: #b86e00; }
.tone-danger  { background: #ffe9e9; color: #d03b3b; }
.tone-success { background: #e4f7ec; color: #14803c; }
.tone-violet  { background: #efebff; color: #5b43c9; }
.tone-dark    { background: #eceef3; color: #3a4153; }
.tone-secondary { background: #f0f1f5; color: #5b6478; }

.hero-card {
  background: linear-gradient(120deg, #2f5bea 0%, #4d74ff 60%, #7b96ff 100%); color: #fff; overflow: hidden; position: relative;
}
.hero-card::after {
  content: ''; position: absolute; right: -60px; top: -60px; width: 220px; height: 220px; border-radius: 50%;
  background: rgba(255, 255, 255, .09);
}
.hero-card::before {
  content: ''; position: absolute; right: 60px; bottom: -90px; width: 200px; height: 200px; border-radius: 50%;
  background: rgba(255, 255, 255, .07);
}
.hero-card .btn-light { color: var(--dt-primary); font-weight: 600; }

/* Badges */
.badge-soft {
  display: inline-flex; align-items: center; gap: .3rem; padding: .32rem .65rem; border-radius: 8px;
  font-size: .72rem; font-weight: 600; white-space: nowrap;
}
.badge-soft-primary { background: #eaf0ff; color: #2548c7; }
.badge-soft-info { background: #e3f6fd; color: #0b6f96; }
.badge-soft-warning { background: #fff4df; color: #945800; }
.badge-soft-danger { background: #ffe9e9; color: #b42323; }
.badge-soft-success { background: #e4f7ec; color: #0f6b31; }
.badge-soft-secondary { background: #f0f1f5; color: #4a5263; }
.badge-soft-dark { background: #e6e8ee; color: #262c3a; }
.pill { display: inline-block; padding: .2rem .6rem; border-radius: 20px; font-size: .7rem; font-weight: 600; border: 1px solid; }
.pill-secondary { color: #5b6478; border-color: #d6d9e2; }
.pill-primary { color: #2548c7; border-color: #bfcdfa; }
.pill-warning { color: #945800; border-color: #f3cf8f; background: #fffaf0; }
.pill-danger { color: #fff; border-color: #d03b3b; background: #d03b3b; }

/* Tables */
.table { --bs-table-bg: transparent; margin: 0; }
.table > :not(caption) > * > * { padding: .9rem 1rem; border-bottom-color: var(--dt-line); vertical-align: middle; }
.table thead th {
  font-size: .72rem; text-transform: uppercase; letter-spacing: .05em; color: var(--dt-muted); font-weight: 600;
  background: #fafbfd; white-space: nowrap;
}
.table tbody tr:hover { background: #fafbff; }
.table td:first-child, .table th:first-child { padding-left: 1.5rem; }
.table td:last-child, .table th:last-child { padding-right: 1.5rem; }
.doc-title { font-weight: 600; color: var(--dt-ink); display: block; max-width: 360px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.doc-title:hover { color: var(--dt-primary); }
.tracking { font-family: ui-monospace, 'SF Mono', Menlo, monospace; font-size: .76rem; color: var(--dt-primary); font-weight: 600; }
.doc-icon { width: 40px; height: 40px; border-radius: 10px; display: grid; place-items: center; font-size: 1.1rem; flex-shrink: 0; }

/* Forms & buttons */
.form-control, .form-select { border-radius: 10px; border-color: var(--dt-line); padding: .6rem .9rem; font-size: .875rem; }
.form-control:focus, .form-select:focus { border-color: #9fb4f6; box-shadow: 0 0 0 .2rem rgba(47, 91, 234, .12); }
.form-label { font-weight: 500; font-size: .8rem; color: var(--dt-ink-2); }
.btn { border-radius: 10px; font-weight: 500; font-size: .85rem; padding: .55rem 1.05rem; }
.btn-primary { background: var(--dt-primary); border-color: var(--dt-primary); }
.btn-primary:hover, .btn-primary:focus { background: var(--dt-primary-600); border-color: var(--dt-primary-600); }
.btn-soft { background: var(--dt-primary-soft); color: var(--dt-primary); border: 0; }
.btn-soft:hover { background: #dbe5ff; color: var(--dt-primary-600); }
.btn-outline-light-ink { border: 1px solid var(--dt-line); color: var(--dt-ink-2); background: var(--dt-card); }
.btn-outline-light-ink:hover { border-color: #c9cfdd; color: var(--dt-ink); }
.nav-pills-dt .nav-link {
  border-radius: 10px; color: var(--dt-ink-2); font-weight: 500; padding: .45rem .9rem; font-size: .82rem;
}
.nav-pills-dt .nav-link.active { background: var(--dt-primary); color: #fff; }
.nav-pills-dt .nav-link .n { opacity: .7; margin-left: .25rem; }
.modal-content { border: 0; border-radius: var(--dt-radius); }
.modal-header { border-bottom: 1px solid var(--dt-line); padding: 1.1rem 1.5rem; }
.modal-body { padding: 1.5rem; }
.modal-footer { border-top: 1px solid var(--dt-line); }

/* Timeline */
.timeline { list-style: none; margin: 0; padding: 0; position: relative; }
.timeline::before { content: ''; position: absolute; left: 17px; top: 6px; bottom: 6px; width: 2px; background: var(--dt-line); }
.timeline li { position: relative; padding: 0 0 1.35rem 3.1rem; }
.timeline li:last-child { padding-bottom: 0; }
.timeline .tl-icon {
  position: absolute; left: 0; top: 0; width: 36px; height: 36px; border-radius: 50%; display: grid; place-items: center;
  box-shadow: 0 0 0 4px var(--dt-card); font-size: .95rem;
}
.timeline .tl-title { font-weight: 600; }
.timeline .tl-meta { font-size: .74rem; color: var(--dt-muted); }
.timeline .tl-remarks { margin-top: .35rem; background: #f7f8fb; border-radius: 10px; padding: .55rem .8rem; font-size: .8rem; color: var(--dt-ink-2); }

/* Route stepper */
.route-steps { display: flex; align-items: center; gap: .5rem; flex-wrap: wrap; }
.route-step { display: flex; align-items: center; gap: .5rem; }
.route-step .node {
  padding: .45rem .8rem; border-radius: 10px; font-weight: 600; font-size: .78rem; background: #f0f1f5; color: var(--dt-ink-2);
}
.route-step .node.done { background: #e4f7ec; color: #0f6b31; }
.route-step .node.now { background: var(--dt-primary); color: #fff; }
.route-step .node.wait { background: #fff4df; color: #945800; border: 1px dashed #f3cf8f; }
.route-step .arrow { color: var(--dt-muted); }

/* Meta list */
.meta dt { font-size: .72rem; color: var(--dt-muted); font-weight: 500; text-transform: uppercase; letter-spacing: .04em; }
.meta dd { font-weight: 500; margin-bottom: .9rem; }

/* Progress bars (office load) */
.bar-row { display: grid; grid-template-columns: 90px 1fr 42px; gap: .75rem; align-items: center; margin-bottom: .8rem; font-size: .8rem; }
.bar-track { height: 8px; background: #f0f2f7; border-radius: 4px; overflow: hidden; }
.bar-fill { height: 100%; background: var(--dt-primary); border-radius: 4px; }

/* Charts */
.chart-legend { display: flex; gap: 1rem; flex-wrap: wrap; font-size: .76rem; color: var(--dt-ink-2); }
.chart-legend span::before { content: ''; display: inline-block; width: 10px; height: 10px; border-radius: 3px; margin-right: .4rem; background: var(--c); vertical-align: -1px; }
.apexcharts-tooltip { border-radius: 10px !important; box-shadow: var(--dt-shadow) !important; border: 1px solid var(--dt-line) !important; }

/* Empty state */
.empty { text-align: center; padding: 2.5rem 1rem; color: var(--dt-muted); }
.empty i { font-size: 2.2rem; display: block; margin-bottom: .5rem; color: #c3c9d8; }

/* Auth pages */
.auth-wrap { min-height: 100vh; display: grid; grid-template-columns: 1.1fr 1fr; }
.auth-art {
  background: linear-gradient(140deg, #2f5bea 0%, #4d74ff 55%, #8aa3ff 100%); color: #fff; padding: 3rem;
  display: flex; flex-direction: column; justify-content: space-between; position: relative; overflow: hidden;
}
.auth-art::after { content: ''; position: absolute; width: 420px; height: 420px; border-radius: 50%; right: -140px; bottom: -140px; background: rgba(255, 255, 255, .08); }
.auth-art h2 { font-size: 2.2rem; font-weight: 700; max-width: 440px; }
.auth-feature { display: flex; gap: .8rem; align-items: flex-start; margin-bottom: 1rem; max-width: 420px; }
.auth-feature i { width: 38px; height: 38px; border-radius: 10px; background: rgba(255, 255, 255, .16); display: grid; place-items: center; flex-shrink: 0; }
.auth-form { display: grid; place-items: center; padding: 2rem 1rem; background: var(--dt-card); }
.auth-form .inner { width: 100%; max-width: 400px; }

/* Public tracker */
.track-hero { background: linear-gradient(120deg, #2f5bea, #6a8cff); color: #fff; padding: 3rem 1rem 6rem; }
.track-card { margin-top: -4.5rem; }

/* Print */
@media print {
  .dt-sidebar, .dt-header, .no-print, .dt-footer { display: none !important; }
  .dt-main { margin: 0; }
  .card { box-shadow: none; border: 1px solid #ddd; }
}

/* ---------------- Responsive ---------------- */
.dt-backdrop { display: none; }
@media (max-width: 1199.98px) {
  .dt-sidebar { transform: translateX(-100%); }
  body.sidebar-open .dt-sidebar { transform: none; box-shadow: 0 0 40px rgba(0, 0, 0, .15); }
  body.sidebar-open .dt-backdrop { display: block; position: fixed; inset: 0; background: rgba(20, 26, 40, .35); z-index: 1035; }
  .dt-main { margin-left: 0; }
}
@media (max-width: 767.98px) {
  .dt-header { padding: 0 1rem; gap: .5rem; }
  .dt-header h1 { font-size: 1.15rem; }
  .dt-content { padding: .5rem 1rem 1.5rem; }
  .dt-search, .dt-profile .d-md-block { display: none !important; }
  .auth-wrap { grid-template-columns: 1fr; }
  .auth-art { display: none; }
  .card-body { padding: 1.1rem; }
  .kpi { padding: 1.1rem; }
}

/* Scan & Receive */
.scan-stage { position: relative; border-radius: 14px; overflow: hidden; background: #0f1422; min-height: 320px; }
.scan-stage #reader { width: 100%; }
.scan-stage #reader video { width: 100% !important; display: block; border-radius: 14px; }
.scan-stage #reader img[alt="Info icon"], .scan-stage #reader__dashboard_section_csr span { display: none !important; }
.scan-idle { position: absolute; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center;
  text-align: center; padding: 1.5rem; background: #f7f8fb; border: 2px dashed #d6dcea; border-radius: 14px; }
.scan-flash { position: absolute; inset: 0; pointer-events: none; border-radius: 14px; transition: box-shadow .2s; }
.scan-flash.ok { box-shadow: inset 0 0 0 6px #1baf7a; }
.scan-flash.bad { box-shadow: inset 0 0 0 6px #d03b3b; }
.scan-row { display: flex; gap: .85rem; align-items: center; padding: .85rem 1.5rem; border-bottom: 1px solid var(--dt-line); }
.scan-row:last-child { border-bottom: 0; }
#btnTorch.active { background: #fff4df; color: #945800; border-color: #f3cf8f; }
