:root {
  --bg: #e8edf5; --screenbg: #f5f7fb; --card: #ffffff; --line: #d9e0ee; --surface: #e9edf5; --track: #e2e8f2; --navbg: #fffffff2;
  --text: #16213a; --muted: #5d6b89; --dim: #93a0b8;
  --primary: #0284c7; --plight: #0284c7;
  --green: #059669; --red: #dc2626; --amber: #d97706;
  --mono: 'JetBrains Mono', Consolas, monospace;
  color-scheme: light;
}
:root[data-theme="light"] {
  --bg: #e8edf5; --screenbg: #f5f7fb; --card: #ffffff; --line: #d9e0ee; --surface: #e9edf5; --track: #e2e8f2; --navbg: #fffffff2;
  --text: #16213a; --muted: #5d6b89; --dim: #93a0b8;
  --primary: #0284c7; --plight: #0284c7;
  --green: #059669; --red: #dc2626; --amber: #d97706;
  color-scheme: light;
}
:root[data-theme="dark"] {
  --bg: #090d16; --screenbg: #090d16; --card: #131927; --line: #1f2738; --surface: #0c1220; --track: #1e2637; --navbg: #0b1120ee;
  --text: #f1f5f9; --muted: #94a3b8; --dim: #64748b;
  --primary: #0284c7; --plight: #38bdf8;
  --green: #10b981; --red: #ef4444; --amber: #f59e0b;
  color-scheme: dark;
}
* { box-sizing: border-box; margin: 0; padding: 0; -webkit-tap-highlight-color: transparent; }
body {
  background: var(--bg); color: var(--text);
  font-family: 'Plus Jakarta Sans', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  padding: 24px 16px 60px; line-height: 1.5;
  -webkit-font-smoothing: antialiased; -moz-osx-font-smoothing: grayscale;
}
.wrap { max-width: 1100px; margin: 0 auto; display: flex; gap: 34px; flex-wrap: wrap; align-items: flex-start; }
.intro { flex: 1; min-width: 260px; max-width: 400px; }
.eyebrow { font-size: 9.5px; letter-spacing: .08em; color: var(--plight); font-weight: 600; text-transform: uppercase; }
.intro h1 { font-size: 27px; margin: 6px 0 8px; }
.intro p { color: var(--muted); font-size: 14px; }
.try { background: var(--card); border: 1px solid var(--line); border-radius: 14px; padding: 14px 16px; margin-top: 16px; font-size: 13px; }
.try b { display: block; margin-bottom: 6px; }
.try ol { margin: 0; padding-left: 18px; display: flex; flex-direction: column; gap: 6px; color: var(--muted); }

/* Phone Frame */
.phone { width: 345px; max-width: 100%; background: #000; border-radius: 42px; padding: 11px; border: 1px solid #2a3448; box-shadow: 0 24px 70px rgba(2,132,199,.25); }
.screen { background: var(--screenbg); color: var(--text); border-radius: 32px; overflow: hidden; height: 650px; display: flex; flex-direction: column; font-size: 13px; position: relative; }
.statusbar { display: flex; justify-content: space-between; padding: 12px 20px 2px; font-size: 11px; color: var(--muted); font-variant-numeric: tabular-nums; }
.view {
  flex: 1; overflow-y: auto; overflow-x: hidden !important; width: 100%; box-sizing: border-box;
  display: none; flex-direction: column; min-width: 0;
  scrollbar-width: thin;
}
.view::-webkit-scrollbar { width: 4px; height: 0px; }
.view::-webkit-scrollbar-track { background: transparent; }
.view::-webkit-scrollbar-thumb { background: rgba(148, 163, 184, 0.2); border-radius: 4px; }
.view.on { display: flex; }
.pad { padding: 10px 12px 14px; display: flex; flex-direction: column; gap: 9px; min-width: 0; width: 100%; box-sizing: border-box; overflow-x: hidden !important; }
.top { display: flex; justify-content: space-between; align-items: center; }
.top h2 { font-size: 16px; font-weight: 700; letter-spacing: -0.3px; line-height: 1.25; color: var(--text); }
.top-actions { display: flex; gap: 6px; align-items: center; }
.backbtn { border: 0; background: none; font-size: 13px; color: var(--plight); font-weight: 700; cursor: pointer; padding: 4px 0; text-align: left; }

.iconbtn {
  width: 36px; height: 36px; border-radius: 12px; border: 1px solid var(--line);
  background: var(--card); color: var(--text); cursor: pointer; display: inline-flex;
  align-items: center; justify-content: center; transition: all .15s ease;
  touch-action: manipulation;
}
.iconbtn:hover { border-color: var(--primary); }
.iconbtn svg { width: 17px; height: 17px; }

.login-top-bar {
  display: flex; justify-content: flex-end; align-items: center; width: 100%;
  flex-shrink: 0; margin-bottom: 2px;
}

@-webkit-keyframes spin {
  0% { -webkit-transform: rotate(0deg); }
  100% { -webkit-transform: rotate(360deg); }
}
@keyframes spin {
  0% { transform: rotate(0deg); }
  100% { transform: rotate(360deg); }
}
.spinning svg {
  transform-origin: center;
  -webkit-transform-origin: center;
  -webkit-animation: spin 0.9s linear infinite;
  animation: spin 0.9s linear infinite;
}
.iconbtn.spinning {
  pointer-events: none;
  opacity: 0.82;
}

/* Segmented Tabs */
.tabs { display: grid; grid-template-columns: repeat(3, 1fr); gap: 4px; background: var(--surface); border: 1px solid var(--line); padding: 4px; border-radius: 13px; }
.tabs button { border: 0; background: transparent; font-size: 11.5px; font-weight: 700; color: var(--muted); padding: 8px 0; border-radius: 10px; cursor: pointer; transition: all .15s ease; }
.tabs button.on { background: var(--primary); color: #fff; box-shadow: 0 2px 6px rgba(2,132,199,0.3); }

/* Toolbar: Search + Sort in 1 clean row */
.toolbar { display: flex; gap: 6px; align-items: center; }
.search-wrap {
  flex: 1; min-width: 0; position: relative; display: flex; align-items: center;
  background: var(--card); border: 1px solid var(--line); border-radius: 10px;
  padding: 0 8px 0 28px; height: 35px; transition: all .15s ease;
}
.search-wrap:focus-within {
  border-color: var(--primary);
  box-shadow: 0 0 0 2px rgba(2, 132, 199, 0.15);
}
.search-wrap svg.search-ico {
  position: absolute; left: 8px; top: 50%; transform: translateY(-50%);
  width: 14px; height: 14px; color: var(--dim); stroke-width: 2.2; pointer-events: none;
}
.search-input {
  width: 100%; min-width: 0; border: none; background: transparent; color: var(--text);
  font-size: 11.5px; outline: none; padding: 0; font-family: inherit; line-height: 35px;
}
.search-input::placeholder { color: var(--dim); font-size: 11.5px; }
.clear-btn {
  border: 0; background: transparent; color: var(--dim); font-size: 11px;
  cursor: pointer; padding: 0 3px; line-height: 1; display: none;
}
.clear-btn:hover { color: var(--text); }

.sort-btn {
  flex-shrink: 0; height: 35px; display: inline-flex; align-items: center; gap: 4px;
  background: var(--card); border: 1px solid var(--line); border-radius: 10px;
  padding: 0 8px; color: var(--muted); font-size: 11px; font-weight: 600;
  cursor: pointer; transition: all .18s ease; white-space: nowrap;
}
.sort-btn svg { width: 13px; height: 13px; stroke-width: 2.2; flex-shrink: 0; }
.sort-btn.active {
  background: rgba(2, 132, 199, 0.09); border-color: var(--primary); color: var(--primary);
}
:root[data-theme="dark"] .sort-btn.active {
  background: rgba(56, 189, 248, 0.12); color: var(--plight);
}

/* Machine rows */
.machine {
  display: flex; gap: 8px; align-items: center; background: var(--card);
  border: 1px solid var(--line); border-radius: 12px; padding: 8px 10px;
  cursor: pointer; min-width: 0; transition: transform .12s, border-color .15s, background .15s;
}
.machine:hover { border-color: rgba(2, 132, 199, 0.35); }
.machine.no-click { cursor: default; }
.machine.no-click:hover { border-color: var(--line); }

.dot { width: 7.5px; height: 7.5px; border-radius: 50%; flex-shrink: 0; }
.dot.on { background: var(--green); box-shadow: 0 0 0 2.5px rgba(16, 185, 129, 0.15); }
.dot.warn { background: var(--amber); box-shadow: 0 0 0 2.5px rgba(245, 158, 11, 0.15); }
.dot.hot, .dot.err { background: var(--red); box-shadow: 0 0 0 2.5px rgba(239, 68, 68, 0.22); }

.machine .mid { flex: 1; min-width: 0; overflow: hidden; }
.machine b { display: block; font-size: 12.5px; font-weight: 700; color: var(--text); line-height: 1.25; }

/* Subtext 1 hàng ngang chuẩn mobile */
.machine small {
  color: var(--muted); font-size: 8.8px; font-family: var(--mono);
  display: block; white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  line-height: 1.35; margin-top: 2px;
}
.machine small .sep { opacity: .45; margin: 0 2px; }

/* Subtext cho từng tab để nằm chuẩn trên 1 hàng ngang */
.sub-temp {
  font-size: 8.8px !important; letter-spacing: -0.25px !important;
  white-space: nowrap; display: inline-block;
}
.sub-winkey {
  font-size: 9.5px !important; letter-spacing: -0.25px !important;
  font-family: var(--mono);
  white-space: nowrap; display: inline-block;
  color: var(--muted);
}
.sub-hw {
  font-size: 9.8px !important; letter-spacing: -0.25px !important;
  font-family: var(--mono);
  white-space: nowrap; display: inline-block;
  color: var(--muted);
}
.ram-badge {
  font-size: 9.5px; font-weight: 700; font-family: var(--mono);
  padding: 2px 6px; border-radius: 5px;
  background: var(--surface); color: var(--text);
  border: 1px solid var(--line); white-space: nowrap; flex-shrink: 0;
}

/* Status Badges: siêu nhỏ gọn, tinh tế, vừa vặn không chiếm diện tích */
.badge-status {
  display: inline-flex; align-items: center; justify-content: center;
  font-size: 8.5px; font-weight: 700;
  padding: 2.5px 6.5px; border-radius: 4px; white-space: nowrap; flex-shrink: 0;
  letter-spacing: .01em; line-height: 1.25;
}
.badge-status.status-ok {
  color: var(--green); background: rgba(16, 185, 129, 0.12);
  border: 1px solid rgba(16, 185, 129, 0.28);
}
.badge-status.status-err {
  color: var(--red); background: rgba(239, 68, 68, 0.12);
  border: 1px solid rgba(239, 68, 68, 0.28);
}
.badge-status.status-warn {
  color: var(--amber); background: rgba(245, 158, 11, 0.12);
  border: 1px solid rgba(245, 158, 11, 0.28);
}

/* Temperature number */
.tv { font-size: 14px; font-weight: 800; font-variant-numeric: tabular-nums; flex-shrink: 0; font-family: var(--mono); }
.tv.hot { color: var(--red); }
.tv.warm { color: var(--amber); }
.tv.cool { color: var(--green); }

/* Home Screen: KPI Summary Cards & Venue Cards */
.kpi-grid {
  display: grid; grid-template-columns: 1fr 1fr; gap: 8px;
}
.kpi-card {
  background: var(--card); border: 1px solid var(--line); border-radius: 14px;
  padding: 11px 12px; display: flex; align-items: flex-start; gap: 9px;
  transition: transform .12s, border-color .15s;
}
.kpi-icon {
  width: 32px; height: 32px; border-radius: 9px; display: flex; align-items: center;
  justify-content: center; flex-shrink: 0;
}
.kpi-icon svg { width: 17px; height: 17px; }
.kpi-blue { background: rgba(2, 132, 199, 0.1); color: var(--primary); }
.kpi-green { background: rgba(16, 185, 129, 0.1); color: var(--green); }

.kpi-content { display: flex; flex-direction: column; min-width: 0; }
.kpi-val {
  font-size: 19px; font-weight: 800; color: var(--text); line-height: 1.15;
  font-variant-numeric: tabular-nums;
}
.kpi-lbl {
  font-size: 10.5px; font-weight: 600; color: var(--text); margin-top: 1px;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.kpi-sub {
  font-size: 9px; color: var(--muted); margin-top: 2px;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}

/* Section Title */
.section-title {
  display: flex; justify-content: space-between; align-items: center;
  font-size: 10.5px; font-weight: 600; color: var(--dim); margin: 2px 0 -3px;
  text-transform: uppercase; letter-spacing: 0.05em;
}
.section-title small {
  font-size: 10px; font-weight: 600; color: var(--dim); text-transform: none;
}

/* Venue Cards: Gọn gàng, liền mạch 1 khối, không chia dòng rời rạc */
.venue-card {
  background: var(--card); border: 1px solid var(--line); border-radius: 14px;
  padding: 12px 14px; cursor: pointer; transition: all .15s ease;
  display: flex; align-items: center; justify-content: space-between; gap: 10px;
}
.venue-card:hover {
  border-color: rgba(2, 132, 199, 0.4); background: rgba(2, 132, 199, 0.02);
  transform: translateY(-1px);
}
.venue-card.venue-offline {
  cursor: default; opacity: .75;
}
.venue-card.venue-offline:hover {
  border-color: var(--line); background: var(--card); transform: none;
}
.venue-card.venue-loading {
  cursor: default; opacity: .92;
}
.venue-card.venue-loading:hover {
  border-color: var(--line); background: var(--card); transform: none;
}

.vcard-left {
  display: flex; flex-direction: column; gap: 3px; min-width: 0;
}
.vcard-name-row {
  display: flex; align-items: center; gap: 7.5px;
}
.vcard-name-row b {
  font-size: 13.5px; font-weight: 700; color: var(--text);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.vcard-dot {
  width: 7.5px; height: 7.5px; border-radius: 50%; flex-shrink: 0;
}
.vcard-dot.on {
  background: var(--green); box-shadow: 0 0 0 2.5px rgba(16, 185, 129, 0.2);
}
.vcard-dot.err {
  background: var(--red); box-shadow: 0 0 0 2.5px rgba(239, 68, 68, 0.2);
}
.vcard-dot.loading {
  background: var(--dim);
  box-shadow: 0 0 0 2.5px rgba(147, 160, 184, 0.25);
  -webkit-animation: pulseDot 1.4s infinite ease-in-out;
  animation: pulseDot 1.4s infinite ease-in-out;
}
@-webkit-keyframes pulseDot {
  0%, 100% { opacity: 0.4; transform: scale(0.85); }
  50% { opacity: 1; transform: scale(1.15); }
}
@keyframes pulseDot {
  0%, 100% { opacity: 0.4; transform: scale(0.85); }
  50% { opacity: 1; transform: scale(1.15); }
}

.vcard-sub {
  font-size: 11px; margin-left: 15px;
}
.vcard-online-text {
  color: var(--green); font-weight: 500; display: flex; align-items: center; gap: 4px; flex-wrap: wrap;
}
.vcard-online-text b {
  font-size: 14px; font-weight: 800; font-family: var(--mono);
}
.vcard-time {
  color: var(--dim); font-size: 10.5px; font-weight: 500; margin-left: 2px; white-space: nowrap;
}
.vcard-off-text {
  color: var(--muted); font-size: 10.5px;
}
.vcard-loading-text {
  color: var(--dim); font-size: 11px; font-weight: 500;
  display: inline-flex; align-items: center; gap: 5.5px;
}
.vcard-mini-spin {
  width: 12px; height: 12px; min-width: 12px; min-height: 12px;
  color: var(--primary);
  -webkit-animation: spin .75s linear infinite;
  animation: spin .75s linear infinite;
  flex-shrink: 0; display: inline-block; vertical-align: middle;
}
.vcard-sync-tag {
  font-size: 9.5px; font-weight: 600; padding: 3px 7px; border-radius: 6px;
  background: rgba(2, 132, 199, 0.08); color: var(--primary);
  border: 1px solid rgba(2, 132, 199, 0.2); white-space: nowrap;
}
.kpi-mini-spin {
  display: inline-block; width: 17px; height: 17px;
  border: 2.2px solid var(--track); border-top-color: var(--primary);
  border-radius: 50%;
  -webkit-animation: spin .7s linear infinite;
  animation: spin .7s linear infinite;
  vertical-align: middle;
}

.vcard-right {
  display: flex; align-items: center; flex-shrink: 0;
}
.vcard-arrow {
  font-size: 19px; line-height: 1; color: var(--dim); font-weight: 300;
  transition: color .15s, transform .15s;
}
.venue-card:hover .vcard-arrow {
  color: var(--primary); transform: translateX(2px);
}
.vcard-off-badge {
  font-size: 9px; font-weight: 700; padding: 2.5px 7px; border-radius: 4px;
  color: var(--red); background: rgba(239, 68, 68, 0.1);
  border: 1px solid rgba(239, 68, 68, 0.25); line-height: 1.2;
}

/* Profile View (Tôi) - Giao diện cải tiến với SVG icons */
.profile-card {
  background: var(--card); border: 1px solid var(--line); border-radius: 14px;
  padding: 12px 14px; display: flex; align-items: center; gap: 12px;
}
.avatar {
  width: 44px; height: 44px; border-radius: 14px; position: relative; flex-shrink: 0;
  background: linear-gradient(135deg, var(--primary), var(--plight));
  display: flex; align-items: center; justify-content: center; color: #fff;
  box-shadow: 0 4px 12px rgba(2, 132, 199, 0.25);
}
.avatar svg { width: 22px; height: 22px; }
.avatar-dot {
  position: absolute; right: -1px; bottom: -1px; width: 10px; height: 10px;
  border-radius: 50%; background: var(--green); border: 2px solid var(--card);
}
.profile-info { flex: 1; min-width: 0; }
.profile-name { font-size: 15px; font-weight: 700; color: var(--text); line-height: 1.25; }
.profile-role {
  display: inline-flex; align-items: center; gap: 4px; font-size: 10.5px;
  color: var(--primary); font-weight: 600; margin-top: 3px;
}

.profile-stats {
  display: grid; grid-template-columns: 1fr 1fr; gap: 8px;
}
.pstat-item {
  background: var(--card); border: 1px solid var(--line); border-radius: 12px;
  padding: 10px 12px; display: flex; align-items: center; gap: 10px;
}
.pstat-item svg { width: 20px; height: 20px; color: var(--primary); flex-shrink: 0; }
.pstat-body { display: flex; flex-direction: column; }
.pstat-val { font-size: 16px; font-weight: 800; color: var(--text); font-variant-numeric: tabular-nums; line-height: 1.2; }
.pstat-lbl { font-size: 10px; color: var(--muted); }

.menu-group {
  background: var(--card); border: 1px solid var(--line); border-radius: 14px;
  overflow: hidden; display: flex; flex-direction: column;
}
.info-row {
  display: flex; align-items: center; justify-content: space-between; gap: 8px;
  padding: 10px 12px; border-bottom: 1px solid var(--line);
}
.info-row.info-row-top {
  align-items: flex-start;
}
.info-row:last-child { border-bottom: 0; }
.info-left { display: flex; align-items: center; gap: 9px; min-width: 0; flex: 1; }
.info-row.info-row-top .info-left { align-items: flex-start; }
.info-ico {
  width: 28px; height: 28px; border-radius: 8px; background: rgba(2, 132, 199, 0.08);
  color: var(--primary); display: flex; align-items: center; justify-content: center; flex-shrink: 0;
}
.info-row.info-row-top .info-ico { margin-top: 1px; }
.info-ico svg { width: 14px; height: 14px; }
.info-body { flex: 1; min-width: 0; }
.info-title { font-size: 11.5px; font-weight: 600; color: var(--text); }
.info-desc { font-size: 10px; color: var(--muted); }
.venue-list {
  display: flex; flex-direction: column; gap: 3px; margin-top: 4px;
}
.venue-line {
  font-size: 11px; color: var(--text); font-weight: 500; line-height: 1.4;
  word-break: break-word; display: flex; align-items: flex-start; gap: 6px;
}
.venue-line::before {
  content: ""; display: inline-block; width: 4px; height: 4px;
  border-radius: 50%; background: var(--primary); flex-shrink: 0;
  margin-top: 5px;
}
.info-badge {
  font-size: 9.5px; font-weight: 700; padding: 2px 6px; border-radius: 4px;
  background: var(--surface); color: var(--muted); border: 1px solid var(--line); white-space: nowrap;
}
.info-row.info-row-top .info-badge { margin-top: 2px; flex-shrink: 0; }

.menu-item {
  display: flex; align-items: center; justify-content: space-between; gap: 8px;
  padding: 13px 14px; min-height: 48px; background: none; border: 0; color: var(--text);
  font-size: 13px; font-family: inherit; width: 100%; cursor: pointer;
  text-align: left; transition: background .15s ease; border-bottom: 1px solid var(--line);
  touch-action: manipulation;
  -webkit-tap-highlight-color: rgba(2, 132, 199, 0.1);
  user-select: none;
  -webkit-user-select: none;
}
.menu-item:last-child { border-bottom: 0; }
.menu-item:hover, .menu-item:focus { background: var(--surface); }
.menu-item:active { background: var(--surface); opacity: .88; }
.menu-item.danger-item:hover, .menu-item.danger-item:focus { background: rgba(239, 68, 68, 0.05); }
.menu-item.danger-item:active { background: rgba(239, 68, 68, 0.12); opacity: .88; }
.menu-item * { pointer-events: none; }
.menu-left { display: flex; align-items: center; gap: 9px; min-width: 0; }
.menu-icon {
  width: 28px; height: 28px; border-radius: 8px; display: flex; align-items: center;
  justify-content: center; flex-shrink: 0; background: var(--surface); color: var(--primary);
}
.menu-icon svg { width: 15px; height: 15px; stroke-width: 2; }
.menu-item.danger-item .menu-icon { background: rgba(239, 68, 68, 0.1); color: var(--red); }
.menu-item.danger-item .menu-title { color: var(--red); }
.menu-title { font-weight: 600; font-size: 12.5px; line-height: 1.25; }
.menu-sub { font-size: 10px; color: var(--muted); }
.menu-right { display: flex; align-items: center; gap: 4px; color: var(--dim); }
.menu-right svg { width: 14px; height: 14px; }

/* Detail Sheet */
.sheetwrap { position: absolute; inset: 0; background: rgba(0,0,0,.55); display: none; align-items: flex-end; z-index: 5; }
.sheetwrap.on { display: flex; }
.sheet { background: var(--card); width: 100%; border-radius: 22px 22px 0 0; border-top: 1px solid var(--line); padding: 8px 14px calc(14px + env(safe-area-inset-bottom, 0px)); max-height: 82%; overflow-y: auto; }
.grab { width: 44px; height: 5px; border-radius: 5px; background: #334155; margin: 2px auto 8px; }
.sheet h3 { font-size: 15px; margin-bottom: 1px; }
.sheet .sub { font-size: 11px; color: var(--muted); margin-bottom: 8px; }
.spec { font-size: 11px; }
.spec h5 { font-size: 10px; letter-spacing: .12em; color: var(--plight); margin: 10px 0 2px; }
.spec h5:first-child { margin-top: 0; }
.kv { display: flex; justify-content: space-between; gap: 10px; padding: 4px 0; border-top: 1px solid var(--line); }
.kv span:first-child { color: var(--muted); flex-shrink: 0; }
.kv b { font-weight: 600; text-align: right; font-family: var(--mono); font-size: 10.5px; word-break: break-word; }
.tbar { height: 5px; border-radius: 5px; background: var(--track); overflow: hidden; margin: 2px 0 3px; }
.tbar i { display: block; height: 100%; border-radius: 5px; }

/* Toast & Navbar */
.toast { position: absolute; left: 14px; right: 14px; bottom: 86px; background: #e2e8f0; color: #0f172a; border-radius: 12px; padding: 10px 14px; font-size: 12px; display: none; z-index: 9; font-weight: 600; text-align: center; }
.toast.on { display: block; }
.navbar { display: grid; grid-template-columns: repeat(3, 1fr); background: var(--navbg); border-top: 1px solid var(--line); padding: 8px 4px calc(10px + env(safe-area-inset-bottom, 0px)); }
.navbar[hidden], .navbar.hide { display: none !important; }
.navbar button { background: none; border: 0; color: var(--dim); font-size: 9.5px; font-weight: 600; cursor: pointer; display: flex; flex-direction: column; align-items: center; gap: 3px; letter-spacing: -0.15px; }
.navbar button.on { color: var(--plight); }
.navbar svg { width: 21px; height: 21px; }

/* Modern Login Screen with SVG Icons */
.loginwrap {
  min-height: 100%; height: 100%;
  display: flex; flex-direction: column; justify-content: space-between;
  padding: 24px 24px 20px; box-sizing: border-box;
  overflow-y: auto; -webkit-overflow-scrolling: touch;
}
.login-body {
  flex: 1;
  display: flex; flex-direction: column; justify-content: center;
  margin: auto 0;
  width: 100%;
  max-width: 330px;
  align-self: center;
  padding: 12px 0 26px;
}
/* Fallback if login-body is omitted */
.loginwrap > .login-header {
  margin-top: auto;
  margin-bottom: 22px;
}
.loginwrap > .login-form {
  margin-bottom: auto;
}
.login-header {
  display: flex; flex-direction: column; align-items: center; text-align: center;
  margin-bottom: 24px;
}
.login-logo {
  width: 68px; height: 68px; border-radius: 22px;
  background: linear-gradient(135deg, var(--primary), var(--plight));
  color: #fff; display: flex; align-items: center; justify-content: center;
  box-shadow: 0 12px 30px rgba(2, 132, 199, 0.28);
  margin-bottom: 16px; position: relative;
}
.login-logo svg { width: 34px; height: 34px; stroke-width: 2.2; }
.login-header h2 {
  font-size: 21px; font-weight: 800; color: var(--text);
  letter-spacing: -0.4px; margin: 0 0 6px;
}
.login-header p {
  color: var(--muted); font-size: 12.5px; margin: 0; line-height: 1.45;
}

.login-form {
  display: flex; flex-direction: column; gap: 13px;
  width: 100%;
}
.input-field {
  position: relative; display: flex; align-items: center;
  background: var(--card); border: 1px solid var(--line);
  border-radius: 14px; height: 48px; padding: 0 14px;
  transition: all .18s ease;
}
.input-field:focus-within {
  border-color: var(--primary);
  box-shadow: 0 0 0 3.5px rgba(2, 132, 199, 0.16);
}
.input-field .input-ico {
  width: 19px; height: 19px; color: var(--dim);
  display: flex; align-items: center; justify-content: center;
  margin-right: 11px; flex-shrink: 0;
}
.input-field .input-ico svg { width: 18px; height: 18px; }
.input-field input {
  flex: 1; min-width: 0; border: none; background: transparent;
  color: var(--text); font-size: 16px; font-family: inherit;
  outline: none; padding: 0; -webkit-text-size-adjust: 100%;
}
.input-field input::placeholder { color: var(--dim); font-size: 14px; }
.pwd-toggle {
  background: none; border: 0; color: var(--dim); cursor: pointer;
  padding: 6px; display: flex; align-items: center; justify-content: center;
  border-radius: 8px; transition: color .15s; touch-action: manipulation;
}
.pwd-toggle:hover { color: var(--text); }
.pwd-toggle svg { width: 18px; height: 18px; }


.login-btn {
  background: var(--primary);
  color: #fff; border: 0; border-radius: 14px; height: 48px;
  font-size: 15px; font-weight: 700; cursor: pointer;
  display: flex; align-items: center; justify-content: center; gap: 8px;
  box-shadow: 0 4px 16px rgba(2, 132, 199, 0.32);
  transition: all .15s ease; width: 100%;
  margin-top: 4px;
  white-space: nowrap; letter-spacing: -0.2px;
  touch-action: manipulation;
}
.login-btn:hover {
  opacity: .94; transform: translateY(-1px);
  box-shadow: 0 6px 20px rgba(2, 132, 199, 0.4);
}
.login-btn:active { transform: translateY(0); }
.login-btn.loading {
  opacity: .88; pointer-events: none; cursor: wait;
}
.login-spinner {
  display: inline-block;
  width: 18px; height: 18px;
  min-width: 18px; min-height: 18px;
  color: #fff;
  vertical-align: middle;
  -webkit-animation: spin .75s linear infinite;
  animation: spin .75s linear infinite;
  flex-shrink: 0;
}

.login-footer {
  display: flex; align-items: center; justify-content: center; gap: 5px;
  font-size: 11.5px; color: var(--dim);
  padding: 10px 0 2px;
  flex-shrink: 0;
}
.empty { text-align: center; color: var(--muted); font-size: 12px; padding: 22px 0; }

/* ── Production shell ──
   V4 above is kept 1:1. On a real phone the decorative phone frame, intro column and fake
   status bar disappear and the screen fills the viewport; on desktop the V4 frame stays. */
.agent-app .wrap { justify-content: center; }
@media (max-width: 520px) {
  body.agent-app { padding: 0; background: var(--screenbg); }
  .agent-app .wrap { display: block; max-width: none; }
  .agent-app .phone { width: 100%; max-width: none; padding: 0; border: 0; border-radius: 0; box-shadow: none; background: var(--screenbg); }
  .agent-app .screen { border-radius: 0; height: 100vh; height: 100dvh; }
  .agent-app .statusbar { display: none; }
  .agent-app .loginwrap {
    padding-top: calc(20px + env(safe-area-inset-top, 0px));
    padding-bottom: calc(18px + env(safe-area-inset-bottom, 0px));
  }
  .agent-app .pad {
    padding-top: calc(10px + env(safe-area-inset-top, 0px));
    padding-bottom: calc(26px + env(safe-area-inset-bottom, 0px));
  }
  .agent-app input, .agent-app select, .agent-app textarea {
    font-size: 16px !important; /* Triệt tiêu hoàn toàn hiện tượng tự động zoom của iOS Safari */
  }
  .agent-app .search-input {
    font-size: 16px !important;
  }
  .agent-app .search-input::placeholder {
    font-size: 13px;
  }
}
.pwd-form { display: flex; flex-direction: column; gap: 10px; margin-top: 4px; }
.pwd-form .input-field { height: 44px; }
.pwd-form .login-btn { height: 44px; font-size: 13.5px; }
