/* ============================================================
   Personal Service Center — Technician Tracking System
   Compact modern UI · responsive (desktop / tablet / mobile)
   ============================================================ */
:root {
  --bg: #0a0f1c;
  --bg2: #0d1526;
  --panel: #101a30;
  --panel2: #16223d;
  --line: rgba(148, 163, 200, 0.14);
  --line2: rgba(148, 163, 200, 0.24);
  --text: #e7ecf6;
  --muted: #8fa0bd;
  --muted2: #64748f;
  --accent: #4f8cff;
  --accent2: #7aa7ff;
  --green: #2dd4a7;
  --red: #f87171;
  --amber: #fbbf24;
  --purple: #b48cff;
  --radius: 10px;
  --shadow: 0 8px 28px rgba(2, 6, 18, 0.55);
  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;

  /* ---- derived / extended palette (theme-switchable) ---- */
  --input-bg: #0c1424;
  --input-bg-disabled: #131d33;
  --thead-bg: #131d33;
  --tbl-wrap-bg: rgba(12, 19, 35, .5);
  --seg-bg: #0c1424;
  --modal-bg: linear-gradient(180deg, #18233d, #121c33);
  --login-card-bg: linear-gradient(180deg, rgba(22,34,61,.95), rgba(16,26,48,.95));
  --card-bg: linear-gradient(180deg, rgba(22,34,61,.55), rgba(16,26,48,.55));
  --topbar-bg: rgba(10, 15, 28, 0.88);
  --bottomnav-bg: rgba(13, 21, 38, 0.97);
  --toast-bg: #1b2a47;
  --toast-err-bg: #3a1a24;
  --scrollbar-thumb: #243350;
  --timeline-dot-bg: #0c1424;
  --rank-badge-bg: #1c2947;
  --rank-bar-bg: #1a2745;
  --overlay-bg: rgba(4, 8, 18, 0.72);
  --body-bg-img:
    radial-gradient(1200px 700px at 85% -10%, rgba(79, 140, 255, 0.14), transparent 60%),
    radial-gradient(900px 500px at -10% 110%, rgba(45, 212, 167, 0.08), transparent 55%);
  --nav-active-color: #fff;
  --btn-green-text: #04110c;
  --brand-logo-text: #06101f;
  --avatar-text: #0a0f1c;
  --rank-gold-text: #2b1a00;
  --rank-silver-text: #232b3a;
  --rank-bronze-text: #2b1400;
  --bg-grad-btn: linear-gradient(135deg, #4f8cff, #3b6fe0);
}
* { box-sizing: border-box; margin: 0; padding: 0; }
html { -webkit-text-size-adjust: 100%; }
body {
  font-family: var(--font);
  background: var(--body-bg-img), var(--bg);
  background-attachment: fixed;
  color: var(--text);
  font-size: 13.5px;
  line-height: 1.45;
  min-height: 100vh;
}
::-webkit-scrollbar { width: 9px; height: 9px; }
::-webkit-scrollbar-thumb { background: var(--scrollbar-thumb); border-radius: 8px; }
::-webkit-scrollbar-track { background: transparent; }

/* ---------- login ---------- */
.login-wrap { min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 20px; }
.login-card {
  width: 100%; max-width: 400px; background: var(--login-card-bg);
  border: 1px solid var(--line); border-radius: 16px; padding: 28px 26px; box-shadow: var(--shadow);
}
.brand-row { display: flex; align-items: center; gap: 12px; margin-bottom: 6px; }
.brand-logo {
  width: 40px; height: 40px; border-radius: 11px; flex: none;
  background: linear-gradient(135deg, #4f8cff, #2dd4a7);
  display: flex; align-items: center; justify-content: center; font-weight: 800; font-size: 17px; color: var(--brand-logo-text);
}
.brand-logo-img {
  width: 46px; height: 46px; border-radius: 12px; flex: none; object-fit: cover;
  box-shadow: 0 4px 14px rgba(0,0,0,.35); background: #fff;
}
.brand-logo-img.sm { width: 34px; height: 34px; border-radius: 9px; }
.brand-title { font-size: 17px; font-weight: 700; letter-spacing: .2px; }
.brand-sub { font-size: 11.5px; color: var(--muted); margin-top: 1px; }
.login-card h1 { font-size: 18px; margin: 18px 0 4px; }
.login-card .hint { color: var(--muted); font-size: 12px; margin-bottom: 16px; }
.demo-btns { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 14px; }
.demo-btn {
  font-size: 11px; padding: 5px 9px; border-radius: 999px; cursor: pointer;
  background: rgba(79,140,255,.1); border: 1px solid rgba(79,140,255,.35); color: var(--accent2);
}
.demo-btn:hover { background: rgba(79,140,255,.2); }

/* ---------- forms ---------- */
label.f { display: block; font-size: 11.5px; color: var(--muted); margin: 0 0 4px 2px; font-weight: 600; letter-spacing: .3px; }
input, select, textarea {
  width: 100%; background: var(--input-bg); color: var(--text);
  border: 1px solid var(--line2); border-radius: 8px;
  padding: 8px 10px; font-size: 13px; font-family: var(--font);
  outline: none; transition: border-color .15s, box-shadow .15s;
}
input:focus, select:focus, textarea:focus { border-color: var(--accent); box-shadow: 0 0 0 3px rgba(79,140,255,.18); }
input:disabled, select:disabled, input[readonly] { background: var(--input-bg-disabled); color: var(--muted); cursor: not-allowed; }
input[type="date"], input[type="time"] { color-scheme: dark; }
html[data-theme="light"] input[type="date"], html[data-theme="light"] input[type="time"] { color-scheme: light; }
textarea { resize: vertical; min-height: 60px; }
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.form-grid .full { grid-column: 1 / -1; }
@media (max-width: 640px) { .form-grid { grid-template-columns: 1fr; } }
.form-foot { display: flex; justify-content: flex-end; gap: 8px; margin-top: 16px; }

/* ---------- buttons ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  border: 1px solid transparent; border-radius: 8px; cursor: pointer;
  font-size: 12.5px; font-weight: 600; padding: 8px 14px; font-family: var(--font);
  transition: filter .15s, background .15s; white-space: nowrap; min-height: 34px;
}
.btn-primary { background: var(--bg-grad-btn); color: #fff; }
.btn-primary:hover { filter: brightness(1.12); }
.btn-ghost { background: transparent; border-color: var(--line2); color: var(--muted); }
.btn-ghost:hover { color: var(--text); border-color: var(--accent); }
.btn-green { background: linear-gradient(135deg, #17b58a, #0f9472); color: var(--btn-green-text); }
.btn-danger { background: rgba(248,113,113,.12); border-color: rgba(248,113,113,.4); color: #f8a5a5; }
.btn-danger:hover { background: rgba(248,113,113,.22); }
.btn-sm { padding: 4px 9px; min-height: 28px; font-size: 11.5px; border-radius: 6px; }
.btn-icon { padding: 6px 8px; }

/* ---------- layout ---------- */
.app { display: none; min-height: 100vh; }
.app.on { display: block; }
.topbar {
  position: sticky; top: 0; z-index: 50;
  display: flex; align-items: center; gap: 12px;
  background: var(--topbar-bg); backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--line); padding: 9px 16px;
}
.topbar .brand-row { margin: 0; }
.topbar .spacer { flex: 1; }
.user-chip { display: flex; align-items: center; gap: 9px; }
.avatar {
  width: 30px; height: 30px; border-radius: 50%; flex: none;
  background: linear-gradient(135deg, #b48cff, #4f8cff); color: var(--avatar-text);
  font-weight: 800; font-size: 12px; display: flex; align-items: center; justify-content: center;
}
.user-meta { line-height: 1.15; text-align: right; }
.user-meta .nm { font-size: 12.5px; font-weight: 700; }
.user-meta .rl { font-size: 10.5px; color: var(--muted); text-transform: uppercase; letter-spacing: .5px; }

.main { display: flex; }
.sidebar {
  width: 212px; flex: none; padding: 14px 10px; border-right: 1px solid var(--line);
  min-height: calc(100vh - 52px); position: sticky; top: 52px; align-self: flex-start;
}
.nav-item {
  display: flex; align-items: center; gap: 10px; padding: 9px 12px; margin-bottom: 3px;
  border-radius: 8px; cursor: pointer; color: var(--muted); font-weight: 600; font-size: 13px;
  border: 1px solid transparent;
}
.nav-item:hover { color: var(--text); background: rgba(79,140,255,.07); }
.nav-item.active { color: var(--nav-active-color); background: linear-gradient(135deg, rgba(79,140,255,.25), rgba(45,212,167,.12)); border-color: rgba(79,140,255,.45); }
.nav-item svg { width: 17px; height: 17px; flex: none; }
.nav-section { font-size: 10px; text-transform: uppercase; letter-spacing: 1px; color: var(--muted2); margin: 14px 6px 6px; }

/* sliding sidebar — desktop collapses to an icon-only rail */
.sidebar { transition: width .18s ease; }
.sidebar.collapsed { width: 66px; padding: 14px 8px; }
.sidebar.collapsed .nav-item { justify-content: center; padding: 10px 0; }
.sidebar.collapsed .nav-item span { display: none; }
.sidebar.collapsed .nav-section { display: none; }

/* hamburger toggle (topbar) */
.nav-toggle {
  flex: none; display: inline-flex; align-items: center; justify-content: center;
  width: 34px; height: 34px; border-radius: 9px; cursor: pointer;
  background: var(--seg-bg); border: 1px solid var(--line2); color: var(--muted);
  transition: color .15s, border-color .15s, background .15s;
}
.nav-toggle:hover { color: var(--text); border-color: var(--accent); }
.nav-toggle svg { width: 17px; height: 17px; }

/* scrim — mobile drawer overlay (hidden on desktop) */
.scrim { display: none; }

.content { flex: 1; padding: 18px 20px 90px; max-width: 1500px; min-width: 0; }

/* mobile bottom nav */
.bottom-nav { display: none; }
@media (max-width: 860px) {
  /* sidebar becomes a sliding drawer that opens over the content */
  .sidebar {
    position: fixed; top: 52px; left: 0; bottom: 0; z-index: 46;
    width: 236px; max-width: 84vw; min-height: 0;
    background: var(--bottomnav-bg); backdrop-filter: blur(12px);
    border-right: 1px solid var(--line2); box-shadow: var(--shadow);
    transform: translateX(-110%); transition: transform .22s ease;
    overflow-y: auto; padding-top: 10px;
  }
  .sidebar.open { transform: translateX(0); }
  .scrim {
    display: block; position: fixed; top: 52px; left: 0; right: 0; bottom: 0;
    z-index: 45; background: var(--overlay-bg);
    opacity: 0; pointer-events: none; transition: opacity .2s;
  }
  .scrim.on { opacity: 1; pointer-events: auto; }
  /* keep the topbar readable on phones with the hamburger present */
  .topbar .user-meta { display: none; }
  .topbar .brand-title { display: none; }
  .content { padding: 14px 12px 84px; }
  .bottom-nav {
    display: flex; position: fixed; bottom: 0; left: 0; right: 0; z-index: 60;
    background: var(--bottomnav-bg); backdrop-filter: blur(10px);
    border-top: 1px solid var(--line); padding: 4px 4px calc(4px + env(safe-area-inset-bottom));
  }
  .bottom-nav .nav-item { flex: 1; flex-direction: column; gap: 3px; font-size: 10px; padding: 7px 2px; margin: 0; border-radius: 10px; text-align: center; }
  .bottom-nav .nav-item svg { width: 19px; height: 19px; }
}

/* ---------- page & cards ---------- */
.page-head { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; margin-bottom: 14px; }
.page-head h2 { font-size: 18px; letter-spacing: .2px; }
.page-head .sub { color: var(--muted); font-size: 12px; width: 100%; margin-top: -6px; }
.page-head .spacer { flex: 1; }

.card {
  background: var(--card-bg);
  border: 1px solid var(--line); border-radius: var(--radius); padding: 14px 16px;
}
.card h3 { font-size: 13px; color: var(--muted); font-weight: 700; text-transform: uppercase; letter-spacing: .8px; margin-bottom: 10px; }

/* KPI grid */
.kpi-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(168px, 1fr)); gap: 10px; margin-bottom: 14px; }
.kpi { position: relative; overflow: hidden; }
.kpi .k-label { font-size: 10.5px; text-transform: uppercase; letter-spacing: .8px; color: var(--muted); font-weight: 700; }
.kpi .k-val { font-size: 22px; font-weight: 800; margin-top: 3px; letter-spacing: .3px; }
.kpi .k-sub { font-size: 11px; color: var(--muted2); margin-top: 2px; }
.kpi .k-ico { position: absolute; right: 10px; top: 10px; opacity: .5; }
.k-green .k-val { color: var(--green); }
.k-blue .k-val { color: var(--accent2); }
.k-purple .k-val { color: var(--purple); }
.k-amber .k-val { color: var(--amber); }

.two-col { display: grid; grid-template-columns: 1.6fr 1fr; gap: 12px; margin-bottom: 12px; }
.three-col { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 12px; margin-bottom: 12px; }
@media (max-width: 1100px) { .three-col { grid-template-columns: 1fr 1fr; } }
@media (max-width: 900px) { .two-col { grid-template-columns: 1fr; } }
@media (max-width: 700px) { .three-col { grid-template-columns: 1fr; } }

/* ---------- tables ---------- */
.tbl-wrap { overflow-x: auto; border-radius: var(--radius); border: 1px solid var(--line); background: var(--tbl-wrap-bg); }
table.tbl { width: 100%; border-collapse: collapse; font-size: 12.5px; min-width: 640px; }
.tbl thead th {
  position: sticky; top: 0; background: var(--thead-bg); color: var(--muted);
  font-size: 10.5px; text-transform: uppercase; letter-spacing: .7px; text-align: left;
  padding: 8px 10px; border-bottom: 1px solid var(--line2); white-space: nowrap; z-index: 5;
}
.tbl tbody td { padding: 7px 10px; border-bottom: 1px solid var(--line); white-space: nowrap; vertical-align: middle; }
.tbl tbody tr:hover { background: rgba(79, 140, 255, 0.06); }
.tbl tbody tr:last-child td { border-bottom: none; }
.num { text-align: right !important; font-variant-numeric: tabular-nums; }
.muted { color: var(--muted); }
.small { font-size: 11.5px; }
.nowrap { white-space: nowrap; }
.td-wrap { white-space: normal; min-width: 180px; }

/* status chips */
.chip {
  display: inline-flex; align-items: center; gap: 5px; font-size: 10.5px; font-weight: 700;
  padding: 3px 8px; border-radius: 999px; letter-spacing: .3px; white-space: nowrap;
}
.chip::before { content: ''; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.chip-prog { background: rgba(79,140,255,.14); color: #8db4ff; }
.chip-wcust { background: rgba(251,191,36,.13); color: #ffd675; }
.chip-wpart { background: rgba(180,140,255,.14); color: #cdb2ff; }
.chip-done { background: rgba(45,212,167,.13); color: #6fe7c4; }
.chip-open { background: rgba(148,163,200,.12); color: #a9b7d4; }
.chip-revisit { background: rgba(248,113,113,.13); color: #ffa1a1; }
.chip-co { background: rgba(251,191,36,.1); color: #fcd34d; border: 1px dashed rgba(251,191,36,.4); }
.chip-co::before { display: none; }

/* icons inside table headers & cells */
.tbl thead th svg { width: 12px; height: 12px; vertical-align: -2px; margin-right: 4px; opacity: .7; }
.tl-cell { display: inline-flex; align-items: center; gap: 5px; }
.tl-cell svg { width: 13px; height: 13px; }
.tl-cell.done svg { color: var(--green); }
.tl-cell.open { color: var(--amber); }
.tl-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--red); display: inline-block; flex: none; }
.loc-cell { display: inline-flex; align-items: center; gap: 5px; }
.loc-cell svg { width: 12px; height: 12px; opacity: .7; }

/* fixed-prefix inputs (+960 phone / QT/20 quotation number) */
.cc-input { display: flex; align-items: stretch; }
.cc-input .cc-fix {
  flex: none; display: inline-flex; align-items: center; padding: 0 10px;
  background: var(--input-bg-disabled); color: var(--muted);
  border: 1px solid var(--line2); border-right: none; border-radius: 8px 0 0 8px;
  font-size: 12.5px; font-weight: 700; white-space: nowrap;
}
.cc-input input { border-radius: 0 8px 8px 0; flex: 1; min-width: 0; width: 100%; }
.cc-input input:focus { position: relative; z-index: 1; }

.pos { color: var(--green); font-weight: 700; }
.neg { color: var(--red); font-weight: 700; }

/* filters bar — ONE flowing inline row: fields, Apply, Export, record count and export format together */
.filters { display: flex; flex-wrap: wrap; gap: 8px; row-gap: 8px; align-items: flex-end; margin-bottom: 12px; }
.filters .f-group { display: flex; flex-direction: column; min-width: 130px; }
.filters select, .filters input { padding: 6px 9px; font-size: 12.5px; }
.filters .search-box { flex: 1; min-width: 170px; }
.filters .f-count { display: inline-flex; align-items: center; min-height: 33px; padding: 0 2px; white-space: nowrap; }
.filters .seg { align-self: flex-end; }

/* toolbar (legacy — other pages) */
.toolbar { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin-bottom: 12px; }

/* segment control */
.seg { display: inline-flex; background: var(--seg-bg); border: 1px solid var(--line2); border-radius: 8px; padding: 2px; gap: 2px; }
.seg button {
  border: none; background: transparent; color: var(--muted); font-size: 12px; font-weight: 600;
  padding: 5px 12px; border-radius: 6px; cursor: pointer; font-family: var(--font);
}
.seg button.on { background: linear-gradient(135deg, #4f8cff, #3b6fe0); color: #fff; }

/* tabs */
.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--line); margin-bottom: 14px; flex-wrap: wrap; }
.tab {
  padding: 8px 14px; font-size: 13px; font-weight: 700; color: var(--muted); cursor: pointer;
  border-bottom: 2px solid transparent; margin-bottom: -1px;
}
.tab:hover { color: var(--text); }
.tab.on { color: var(--accent2); border-bottom-color: var(--accent); }

/* modal */
.modal-overlay {
  position: fixed; inset: 0; background: var(--overlay-bg); backdrop-filter: blur(4px);
  display: none; align-items: flex-start; justify-content: center; z-index: 100; padding: 30px 14px; overflow-y: auto;
}
.modal-overlay.on { display: flex; }
.modal {
  width: 100%; max-width: 620px; background: var(--modal-bg);
  border: 1px solid var(--line2); border-radius: 14px; box-shadow: var(--shadow); padding: 20px 20px 16px;
}
.modal-head { display: flex; align-items: center; margin-bottom: 14px; }
.modal-head h3 { font-size: 15.5px; }
.modal-head .spacer { flex: 1; }
.modal-close { background: none; border: none; color: var(--muted); font-size: 20px; cursor: pointer; padding: 2px 8px; border-radius: 6px; }
.modal-close:hover { color: var(--text); background: rgba(148,163,200,.12); }

/* toast */
#toast {
  position: fixed; bottom: 24px; left: 50%; transform: translateX(-50%) translateY(20px);
  background: var(--toast-bg); border: 1px solid var(--line2); color: var(--text);
  padding: 10px 18px; border-radius: 10px; font-size: 13px; font-weight: 600;
  opacity: 0; pointer-events: none; transition: all .25s; z-index: 200; box-shadow: var(--shadow);
  max-width: 90vw; text-align: center;
}
#toast.on { opacity: 1; transform: translateX(-50%) translateY(0); }
#toast.err { border-color: rgba(248,113,113,.5); background: var(--toast-err-bg); }
#toast.ok { border-color: rgba(45,212,167,.5); }

/* timeline */
.timeline { list-style: none; margin-top: 6px; }
.timeline li { position: relative; padding: 0 0 14px 26px; }
.timeline li::before {
  content: ''; position: absolute; left: 7px; top: 6px; bottom: -4px; width: 2px; background: var(--line2);
}
.timeline li:last-child::before { display: none; }
.timeline .dot {
  position: absolute; left: 0; top: 3px; width: 16px; height: 16px; border-radius: 50%;
  border: 2px solid var(--accent); background: var(--timeline-dot-bg); display: flex; align-items: center; justify-content: center;
}
.timeline .dot.done { border-color: var(--green); }
.timeline .t-title { font-weight: 700; font-size: 13px; }
.timeline .t-when { font-size: 11.5px; color: var(--muted); }
.timeline .t-note { font-size: 11.5px; color: var(--muted2); }
.big-dur { display: flex; align-items: baseline; gap: 8px; padding: 10px 14px; border-radius: 10px; background: rgba(45,212,167,.08); border: 1px solid rgba(45,212,167,.25); margin-bottom: 12px; }
.big-dur .bd-val { font-size: 20px; font-weight: 800; color: var(--green); }
.big-dur .bd-lab { font-size: 11px; color: var(--muted); }

/* ranking list */
.rank-row { display: flex; align-items: center; gap: 10px; padding: 7px 4px; border-bottom: 1px solid var(--line); }
.rank-row:last-child { border-bottom: none; }
.rank-badge {
  width: 24px; height: 24px; border-radius: 7px; flex: none; font-size: 11.5px; font-weight: 800;
  display: flex; align-items: center; justify-content: center; background: var(--rank-badge-bg); color: var(--muted);
}
.rank-1 { background: linear-gradient(135deg, #ffd166, #f4a63a); color: var(--rank-gold-text); }
.rank-2 { background: linear-gradient(135deg, #d7dde8, #a9b4c7); color: var(--rank-silver-text); }
.rank-3 { background: linear-gradient(135deg, #e8a06b, #c77b42); color: var(--rank-bronze-text); }
.rank-row .r-name { flex: 1; font-weight: 600; font-size: 12.5px; }
.rank-row .r-val { font-weight: 800; font-size: 13px; }
.rank-bar { height: 4px; border-radius: 4px; background: var(--rank-bar-bg); margin-top: 3px; overflow: hidden; }
.rank-bar > div { height: 100%; border-radius: 4px; background: linear-gradient(90deg, var(--accent), var(--green)); }

/* mini stats rows */
.stat-line { display: flex; justify-content: space-between; padding: 6px 2px; border-bottom: 1px dashed var(--line); font-size: 12.5px; }
.stat-line:last-child { border-bottom: none; }
.stat-line b { font-variant-numeric: tabular-nums; }

/* empty state */
.empty { text-align: center; color: var(--muted2); padding: 34px 10px; font-size: 13px; }
.empty svg { width: 34px; height: 34px; opacity: .4; margin-bottom: 8px; }

/* legend */
.legend { display: flex; gap: 14px; flex-wrap: wrap; font-size: 11.5px; color: var(--muted); margin-top: 8px; }
.legend span { display: inline-flex; align-items: center; gap: 5px; }
.legend i { width: 9px; height: 9px; border-radius: 3px; display: inline-block; }

/* mobile card list (tables -> cards on small screens for daily logs) */
@media (max-width: 720px) {
  .tbl-desktop { display: table; }
}
.item-chips { display: inline-flex; gap: 4px; flex-wrap: wrap; }
.item-chip { font-size: 10.5px; background: rgba(79,140,255,.1); border: 1px solid rgba(79,140,255,.25); color: #9dc0ff; padding: 2px 7px; border-radius: 6px; font-weight: 700; }
.item-chip.dsk { background: rgba(45,212,167,.08); border-color: rgba(45,212,167,.25); color: #7fe9c9; }
.item-chip.sys { background: rgba(180,140,255,.1); border-color: rgba(180,140,255,.3); color: #cdb2ff; }

/* users page */
.u-dot { width: 8px; height: 8px; border-radius: 50%; display: inline-block; margin-right: 6px; }
.u-dot.on { background: var(--green); }
.u-dot.off { background: var(--red); }

/* misc */
.mt { margin-top: 12px; }
.mb { margin-bottom: 12px; }
.pill { font-size: 10.5px; background: rgba(148,163,200,.12); color: var(--muted); padding: 2px 8px; border-radius: 999px; font-weight: 700; }
a { color: var(--accent2); }

/* print */

/* ============================================================
   LIGHT MODE — applied when html[data-theme="light"]
   ============================================================ */
html[data-theme="light"] {
  --bg: #eef2f8;
  --bg2: #e6ecf5;
  --panel: #ffffff;
  --panel2: #f4f7fc;
  --line: rgba(23, 42, 74, 0.14);
  --line2: rgba(23, 42, 74, 0.24);
  --text: #1a2537;
  --muted: #5b6b85;
  --muted2: #8494ab;
  --accent: #3f74e6;
  --accent2: #2f5fd4;
  --green: #0e9e77;
  --red: #d64545;
  --amber: #b57e0f;
  --purple: #7c5cd6;
  --radius: 10px;
  --shadow: 0 8px 24px rgba(23, 42, 74, 0.16);

  --input-bg: #ffffff;
  --input-bg-disabled: #eef1f6;
  --thead-bg: #f2f5fa;
  --tbl-wrap-bg: #ffffff;
  --seg-bg: #e7edf6;
  --modal-bg: #ffffff;
  --login-card-bg: #ffffff;
  --card-bg: #ffffff;
  --topbar-bg: rgba(255, 255, 255, 0.92);
  --bottomnav-bg: rgba(255, 255, 255, 0.97);
  --toast-bg: #ffffff;
  --toast-err-bg: #fdecee;
  --scrollbar-thumb: #c3cedd;
  --timeline-dot-bg: #ffffff;
  --rank-badge-bg: #edf1f7;
  --rank-bar-bg: #e2e8f1;
  --overlay-bg: rgba(23, 42, 74, 0.35);
  --body-bg-img:
    radial-gradient(1200px 700px at 85% -10%, rgba(63, 116, 230, 0.07), transparent 60%),
    radial-gradient(900px 500px at -10% 110%, rgba(14, 158, 119, 0.05), transparent 55%);
  --nav-active-color: #1a2537;
  --btn-green-text: #ffffff;
  --brand-logo-text: #06101f;
  --avatar-text: #ffffff;
  --rank-gold-text: #5c4000;
  --rank-silver-text: #3a4557;
  --rank-bronze-text: #5c3010;
  --bg-grad-btn: linear-gradient(135deg, #4f8cff, #3b6fe0);
}
html[data-theme="light"] .brand-logo-img { box-shadow: 0 2px 10px rgba(23,42,74,.18); background: #fff; }
html[data-theme="light"] .chip-prog { background: rgba(63,116,230,.12); color: #2f5fd4; }
html[data-theme="light"] .chip-wcust { background: rgba(181,126,15,.12); color: #8a6208; }
html[data-theme="light"] .chip-wpart { background: rgba(124,92,214,.12); color: #6a4ec2; }
html[data-theme="light"] .chip-done { background: rgba(14,158,119,.12); color: #0b8266; }
html[data-theme="light"] .chip-open { background: rgba(91,107,133,.12); color: #5b6b85; }
html[data-theme="light"] .chip-revisit { background: rgba(214,69,69,.12); color: #c23c3c; }
html[data-theme="light"] .chip-co { background: rgba(181,126,15,.09); color: #8a6208; border: 1px dashed rgba(181,126,15,.45); }
html[data-theme="light"] .item-chip { background: rgba(63,116,230,.09); border-color: rgba(63,116,230,.28); color: #2f5fd4; }
html[data-theme="light"] .item-chip.dsk { background: rgba(14,158,119,.08); border-color: rgba(14,158,119,.3); color: #0b8266; }
html[data-theme="light"] .item-chip.sys { background: rgba(124,92,214,.09); border-color: rgba(124,92,214,.3); color: #6a4ec2; }
html[data-theme="light"] .demo-btn { background: rgba(63,116,230,.08); border-color: rgba(63,116,230,.3); color: #2f5fd4; }
html[data-theme="light"] .demo-btn:hover { background: rgba(63,116,230,.16); }
html[data-theme="light"] .pos { color: #0e9e77; }
html[data-theme="light"] .neg { color: #d64545; }
html[data-theme="light"] .btn-danger { background: rgba(214,69,69,.09); border-color: rgba(214,69,69,.35); color: #c23c3c; }
html[data-theme="light"] .btn-danger:hover { background: rgba(214,69,69,.16); }
html[data-theme="light"] .nav-item:hover { background: rgba(63,116,230,.07); }
html[data-theme="light"] .nav-item.active { background: linear-gradient(135deg, rgba(63,116,230,.16), rgba(14,158,119,.08)); border-color: rgba(63,116,230,.4); }
html[data-theme="light"] .tbl tbody tr:hover { background: rgba(63,116,230,.05); }
html[data-theme="light"] .modal-close:hover { background: rgba(23,42,74,.08); }
html[data-theme="light"] .pill { background: rgba(91,107,133,.13); }
html[data-theme="light"] .big-dur { background: rgba(14,158,119,.07); border-color: rgba(14,158,119,.3); }
html[data-theme="light"] .timeline li::before { background: rgba(23,42,74,.2); }
html[data-theme="light"] #toast.ok { border-color: rgba(14,158,119,.45); }
html[data-theme="light"] .btn-ghost { color: #5b6b85; }
html[data-theme="light"] .btn-ghost:hover { color: #1a2537; }

/* ---------- SERVICE ID duplicate alert (wave 5) ---------- */
/* small popup layered above the open form modal (z-index 300 > modal 100) so the
   user's half-typed data stays intact underneath */
.sid-alert-overlay {
  position: fixed; inset: 0; z-index: 300;
  display: flex; align-items: center; justify-content: center;
  background: rgba(8, 12, 22, 0.55); padding: 20px;
}
.sid-alert {
  max-width: 420px; width: 100%;
  background: var(--panel); border: 1px solid rgba(248, 113, 113, 0.45);
  border-top: 3px solid var(--red); border-radius: 12px;
  box-shadow: var(--shadow); padding: 22px 22px 18px;
  text-align: center; animation: sidPop .18s ease-out;
}
@keyframes sidPop { from { transform: scale(.92); opacity: 0; } to { transform: scale(1); opacity: 1; } }
.sid-alert-ico { font-size: 30px; margin-bottom: 8px; }
.sid-alert-title { font-weight: 800; font-size: 16px; color: var(--red); margin-bottom: 8px; }
.sid-alert-msg { font-size: 13.5px; color: var(--text); line-height: 1.5; }
.sid-alert-msg b { color: var(--red); }
.sid-alert-sub { font-size: 12px; color: var(--muted); margin-top: 7px; line-height: 1.5; }
.sid-alert .btn { margin-top: 16px; }
input.err, select.err, textarea.err { border-color: var(--red) !important; box-shadow: 0 0 0 3px rgba(248, 113, 113, 0.18) !important; }

/* ---------- theme toggle ---------- */
.theme-toggle {
  flex: none; display: inline-flex; align-items: center; justify-content: center;
  width: 34px; height: 34px; border-radius: 9px; cursor: pointer;
  background: var(--seg-bg); border: 1px solid var(--line2); color: var(--muted);
  transition: color .15s, border-color .15s, background .15s;
}
.theme-toggle:hover { color: var(--text); border-color: var(--accent); }
.theme-toggle svg { width: 17px; height: 17px; }
.theme-toggle .ico-moon { display: none; }
html[data-theme="light"] .theme-toggle .ico-sun { display: none; }
html[data-theme="light"] .theme-toggle .ico-moon { display: block; }
.login-theme-row { display: flex; justify-content: center; margin-top: 14px; }

/* print stays paper-white regardless of theme */
@media print {
  html[data-theme="light"] body, body { background: #fff; color: #111; }
}
@media print {
  body { background: #fff; color: #111; }
  .topbar, .sidebar, .bottom-nav, .filters, .toolbar, .form-foot { display: none !important; }
  .card { border: 1px solid #ccc; background: #fff; }
  .content { padding: 0; max-width: none; }
}


/* ===== Wave 7: Technician Performance Report card ===== */
.cr-card { border-left: 3px solid var(--accent); margin-bottom: 18px; }
.cr-card h3 { display: flex; align-items: center; gap: 8px; }
.cr-card h3 svg { width: 15px; height: 15px; color: var(--accent); }
.cr-sub { font-size: 12px; margin: 2px 0 4px; line-height: 1.5; }
.cr-filters { margin: 12px 0 10px; }
.btn-pdf { background: linear-gradient(135deg, #e05252, #c03535); color: #fff; }
.btn-pdf:hover { filter: brightness(1.12); }
.cr-meta { display: flex; flex-wrap: wrap; gap: 6px 22px; padding: 9px 12px; background: var(--tbl-wrap-bg); border: 1px solid var(--line); border-radius: 8px; font-size: 12px; margin-bottom: 12px; color: var(--muted); }
.cr-meta b { color: var(--text); font-weight: 600; }
.cr-empty { padding: 20px; }
.cr-sect { margin-bottom: 16px; }
.cr-sect + .cr-sect { margin-top: 22px; border-top: 2.5px solid var(--cr-edge, var(--line2)); padding-top: 16px; }
.cr-sec { display: flex; align-items: center; gap: 10px; margin-bottom: 8px; }
.cr-no { display: inline-flex; align-items: center; justify-content: center; min-width: 24px; height: 24px; padding: 0 7px; border-radius: 7px; background: var(--accent); color: #fff; font-weight: 800; font-size: 13px; }
.cr-title { font-size: 15px; font-weight: 800; letter-spacing: .3px; }
.cr-count { margin-left: auto; font-size: 12px; color: var(--muted); }
.cr-group td { background: rgba(79, 140, 255, .12); color: var(--accent2); font-weight: 700; font-size: 12.5px; letter-spacing: .2px; }
.cr-tl td { background: var(--tbl-wrap-bg); border-bottom: 1px dashed var(--line2); padding: 7px 10px; }
.cr-tl-sum { display: flex; align-items: center; gap: 7px; font-size: 12px; color: var(--text); font-style: italic; }
.cr-tl-sum svg { width: 13px; height: 13px; color: var(--amber); flex: none; }
.cr-tot { margin-top: 8px; padding: 9px 12px; border: 1px solid rgba(45, 212, 167, .3); background: rgba(45, 212, 167, .08); border-radius: 8px; font-weight: 700; font-size: 12.5px; }

/* ---- Wave 7.3: per-report colour identity (screen + A3 print) ---- */
.cr-c-daily  { --cr: #4f8cff; --cr-edge: #4f8cff; --cr-tint: rgba(79, 140, 255, .14); --cr-text: var(--accent2); }
.cr-c-visits { --cr: #14b8a6; --cr-edge: #14b8a6; --cr-tint: rgba(20, 184, 166, .14); --cr-text: #2dd4bf; }
.cr-c-ready  { --cr: #a78bfa; --cr-edge: #a78bfa; --cr-tint: rgba(167, 139, 250, .16); --cr-text: #b9a5ff; }
html[data-theme="light"] .cr-c-daily  { --cr: #1e3a8a; --cr-edge: #2f5fd4; --cr-tint: #e3ebfd; --cr-text: #1e3a8a; }
html[data-theme="light"] .cr-c-visits { --cr: #0d5f55; --cr-edge: #0e9488; --cr-tint: #dff3ef; --cr-text: #0d5f55; }
html[data-theme="light"] .cr-c-ready  { --cr: #4c1d95; --cr-edge: #6d4bd8; --cr-tint: #efe9fc; --cr-text: #4c1d95; }

.cr-sec-band { display: flex; align-items: center; gap: 10px; margin-bottom: 8px; padding: 9px 12px; border-radius: 8px; border-left: 5px solid var(--cr-edge); background: linear-gradient(90deg, var(--cr-tint), transparent 85%); }
.cr-sec-band .cr-no { background: var(--cr); }
.cr-sec-band .cr-title { color: var(--cr-text); }
.cr-c-sect .cr-group td { background: var(--cr-tint); color: var(--cr-text); }
.cr-c-sect .tbl thead th { background: var(--cr-tint); color: var(--cr-text); border-bottom: 2px solid var(--cr-edge); }
.cr-c-sect .cr-tot { border-color: var(--cr-edge); background: var(--cr-tint); color: var(--cr-text); }

/* ---- Wave 7.5: summary reports card (top of performance report) ---- */
.cr-sum { margin: 0 0 14px; border: 1px solid var(--line2); border-radius: 10px; overflow: hidden; background: var(--tbl-wrap-bg); }
.cr-sum-title { padding: 8px 14px; font-size: 11px; font-weight: 800; letter-spacing: 1.2px; text-transform: uppercase; color: var(--muted); border-bottom: 1px solid var(--line2); }
.cr-sum-row { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 18px; padding: 9px 14px; border-left: 4px solid var(--cr-edge, var(--line2)); background: linear-gradient(90deg, var(--cr-tint, transparent), transparent 72%); }
.cr-sum-row + .cr-sum-row { border-top: 1px solid var(--line); }
.cr-sum-row .cr-no { background: var(--cr, var(--accent)); min-width: 20px; height: 20px; font-size: 11.5px; border-radius: 6px; }
.cr-sum-name { font-size: 13px; font-weight: 800; color: var(--cr-text, var(--text)); display: inline-flex; align-items: center; gap: 8px; }
.cr-sum-desc { font-weight: 500; font-size: 11.5px; color: var(--muted); }
.cr-sum-tot { margin-left: auto; font-size: 12px; font-weight: 800; color: var(--text); text-align: right; }
@media (max-width: 980px) { .cr-sum-tot { margin-left: 0; flex-basis: 100%; } }
@media print {
  .cr-tl td { background: #fff !important; }
  .cr-c-daily  { --cr-tint: #e3ebfd; --cr-text: #1e3a8a; --cr-edge: #2f5fd4; }
  .cr-c-visits { --cr-tint: #dff3ef; --cr-text: #0d5f55; --cr-edge: #0e9488; }
  .cr-c-ready  { --cr-tint: #efe9fc; --cr-text: #4c1d95; --cr-edge: #6d4bd8; }
  .cr-meta { background: #fff; }
}
/* when printing via the A3 Print button, hide everything except the performance report */
@media print {
  body.cr-print-only .topbar, body.cr-print-only .sidebar, body.cr-print-only .bottom-nav,
  body.cr-print-only .filters, body.cr-print-only .tabs, body.cr-print-only .page-head,
  body.cr-print-only #rp-body, body.cr-print-only .cr-empty { display: none !important; }
  body.cr-print-only #cr-card { border: none; background: none; box-shadow: none; }
  body.cr-print-only #cr-card h3, body.cr-print-only .cr-sub { display: none; }
  body.cr-print-only #cr-body { display: block !important; }
  body.cr-print-only .tbl { font-size: 9.5px; }
  body.cr-print-only .tbl th, body.cr-print-only .tbl td { padding: 4px 6px; }
  body.cr-print-only .cr-sec { page-break-inside: avoid; }
  body.cr-print-only .cr-sum { border: 1px solid #ccc; page-break-inside: avoid; }
  body.cr-print-only .cr-sum-row { background: var(--cr-tint, #fff) !important; -webkit-print-color-adjust: exact; print-color-adjust: exact; }
  body.cr-print-only .cr-sum-title { color: #333; border-bottom: 1px solid #ccc; }
  body.cr-print-only .cr-sect { page-break-before: auto; }
  body.cr-print-only .cr-sect + .cr-sect { page-break-before: always; }
}
