:root { --bg:#11111b; --card:#1e1e2e; --card2:#181825; --line:#313244; --txt:#cdd6f4; --dim:#9399b2; --acc:#cba6f7; --ok:#a6e3a1; --warn:#f9e2af; --bad:#f38ba8; --blue:#89b4fa; }
* { box-sizing: border-box; }
html, body { margin:0; background:var(--bg); color:var(--txt); font:15px/1.45 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif; -webkit-text-size-adjust:100%; }
main { max-width: 980px; margin: 0 auto; padding: 12px 12px 80px; padding-left: max(12px, env(safe-area-inset-left)); padding-right: max(12px, env(safe-area-inset-right)); }
h1 { font-size: 18px; margin: 0; }
h2 { font-size: 15px; margin: 0 0 10px; color: var(--acc); }
button, input, select { font: inherit; color: inherit; }
button { background: var(--line); border: 0; border-radius: 10px; padding: 10px 14px; min-height: 42px; cursor: pointer; }
button:hover { filter: brightness(1.15); }
button:disabled { opacity: .5; cursor: default; }
button.primary { background: var(--acc); color: #1e1e2e; font-weight: 700; }
button.danger { background: #45283a; color: var(--bad); }
button.ghost { background: transparent; border: 1px solid var(--line); }
input, select { width: 100%; font-size: 16px; background: var(--card2); border: 1px solid var(--line); border-radius: 10px; padding: 10px 12px; min-height: 42px; }   /* 16px: iPhone không tự phóng to khi chạm vào ô nhập */
input:focus, select:focus { outline: 2px solid var(--acc); outline-offset: 0; }
input[type="checkbox"], input[type="radio"] { width: 18px; height: 18px; min-height: 0; padding: 0; flex: 0 0 18px; accent-color: var(--acc); cursor: pointer; }
label { display:block; font-size: 12px; color: var(--dim); margin: 8px 0 4px; }
.card { background: var(--card); border: 1px solid var(--line); border-radius: 14px; padding: 14px; margin: 12px 0; }
.row { display:flex; gap:8px; align-items:center; flex-wrap:wrap; }
.row > * { flex: 0 0 auto; }
.grow { flex: 1 1 140px !important; min-width: 0; }
.top { display:flex; align-items:center; justify-content:space-between; gap:8px; padding: 6px 0 4px; }
.chip { display:inline-block; padding:2px 9px; border-radius:99px; font-size:12px; background:var(--line); color:var(--dim); white-space:nowrap; }
.chip.ok { background:#23382b; color:var(--ok); } .chip.warn { background:#3d3622; color:var(--warn); } .chip.bad { background:#45283a; color:var(--bad); } .chip.blue { background:#22304a; color:var(--blue); }
.tabs { display:flex; gap:6px; margin: 8px 0; }
.tabs button { flex:1; background:var(--card); }
.tabs button.on { background:var(--acc); color:#1e1e2e; font-weight:700; }
.key { font: 13px ui-monospace, SFMono-Regular, Menlo, monospace; letter-spacing:.3px; word-break: break-all; }
.item { border-top:1px solid var(--line); padding: 11px 2px; display:flex; gap:10px; align-items:flex-start; justify-content:space-between; cursor:pointer; }
.item:first-child { border-top:0; }
.item .meta { color:var(--dim); font-size:12.5px; margin-top:3px; }
.dim { color: var(--dim); } .small { font-size:12.5px; }
.err { color: var(--bad); margin: 8px 0 0; font-size: 13.5px; }
.kv { display:grid; grid-template-columns: 110px 1fr; gap:4px 10px; font-size:13.5px; }
.kv > :nth-child(odd) { color: var(--dim); }
.ev { font: 12px ui-monospace, Menlo, monospace; border-top:1px dashed var(--line); padding:5px 0; word-break: break-word; }
.big-key { background:var(--card2); border:1px dashed var(--acc); border-radius:12px; padding:14px; text-align:center; font: 17px ui-monospace, Menlo, monospace; word-break: break-all; margin:10px 0; user-select: all; }
#toast { position: fixed; left: 50%; bottom: calc(18px + env(safe-area-inset-bottom)); transform: translateX(-50%) translateY(20px); background:#313244; color:var(--txt); padding:10px 16px; border-radius:99px; opacity:0; pointer-events:none; transition: .2s; max-width: 92vw; z-index: 50; }
#toast.show { opacity:1; transform: translateX(-50%) translateY(0); }
#toast.bad { background:#45283a; color:var(--bad); }
.login { max-width: 360px; margin: 14vh auto 0; }
@media (min-width: 720px) { .kv { grid-template-columns: 150px 1fr; } }

.icon-btn { padding: 6px 9px; min-height: 34px; min-width: 34px; font-size: 15px; line-height: 1; }
.ghost .lbl { font-size: 12.5px; margin-left: 5px; line-height: 1; vertical-align: 1px; }   /* chữ ngắn cạnh biểu tượng */
.item .icon-btn { padding: 6px 8px; }
@media (max-width: 420px) { .item > div:last-child .row { gap: 6px; } .item .icon-btn { min-height: 36px; padding: 6px 7px; } .ghost .lbl { font-size: 12px; margin-left: 4px; } .sep { padding: 0; } }
.list-scroll { max-height: 420px; overflow-y: auto; -webkit-overflow-scrolling: touch; }
.list-scroll .item:first-child { border-top: 0; }
summary.card-summary { cursor: pointer; font-size: 15px; color: var(--acc); list-style: none; display: flex; align-items: center; gap: 6px; user-select: none; }
summary.card-summary::-webkit-details-marker { display: none; }
summary.card-summary::before { content: '▸'; font-size: 12px; transition: transform .15s; display: inline-block; }
details[open] > summary.card-summary::before { transform: rotate(90deg); }
details.card { padding: 0; }
details.card > summary.card-summary { padding: 14px; margin: 0; }
details.card > .details-body { padding: 0 14px 14px; }
.modal-backdrop { position: fixed; inset: 0; background: rgba(0,0,0,.55); display: flex; align-items: center; justify-content: center; padding: 12px; padding-left: max(12px, env(safe-area-inset-left)); padding-right: max(12px, env(safe-area-inset-right)); padding-bottom: max(12px, env(safe-area-inset-bottom)); overflow: hidden; z-index: 40; }
.modal-backdrop .card { max-width: 560px; width: 100%; margin: 0; max-height: calc(100vh - 24px); max-height: calc(100dvh - 24px); overflow-y: auto; overscroll-behavior: contain; -webkit-overflow-scrolling: touch; }
body.modal-open { overflow: hidden; }
.modal-head { position: sticky; top: -14px; z-index: 2; background: var(--card); margin: -14px -14px 6px; padding: 14px 14px 10px; border-bottom: 1px solid var(--line); }
.modal-backdrop .kv > div { overflow-wrap: anywhere; min-width: 0; }
.extend-row { flex-wrap: nowrap; margin-top: 4px; }
.extend-row input { flex: 0 0 110px; width: 110px; }
.extend-row button { flex: 1 1 auto; }
.actions-row > button { flex: 1 1 150px; }
.sep { color: var(--dim); opacity: .7; padding: 0 2px; align-self: center; font-size: 18px; line-height: 1; }
.vline { font-weight: 600; }
.vstat { font-weight: 500; color: var(--dim); } .vstat.ok { color: var(--ok); } .vstat.warn { color: var(--warn); } .vstat.blue { color: var(--blue); }
@media (max-width: 420px) { .kv { grid-template-columns: 96px 1fr; } .item { flex-wrap: wrap; } .item > div:last-child { flex: 1 1 100%; text-align: left !important; } .item > div:last-child .row { justify-content: flex-start !important; } }
@media (max-width: 420px) { .create-row .grow { flex: 1 1 100% !important; } .filter-row > div:first-child { flex: 1 1 100% !important; } }
.extend-row select { flex: 1 1 140px; width: auto; min-width: 0; }
label.opt { display: flex; align-items: center; gap: 8px; flex: 1 1 140px; margin: 0; padding: 10px 12px; font-size: 14px; color: var(--txt); background: var(--card2); border: 1px solid var(--line); border-radius: 10px; cursor: pointer; }
label.opt:has(input:checked) { border-color: var(--acc); }
.opt-row { margin: 10px 0 4px; }
.confirm-list { margin: 4px 0 10px; padding-left: 20px; font-size: 14px; line-height: 1.5; }
.confirm-list li { margin: 4px 0; overflow-wrap: anywhere; }
