:root {
  color-scheme: light;
  --bg: #f4f7f8;
  --surface: #ffffff;
  --surface-muted: #f7fafb;
  --ink: #17252a;
  --muted: #68777c;
  --line: #dce5e7;
  --brand: #087b72;
  --brand-strong: #05645d;
  --blue: #2778da;
  --green: #258a58;
  --amber: #b97708;
  --red: #d84242;
  --shadow: 0 8px 24px rgba(30, 54, 61, .09);
  font-family: "Microsoft YaHei UI", "PingFang SC", system-ui, sans-serif;
  font-size: 16px;
  letter-spacing: 0;
}

* { box-sizing: border-box; }
html, body { margin: 0; min-height: 100%; background: var(--bg); color: var(--ink); }
button, input, select, textarea { font: inherit; letter-spacing: 0; }
button { cursor: pointer; }
[hidden] { display: none !important; }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; overflow: hidden; clip: rect(0,0,0,0); white-space: nowrap; border: 0; }

.login-shell { min-height: 100vh; display: grid; place-items: center; padding: 24px; background: linear-gradient(145deg, #e8f4f2 0%, #f6f8f9 52%, #eaf0f3 100%); }
.login-panel { width: min(400px, 100%); padding: 34px 30px; background: var(--surface); border: 1px solid var(--line); border-radius: 8px; box-shadow: var(--shadow); }
.login-panel h1 { margin: 16px 0 4px; font-size: 26px; }
.login-panel > p { margin: 0 0 28px; color: var(--muted); }
.login-panel form { display: grid; gap: 18px; }
.login-panel label, .form-grid label { display: grid; gap: 7px; color: #45555a; font-weight: 600; }
input, select, textarea { width: 100%; border: 1px solid #cbd7da; border-radius: 5px; background: #fff; color: var(--ink); padding: 11px 12px; outline: 0; }
input:focus, select:focus, textarea:focus { border-color: var(--brand); box-shadow: 0 0 0 3px rgba(8, 123, 114, .12); }
textarea { resize: vertical; }

.brand-mark { width: 52px; height: 52px; display: flex; align-items: end; justify-content: center; gap: 4px; padding: 11px; border-radius: 8px; background: var(--brand); box-shadow: inset 0 0 0 2px rgba(255,255,255,.2); }
.brand-mark span { width: 7px; border-radius: 2px 2px 0 0; background: #fff; }
.brand-mark span:nth-child(1) { height: 14px; }
.brand-mark span:nth-child(2) { height: 22px; }
.brand-mark span:nth-child(3) { height: 30px; }
.brand-mark.small { width: 38px; height: 38px; padding: 8px; gap: 3px; }
.brand-mark.small span { width: 5px; }
.brand-mark.small span:nth-child(1) { height: 10px; }
.brand-mark.small span:nth-child(2) { height: 16px; }
.brand-mark.small span:nth-child(3) { height: 22px; }

.app-shell { min-height: 100vh; padding-bottom: calc(84px + env(safe-area-inset-bottom)); background: radial-gradient(circle at 8% 18%, rgba(8,123,114,.055), transparent 28%), radial-gradient(circle at 92% 62%, rgba(95,76,224,.045), transparent 24%), var(--bg); }
.app-header { position: sticky; top: 0; z-index: 20; padding-bottom: 12px; background: rgba(255,255,255,.95); border-bottom: 1px solid rgba(202,217,220,.82); box-shadow: 0 6px 22px rgba(26,55,62,.065); backdrop-filter: blur(14px); }
.brand-row, .device-strip { display: flex; align-items: center; justify-content: space-between; gap: 12px; max-width: 1180px; margin: 0 auto; padding: 12px 18px; }
.brand-row { padding-bottom: 8px; }
.device-strip { width: calc(100% - 32px); margin-top: 0; padding: 4px 12px; border: 1px solid #d4e1e3; border-radius: 12px; background: #fff; box-shadow: 0 4px 14px rgba(30,54,61,.04); }
.brand-compact { display: flex; align-items: center; gap: 10px; }
.brand-compact strong { display: block; font-size: 20px; letter-spacing: -.02em; }
.brand-compact small { display: block; color: var(--muted); margin-top: 2px; }
.device-icon { flex: none; color: var(--brand); font-size: 21px; }
.device-strip select { flex: 1; min-width: 0; height: 46px; padding: 8px 3px; border: 0; background: #fff; box-shadow: none; font-size: 17px; font-weight: 700; }
.device-state { flex: none; border-radius: 9px; padding: 7px 11px; font-size: 13px; font-weight: 800; }
.device-state.online { color: var(--green); background: #e8f8ef; box-shadow: 0 0 18px rgba(37,138,88,.13); animation: online-pulse 2.8s ease-in-out infinite; }
.device-state.offline { color: var(--red); background: #fff0f0; }
.icon-button { width: 42px; height: 42px; flex: none; display: grid; place-items: center; border: 1px solid var(--line); border-radius: 50%; background: #fff; color: var(--brand); font-size: 23px; font-weight: 700; }
.profile-button { border-color: rgba(8,123,114,.55); box-shadow: 0 4px 12px rgba(8,123,114,.08); }
@keyframes online-pulse { 50% { box-shadow: 0 0 22px rgba(37,138,88,.24); } }

.tabs { position: fixed; inset: auto 0 0; z-index: 50; display: grid; grid-template-columns: repeat(3, 1fr); gap: 0; height: calc(70px + env(safe-area-inset-bottom)); padding: 7px max(16px, calc((100vw - 660px) / 2)) env(safe-area-inset-bottom); background: rgba(255,255,255,.94); border-top: 1px solid rgba(207,219,222,.9); box-shadow: 0 -8px 28px rgba(25,49,57,.09); backdrop-filter: blur(16px); }
.tab { position: relative; min-width: 0; height: 56px; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px; border: 0; background: transparent; color: #78878c; font-size: 12px; font-weight: 700; }
.tab > i, .tab-icon-wrap > i { font-size: 23px; line-height: 1; }
.tab.active { color: var(--brand); }
.tab.active::after { content: ""; position: absolute; bottom: 0; width: 28px; height: 3px; border-radius: 3px; background: var(--brand); box-shadow: 0 0 9px rgba(8,123,114,.28); }
.tab-icon-wrap { position: relative; display: grid; place-items: center; }
.badge { position: absolute; top: -8px; right: -18px; display: inline-grid; place-items: center; min-width: 22px; height: 22px; padding: 0 5px; border: 2px solid #fff; border-radius: 12px; background: var(--red); color: #fff; font-size: 11px; box-shadow: 0 3px 8px rgba(216,66,66,.24); }

.view { display: none; max-width: 1180px; margin: 0 auto; padding: 14px 16px 28px; }
.view.active { display: block; }
.summary-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); margin-bottom: 14px; padding: 11px 4px; overflow: hidden; border: 1px solid #d6e2e4; border-radius: 12px; background: rgba(255,255,255,.96); box-shadow: 0 8px 22px rgba(30,54,61,.055); }
.summary-grid article { position: relative; min-width: 0; padding: 5px 10px; text-align: center; }
.summary-grid article + article::before { content: ""; position: absolute; inset: 5px auto 5px 0; width: 1px; background: #e0e8ea; }
.summary-grid span { display: block; color: var(--muted); font-size: 12px; white-space: nowrap; }
.summary-grid strong { display: block; margin-top: 5px; font-size: 23px; font-variant-numeric: tabular-nums; }
.summary-grid .summary-last-update strong { color: var(--brand); font-size: 17px; line-height: 1.25; }
.summary-grid .summary-last-update small { display: block; margin-top: 2px; color: #7a898d; font-size: 11px; }
.command-panel { margin-bottom: 12px; padding: 12px; background: var(--surface); border: 1px solid var(--line); border-radius: 6px; }
.command-panel-head { display: flex; align-items: baseline; justify-content: space-between; gap: 10px; margin-bottom: 8px; }
.command-panel-head h2 { margin: 0; font-size: 15px; }
.command-panel-head span { color: var(--muted); font-size: 12px; }
.command-list { display: grid; gap: 6px; }
.command-item { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 4px 10px; padding: 9px 10px; border: 1px solid #e4ebed; border-left: 4px solid #8c999d; border-radius: 4px; background: var(--surface-muted); }
.command-item.succeeded { border-left-color: var(--green); }
.command-item.failed, .command-item.cancelled { border-left-color: var(--red); }
.command-item-head { display: flex; align-items: center; gap: 8px; }
.command-pill { padding: 2px 6px; border-radius: 3px; background: #e8edef; color: #536267; font-size: 11px; font-weight: 700; }
.command-pill.succeeded { background: #e6f5ed; color: var(--green); }
.command-pill.failed, .command-pill.cancelled { background: #fff0f0; color: var(--red); }
.command-detail { grid-column: 1; color: #526267; font-size: 12px; overflow-wrap: anywhere; }
.command-item time { grid-column: 2; grid-row: 1 / span 2; align-self: center; color: var(--muted); font-size: 11px; white-space: nowrap; }
.command-empty { padding: 14px; text-align: center; color: var(--muted); font-size: 12px; }
.toolbar { display: grid; grid-template-columns: minmax(118px, 1.12fr) minmax(82px, .78fr) minmax(74px, .7fr); gap: 9px; margin-bottom: 14px; }
.search-box { min-width: 0; height: 44px; display: flex; align-items: center; gap: 7px; padding: 0 11px; border: 1px solid #cddadd; border-radius: 9px; background: rgba(255,255,255,.95); color: #66777c; box-shadow: 0 4px 12px rgba(30,54,61,.035); }
.search-box i { flex: none; font-size: 18px; }
.search-box input { min-width: 0; height: 42px; padding: 0; border: 0; background: transparent; box-shadow: none; }

.button { min-height: 42px; display: inline-flex; align-items: center; justify-content: center; gap: 7px; border: 1px solid transparent; border-radius: 9px; padding: 0 15px; font-weight: 750; }
.button.primary { background: linear-gradient(135deg, #0b9187, #087b72 62%, #05645d); color: #fff; box-shadow: 0 8px 18px rgba(8,123,114,.19); }
.button.primary:hover { transform: translateY(-1px); box-shadow: 0 10px 22px rgba(8,123,114,.25); }
.button.secondary { border-color: #c5d3d6; background: rgba(255,255,255,.96); color: #33494f; box-shadow: 0 4px 12px rgba(30,54,61,.035); }
.button.danger { background: #fff0f0; border-color: #f0bcbc; color: var(--red); }
.button.wide { width: 100%; }
.button:disabled { opacity: .52; cursor: not-allowed; }
.refresh-all { position: relative; overflow: hidden; }
.refresh-all::after { content: ""; position: absolute; inset: -20% auto -20% -35%; width: 26%; transform: skewX(-18deg); background: linear-gradient(90deg, transparent, rgba(255,255,255,.7), transparent); animation: button-sheen 4.6s ease-in-out infinite; }
.refresh-all i { font-size: 19px; }
@keyframes button-sheen { 0%, 70% { left: -35%; } 92%, 100% { left: 120%; } }

.row-list { display: grid; gap: 14px; }
.data-card { --card-accent: #08a99c; position: relative; overflow: hidden; border: 1px solid rgba(8,123,114,.22); border-radius: 14px; background: rgba(255,255,255,.97); box-shadow: 0 12px 30px rgba(22,65,69,.11), 0 0 0 1px rgba(255,255,255,.84) inset; transition: transform .2s ease, box-shadow .2s ease; }
.data-card::before { content: ""; position: absolute; inset: 0 0 auto; height: 4px; background: linear-gradient(90deg, var(--brand), var(--card-accent), #38d4d0); box-shadow: 0 0 14px color-mix(in srgb, var(--card-accent) 45%, transparent); }
.data-card:hover { transform: translateY(-2px); box-shadow: 0 16px 34px rgba(22,65,69,.145), 0 0 24px color-mix(in srgb, var(--card-accent) 11%, transparent); }
.data-card.accent-1 { --card-accent: #7759ea; border-color: rgba(94,71,207,.22); }
.data-card.accent-2 { --card-accent: #2778da; border-color: rgba(39,120,218,.2); }
.data-card.failed { --card-accent: var(--red); border-color: rgba(216,66,66,.3); }
.data-card.checking { --card-accent: #8c999d; }
.card-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 16px 15px 10px; }
.remarks { min-width: 0; display: flex; align-items: center; gap: 9px; }
.card-status-dot { width: 8px; height: 8px; flex: none; border-radius: 50%; background: var(--green); box-shadow: 0 0 0 4px rgba(37,138,88,.1), 0 0 12px rgba(37,138,88,.32); }
.remark-title { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 15px; }
.sync-pill { flex: none; padding: 5px 9px; border-radius: 7px; color: var(--green); background: #e8f7ee; font-size: 12px; font-weight: 800; }
.sync-pill.failed, .link-progress-status.failed { color: var(--red); background: #fff0f0; }
.sync-pill.checking, .link-progress-status.checking { color: #66777c; background: #edf1f2; }
.link-progress-group { display: grid; gap: 9px; padding: 0 12px 8px; }
.link-progress { display: grid; grid-template-columns: 108px minmax(0,1fr); align-items: stretch; overflow: hidden; border: 1px solid rgba(8,123,114,.14); border-radius: 10px; background: linear-gradient(90deg, rgba(8,123,114,.105), rgba(255,255,255,.94) 46%); }
.link-progress.sub { border-color: rgba(238,154,35,.28); background: linear-gradient(90deg, rgba(255,171,48,.13), rgba(255,252,247,.97) 48%); }
.link-progress.failed { border-color: rgba(216,66,66,.28); background: linear-gradient(90deg, rgba(216,66,66,.1), #fff 48%); }
.link-progress-identity { display: flex; flex-direction: column; align-items: flex-start; justify-content: center; gap: 5px; padding: 12px 11px; border-right: 1px solid rgba(8,123,114,.1); }
.link-progress-identity strong { font-size: 15px; }
.link-progress.main .link-progress-identity strong { color: #076f68; }
.link-progress.sub .link-progress-identity { border-right-color: rgba(238,154,35,.18); }
.link-progress.sub .link-progress-identity strong { color: #995100; }
.link-progress-status { color: var(--green); font-size: 11px; font-weight: 800; }
.metrics { display: grid; grid-template-columns: repeat(4, minmax(0,1fr)); }
.metric { min-width: 0; padding: 10px 3px 7px; text-align: center; border: 0; background: transparent; color: inherit; }
.metric + .metric { border-left: 1px solid rgba(203,216,219,.6); }
.metric-button { cursor: pointer; }
.metric-button:hover, .metric-button:focus-visible { background: rgba(8,123,114,.07); outline: 2px solid rgba(8,123,114,.18); outline-offset: -2px; }
.metric span { display: block; overflow: hidden; color: var(--muted); font-size: 10px; text-overflow: ellipsis; white-space: nowrap; }
.metric strong { display: block; margin-top: 4px; font-size: 17px; font-variant-numeric: tabular-nums; }
.link-progress.main .metric:last-child strong { color: #078b7f; }
.link-progress.sub .metric:last-child strong { color: #dc7400; }
.metric.speed strong.negative { color: var(--red); }
.progress-track { grid-column: 2; height: 7px; margin: 0 11px 10px; overflow: hidden; border: 1px solid rgba(8,123,114,.1); border-radius: 7px; background: rgba(8,123,114,.06); }
.link-progress.sub .progress-track { border-color: rgba(238,154,35,.18); background: rgba(255,171,48,.07); }
.progress-value { position: relative; display: block; width: var(--progress); height: 100%; min-width: 0; border-radius: inherit; background: linear-gradient(90deg, #069489, #38c9bd); box-shadow: 0 0 10px rgba(8,169,156,.28); overflow: hidden; }
.link-progress.sub .progress-value { background: linear-gradient(90deg, #f59c16, #ffc160); box-shadow: 0 0 10px rgba(245,156,22,.22); }
.progress-value::after { content: ""; position: absolute; inset: 0; transform: translateX(-120%); background: linear-gradient(90deg, transparent, rgba(255,255,255,.8), transparent); animation: progress-sheen 3.8s ease-in-out infinite; }
@keyframes progress-sheen { 55%, 100% { transform: translateX(150%); } }
.card-foot { padding: 1px 13px 13px; }
.link-addresses { display: grid; gap: 5px; padding: 2px 0 8px; }
.link-address { min-width: 0; display: flex; align-items: center; gap: 7px; }
.link-kind { width: 25px; height: 25px; flex: none; display: grid; place-items: center; border-radius: 6px; background: #e6f7ef; color: var(--green); font-size: 12px; font-weight: 900; }
.link-address.sub .link-kind { background: #fff3d8; color: #c66900; }
.link-value { min-width: 0; display: flex; align-items: center; gap: 5px; padding: 3px 0; overflow: hidden; border: 0; background: transparent; color: var(--blue); font: 12px Consolas, monospace; text-align: left; }
.link-value i { flex: none; color: #617278; font-size: 15px; }
.link-value span { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.link-value:hover span, .link-value:focus-visible span { text-decoration: underline; }
.link-password { flex: none; max-width: 110px; overflow: hidden; color: #8a6815; font: 11px Consolas, monospace; text-overflow: ellipsis; white-space: nowrap; }
.card-footer-row { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding-top: 8px; border-top: 1px solid #e8edef; }
.updated { color: #7d8c91; font-size: 11px; white-space: nowrap; }
.card-actions { display: flex; gap: 5px; }
.card-actions button { height: 34px; display: inline-flex; align-items: center; gap: 5px; border: 1px solid #cbd7da; border-radius: 7px; background: #fff; color: #354b51; padding: 0 9px; font-size: 12px; }
.card-actions button:hover { border-color: var(--brand); color: var(--brand); box-shadow: 0 4px 10px rgba(8,123,114,.08); }

.empty-state { padding: 80px 20px; text-align: center; color: var(--muted); background: var(--surface); border: 1px dashed #cbd7da; border-radius: 6px; }
.section-heading { display: flex; justify-content: space-between; align-items: center; gap: 12px; margin-bottom: 12px; }
.section-heading h2 { margin: 0; font-size: 20px; }
.section-heading p { margin: 4px 0 0; color: var(--muted); font-size: 13px; }
.section-actions { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: 8px; }
.alert-list, .user-list { display: grid; gap: 8px; }
.alert-item, .user-item, .setting-card { padding: 13px; background: var(--surface); border: 1px solid var(--line); border-radius: 6px; }
.alert-item { border-left: 4px solid var(--red); }
.alert-item.acknowledged { opacity: .65; border-left-color: #9aa6a9; }
.alert-top { display: flex; justify-content: space-between; gap: 10px; align-items: center; }
.user-item { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 12px; align-items: center; }
.user-card-main { min-width: 0; }
.user-card-main > strong { font-size: 15px; }
.user-access-summary { margin-top: 7px; color: #35635f; font-size: 12px; line-height: 1.5; overflow-wrap: anywhere; }
.user-access-summary.empty { color: var(--red); }
.user-card-actions { display: grid; justify-items: end; gap: 8px; }
.user-access-button { min-height: 34px; padding: 0 11px; font-size: 12px; }
.alert-item h3 { margin: 0 0 5px; font-size: 15px; }
.alert-item p { margin: 0; color: #45565b; line-height: 1.55; }
.alert-item time { display: block; margin-top: 7px; color: var(--muted); font-size: 12px; }
.setting-card { display: grid; grid-template-columns: 1fr auto; gap: 8px 12px; align-items: center; }
.setting-card span { color: var(--muted); }
.setting-card strong { grid-row: 2; font: 700 28px Consolas, monospace; letter-spacing: 2px; }
.setting-card button { grid-column: 2; grid-row: 1 / span 2; }
.users-heading { margin-top: 22px; }
.user-meta { color: var(--muted); font-size: 13px; }
.device-access-fieldset { min-width: 0; margin: 0; padding: 11px; border: 1px solid var(--line); border-radius: 8px; }
.device-access-fieldset legend { padding: 0 5px; color: #45555a; font-weight: 700; }
.device-access-fieldset > small { display: block; margin-top: 8px; color: var(--muted); }
.device-access-fieldset:disabled { opacity: .58; }
.device-access-list { display: grid; gap: 7px; max-height: 220px; overflow-y: auto; }
.device-access-list.standalone { max-height: min(52vh, 360px); margin: 15px 0 5px; padding: 2px; }
.device-access-option { min-width: 0; display: flex !important; grid-template-columns: none !important; align-items: center; gap: 10px !important; padding: 9px 10px; border: 1px solid #dce7e9; border-radius: 7px; background: #f8fbfb; cursor: pointer; }
.device-access-option:has(input:checked) { border-color: rgba(8,123,114,.45); background: #eaf7f4; box-shadow: 0 0 0 2px rgba(8,123,114,.06); }
.device-access-option input { width: 18px; height: 18px; flex: none; accent-color: var(--brand); }
.device-access-option span { min-width: 0; }
.device-access-option strong, .device-access-option small { display: block; }
.device-access-option small { margin-top: 2px; color: var(--muted); font-weight: 400; }
.device-access-empty { padding: 18px 10px; text-align: center; color: var(--muted); }

.modal { width: min(680px, calc(100vw - 24px)); max-height: calc(100vh - 24px); padding: 0; border: 0; border-radius: 7px; box-shadow: 0 20px 70px rgba(0,0,0,.25); }
.modal.compact { width: min(430px, calc(100vw - 24px)); }
.modal::backdrop { background: rgba(14, 27, 31, .52); }
.modal form, .dialog-body { padding: 18px; }
.profile-password { display: grid; gap: 12px; margin: 18px 0; padding: 16px 0; border-top: 1px solid var(--line); border-bottom: 1px solid var(--line); }
.profile-password label { display: grid; gap: 6px; color: var(--muted); font-size: 14px; }
.profile-password input { width: 100%; }
.modal header { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 18px; }
.modal h2 { margin: 0; font-size: 21px; }
.close-button { width: 36px; height: 36px; border: 0; background: transparent; color: #7b898d; font-size: 27px; line-height: 1; }
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; max-height: calc(100vh - 230px); overflow-y: auto; padding: 2px; }
.form-grid.one-column { grid-template-columns: 1fr; }
.form-grid .full { grid-column: 1 / -1; }
.form-grid small { color: var(--muted); font-weight: 400; }
.modal footer { display: flex; justify-content: flex-end; gap: 9px; margin-top: 18px; }
.form-error { min-height: 20px; color: var(--red); font-size: 13px; }

.archive-modal { width: min(920px, calc(100vw - 24px)); }
.archive-dialog-body { display: flex; flex-direction: column; height: min(780px, calc(100vh - 32px)); min-height: 430px; padding: 18px; overflow: hidden; }
.archive-dialog-body header { flex: none; margin-bottom: 12px; }
.dialog-subtitle { margin: 4px 0 0; color: var(--muted); font-size: 13px; }
.archive-context { flex: none; display: flex; align-items: center; gap: 10px; margin-bottom: 12px; }
.archive-source { min-width: 0; flex: 1; display: grid; gap: 6px; }
.archive-link, .archive-password { min-width: 0; padding: 9px 10px; border: 1px solid var(--line); background: var(--surface-muted); color: #4a5c61; font: 13px Consolas, monospace; white-space: normal; overflow-wrap: anywhere; word-break: break-word; user-select: text; }
.archive-password { color: #805d08; background: #fff9e8; border-color: #ead79b; }
.history-list, .account-list { flex: 1 1 auto; min-height: 0; overflow-y: auto; scrollbar-gutter: stable; border: 1px solid var(--line); background: var(--surface-muted); }
.history-list { display: grid; align-content: start; gap: 8px; padding: 8px; }
.history-card { background: var(--surface); border: 1px solid var(--line); border-left: 4px solid var(--green); }
.history-card.failed { border-left-color: var(--red); }
.history-card-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 10px; border-bottom: 1px solid #edf1f2; }
.history-card-head time { color: var(--muted); font-size: 13px; font-variant-numeric: tabular-nums; }
.history-metrics { display: grid; grid-template-columns: repeat(6, minmax(0, 1fr)); }
.archive-metric { min-width: 0; padding: 10px 5px; text-align: center; border-right: 1px solid #edf1f2; }
.archive-metric:last-child { border-right: 0; }
.archive-metric span { display: block; color: var(--muted); font-size: 11px; white-space: nowrap; }
.archive-metric strong { display: block; margin-top: 4px; font-size: 17px; font-variant-numeric: tabular-nums; }
.history-actions { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 9px 10px; border-top: 1px solid #edf1f2; }
.account-count { color: var(--muted); font-size: 12px; }
.dialog-loading, .dialog-empty { padding: 70px 20px; text-align: center; color: var(--muted); }
.dialog-empty { flex: 1 1 auto; border: 1px dashed var(--line); }
.account-toolbar { display: grid; grid-template-columns: minmax(0, 1fr) 140px auto; }
.account-toolbar input, .account-toolbar select { height: 42px; }
.account-summary { flex: none; margin-bottom: 8px; padding: 8px 10px; background: #edf6f4; color: #46605e; font-size: 13px; }
.account-list { display: grid; align-content: start; }
.account-card { padding: 11px 12px; background: var(--surface); border-bottom: 1px solid var(--line); }
.account-card:last-child { border-bottom: 0; }
.account-card-head, .account-change { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.account-identity { min-width: 0; }
.account-identity strong { display: block; font: 700 14px Consolas, monospace; overflow-wrap: anywhere; }
.account-identity span { display: block; margin-top: 3px; color: var(--muted); font-size: 12px; }
.account-status { flex: none; font-weight: 700; color: var(--green); }
.account-change { margin-top: 9px; padding-top: 8px; border-top: 1px solid #edf1f2; color: var(--muted); font-size: 12px; }
.account-change strong { color: var(--blue); }
.account-change span:last-child { min-width: 0; flex: 1; text-align: right; overflow-wrap: anywhere; }

.toast-region { position: fixed; z-index: 100; right: 14px; bottom: 16px; display: grid; gap: 8px; width: min(360px, calc(100vw - 28px)); pointer-events: none; }
.toast { padding: 12px 14px; border-radius: 5px; background: #233338; color: #fff; box-shadow: var(--shadow); animation: toast-in .2s ease-out; }
.toast.error { background: #a92d2d; }
@keyframes toast-in { from { transform: translateY(10px); opacity: 0; } }

@media (min-width: 760px) {
  .brand-row, .device-strip { max-width: 820px; }
  .device-strip { width: calc(100% - 36px); }
  .row-list { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

@media (max-width: 430px) {
  .app-shell { padding-bottom: calc(70px + env(safe-area-inset-bottom)); }
  .app-header { padding-bottom: 7px; }
  .brand-row { padding: 8px 12px 6px; }
  .brand-mark.small { width: 34px; height: 34px; padding: 7px; }
  .brand-mark.small span:nth-child(1) { height: 9px; }
  .brand-mark.small span:nth-child(2) { height: 14px; }
  .brand-mark.small span:nth-child(3) { height: 20px; }
  .brand-compact strong { font-size: 19px; }
  .brand-compact small { margin-top: 0; font-size: 11px; }
  .icon-button { width: 38px; height: 38px; font-size: 21px; }
  .device-strip { width: calc(100% - 20px); padding: 2px 9px; border-radius: 10px; }
  .device-strip select { height: 39px; padding-top: 5px; padding-bottom: 5px; font-size: 16px; }
  .device-state { padding: 5px 9px; font-size: 12px; }
  .view { padding: 8px 10px 20px; }
  .summary-grid { margin-bottom: 8px; padding: 7px 2px; border-radius: 10px; }
  .summary-grid article { padding: 3px 5px; }
  .summary-grid span { font-size: 10px; }
  .summary-grid strong { margin-top: 3px; font-size: 20px; }
  .summary-grid .summary-last-update strong { font-size: 14px; }
  .summary-grid .summary-last-update small { margin-top: 0; font-size: 10px; }
  .toolbar { grid-template-columns: minmax(114px, 1.15fr) minmax(76px, .78fr) minmax(70px, .7fr); gap: 7px; margin-bottom: 9px; }
  .toolbar .button { width: 100%; padding-left: 8px; padding-right: 8px; }
  .toolbar .button, .search-box { min-height: 39px; height: 39px; }
  .search-box { padding-left: 9px; padding-right: 9px; }
  .search-box input { height: 37px; }
  .row-list { gap: 10px; }
  .data-card { border-radius: 12px; }
  .section-heading { align-items: flex-start; }
  .section-actions { max-width: 190px; }
  .card-head { padding: 12px 12px 7px; }
  .remark-title { font-size: 14px; }
  .sync-pill { padding: 4px 7px; font-size: 11px; }
  .link-progress-group { gap: 7px; padding: 0 10px 6px; }
  .link-progress { grid-template-columns: 92px minmax(0,1fr); }
  .link-progress-identity { gap: 3px; padding: 8px 7px 8px 9px; }
  .link-progress-identity strong { font-size: 14px; }
  .link-progress-status { font-size: 10px; }
  .metric { padding: 7px 1px 5px; }
  .metric span { font-size: 9px; }
  .metric strong { margin-top: 2px; font-size: 16px; }
  .progress-track { height: 5px; margin: 0 9px 7px; }
  .card-foot { padding: 1px 11px 9px; }
  .link-addresses { gap: 3px; padding: 1px 0 5px; }
  .link-kind { width: 22px; height: 22px; border-radius: 5px; font-size: 11px; }
  .link-value { gap: 4px; padding: 1px 0; font-size: 11px; }
  .link-value i { font-size: 13px; }
  .card-footer-row { gap: 7px; padding-top: 6px; }
  .updated { font-size: 10px; }
  .card-actions { justify-content: flex-end; }
  .card-actions button { height: 31px; gap: 3px; padding-left: 7px; padding-right: 7px; font-size: 11px; }
  .tabs { height: calc(62px + env(safe-area-inset-bottom)); padding-top: 4px; }
  .tab { height: 52px; }
  .tab > i, .tab-icon-wrap > i { font-size: 21px; }
  .form-grid { grid-template-columns: 1fr; }
  .form-grid .full { grid-column: auto; }
  .archive-modal { width: calc(100vw - 12px); max-height: calc(100dvh - 12px); }
  .archive-dialog-body { height: calc(100dvh - 12px); min-height: 0; padding: 12px; }
  .archive-context { align-items: stretch; }
  .history-metrics { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .archive-metric:nth-child(-n+3) { border-bottom: 1px solid #edf1f2; }
  .archive-metric:nth-child(3), .archive-metric:nth-child(6) { border-right: 0; }
  .account-toolbar { grid-template-columns: minmax(0, 1fr) 116px; }
  .account-toolbar .button { grid-column: 1 / -1; }
  .account-card-head, .account-change { align-items: flex-start; }
  .account-change { flex-wrap: wrap; }
  .user-item { align-items: start; }
  .user-card-actions { min-width: 82px; }
}

@media (max-width: 350px) {
  .toolbar { grid-template-columns: 1fr 1fr; }
  .toolbar .refresh-all { grid-column: 1 / -1; }
  .link-progress { grid-template-columns: 78px minmax(0,1fr); }
  .link-progress-identity strong { font-size: 13px; }
  .card-footer-row { align-items: flex-start; flex-direction: column; }
  .card-actions { width: 100%; }
  .card-actions button { flex: 1; justify-content: center; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; animation-duration: .01ms !important; animation-iteration-count: 1 !important; transition-duration: .01ms !important; }
}
