/* Shopee68 Cloud Phone — visual identity of the Shopee68 Changer desktop app (UI/ThemeColors.cs "dark" profile,
   Shopee orange accent, teal/mint logo), laid out web-first: phone-width first, bottom tab bar on small screens. */
:root {
  --bg: #111720; --nav: #151d28; --panel: #1a222e; --card: #1c2632; --control: #202b38; --line: #354356;
  --hover: #2e3a4b; --text: #ecf1f8; --muted: #9aa8bc; --disabled: #6a7788;
  --accent: #ee4d2d; --accent-soft: color-mix(in srgb, var(--accent) 16%, var(--card));
  --brand: #123c3a; --mint: #43dbb1; --progress: #389fb0; --track: #314150;
  --ok: #2ac984; --warn: #e3ad4c; --bad: #f46868;
  --radius: 12px; --radius-sm: 8px;
  --shadow: 0 10px 30px rgb(0 0 0 / 28%);
  --font: "Segoe UI", system-ui, -apple-system, Roboto, "Helvetica Neue", sans-serif;
  --tabbar: 64px;
  color-scheme: dark;
}
@media (prefers-color-scheme: light) {
  :root { /* Changer "shopee" profile */
    --bg: #f7f8f9; --nav: #fff; --panel: #fff; --card: #fff; --control: #fff4ef; --line: #dce3e4; --hover: #ffece4;
    --text: #202b30; --muted: #647278; --disabled: #9ba7aa; --track: #dee7e7; --progress: #ee4d2d;
    --ok: #147b6e; --warn: #9a6a10; --bad: #bd3c3c; --shadow: 0 8px 24px rgb(32 43 48 / 10%);
    color-scheme: light;
  }
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; font: 15px/1.45 var(--font); background: var(--bg); color: var(--text); min-height: 100vh; }
.hidden { display: none !important; }
.muted { color: var(--muted); }
.small { font-size: 13px; }
h1, h2, h3 { margin: 0; font-weight: 600; letter-spacing: -.01em; }
h2 { font-size: 20px; } h3 { font-size: 15px; }
a { color: var(--accent); }

/* ---- controls ---- */
button, input, select, textarea { font: inherit; color: inherit; }
input, select, textarea {
  width: 100%; min-height: 42px; padding: 9px 12px; border: 1px solid var(--line); border-radius: var(--radius-sm);
  background: var(--control); color: var(--text);
}
/* Phones zoom the page into a field smaller than 16px and stay zoomed (seen after signing in). */
@media (max-width: 900px), (pointer: coarse) { input, select, textarea { font-size: max(16px, 1em); } }
input:focus-visible, select:focus-visible, textarea:focus-visible, button:focus-visible, [tabindex]:focus-visible {
  outline: 2px solid var(--accent); outline-offset: 2px;
}
label { display: grid; gap: 6px; font-size: 13px; font-weight: 600; color: var(--muted); }
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-height: 40px; padding: 8px 14px;
  border: 1px solid var(--line); border-radius: var(--radius-sm); background: var(--control); cursor: pointer;
  font-weight: 600; transition: background .15s, border-color .15s, transform .1s; white-space: nowrap;
}
.btn:hover { background: var(--hover); border-color: color-mix(in srgb, var(--accent) 55%, var(--line)); }
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: .45; cursor: not-allowed; transform: none; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn.primary:hover { background: color-mix(in srgb, var(--accent) 88%, #fff); }
.btn.ghost { background: transparent; }
.btn.danger { color: var(--bad); border-color: color-mix(in srgb, var(--bad) 45%, var(--line)); background: transparent; }
.btn.block { width: 100%; min-height: 48px; font-size: 16px; white-space: normal; } /* a long label wraps instead of widening the login card */
.btn.link { border: 0; background: none; padding: 0; min-height: 0; color: var(--accent); font-weight: 600; }
.icon { width: 18px; height: 18px; flex: none; }

/* pill badge (Controls/PillBadge.cs): tinted fill, soft border, accent text */
.pill {
  --c: var(--muted);
  display: inline-flex; align-items: center; gap: 6px; padding: 2px 10px; border-radius: 999px; font-size: 12px; font-weight: 700;
  color: var(--c); background: color-mix(in srgb, var(--c) 16%, transparent); border: 1px solid color-mix(in srgb, var(--c) 45%, transparent);
  white-space: nowrap;
}
.pill.ok { --c: var(--ok); } .pill.warn { --c: var(--warn); } .pill.bad { --c: var(--bad); } .pill.accent { --c: var(--accent); }
.pill.info { --c: var(--progress); }
.pill .dot { width: 7px; height: 7px; border-radius: 50%; background: currentColor; }
.chip {
  min-height: 34px; padding: 6px 14px; border-radius: 999px; border: 1px solid var(--line); background: var(--card);
  color: var(--muted); font-weight: 600; cursor: pointer; white-space: nowrap;
}
.chip[aria-pressed="true"] { color: var(--text); border-color: var(--accent); background: var(--accent-soft); }

/* ---- shell ---- */
.topbar {
  position: sticky; top: 0; z-index: 5; display: flex; align-items: center; gap: 12px; padding: 10px 16px;
  background: color-mix(in srgb, var(--nav) 92%, transparent); backdrop-filter: blur(10px); border-bottom: 1px solid var(--line);
}
.brand { display: flex; align-items: center; gap: 10px; margin-right: auto; min-width: 0; }
.brand img { width: 32px; height: 32px; }
.brand > div { min-width: 0; }
.brand b { display: block; font-size: 16px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.brand img, .topbar .icon-btn, .wallet-chip, .topbar .nav { flex: none; }
.brand span { display: block; font-size: 12px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.wallet-chip {
  display: inline-flex; align-items: center; gap: 8px; padding: 6px 12px; border-radius: 999px; border: 1px solid var(--line);
  background: var(--card); font-weight: 700; cursor: pointer; white-space: nowrap;
}
.wallet-chip small { color: var(--muted); font-weight: 600; }
.nav { display: flex; gap: 4px; }
.nav button {
  display: flex; align-items: center; gap: 8px; border: 0; background: none; color: var(--muted); padding: 8px 12px; border-radius: var(--radius-sm);
  font-weight: 600; cursor: pointer; position: relative; white-space: nowrap;
}
.nav button[aria-selected="true"] { color: var(--text); background: var(--accent-soft); }
.nav button[aria-selected="true"] .icon { color: var(--accent); }
.nav .count { min-width: 18px; padding: 0 5px; border-radius: 9px; background: var(--accent); color: #fff; font-size: 11px; line-height: 18px; text-align: center; }
.page { width: min(1180px, 100%); margin: 0 auto; padding: 20px 16px 32px; display: grid; gap: 18px; }
.page-head { display: flex; align-items: end; gap: 12px; flex-wrap: wrap; }
.page-head h2 { margin-right: auto; }
.note { margin: 0; padding: 10px 12px; border-radius: var(--radius-sm); background: var(--panel); border: 1px solid var(--line); color: var(--muted); font-size: 13px; }
.filters { display: flex; gap: 8px; overflow-x: auto; scrollbar-width: none; padding-bottom: 2px; }
.filters::-webkit-scrollbar { display: none; }
.empty { padding: 36px 16px; text-align: center; color: var(--muted); border: 1px dashed var(--line); border-radius: var(--radius); }
.error { color: var(--bad); min-height: 1em; margin: 0; }
.okmsg { color: var(--ok); min-height: 1em; margin: 0; }

@media (max-width: 760px) {
  body { padding-bottom: calc(var(--tabbar) + env(safe-area-inset-bottom)); }
  .topbar { backdrop-filter: none; background: var(--nav); } /* a filter would make it the fixed tab bar's containing block */
  .topbar .nav {
    position: fixed; inset: auto 0 0 0; z-index: 6; height: calc(var(--tabbar) + env(safe-area-inset-bottom));
    padding: 6px 6px env(safe-area-inset-bottom); background: var(--nav); border-top: 1px solid var(--line); justify-content: space-around;
  }
  .nav button { flex: 1 1 auto; min-width: 40px; flex-direction: column; align-items: center; gap: 2px; font-size: 11px; padding: 6px 0; }
  .nav button[aria-selected="true"] { background: none; }
  .nav .count { position: absolute; top: 2px; left: calc(50% + 6px); }
  .brand span { display: none; }
  .page { padding: 16px 12px 24px; gap: 14px; }
  h2 { font-size: 18px; }
}

/* tablets, landscape phones, zoomed desktops: six tabs do not fit beside the name in one row, so icon over label */
@media (min-width: 761px) and (max-width: 1200px) {
  .as-renter .brand > div { display: none; }
  .as-renter .nav { gap: 2px; }
  .as-renter .nav button { flex-direction: column; justify-content: center; min-width: 48px; gap: 2px; font-size: 12px; padding: 5px 9px; }
  .as-renter .nav .count { position: absolute; top: 0; left: calc(50% + 6px); }
  .as-renter .topbar { gap: 8px; padding-block: 6px; }
}
@media (max-width: 380px) { .nav button { font-size: 10.5px; } }

/* ---- catalog: one card per model (Controls/DeviceCard.cs look) ---- */
.models { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 14px; }
.model {
  position: relative; display: grid; grid-template-columns: 76px 1fr; gap: 14px; padding: 14px; border-radius: var(--radius);
  background: var(--card); border: 1px solid var(--line); transition: border-color .15s, transform .15s, box-shadow .15s;
}
.model:hover { border-color: color-mix(in srgb, var(--accent) 60%, var(--line)); box-shadow: var(--shadow); transform: translateY(-2px); }
.model.soldout { opacity: .62; }
.model.soldout:hover { transform: none; box-shadow: none; border-color: var(--line); }
.model .art { display: grid; place-items: center; border-radius: 10px; background: radial-gradient(120% 90% at 50% 10%, color-mix(in srgb, var(--mint) 18%, var(--panel)), var(--panel)); }
.model .art svg { width: 52px; height: auto; filter: drop-shadow(0 6px 10px rgb(0 0 0 / 35%)); }
.model .body { display: grid; gap: 6px; min-width: 0; align-content: start; }
.model .brandline { font-size: 12px; color: var(--muted); font-weight: 600; text-transform: uppercase; letter-spacing: .06em; }
.model .name { font-size: 17px; font-weight: 700; line-height: 1.25; }
.model .code { font-size: 12px; color: var(--muted); }
.model .stock { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.model .foot { grid-column: 1 / -1; display: flex; align-items: center; gap: 10px; padding-top: 10px; border-top: 1px solid var(--line); }
.price { margin-right: auto; display: grid; line-height: 1.2; }
.price small { color: var(--muted); font-size: 12px; }
.price b { font-size: 18px; color: var(--accent); }
.price b span { font-size: 12px; color: var(--muted); font-weight: 600; }

/* ---- sheet (bottom sheet on phones, dialog on desktop) ---- */
.sheet-backdrop { position: fixed; inset: 0; z-index: 20; background: rgb(0 0 0 / 55%); display: grid; place-items: center; padding: 16px; animation: fade .15s ease-out; }
.sheet {
  width: min(520px, 100%); max-height: min(88vh, 760px); overflow: auto; background: var(--panel); border: 1px solid var(--line);
  border-radius: 16px; box-shadow: var(--shadow); display: grid; gap: 14px; padding: 18px; animation: rise .2s cubic-bezier(.16, 1, .3, 1);
}
.sheet-head { display: grid; grid-template-columns: 56px 1fr auto; gap: 12px; align-items: center; }
.sheet-head .art svg { width: 40px; height: auto; }
.sheet-head .close { width: 36px; height: 36px; padding: 0; border-radius: 50%; }
@media (max-width: 760px) {
  .sheet-backdrop { place-items: end stretch; padding: 0; }
  .sheet { width: 100%; border-radius: 18px 18px 0 0; border-bottom: 0; padding: 16px 16px calc(16px + env(safe-area-inset-bottom)); max-height: 90vh; }
  .sheet::before { content: ""; justify-self: center; width: 40px; height: 4px; border-radius: 2px; background: var(--line); margin: -6px 0 2px; }
}
@keyframes fade { from { opacity: 0; } }
@keyframes rise { from { transform: translateY(24px); opacity: 0; } }
.group-title { font-size: 12px; font-weight: 700; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); }
.plans { display: grid; grid-template-columns: minmax(0, 1fr); gap: 8px; }
.plan {
  display: grid; grid-template-columns: auto minmax(0, 1fr) auto; gap: 4px 12px; align-items: center; padding: 12px; border-radius: 10px;
  border: 1px solid var(--line); background: var(--card); cursor: pointer;
}
.plan:hover { border-color: color-mix(in srgb, var(--accent) 55%, var(--line)); }
.plan input { width: 18px; height: 18px; min-height: 0; accent-color: var(--accent); grid-row: span 2; margin: 0; }
.plan:has(input:checked) { border-color: var(--accent); background: var(--accent-soft); }
.plan .pname { font-weight: 700; color: var(--text); font-size: 15px; }
.plan .pprice { font-weight: 700; color: var(--accent); font-size: 16px; text-align: right; }
.plan .pmeta { grid-column: 2 / -1; display: flex; gap: 6px; flex-wrap: wrap; font-weight: 400; }
.summary { display: grid; gap: 6px; padding: 12px; border-radius: 10px; background: var(--card); border: 1px solid var(--line); }
.summary div { display: flex; justify-content: space-between; gap: 12px; }
.summary .total { font-weight: 700; font-size: 16px; padding-top: 6px; border-top: 1px solid var(--line); }
.summary .neg { color: var(--bad); }

/* ---- my phones ---- */
.rentals { display: grid; grid-template-columns: repeat(auto-fill, minmax(320px, 1fr)); gap: 14px; }
.rental { display: grid; gap: 12px; padding: 14px; border-radius: var(--radius); background: var(--card); border: 1px solid var(--line); }
.rental.selected { border-color: var(--accent); }
.rental .top { display: grid; grid-template-columns: 44px 1fr auto; gap: 12px; align-items: center; }
.rental .top svg { width: 34px; height: auto; }
.rental .title { font-weight: 700; font-size: 16px; line-height: 1.25; }
.rental .sub { font-size: 12px; color: var(--muted); overflow-wrap: anywhere; }
.timer { display: grid; gap: 6px; }
.timer .row { display: flex; justify-content: space-between; align-items: baseline; gap: 8px; }
.timer b { font-size: 22px; font-variant-numeric: tabular-nums; letter-spacing: .01em; }
.timer.low b { color: var(--warn); }
.bar { height: 6px; border-radius: 3px; background: var(--track); overflow: hidden; }
.bar i { display: block; height: 100%; width: var(--p, 0%); background: var(--progress); border-radius: inherit; transition: width .5s; }
.timer.low .bar i { background: var(--warn); }
.rental .actions { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.rental .actions .wide { grid-column: 1 / -1; }
.tools { display: grid; gap: 10px; padding-top: 12px; border-top: 1px solid var(--line); }
.tools form { display: flex; gap: 8px; }
.tools form > :first-child { flex: 1; min-width: 0; }
.output {
  margin: 0; padding: 10px 12px; border-radius: var(--radius-sm); background: var(--bg); border: 1px solid var(--line);
  font: 12px/1.45 ui-monospace, Consolas, monospace; white-space: pre-wrap; word-break: break-word; max-height: 240px; overflow: auto;
}
.output:empty { display: none; }
.history { display: grid; gap: 0; border: 1px solid var(--line); border-radius: var(--radius); background: var(--card); overflow: hidden; }
.history .item { display: grid; grid-template-columns: 1fr auto; gap: 2px 12px; padding: 12px 14px; border-top: 1px solid var(--line); }
.history .item:first-child { border-top: 0; }
.history .item .what { font-weight: 600; }
.history .item .when { font-size: 12px; color: var(--muted); }
.history .item .amount { grid-row: span 2; align-self: center; font-weight: 700; font-variant-numeric: tabular-nums; }
.amount.plus { color: var(--ok); } .amount.minus { color: var(--text); }

/* ---- wallet ---- */
.wallet-grid { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 14px; align-items: start; }
@media (max-width: 860px) { .wallet-grid { grid-template-columns: 1fr; } }
.balance-card {
  display: grid; gap: 14px; padding: 18px; border-radius: 16px; color: #fff; position: relative; overflow: hidden;
  background: linear-gradient(135deg, #123c3a 0%, #17504c 55%, #1d6b5f 100%); border: 1px solid #1f5a55;
}
.balance-card::after {
  content: ""; position: absolute; right: -40px; top: -40px; width: 180px; height: 180px; border-radius: 50%;
  background: radial-gradient(circle, rgb(67 219 177 / 35%), transparent 70%);
}
.balance-card small { color: rgb(255 255 255 / 75%); font-weight: 600; }
.balance-card .big { font-size: 32px; font-weight: 700; font-variant-numeric: tabular-nums; line-height: 1.1; }
.card { display: grid; gap: 12px; padding: 16px; border-radius: var(--radius); background: var(--card); border: 1px solid var(--line); }
.amounts { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; }
.amounts .chip { padding: 6px 4px; }
.qrbox { display: grid; grid-template-columns: 180px 1fr; gap: 14px; align-items: start; }
@media (max-width: 480px) { .qrbox { grid-template-columns: 1fr; justify-items: center; } }
.qrbox img { width: 180px; height: 180px; border-radius: 10px; background: #fff; padding: 6px; }
.kv { display: grid; gap: 6px; width: 100%; font-size: 14px; }
.kv div { display: flex; justify-content: space-between; gap: 10px; border-bottom: 1px dashed var(--line); padding-bottom: 6px; }
.kv dt { color: var(--muted); } .kv dd { margin: 0; font-weight: 700; text-align: right; overflow-wrap: anywhere; }
.kv .code { color: var(--accent); font-family: ui-monospace, Consolas, monospace; }

/* ---- login ---- */
.login { min-height: 100vh; display: grid; place-items: center; padding: 20px 16px; background:
  radial-gradient(80% 60% at 50% 0%, color-mix(in srgb, var(--brand) 70%, transparent), transparent 70%), var(--bg); }
.login-card { width: min(400px, 100%); display: grid; gap: 16px; padding: 24px; border-radius: 18px; background: var(--panel); border: 1px solid var(--line); box-shadow: var(--shadow); }
.login-brand { display: grid; justify-items: center; gap: 8px; text-align: center; }
.login-brand img { width: 56px; height: 56px; }
.login-brand h1 { font-size: 22px; }
.seg { display: grid; grid-template-columns: 1fr 1fr; padding: 4px; border-radius: 10px; background: var(--bg); border: 1px solid var(--line); }
.seg button { border: 0; background: none; padding: 8px; border-radius: 7px; color: var(--muted); font-weight: 600; cursor: pointer; }
.seg button[aria-selected="true"] { background: var(--card); color: var(--text); box-shadow: 0 1px 3px rgb(0 0 0 / 25%); }
.stack { display: grid; gap: 12px; }

/* ---- page details added for the live page ---- */
.icon-btn { width: 40px; padding: 0; }
.quota-card .row { display: flex; justify-content: space-between; gap: 12px; align-items: baseline; }
.quota-card .bar.full i { background: var(--bad); }
.change-left { margin: 0; font-size: 13px; color: var(--muted); }
.change-left.none { color: var(--bad); }
.small-btn { min-height: 32px; padding: 4px 10px; font-size: 13px; }
.mono { font-family: ui-monospace, Consolas, monospace; font-size: 13px; overflow-wrap: anywhere; }
.filter-sep { flex: none; width: 1px; margin: 4px 2px; background: var(--line); }
.badges { display: grid; justify-items: end; gap: 4px; }
.check { display: flex; align-items: center; gap: 8px; font-weight: 500; color: var(--text); font-size: 14px; }
.check input { width: 18px; height: 18px; min-height: 0; accent-color: var(--accent); margin: 0; }
.checks { display: flex; flex-wrap: wrap; gap: 8px 18px; }
.grid2 { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 10px; }
.grid3 { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: 10px; }
.actions-row { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
select.compact { width: auto; min-height: 36px; padding: 6px 10px; }
.panel { display: grid; gap: 10px; padding-top: 14px; border-top: 1px solid var(--line); }
details > summary { cursor: pointer; list-style: none; display: flex; flex-wrap: wrap; gap: 6px; align-items: baseline; }
details > summary::-webkit-details-marker { display: none; }
details > summary::before { content: "▸"; color: var(--muted); transition: transform .15s; display: inline-block; }
details[open] > summary::before { transform: rotate(90deg); }
details[open] > summary { margin-bottom: 4px; }
.call { display: grid; grid-template-columns: 96px 1fr; gap: 8px; margin-top: 10px; }
.call textarea, .call button { grid-column: 1 / -1; }
.history .item.with-action { grid-template-columns: 1fr auto auto; }
.history .item.with-action .when { grid-column: 1 / 2; }
.history .item.with-action .btn { grid-row: 1 / span 2; grid-column: 3; align-self: center; }
.history .item.muted { display: block; color: var(--muted); }
.summary .total.short span:last-child { color: var(--bad); }
.summary .neg-row span:last-child { color: var(--bad); }
body.sheet-open, body.viewing { overflow: hidden; }
body.as-owner { padding-bottom: 0; }
.rental .output { margin-top: -2px; }
.model .name { margin: 0; }

/* tables (owner) */
.table-wrap { overflow-x: auto; margin: 0 -4px; }
table { width: 100%; border-collapse: collapse; font-size: 14px; }
th { text-align: left; font-size: 12px; font-weight: 700; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); padding: 8px 6px; border-bottom: 1px solid var(--line); }
td { text-align: left; padding: 10px 6px; border-bottom: 1px solid var(--line); vertical-align: middle; }
tbody tr:last-child td { border-bottom: 0; }
#phones tbody tr { cursor: pointer; }
#phones tbody tr:hover, #phones tbody tr.active { background: var(--accent-soft); }
#phones tbody tr.active td:first-child { box-shadow: inset 3px 0 0 var(--accent); }
tr.muted td { color: var(--muted); }
.owner-grid { display: grid; grid-template-columns: minmax(280px, 400px) minmax(0, 1fr); gap: 14px; align-items: start; }
@media (max-width: 860px) { .owner-grid { grid-template-columns: 1fr; } }
#ownerView .output { min-height: 90px; }
#ownerView .output:empty { display: block; }
#ownerView .output:empty::before { content: "Kết quả lệnh hiện ở đây."; color: var(--muted); }

/* toast */
.toast {
  position: fixed; left: 50%; bottom: 20px; z-index: 40; transform: translateX(-50%); width: max-content; max-width: min(560px, calc(100vw - 24px));
  padding: 12px 16px; border-radius: 12px; background: var(--panel); border: 1px solid color-mix(in srgb, var(--ok) 55%, var(--line));
  box-shadow: var(--shadow); font-weight: 600; animation: rise .2s cubic-bezier(.16, 1, .3, 1);
}
.toast.bad { border-color: color-mix(in srgb, var(--bad) 60%, var(--line)); color: var(--bad); }
@media (max-width: 420px) { .brand b { display: none; } }
@media (max-width: 760px) { body.as-renter .toast { bottom: calc(var(--tabbar) + 12px + env(safe-area-inset-bottom)); } }

p.small, p.muted { margin: 0; }
td.mono .muted { font-family: var(--font); font-size: 12px; }

/* ---- Đổi máy options (renter) ---- */
.change-panel { border: 1px solid var(--line); border-radius: var(--radius-sm); padding: 10px 12px; background: var(--bg); }
.change-panel > summary { cursor: pointer; font-weight: 600; list-style-position: inside; }
.change-panel[open] > summary { margin-bottom: 8px; }
.change-panel > p { font-size: 13px; margin: 0 0 10px; }
.change-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
.change-grid .field { display: grid; gap: 4px; font-size: 13px; color: var(--muted); }
.change-grid .field:first-child, .change-grid .checks, .change-grid .wide { grid-column: 1 / -1; }
@media (max-width: 520px) { .change-grid { grid-template-columns: 1fr; } }

/* ---- "Máy của tôi": compact Change tab (grid + selected phone's actions + Nhật ký) ---- */
.change-board { display: grid; grid-template-columns: minmax(0, 1fr) 340px; grid-template-areas: "grid side" "log side"; gap: 12px 14px; align-items: start; }
.change-board .grid-wrap { grid-area: grid; min-width: 0; }
.change-board .log-card { grid-area: log; min-width: 0; }
.change-board .board-side { grid-area: side; }
.grid-wrap { margin: 0; border: 1px solid var(--line); border-radius: var(--radius); background: var(--card); }
.phone-grid th { background: var(--panel); position: sticky; top: 0; }
.phone-grid th:first-child, .phone-grid td:first-child { padding-left: 12px; }
.phone-grid td { padding: 8px 6px; }
.phone-grid tbody tr { cursor: pointer; transition: background .12s; }
.phone-grid tbody tr:hover { background: var(--hover); }
.phone-grid tbody tr[aria-selected="true"] { background: var(--accent-soft); }
.phone-grid tbody tr[aria-selected="true"] td:first-child { box-shadow: inset 3px 0 0 var(--accent); }
.phone-grid tbody tr:focus-visible { outline: 2px solid var(--accent); outline-offset: -2px; }
.phone-grid .stt { width: 44px; color: var(--muted); font-variant-numeric: tabular-nums; }
.phone-grid td.name { display: flex; align-items: center; gap: 10px; min-width: 180px; }
.phone-grid td.name b { display: block; font-size: 14px; }
.phone-grid td.name small { display: block; font-size: 12px; }
.mini-art { width: 18px; height: auto; flex: none; }
.phone-grid td.left { white-space: nowrap; font-variant-numeric: tabular-nums; }
.phone-grid td.left.low { color: var(--warn); }
.phone-grid td.progress { color: var(--muted); font-size: 13px; min-width: 160px; }
.phone-grid td.progress.busy { color: var(--progress); font-weight: 600; }
.phone-grid td.progress.bad { color: var(--bad); }
.log-card { display: grid; gap: 6px; }
.log-head { display: flex; align-items: baseline; gap: 10px; }
.log {
  margin: 0; min-height: 96px; max-height: 220px; overflow: auto; padding: 10px 12px; border-radius: var(--radius-sm);
  background: var(--bg); border: 1px solid var(--line); color: var(--muted);
  font: 12px/1.5 ui-monospace, Consolas, monospace; white-space: pre-wrap; word-break: break-word;
}
.board-side { position: sticky; top: 76px; gap: 14px; }
.panel-head { display: grid; grid-template-columns: 30px 1fr; gap: 10px; align-items: center; }
.panel-head svg { width: 26px; height: auto; }
.panel-head b { display: block; font-size: 15px; }
.panel-head small { display: block; font-size: 12px; overflow-wrap: anywhere; }
.action-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.action-grid .span2 { grid-column: 1 / -1; }
.btn.accent { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn.accent:hover { background: color-mix(in srgb, var(--accent) 86%, #fff); }
.btn.big { min-height: 50px; font-size: 16px; font-weight: 800; letter-spacing: .04em; width: 100%; }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.change-block { display: grid; gap: 6px; padding: 10px; border-radius: var(--radius-sm); border: 1px solid color-mix(in srgb, var(--accent) 40%, var(--line)); background: var(--panel); }
.settings-line { display: flex; justify-content: space-between; align-items: baseline; gap: 8px; }
.settings-line .muted { overflow-wrap: anywhere; }
.inline-form { grid-column: 1 / -1; display: flex; gap: 8px; }
.inline-form > :first-child { flex: 1; min-width: 0; }
.misc { display: flex; gap: 8px; }
.misc .btn { flex: 1; }

/* ---- "Cài đặt" ---- */
.settings-grid { display: grid; grid-template-columns: minmax(0, 1.3fr) minmax(0, 1fr); gap: 14px; align-items: start; }
.settings-card h3 { font-size: 16px; }
.settings-card p { margin: 0; }
.field { display: grid; gap: 6px; }
.combo-row { display: grid; grid-template-columns: 1fr auto; gap: 10px; align-items: end; }
.rnd { display: flex; align-items: center; gap: 6px; min-height: 42px; font-weight: 500; color: var(--text); font-size: 13px; }
.rnd input { width: 18px; height: 18px; min-height: 0; margin: 0; accent-color: var(--accent); }
select:disabled { opacity: .55; }
.row-actions { display: flex; gap: 8px; flex-wrap: wrap; }

@media (max-width: 900px) {
  .change-board { grid-template-columns: minmax(0, 1fr); grid-template-areas: "grid" "side" "log"; }
  .board-side { position: static; }
  .settings-grid { grid-template-columns: 1fr; }
}
@media (max-width: 560px) {
  .phone-grid thead { display: none; }
  .phone-grid, .phone-grid tbody { display: block; }
  .phone-grid tbody tr { display: grid; grid-template-columns: 30px 1fr auto; grid-template-areas: "stt name state" "stt progress left"; column-gap: 8px; padding: 8px 10px; border-bottom: 1px solid var(--line); }
  .phone-grid tbody tr:last-child { border-bottom: 0; }
  .phone-grid td { padding: 2px 0; border: 0; }
  .phone-grid td.stt { grid-area: stt; align-self: center; }
  .phone-grid td.name { grid-area: name; min-width: 0; }
  .phone-grid td.state { grid-area: state; justify-self: end; }
  .phone-grid td.progress { grid-area: progress; min-width: 0; }
  .phone-grid td.left { grid-area: left; justify-self: end; }
  .phone-grid tbody tr[aria-selected="true"] td:first-child { box-shadow: none; }
  .phone-grid tbody tr[aria-selected="true"] { box-shadow: inset 3px 0 0 var(--accent); }
}

/* ---- field errors and Backup + Đổi máy (Máy của tôi) ---- */
[aria-invalid="true"] { border-color: var(--bad); box-shadow: 0 0 0 2px color-mix(in srgb, var(--bad) 30%, transparent); }
.field-error { margin: 0; color: var(--bad); font-size: 13px; font-weight: 600; }
.field-error:empty { display: none; }
.backup-block { display: grid; gap: 8px; }
.backup-block p { margin: 0; }
.btn.both { width: 100%; min-height: 46px; border-color: var(--accent); font-weight: 700; white-space: normal; }
#setModelNote { white-space: pre-line; }

/* owner's plans on a phone: one block per plan, the buttons always in view */
#plans td:last-child { white-space: nowrap; }
@media (max-width: 640px) {
  #plans thead { display: none; }
  #plans tr { display: grid; grid-template-columns: 1fr auto; gap: 2px 10px; padding: 10px 0; border-bottom: 1px solid var(--line); }
  #plans td { border: 0; padding: 2px 4px; }
  #plans td:nth-child(1) { font-weight: 700; }
  #plans td:nth-child(2), #plans td:nth-child(3) { text-align: right; }
  #plans td:nth-child(3) { grid-column: 2; grid-row: 2; font-weight: 700; }
  #plans td:nth-child(4) { grid-column: 1; grid-row: 2 / span 2; color: var(--muted); font-size: 13px; }
  #plans td:nth-child(5) { grid-column: 2; grid-row: 3; text-align: right; color: var(--muted); font-size: 13px; }
  #plans td:last-child { grid-column: 1 / -1; }
}
.plan .pmeta { min-width: 0; }
.misc { display: flex; flex-wrap: wrap; gap: 8px; }
.misc .btn { flex: 1 1 auto; }
