.guest-page-link { overflow-wrap: anywhere; word-break: break-word; }
.guest-live-content { white-space: pre-wrap; overflow-wrap: anywhere; }

:root {
  color-scheme: dark;
  --bg: #071019;
  --bg-deep: #040a10;
  --surface: rgba(15, 28, 40, 0.88);
  --surface-solid: #0f1c28;
  --surface-raised: #142433;
  --border: rgba(151, 184, 207, 0.14);
  --border-strong: rgba(70, 214, 255, 0.3);
  --text: #edf8ff;
  --muted: #8da4b5;
  --cyan: #48d8ff;
  --cyan-soft: rgba(72, 216, 255, 0.12);
  --green: #57e6a8;
  --green-soft: rgba(87, 230, 168, 0.12);
  --amber: #ffc566;
  --red: #ff6b7c;
  --red-soft: rgba(255, 107, 124, 0.12);
  --shadow: 0 24px 80px rgba(0, 0, 0, 0.38);
  font-family: Inter, "Segoe UI", "Microsoft YaHei UI", system-ui, sans-serif;
}

* { box-sizing: border-box; }
html { min-width: 320px; background: var(--bg-deep); }
body { min-height: 100vh; margin: 0; background: radial-gradient(circle at 10% 10%, #0d2637 0, transparent 34%), linear-gradient(145deg, var(--bg-deep), var(--bg)); color: var(--text); font-size: 16px; }
button, input, select, textarea { font: inherit; }
button { color: inherit; }
.hidden { display: none !important; }
.muted { color: var(--muted); }
.eyebrow { margin: 0 0 8px; color: var(--cyan); font-size: .75rem; font-weight: 750; letter-spacing: .16em; text-transform: uppercase; }
h1, h2, p { margin-top: 0; }
h1 { margin-bottom: 0; font-size: clamp(1.6rem, 2.4vw, 2.25rem); letter-spacing: -.035em; }
h2 { margin-bottom: 0; font-size: 1.12rem; letter-spacing: -.02em; }

.ambient { position: fixed; z-index: 0; width: 35rem; height: 35rem; border-radius: 50%; filter: blur(110px); opacity: .12; pointer-events: none; }
.ambient-a { top: -15rem; right: -10rem; background: var(--cyan); }
.ambient-b { bottom: -18rem; left: -12rem; background: #366cff; }
.login-screen { position: relative; z-index: 1; display: grid; min-height: 100vh; place-items: center; padding: 24px; }
.login-card { position: relative; width: min(100%, 430px); overflow: hidden; padding: 42px; border: 1px solid var(--border-strong); border-radius: 22px; background: linear-gradient(160deg, rgba(19, 37, 52, .96), rgba(8, 18, 27, .96)); box-shadow: var(--shadow); }
.login-card::after { position: absolute; top: 0; left: 0; width: 42%; height: 2px; background: linear-gradient(90deg, var(--cyan), transparent); content: ""; }
.login-card h1 { margin: 0 0 10px; font-size: 2.25rem; }
.brand-mark { display: flex; align-items: end; gap: 4px; width: 40px; height: 40px; margin-bottom: 28px; padding: 9px; border: 1px solid var(--border-strong); border-radius: 12px; background: var(--cyan-soft); }
.brand-mark span { display: block; width: 5px; border-radius: 2px; background: var(--cyan); box-shadow: 0 0 12px rgba(72, 216, 255, .75); }
.brand-mark span:nth-child(1) { height: 11px; }
.brand-mark span:nth-child(2) { height: 20px; }
.brand-mark span:nth-child(3) { height: 15px; }
.brand-mark.small { width: 34px; height: 34px; margin: 0; padding: 7px; border-radius: 10px; }
.form-stack { display: grid; gap: 17px; margin-top: 28px; }
.form-stack.compact { margin-top: 20px; }
label { display: grid; gap: 8px; color: #bfd0dc; font-size: .88rem; font-weight: 650; }
input, select, textarea { width: 100%; min-height: 44px; border: 1px solid var(--border); border-radius: 9px; outline: none; background: rgba(4, 12, 19, .72); color: var(--text); padding: 10px 12px; transition: border-color .18s, box-shadow .18s, background .18s; }
textarea { resize: vertical; }
input::placeholder, textarea::placeholder { color: #61798b; }
input:focus, select:focus, textarea:focus { border-color: var(--cyan); background: #091722; box-shadow: 0 0 0 3px rgba(72, 216, 255, .1); }
.button, .icon-button, .text-button, .nav-item, .link-button { border: 0; cursor: pointer; }
.button { display: inline-flex; min-height: 42px; align-items: center; justify-content: center; gap: 12px; border-radius: 9px; padding: 10px 16px; font-weight: 750; transition: transform .15s, border-color .15s, background .15s; }
.button:hover { transform: translateY(-1px); }
.button:disabled { cursor: wait; opacity: .6; transform: none; }
.button-wide { width: 100%; justify-content: space-between; padding-inline: 18px; }
.button-primary { background: var(--cyan); color: #031018; box-shadow: 0 8px 25px rgba(72, 216, 255, .16); }
.button-primary:hover { background: #76e4ff; }
.button-secondary { border: 1px solid var(--border); background: var(--surface-raised); color: var(--text); }
.button-secondary:hover { border-color: var(--border-strong); }
.button-ghost { border: 1px solid transparent; background: transparent; color: var(--muted); }
.button-ghost:hover { border-color: var(--border); background: rgba(255, 255, 255, .025); color: var(--text); }
.button-danger { border: 1px solid rgba(255, 107, 124, .25); background: var(--red-soft); color: #ff9daa; }
.button-danger:hover { border-color: rgba(255, 107, 124, .65); background: rgba(255, 107, 124, .2); color: #ffd3d8; }
.form-error { min-height: 22px; margin: -6px 0 0; color: #ff91a0; font-size: .86rem; }
input[aria-invalid="true"] { border-color: var(--red); box-shadow: 0 0 0 3px rgba(255, 107, 124, .1); }
.secure-note, .status-line { display: flex; align-items: center; gap: 9px; color: var(--muted); font-size: .78rem; }
.secure-note { margin-top: 22px; padding-top: 20px; border-top: 1px solid var(--border); }
.pulse-dot { width: 7px; height: 7px; border-radius: 50%; background: var(--green); box-shadow: 0 0 0 5px rgba(87, 230, 168, .08), 0 0 16px rgba(87, 230, 168, .65); }

.console { position: relative; z-index: 1; display: grid; min-height: 100vh; grid-template-columns: 232px minmax(0, 1fr); }
.sidebar { position: sticky; top: 0; display: flex; height: 100vh; overflow-y: auto; flex-direction: column; border-right: 1px solid var(--border); background: rgba(5, 13, 20, .82); padding: 24px 18px; backdrop-filter: blur(18px); }
.brand-row { display: flex; align-items: center; gap: 12px; padding: 0 8px 28px; }
.brand-row strong, .brand-row small { display: block; }
.brand-row strong { letter-spacing: .08em; }
.brand-row small { margin-top: 2px; color: var(--muted); font-size: .62rem; letter-spacing: .12em; }
nav { display: grid; gap: 6px; }
.nav-item { display: grid; grid-template-columns: 24px 1fr; align-items: center; border-radius: 9px; background: transparent; padding: 12px 13px; color: var(--muted); text-align: left; font-size: .9rem; font-weight: 650; }
.nav-item span { color: #628094; font-size: 1.15rem; }
.nav-item:hover { background: rgba(255, 255, 255, .035); color: var(--text); }
.nav-item.active { background: linear-gradient(90deg, var(--cyan-soft), rgba(72, 216, 255, .035)); color: var(--text); box-shadow: inset 2px 0 var(--cyan); }
.nav-item.active span { color: var(--cyan); }
.sidebar-foot { display: grid; gap: 16px; margin-top: auto; padding: 20px 10px 4px; border-top: 1px solid var(--border); }
.text-button, .link-button { width: max-content; background: none; padding: 0; color: var(--muted); font-size: .82rem; }
.text-button:hover, .link-button:hover { color: var(--cyan); }
.workspace { min-width: 0; }
.topbar { display: flex; min-height: 118px; align-items: center; justify-content: space-between; gap: 24px; border-bottom: 1px solid var(--border); padding: 24px clamp(22px, 4vw, 54px); background: rgba(7, 16, 25, .6); backdrop-filter: blur(14px); }
.topbar-actions { display: flex; align-items: center; gap: 14px; font-size: .78rem; }
.icon-button { display: grid; width: 40px; height: 40px; place-items: center; border: 1px solid var(--border); border-radius: 9px; background: var(--surface); font-size: 1.2rem; }
.icon-button:hover { border-color: var(--border-strong); color: var(--cyan); }
.content { padding: 30px clamp(22px, 4vw, 54px) 60px; }
.view { display: none; }
.view.active { display: block; animation: fade-in .22s ease-out; }
@keyframes fade-in { from { opacity: 0; transform: translateY(4px); } }
.stats-grid { display: grid; grid-template-columns: repeat(6, minmax(135px, 1fr)); gap: 12px; }
.stat-card { position: relative; min-height: 132px; overflow: hidden; border: 1px solid var(--border); border-radius: 13px; background: linear-gradient(150deg, var(--surface-raised), rgba(10, 22, 31, .82)); padding: 18px; }
.stat-card::after { position: absolute; right: -20px; bottom: -40px; width: 85px; height: 85px; border-radius: 50%; background: var(--accent, var(--cyan)); filter: blur(35px); opacity: .12; content: ""; }
.stat-label { color: var(--muted); font-size: .78rem; }
.stat-value { display: block; margin-top: 19px; font-size: 2rem; font-weight: 760; letter-spacing: -.04em; }
.stat-meta { color: var(--green); font-size: .7rem; letter-spacing: .08em; }
.two-column { display: grid; grid-template-columns: minmax(0, 1.35fr) minmax(300px, .65fr); gap: 16px; margin-top: 16px; }
.key-layout { grid-template-columns: minmax(280px, .42fr) minmax(580px, 1fr); align-items: start; }
.panel { overflow: hidden; border: 1px solid var(--border); border-radius: 13px; background: var(--surface); padding: 22px; box-shadow: 0 14px 40px rgba(0, 0, 0, .12); backdrop-filter: blur(12px); }
.panel-heading { display: flex; align-items: center; justify-content: space-between; gap: 18px; margin-bottom: 20px; }
.policy-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 1px; overflow: hidden; border: 1px solid var(--border); border-radius: 10px; background: var(--border); }
.policy-item { min-height: 78px; background: #0d1a25; padding: 14px; }
.policy-item dt { margin-bottom: 8px; color: var(--muted); font-size: .74rem; }
.policy-item dd { margin: 0; font-weight: 700; word-break: break-word; }
.quick-form, .form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px; }
.price-fields { display: grid; gap: 10px; }
.price-row { display: grid; grid-template-columns: minmax(120px, .8fr) minmax(130px, 1fr) auto; gap: 10px; align-items: end; }
.price-row .price-label { align-self: center; color: var(--text); font-weight: 700; }
.price-row .price-label small { display: block; margin-top: 3px; color: var(--muted); font-weight: 400; }
.price-row input { width: 100%; }
.discount-price-row { grid-template-columns: minmax(100px, 1fr) minmax(90px, .7fr) minmax(100px, .8fr) auto; }
.discount-hint { grid-column: 1 / -1; color: var(--muted); }
.discount-bulk { display: flex; align-items: end; gap: 10px; padding-bottom: 12px; border-bottom: 1px solid var(--border); }
.discount-bulk label { flex: 1; min-width: 0; }
.discount-bulk input { width: 100%; }
@media (max-width: 600px) {
  .discount-price-row { grid-template-columns: 1fr 1fr; }
  .discount-price-row .price-label, .discount-price-row .discount-hint { grid-column: 1 / -1; }
  .discount-bulk { align-items: stretch; flex-direction: column; }
}
.custom-package-section { display: grid; gap: 16px; margin-top: 22px; padding: 18px; border: 1px solid var(--border); border-radius: 12px; background: rgba(4, 12, 19, .35); }
.custom-package-section .panel-heading { margin-bottom: 0; }
.package-edit-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; align-items: end; }
.package-edit-grid label { min-width: 0; }
.package-edit-grid input, .package-edit-grid select { width: 100%; }
.package-card { display: grid; gap: 10px; padding: 14px; border: 1px solid var(--border); border-radius: 10px; }
.package-card-heading { display: flex; justify-content: space-between; align-items: center; gap: 10px; }
.package-card-heading small { color: var(--muted); }
.package-card .button { justify-self: end; }
.package-delete-note { color: #ff9daa; line-height: 1.5; }
.duration-choice-list { display: flex; flex-wrap: wrap; gap: 8px 14px; }
.duration-choice-list label { display: inline-flex; align-items: center; gap: 6px; }
.duration-choice-list input[type="checkbox"] { width: 16px; min-height: 16px; }
.billing-note { margin: 16px 0 0; line-height: 1.65; }
.amount-positive { color: var(--green); font-weight: 700; }
.amount-negative { color: var(--red); font-weight: 700; }
.compact-heading { margin-bottom: 12px; }
.duration-options { display: flex; flex-wrap: wrap; align-items: center; gap: 9px 14px; grid-column: span 2; min-width: 0; margin: 0; padding: 12px; border: 1px solid var(--border); border-radius: 9px; }
.duration-options legend { width: 100%; color: var(--muted); font-size: .78rem; }
.duration-options label { display: inline-flex; align-items: center; gap: 6px; font-size: .82rem; }
.duration-options input[type="checkbox"] { width: 16px; min-height: 16px; accent-color: var(--cyan); }
.duration-options .custom-duration-input { flex: 1 1 180px; }
.duration-options .custom-duration-input input { min-height: 34px; width: 100%; }
.span-two { grid-column: span 2; }
.filter-row { display: flex; align-items: center; gap: 8px; }
.filter-row input { width: min(220px, 24vw); }
.filter-row select { width: 120px; }
.filter-row input, .filter-row select, .filter-row .button { min-height: 38px; padding-block: 7px; font-size: .82rem; }
.panel-heading.list-heading { flex-direction: row; align-items: center; flex-wrap: wrap; }
.agent-list-filter { width: 100%; flex-wrap: wrap; margin-bottom: 16px; }
.agent-list-filter input { flex: 1 1 200px; width: auto; min-width: 0; }
.agent-list-filter select { flex: 0 1 120px; }
.creation-options { padding: 12px; border: 1px solid var(--border); border-radius: 9px; }
.creation-options summary { cursor: pointer; color: var(--muted); font-weight: 650; }
.creation-options[open] summary { margin-bottom: 14px; color: var(--text); }
.create-agent-form > .muted { margin: -8px 0 0; font-size: .78rem; line-height: 1.6; }
.create-agent-form > .panel-heading { flex-direction: row; align-items: flex-start; gap: 12px; }
.create-agent-form .icon-button.dialog-close { width: 44px; height: 44px; flex: 0 0 44px; }
.create-agent-form > .dialog-actions { position: sticky; bottom: 0; border-top: 1px solid var(--border); background: #0d1a25; padding: 12px 0 0; }
.create-agent-form > .dialog-actions .button { flex: 1; min-height: 44px; }
.user-panel-heading { margin-bottom: 14px; }
.user-activity-panel { margin-bottom: 16px; padding: 14px; border: 1px solid var(--border); border-radius: 10px; }
.user-activity-panel summary { cursor: pointer; font-size: .85rem; font-weight: 600; }
.user-activity-panel p { margin: 10px 0; font-size: .75rem; line-height: 1.6; }
.user-activity-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 24px; }
.user-activity-grid h3 { font-size: .86rem; }
.user-activity-grid section > div { max-height: 260px; overflow-y: auto; }
.user-distribution-row { display: grid; grid-template-columns: minmax(90px, 1fr) 1fr auto; align-items: center; gap: 10px; margin: 10px 0; font-size: .77rem; }
.user-distribution-row meter { width: 100%; height: 12px; accent-color: var(--cyan); }
@media (max-width: 900px) { .user-activity-grid { grid-template-columns: 1fr; } }
.table-summary { font-size: .78rem; }
.user-filter { flex-wrap: wrap; margin-bottom: 14px; padding: 12px; border: 1px solid var(--border); border-radius: 10px; background: rgba(4, 12, 19, .32); }
.user-filter input { flex: 1 1 250px; width: auto; }
.user-filter select { flex: 0 1 145px; width: auto; }
.table-wrap { width: 100%; overflow: auto; border: 1px solid var(--border); border-radius: 10px; }
table { width: 100%; border-collapse: collapse; white-space: nowrap; }
th, td { border-bottom: 1px solid var(--border); padding: 13px 14px; text-align: left; font-size: .82rem; }
th { position: sticky; top: 0; z-index: 1; background: #10202c; color: #7891a3; font-size: .68rem; letter-spacing: .08em; text-transform: uppercase; }
.sort-button { display: inline-flex; align-items: center; gap: 7px; margin: -8px -9px; border: 0; border-radius: 6px; background: transparent; color: inherit; padding: 8px 9px; cursor: pointer; font: inherit; letter-spacing: inherit; text-transform: inherit; white-space: nowrap; }
.sort-button:hover { background: rgba(72, 216, 255, .07); color: var(--text); }
.sort-button:focus-visible { outline: 2px solid var(--cyan); outline-offset: 1px; }
.sort-button span { width: 10px; color: #526a7b; font-size: .78rem; letter-spacing: 0; }
th[aria-sort] .sort-button { color: var(--cyan); }
th[aria-sort] .sort-button span { color: var(--cyan); }
.user-table th:last-child { right: 0; z-index: 3; min-width: 220px; box-shadow: -10px 0 18px rgba(2, 8, 13, .3); }
.user-table td:last-child { position: sticky; right: 0; min-width: 220px; background: #0d1b26; box-shadow: -10px 0 18px rgba(2, 8, 13, .3); }
.user-table tbody tr:hover td:last-child { background: #10202c; }
tbody tr:last-child td { border-bottom: 0; }
tbody tr:hover { background: rgba(72, 216, 255, .025); }
.mono { font-family: "Cascadia Code", Consolas, monospace; font-size: .78rem; letter-spacing: .03em; }
.badge { display: inline-flex; align-items: center; border-radius: 999px; padding: 5px 9px; font-size: .69rem; font-weight: 750; }
.badge-active, .badge-unused, .badge-online { background: var(--green-soft); color: var(--green); }
.badge-disabled, .badge-revoked { background: var(--red-soft); color: #ff9daa; }
.badge-offline { background: rgba(148, 163, 184, .14); color: var(--muted); }
.badge-used, .badge-info { background: var(--cyan-soft); color: var(--cyan); }
.row-actions { display: flex; justify-content: flex-end; gap: 7px; }
.runtime-files { margin-top: 20px; min-width: 0; }
.runtime-summary { display: flex; align-items: center; flex-wrap: wrap; gap: 12px; }
.runtime-actions { margin: 14px 0; }
.runtime-files .table-wrap { border: 0; }
.runtime-file-name { min-width: 180px; overflow-wrap: anywhere; }
.runtime-file-error { color: var(--danger, #d34c4c); }
.runtime-files .row-actions { flex-wrap: wrap; }
.row-button { border: 1px solid var(--border); border-radius: 7px; background: transparent; color: var(--muted); padding: 6px 9px; cursor: pointer; font-size: .72rem; }
.row-button:hover { border-color: var(--border-strong); color: var(--text); }
.row-button.danger:hover { border-color: rgba(255, 107, 124, .4); color: #ff9daa; }
.pagination { display: flex; min-height: 36px; align-items: center; justify-content: flex-end; gap: 8px; margin-top: 14px; color: var(--muted); font-size: .76rem; }
.pagination button { border: 1px solid var(--border); border-radius: 7px; background: var(--surface-raised); color: var(--text); padding: 6px 10px; cursor: pointer; }
.pagination button:disabled { cursor: default; opacity: .35; }
.empty-row { height: 110px; color: var(--muted); text-align: center; }
.settings-panel { max-width: 850px; }
.offset-panel { max-width: 1080px; }
.offset-editor { min-height: 430px; resize: vertical; white-space: pre; tab-size: 4; }
.offset-meta { margin: -7px 0 0; overflow-wrap: anywhere; }
.offset-mode-form { margin-bottom: 24px; border-bottom: 1px solid var(--border); padding-bottom: 24px; }
.offset-mode-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.force-mode-option:has(input:checked) { border-color: var(--red); background: var(--red-soft); }
.secondary-settings { margin-top: 16px; }
.settings-form { display: grid; gap: 18px; }
.update-source { min-width: 0; margin: 0; padding: 0; border: 0; }
.update-source legend { margin-bottom: 10px; color: var(--muted); font-size: .84rem; }
.update-source-option { display: flex; align-items: center; gap: 12px; padding: 14px; border: 1px solid var(--border); border-radius: 10px; cursor: pointer; }
.update-source-option:has(input:checked) { border-color: var(--cyan); background: rgba(72, 216, 255, .06); }
.update-source-option input { width: 18px; min-height: 18px; margin: 0; flex: 0 0 auto; accent-color: var(--cyan); }
.update-source-option strong, .update-source-option small { display: block; }
.update-source-option small { margin-top: 5px; color: var(--muted); font-weight: 400; }
.upload-fields, .upload-status { display: grid; gap: 10px; min-width: 0; }
.upload-fields p { margin: 0; overflow-wrap: anywhere; }
.upload-fields .link-button { justify-self: start; }
.upload-status { color: var(--cyan); font-size: .84rem; }
.upload-status progress { width: 100%; height: 8px; accent-color: var(--cyan); }
.switch-row { display: grid; grid-template-columns: repeat(2, 1fr); gap: 12px; }
.switch-label { display: flex; min-height: 74px; cursor: pointer; align-items: center; gap: 13px; border: 1px solid var(--border); border-radius: 10px; padding: 13px; background: rgba(4, 12, 19, .4); }
.switch-label input { position: absolute; width: 1px; height: 1px; opacity: 0; }
.switch-label strong, .switch-label small { display: block; }
.switch-label small { margin-top: 4px; color: var(--muted); font-weight: 400; }
.switch { position: relative; width: 42px; height: 23px; flex: 0 0 auto; border-radius: 999px; background: #263746; transition: background .2s; }
.switch::after { position: absolute; top: 3px; left: 3px; width: 17px; height: 17px; border-radius: 50%; background: #9eb0bd; transition: transform .2s, background .2s; content: ""; }
.switch-label input:checked + .switch { background: rgba(72, 216, 255, .32); }
.switch-label input:checked + .switch::after { background: var(--cyan); transform: translateX(19px); }
.danger-switch input:checked + .switch { background: rgba(255, 107, 124, .3); }
.danger-switch input:checked + .switch::after { background: var(--red); }
.switch-label input:focus-visible + .switch { box-shadow: 0 0 0 3px rgba(72, 216, 255, .2); }
.check-label { display: flex; align-items: center; gap: 10px; }
.check-label input { width: 18px; min-height: 18px; accent-color: var(--cyan); }

dialog { width: min(92vw, 540px); max-width: calc(100vw - 24px); max-height: calc(100dvh - 24px); overflow: hidden; border: 1px solid var(--border-strong); border-radius: 15px; background: #0d1a25; color: var(--text); padding: 0; box-shadow: var(--shadow); }
dialog.wide-dialog { width: min(94vw, 980px); }
dialog::backdrop { background: rgba(1, 6, 10, .75); backdrop-filter: blur(5px); }
.dialog-card { display: grid; width: 100%; max-width: 100%; max-height: calc(100dvh - 26px); min-width: 0; gap: 16px; overflow-x: hidden; overflow-y: auto; margin: 0; padding: 24px; }
.dialog-card > *, .dialog-section, .dialog-section > *, .price-fields, .price-row { min-width: 0; }
.dialog-card > .duration-options { width: 100%; max-width: 100%; grid-column: auto; }
.dialog-card .panel-heading { margin-bottom: 2px; }
.dialog-card h3 { margin: 0; color: #bfd0dc; font-size: .82rem; letter-spacing: .08em; text-transform: uppercase; }
.management-tabs { position: sticky; top: 0; z-index: 3; display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 6px; padding: 4px 0; background: #0d1a25; }
.management-tabs button { min-width: 0; min-height: 44px; padding: 9px 5px; border: 1px solid var(--border); border-radius: 8px; background: rgba(4, 12, 19, .65); color: var(--muted); font: inherit; font-size: .76rem; cursor: pointer; }
.management-tabs button[aria-selected="true"] { border-color: var(--cyan); background: rgba(72, 216, 255, .1); color: var(--cyan); }
.management-tabs button:focus-visible { outline: 2px solid var(--cyan); outline-offset: 2px; }
[data-management-form="child"] .management-tabs { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.management-panel { display: grid; min-width: 0; gap: 16px; }
.management-panel[hidden] { display: none !important; }
.management-form > .dialog-actions { position: sticky; bottom: 0; z-index: 2; border-top: 1px solid var(--border); background: #0d1a25; padding-top: 12px; }
@media (max-width: 620px) { [data-management-form="agent"] .management-tabs { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
.icon-button.dialog-close { width: 34px; height: 34px; }
.dialog-actions { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: 9px; margin-top: 6px; }
.dialog-actions .button { max-width: 100%; white-space: nowrap; }
#balance-confirm-dialog { width: min(92vw, 440px); }
#action-confirm-dialog { width: min(92vw, 440px); }
.balance-confirm-details { display: grid; gap: 1px; overflow: hidden; margin: 0; border: 1px solid var(--border); border-radius: 9px; background: var(--border); }
.balance-confirm-details > div { display: grid; grid-template-columns: 68px minmax(0, 1fr); gap: 10px; background: rgba(4, 12, 19, .7); padding: 11px 12px; }
.balance-confirm-details dt { color: var(--muted); font-size: .78rem; }
.balance-confirm-details dd { min-width: 0; overflow-wrap: anywhere; margin: 0; font-weight: 700; }
.dialog-actions-split { display: grid; grid-template-columns: auto 1fr auto auto; }
.dialog-section { display: grid; gap: 13px; border-top: 1px solid var(--border); padding-top: 16px; }
.dialog-form-grid { display: grid; grid-template-columns: minmax(0, .7fr) minmax(0, 1.3fr); gap: 12px; }
.user-detail-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 1px; overflow: hidden; margin: 0; border: 1px solid var(--border); border-radius: 9px; background: var(--border); }
.user-detail-grid > div { min-width: 0; background: rgba(4, 12, 19, .7); padding: 11px 12px; }
.user-detail-grid dt { margin-bottom: 5px; color: var(--muted); font-size: .68rem; }
.user-detail-grid dd { overflow: hidden; margin: 0; color: var(--text); font-size: .78rem; font-weight: 700; text-overflow: ellipsis; white-space: nowrap; }
.quick-expiry { display: flex; flex-wrap: wrap; align-items: center; gap: 7px; }
.quick-expiry > span { margin-right: 3px; color: var(--muted); font-size: .74rem; }
.history-dialog-card { min-width: 0; }
.history-summary { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
.history-summary > div { border: 1px solid var(--border); border-radius: 9px; background: rgba(4, 12, 19, .45); padding: 12px; }
.history-summary span, .history-summary strong { display: block; }
.history-summary span { color: var(--muted); font-size: .7rem; }
.history-summary strong { margin-top: 5px; font-size: .92rem; }
.history-kind { color: var(--cyan); font-weight: 700; }
.keys-result { gap: 12px; }
.keys-result pre { max-height: 340px; overflow: auto; margin: 0; border: 1px solid var(--border); border-radius: 9px; background: #061018; color: #bdeeff; padding: 14px; font: .8rem/1.7 "Cascadia Code", Consolas, monospace; user-select: all; }
.guest-admin-layout { align-items: start; }
.guest-admin-list { display: grid; gap: 9px; margin-top: 16px; }
.guest-admin-card { min-width: 0; }
.agent-file-grant-list { display: grid; gap: 12px; }
.agent-file-grant { display: grid; gap: 10px; min-width: 0; padding: 14px; border: 1px solid var(--border); border-radius: 10px; background: var(--surface-raised); }
.agent-file-grant .check-label { align-items: flex-start; overflow-wrap: anywhere; }
.agent-file-grant .muted { margin: 0; overflow-wrap: anywhere; font-size: .75rem; }
#agent-guest-files-dialog { width: min(680px, calc(100vw - 24px)); }
.guest-archive-status { margin: 8px; }
.guest-admin-item { display: flex; align-items: center; justify-content: space-between; gap: 14px; min-width: 0; border: 1px solid var(--border); border-radius: 9px; background: rgba(4, 13, 20, .45); padding: 12px; }
.guest-admin-item > div:first-child { display: grid; min-width: 0; gap: 5px; }
.guest-admin-item strong { overflow-wrap: anywhere; font-size: .83rem; }
.guest-admin-item .muted { overflow-wrap: anywhere; font-size: .72rem; }
.guest-admin-item .row-actions { flex: 0 0 auto; flex-wrap: wrap; }
.guest-zip-details { max-height: 430px; overflow: auto; margin: 0 8px; padding: 10px; border: 1px solid var(--border); border-top: 0; border-radius: 0 0 9px 9px; background: rgba(4, 13, 20, .7); }
.guest-zip-details > input[type="search"] { width: 100%; margin-bottom: 8px; }
.guest-archive-folder { margin: 4px 0; border-left: 1px solid var(--border); }
.guest-archive-folder > summary { cursor: pointer; padding: 8px 10px; color: var(--cyan); font-size: .83rem; font-weight: 700; }
.guest-archive-children { margin-left: 14px; padding-left: 9px; border-left: 1px solid var(--border); }
.guest-zip-entry { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 12px; padding: 9px 4px; border-bottom: 1px solid var(--border); }
.guest-zip-entry:last-child { border-bottom: 0; }
.guest-zip-entry > div:first-child { display: grid; min-width: 0; gap: 3px; }
.guest-zip-entry strong { overflow-wrap: anywhere; font-size: .8rem; }
.guest-zip-entry .row-actions { flex: 0 0 auto; flex-wrap: wrap; }
.guest-zip-preview { width: 100%; max-height: 260px; overflow: auto; padding: 10px; border: 1px solid var(--border); border-radius: 7px; background: #061018; }
.guest-zip-preview pre { margin: 0; color: #d1eaf1; white-space: pre-wrap; overflow-wrap: anywhere; font: .75rem/1.5 Consolas, monospace; }
.guest-zip-preview img { display: block; max-width: 100%; max-height: 235px; object-fit: contain; }
.symbol-summary { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 12px; margin-bottom: 16px; }
.symbol-summary > div { padding: 14px; border: 1px solid var(--border); border-radius: 9px; }
.symbol-summary span, .symbol-summary strong { display: block; }
.symbol-summary span { color: var(--muted); font-size: .74rem; }
.symbol-summary strong { margin-top: 8px; font-size: 1.15rem; }
.symbol-note { font-size: .78rem; line-height: 1.7; }
.feature-build-note { font-size: .78rem; line-height: 1.7; }
.feature-build-table { width: 100%; min-width: 660px; }
.feature-build-table td { vertical-align: top; }
.feature-build-table td:first-child { min-width: 110px; }
.feature-build-table td:first-child .muted { margin-top: 5px; font-size: .75rem; }
.feature-build-identity { min-width: 0; max-width: 360px; white-space: pre-wrap; overflow-wrap: anywhere; }
.feature-build-id { display: grid; grid-template-columns: 58px minmax(0, 1fr) auto; align-items: start; gap: 8px; margin-bottom: 7px; }
.feature-build-id:last-child { margin-bottom: 0; }
.feature-build-id .muted, .feature-build-id .link-button { font-size: .7rem; }
.feature-build-id code { overflow-wrap: anywhere; white-space: normal; font-size: .7rem; user-select: all; }
.feature-build-actions { flex-wrap: wrap; gap: 8px; }
#feature-build-register-dialog { width: min(680px, calc(100vw - 24px)); }
[data-management-form="feature-build"] .management-tabs { grid-template-columns: repeat(2, minmax(0, 1fr)); }
#feature-build-key-value { width: 100%; font-size: .75rem; }
#feature-build-json { width: 100%; resize: vertical; font-size: .75rem; }
.symbol-identity { min-width: 240px; }
.symbol-identity .mono { font-size: .7rem; }
.symbol-downloads { min-width: 150px; }
.symbol-downloads .muted { margin-top: 5px; font-size: .7rem; }
.symbol-checksum { min-width: 140px; max-width: 240px; }
.symbol-checksum summary { cursor: pointer; }
.symbol-checksum details > div { width: 220px; margin-top: 8px; white-space: normal; overflow-wrap: anywhere; user-select: all; }
.crash-text-panel { margin-top: 18px; padding: 16px; border: 1px solid var(--border); border-radius: 8px; }
.crash-text-panel pre { max-height: 480px; overflow: auto; white-space: pre-wrap; overflow-wrap: anywhere; font: .78rem/1.5 Consolas, monospace; }
.crash-policy-panel { margin-bottom: 16px; }
.crash-policy-actions { display: flex; flex-wrap: wrap; align-items: center; gap: 16px; }
.crash-policy-actions .filter-row { display: flex; flex-wrap: wrap; align-items: center; gap: 9px; margin: 0; }
.crash-policy-actions input[type="number"] { width: 90px; }
.crash-policy-panel > p { margin: 14px 0 0; font-size: .78rem; }
@media (max-width: 700px) { .guest-admin-item, .guest-zip-entry { align-items: flex-start; flex-direction: column; } }
.toast-region { position: fixed; z-index: 100; right: 22px; bottom: 22px; display: grid; gap: 9px; width: min(360px, calc(100vw - 44px)); }
.toast { border: 1px solid var(--border-strong); border-radius: 10px; background: #102330; padding: 13px 15px; box-shadow: var(--shadow); font-size: .84rem; animation: toast-in .2s ease-out; }
.toast.error { border-color: rgba(255, 107, 124, .45); }
.toast-in-dialog { position: absolute; z-index: 10000; top: 12px; left: 50%; width: min(360px, calc(100vw - 32px)); transform: translateX(-50%); animation: toast-dialog-in .2s ease-out; }
@keyframes toast-in { from { opacity: 0; transform: translateY(8px); } }
@keyframes toast-dialog-in { from { opacity: 0; transform: translate(-50%, -8px); } }

@media (max-width: 1200px) {
  .stats-grid { grid-template-columns: repeat(3, 1fr); }
  .key-layout { grid-template-columns: 1fr; }
}
@media (max-width: 860px) {
  .console { grid-template-columns: 76px minmax(0, 1fr); }
  .sidebar { padding-inline: 10px; }
  .brand-row { justify-content: center; padding-inline: 0; }
  .brand-row > div:last-child, .nav-item:not(.active)::after, .nav-item { font-size: 0; }
  .nav-item { grid-template-columns: 1fr; justify-items: center; padding: 13px 8px; }
  .nav-item span { font-size: 1.2rem; }
  .sidebar-foot .status-line { display: none; }
  .text-button { margin: auto; font-size: .74rem; }
  .two-column { grid-template-columns: 1fr; }
  .panel-heading { align-items: flex-start; flex-direction: column; }
  .filter-row { width: 100%; flex-wrap: wrap; }
  .filter-row input { width: min(100%, 260px); }
  .user-filter input, .user-filter select { flex-grow: 1; width: auto; }
}
@media (max-width: 620px) {
  .console { display: block; padding-bottom: calc(184px + env(safe-area-inset-bottom)); }
  .sidebar { position: fixed; z-index: 20; top: auto; right: 0; bottom: 0; left: 0; display: block; width: 100%; height: auto; overflow: visible; border-top: 1px solid var(--border); border-right: 0; padding: 6px 6px calc(6px + env(safe-area-inset-bottom)); }
  .brand-row, .sidebar-foot { display: none; }
  nav { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 2px; }
  .nav-item { display: flex; min-width: 0; min-height: 56px; flex-direction: column; align-items: center; justify-content: center; padding: 3px 1px; font-size: .65rem; line-height: 1.15; overflow-wrap: anywhere; text-align: center; white-space: normal; }
  .nav-item.active { box-shadow: inset 0 -2px var(--cyan); }
  .topbar { min-height: 96px; padding: 18px; }
  .topbar-actions .muted { display: none; }
  .content { padding: 18px 14px 32px; }
  .stats-grid { grid-template-columns: repeat(2, 1fr); }
  .symbol-summary { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .stat-card { min-height: 108px; padding: 14px; }
  .stat-value { margin-top: 12px; font-size: 1.65rem; }
  .panel { padding: 16px; }
  .agent-list-filter input { flex-basis: 100%; width: 100%; }
  .agent-list-filter select { flex: 1; min-width: 0; }
  .agent-list-filter .button, .list-heading > .button { min-height: 44px; }
  /* Agent cards avoid horizontal panning and browser focus scrolls on phones. */
  .agent-table, .agent-table tbody { display: block; width: 100%; min-width: 0; white-space: normal; }
  .agent-table thead { display: none; }
  .agent-table tbody tr { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; padding: 14px; border-bottom: 1px solid var(--border); }
  .agent-table tbody tr:last-child { border-bottom: 0; }
  .agent-table td { display: flex; min-width: 0; flex-direction: column; align-items: flex-start; gap: 5px; border: 0; padding: 0; overflow-wrap: anywhere; white-space: normal; }
  .agent-table td[data-label]::before { content: attr(data-label); color: var(--muted); font: .7rem/1.4 Inter, "Segoe UI", "Microsoft YaHei UI", system-ui, sans-serif; letter-spacing: 0; }
  .agent-table td:first-child { grid-column: 1 / -1; font-weight: 700; }
  .agent-table td.row-actions { grid-column: 1 / -1; flex-direction: row; align-items: center; justify-content: flex-end; padding-top: 10px; border-top: 1px solid var(--border); }
  .agent-table .row-button { min-width: 72px; min-height: 44px; font-size: .82rem; touch-action: manipulation; }
  .agent-table [data-agent-edit], .agent-table [data-child-manage] { flex: 1; border-color: var(--border-strong); background: var(--cyan-soft); color: var(--cyan); }
  .agent-table td.empty-row { grid-column: 1 / -1; min-height: 100px; align-items: center; justify-content: center; font-weight: 400; }
  .policy-grid, .quick-form, .form-grid, .switch-row, .price-row { grid-template-columns: 1fr; }
  .package-edit-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .dialog-card { padding: 18px; }
  .dialog-form-grid, .user-detail-grid, .history-summary { grid-template-columns: 1fr; }
  .dialog-actions-split { grid-template-columns: 1fr 1fr; }
  .dialog-actions-split > span { display: none; }
  .dialog-actions-split .button { width: 100%; }
  .span-two { grid-column: auto; }
  .login-card { padding: 30px 24px; }
  .login-card h1 { font-size: 1.9rem; }
}

.user-connection-cell { min-width: 190px; max-width: 240px; white-space: normal; overflow-wrap: anywhere; }
.user-connection-cell > span, .user-connection-cell > small { display: block; line-height: 1.6; }

.user-table td.row-actions { display: table-cell; vertical-align: middle; }
.user-table td.row-actions > button { margin-right: 6px; }
.user-table td.row-actions > button:last-child { margin-right: 0; }
