:root {
  color-scheme: light;
  --bg: #f4f6f9;
  --surface: #ffffff;
  --surface-subtle: #f8fafc;
  --text: #172033;
  --muted: #58667c;
  --border: #dbe2ea;
  --primary: #183b61;
  --primary-hover: #102f50;
  --on-primary: #ffffff;
  --accent: #147a4c;
  --accent-soft: #e5f5ec;
  --danger: #b42318;
  --danger-soft: #feeeec;
  --warning: #8a5600;
  --warning-soft: #fff4d6;
  --focus: #2f71b5;
  --shadow: 0 1px 2px rgb(15 23 42 / 0.05), 0 4px 16px rgb(15 23 42 / 0.04);
}

:root[data-theme="dark"] {
  color-scheme: dark;
  --bg: #0b1220;
  --surface: #111a2b;
  --surface-subtle: #162135;
  --text: #edf2f8;
  --muted: #a9b6c8;
  --border: #2a3950;
  --primary: #7db2e8;
  --primary-hover: #9bc5ed;
  --on-primary: #0b1b2e;
  --accent: #69d397;
  --accent-soft: #153b2a;
  --danger: #ff8b82;
  --danger-soft: #45221f;
  --warning: #ffd06b;
  --warning-soft: #423317;
  --focus: #8bc4ff;
  --shadow: 0 1px 2px rgb(0 0 0 / 0.2), 0 8px 24px rgb(0 0 0 / 0.16);
}

@media (prefers-color-scheme: dark) {
  :root[data-theme="auto"] {
    color-scheme: dark;
    --bg: #0b1220; --surface: #111a2b; --surface-subtle: #162135;
    --text: #edf2f8; --muted: #a9b6c8; --border: #2a3950;
    --primary: #7db2e8; --primary-hover: #9bc5ed; --on-primary: #0b1b2e;
    --accent: #69d397; --accent-soft: #153b2a;
    --danger: #ff8b82; --danger-soft: #45221f;
    --warning: #ffd06b; --warning-soft: #423317;
    --focus: #8bc4ff; --shadow: 0 1px 2px rgb(0 0 0 / 0.2), 0 8px 24px rgb(0 0 0 / 0.16);
  }
}

* { box-sizing: border-box; }
html { min-width: 320px; background: var(--bg); }
body { margin: 0; color: var(--text); background: var(--bg); font: 16px/1.55 "Segoe UI", "Microsoft YaHei", system-ui, sans-serif; }
a { color: var(--primary); text-decoration-thickness: 1px; text-underline-offset: 3px; }
a:hover { text-decoration-thickness: 2px; }
button, input, select, textarea { font: inherit; }
button, a { touch-action: manipulation; }
:focus-visible { outline: 3px solid var(--focus); outline-offset: 2px; }
h1, h2, h3, p { margin-top: 0; }
h1 { margin-bottom: 4px; font-size: clamp(1.55rem, 2vw, 2rem); line-height: 1.25; }
h2 { margin-bottom: 4px; font-size: 1.12rem; }
h3 { font-size: 1rem; }
.muted, .page-header p, .panel-header p { color: var(--muted); }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; border: 0; }
.skip-link { position: fixed; z-index: 1000; top: 8px; left: 8px; padding: 10px 14px; background: var(--surface); transform: translateY(-150%); }
.skip-link:focus { transform: translateY(0); }

.app-shell { min-height: 100dvh; display: grid; grid-template-columns: 240px minmax(0, 1fr); }
.sidebar { position: sticky; top: 0; height: 100dvh; display: flex; flex-direction: column; gap: 28px; padding: 24px 16px; color: #eaf0f7; background: #132b46; }
.brand { display: flex; align-items: center; gap: 12px; color: #fff; text-decoration: none; }
.brand small { display: block; margin-top: 1px; color: #aebfd2; font-size: .72rem; letter-spacing: .08em; }
.brand-mark { width: 40px; height: 40px; display: inline-grid; place-items: center; flex: 0 0 auto; border-radius: 10px; color: #122a45; background: #e7f0f8; font-weight: 800; }
.nav-list { display: grid; gap: 4px; }
.nav-list a { min-height: 44px; display: flex; align-items: center; padding: 9px 12px; border-radius: 8px; color: #c8d6e5; text-decoration: none; font-weight: 600; transition: background-color 160ms ease, color 160ms ease; }
.nav-list a:hover { color: #fff; background: rgb(255 255 255 / .08); }
.nav-list a[aria-current="page"] { color: #fff; background: #244d76; box-shadow: inset 3px 0 0 #87c7a5; }
.sidebar-footer { margin-top: auto; padding: 12px; border-top: 1px solid rgb(255 255 255 / .15); }
.user-name { display: block; margin-bottom: 4px; font-weight: 600; }
.footer-link { min-height: 36px; display: inline-flex; align-items: center; margin-right: 12px; color: #bdcad8; font-size: .88rem; }
.text-button { min-height: 44px; padding: 0; border: 0; color: #bdcad8; background: transparent; cursor: pointer; text-decoration: underline; text-underline-offset: 3px; }
.content-shell { min-width: 0; }
.topbar { min-height: 72px; display: flex; align-items: center; justify-content: space-between; gap: 16px; padding: 12px clamp(16px, 3vw, 36px); border-bottom: 1px solid var(--border); background: color-mix(in srgb, var(--surface) 94%, transparent); }
.topbar strong { font-size: 1.05rem; }
.eyebrow { margin-bottom: 0; color: var(--muted); font-size: .72rem; font-weight: 700; letter-spacing: .09em; text-transform: uppercase; }
.theme-toggle { min-height: 44px; padding: 8px 12px; border: 1px solid var(--border); border-radius: 8px; color: var(--text); background: var(--surface); cursor: pointer; }
.main-content { width: 100%; max-width: 1480px; margin-inline: auto; padding: clamp(20px, 3vw, 36px); }
.page-header { display: flex; align-items: flex-start; justify-content: space-between; gap: 24px; margin-bottom: 24px; }
.page-header p { margin-bottom: 0; }
.page-actions { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: 8px; }

.button { min-height: 44px; display: inline-flex; align-items: center; justify-content: center; padding: 9px 16px; border: 1px solid transparent; border-radius: 8px; cursor: pointer; font-weight: 700; text-decoration: none; transition: background-color 160ms ease, border-color 160ms ease; }
.button-primary { color: var(--on-primary); background: var(--primary); }
.button-primary:hover { color: var(--on-primary); background: var(--primary-hover); }
.button-secondary { color: var(--primary); border-color: var(--border); background: var(--surface); }
.button-secondary:hover, .button-ghost:hover { background: var(--surface-subtle); }
.button-ghost { color: var(--text); background: transparent; }
.button-danger { color: #fff; background: var(--danger); }
.button-danger:hover { color: #fff; background: color-mix(in srgb, var(--danger) 85%, #000); }
.button-block { width: 100%; }
.button:disabled { cursor: not-allowed; opacity: .48; }

.stats-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 16px; margin-bottom: 24px; }
.stats-grid-small { grid-template-columns: repeat(2, minmax(0, 260px)); }
.stat-card, .panel, .form-panel, .asset-card { border: 1px solid var(--border); border-radius: 12px; background: var(--surface); box-shadow: var(--shadow); }
.stat-card { padding: 18px; color: var(--text); text-decoration: none; }
.stat-card:hover { border-color: color-mix(in srgb, var(--primary) 45%, var(--border)); }
.stat-card-warning { border-color: color-mix(in srgb, var(--warning) 48%, var(--border)); background: color-mix(in srgb, var(--warning-soft) 45%, var(--surface)); }
.stat-card span, .stat-card small { display: block; color: var(--muted); }
.stat-card strong { display: block; margin: 6px 0 2px; font-size: 1.9rem; font-variant-numeric: tabular-nums; line-height: 1.2; }
.panel { margin-bottom: 24px; padding: 20px; }
.panel-flush { padding: 0; overflow: hidden; }
.panel-header { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; margin-bottom: 16px; }
.panel-header p { margin-bottom: 0; }
.empty-state { padding: 36px 18px; text-align: center; color: var(--muted); }
.empty-state strong { display: block; margin-bottom: 4px; color: var(--text); font-size: 1.05rem; }

.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
th, td { padding: 13px 16px; border-bottom: 1px solid var(--border); text-align: left; vertical-align: middle; }
th { color: var(--muted); background: var(--surface-subtle); font-size: .78rem; letter-spacing: .02em; white-space: nowrap; }
tbody tr:last-child td { border-bottom: 0; }
tbody tr:hover { background: color-mix(in srgb, var(--surface-subtle) 70%, transparent); }
.table-subtext { display: block; margin-top: 2px; color: var(--muted); }
.table-value { display: block; min-width: 0; }
.table-action { display: inline-flex; min-height: 44px; align-items: center; font-weight: 700; white-space: nowrap; }
.asset-number { color: var(--primary); font-family: "Cascadia Mono", Consolas, monospace; font-size: .92rem; font-variant-numeric: tabular-nums; font-weight: 700; }
.status { display: inline-flex; align-items: center; min-height: 28px; padding: 3px 9px; border-radius: 999px; color: var(--muted); background: var(--surface-subtle); font-size: .8rem; font-weight: 700; white-space: nowrap; }
.status-in_use, .status-approved, .status-active { color: var(--accent); background: var(--accent-soft); }
.status-seen, .status-completed { color: var(--accent); background: var(--accent-soft); }
.status-pending, .status-due, .status-inactive { color: var(--warning); background: var(--warning-soft); }
.status-scrapped, .status-rejected, .status-missing, .status-exception, .status-expired, .status-archived { color: var(--danger); background: var(--danger-soft); }

.filter-bar { display: flex; align-items: flex-end; gap: 12px; margin-bottom: 16px; padding: 16px; border: 1px solid var(--border); border-radius: 12px; background: var(--surface); }
.filter-bar.compact { justify-content: flex-end; }
.field-grow { flex: 1 1 320px; }
.stack-form { display: grid; gap: 18px; }
.asset-registration-form { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px 18px; }
.asset-registration-form > .asset-type-fields,
.asset-registration-form > .form-actions,
.asset-registration-form > .form-errors,
.asset-registration-form > .form-note { grid-column: 1 / -1; }
.field { display: grid; gap: 6px; min-width: 180px; }
.field label { font-size: .9rem; font-weight: 700; }
.required { color: var(--danger); }
input, select, textarea { width: 100%; min-height: 44px; padding: 9px 11px; border: 1px solid var(--border); border-radius: 8px; color: var(--text); background: var(--surface); }
input[type="checkbox"] { width: 20px; min-height: 20px; padding: 0; accent-color: var(--primary); }
.field > div { display: grid; gap: 8px; }
.field > div > div label { min-height: 44px; display: flex; align-items: center; gap: 10px; padding: 8px 10px; border: 1px solid var(--border); border-radius: 8px; background: var(--surface-subtle); font-weight: 500; cursor: pointer; }
textarea { resize: vertical; }
input:hover, select:hover, textarea:hover { border-color: color-mix(in srgb, var(--primary) 55%, var(--border)); }
.field-error input, .field-error select, .field-error textarea { border-color: var(--danger); }
.help-text, .error-text { color: var(--muted); font-size: .82rem; }
.error-text { color: var(--danger); font-weight: 600; }
.form-errors { padding: 12px 14px; border: 1px solid var(--danger); border-radius: 8px; color: var(--danger); background: var(--danger-soft); }
.form-errors p { margin: 0; }
.form-panel { max-width: 720px; padding: clamp(20px, 3vw, 28px); }
.form-actions { display: flex; justify-content: flex-end; gap: 8px; padding-top: 4px; }
.form-note { padding: 12px 14px; border-left: 3px solid var(--primary); color: var(--muted); background: var(--surface-subtle); }
.asset-type-fields { display: grid; gap: 12px; margin: 0; padding: 16px; border: 1px solid var(--border); border-radius: 10px; background: var(--surface-subtle); }
.asset-type-fields[hidden] { display: none; }
.asset-type-fields legend { padding: 0 6px; color: var(--text); font-weight: 700; }
.asset-type-fields > .help-text { margin: 0; }
.asset-type-field-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px; }
.danger-confirm { border-color: color-mix(in srgb, var(--danger) 40%, var(--border)); }
.danger-confirm > strong { display: block; color: var(--danger); font-size: 1.15rem; }
.danger-confirm > p { margin: 8px 0 24px; color: var(--muted); }

.detail-grid { display: grid; grid-template-columns: minmax(0, 1fr) minmax(360px, .8fr); gap: 20px; align-items: start; }
.detail-grid-review { grid-template-columns: minmax(0, 1fr) minmax(360px, .9fr); }
.detail-list { margin: 0; }
.detail-list > div { display: grid; grid-template-columns: 130px minmax(0, 1fr); gap: 16px; padding: 11px 0; border-bottom: 1px solid var(--border); }
.detail-list dt { color: var(--muted); }
.detail-list dd { margin: 0; }
.custom-fields { margin-top: 20px; }
.custom-fields pre { overflow: auto; padding: 14px; border-radius: 8px; background: var(--surface-subtle); white-space: pre-wrap; }
.compact-detail-list > div { grid-template-columns: minmax(110px, .35fr) minmax(0, 1fr); }
.timeline { position: relative; margin: 0; padding: 0; list-style: none; }
.timeline li { display: grid; grid-template-columns: 18px 1fr; gap: 10px; padding-bottom: 20px; }
.timeline li:not(:last-child)::before { content: ""; position: absolute; left: 6px; margin-top: 13px; width: 2px; height: 54px; background: var(--border); }
.timeline-dot { width: 14px; height: 14px; margin-top: 5px; border: 3px solid var(--surface); border-radius: 50%; background: var(--accent); box-shadow: 0 0 0 1px var(--accent); }
.timeline p { margin: 2px 0; color: var(--muted); }
.timeline small { color: var(--muted); }

.asset-card-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(250px, 1fr)); gap: 16px; }
.asset-card { display: grid; gap: 8px; padding: 18px; color: var(--text); text-decoration: none; }
.asset-card:hover { border-color: color-mix(in srgb, var(--primary) 45%, var(--border)); }
.asset-card small, .asset-card p { color: var(--muted); }
.asset-card-static { display: block; }
.asset-card-heading { display: flex; justify-content: space-between; gap: 12px; }
.asset-card-static h2 { margin: 14px 0 4px; }
.asset-card-static p { margin-bottom: 18px; }
.card-actions { min-height: 44px; display: flex; flex-wrap: wrap; align-items: center; gap: 6px; }
.pending-note { color: var(--warning); font-weight: 700; }

.dashboard-grid { display: grid; grid-template-columns: minmax(0, 1.45fr) minmax(300px, .55fr); gap: 20px; align-items: start; }
.dashboard-grid > .panel { margin-bottom: 0; }
.resource-panel-header { margin: 0; padding: 20px; }
.reminder-stack, .grant-list, .resource-side-stack { display: grid; gap: 10px; }
.reminder-item, .grant-item { min-height: 56px; display: flex; align-items: center; justify-content: space-between; gap: 14px; padding: 10px 0; border-bottom: 1px solid var(--border); color: var(--text); text-decoration: none; }
.reminder-item:last-child, .grant-item:last-child { border-bottom: 0; }
.reminder-item small, .grant-item small { display: block; color: var(--muted); }
.grant-item a { min-height: 44px; display: inline-flex; align-items: center; }
.resource-side-stack > .panel { margin-bottom: 0; }
.tag-list { display: flex; flex-wrap: wrap; gap: 8px; }
.tag-list a { min-height: 36px; display: inline-flex; align-items: center; padding: 5px 10px; border: 1px solid var(--border); border-radius: 999px; background: var(--surface-subtle); text-decoration: none; }
.compact-tags { gap: 6px; }
.compact-tags span { display: inline-flex; align-items: center; padding: 3px 8px; border: 1px solid var(--border); border-radius: 999px; background: var(--surface-subtle); font-size: .78rem; font-weight: 600; }
.compact-empty { padding: 18px 0 0; }
.secondary-action-row { display: flex; justify-content: flex-end; margin-top: 4px; }
.danger-link { min-height: 44px; display: inline-flex; align-items: center; color: var(--danger); }
.shop-summary { padding: 0; }
.shop-summary dl { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); margin: 0; }
.shop-summary dl div { padding: 18px 20px; border-right: 1px solid var(--border); }
.shop-summary dl div:last-child { border-right: 0; }
.shop-summary dt { color: var(--muted); font-size: .82rem; }
.shop-summary dd { margin: 4px 0 0; font-size: 1.05rem; font-weight: 700; }

.resource-operations-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 20px; align-items: start; margin-top: 20px; }
.resource-operations-grid > .panel { margin-bottom: 0; }
.resource-operations-grid .panel-header > a { white-space: nowrap; }
.attachment-list, .credential-list, .version-list { display: grid; gap: 10px; }
.attachment-item, .credential-item { padding: 14px; border: 1px solid var(--border); border-radius: 10px; background: var(--surface-subtle); }
.attachment-heading, .credential-item { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; }
.attachment-heading small, .version-list small { display: block; color: var(--muted); }
.attachment-heading > a { min-height: 44px; display: inline-flex; align-items: center; white-space: nowrap; }
.attachment-item details { margin-top: 10px; }
.attachment-item summary { min-height: 44px; display: flex; align-items: center; color: var(--primary); cursor: pointer; font-weight: 700; }
.version-list > div { min-height: 52px; display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; padding: 12px 0; border-top: 1px solid var(--border); }
.version-main { min-width: 0; }
.version-title-row { display: flex; flex-wrap: wrap; align-items: center; gap: 7px; overflow-wrap: anywhere; }
.version-title-row > strong { color: var(--primary); font-variant-numeric: tabular-nums; }
.version-note { margin: 7px 0 0; color: var(--text); font-size: .88rem; }
.version-actions { display: flex; flex: 0 0 auto; flex-wrap: wrap; align-items: center; justify-content: flex-end; gap: 8px; }
.version-actions form { margin: 0; }
.version-actions .button { min-height: 44px; white-space: nowrap; }
.status-current { color: var(--accent); background: var(--accent-soft); }
.credential-item h3 { margin: 8px 0 2px; }
.credential-item p { margin-bottom: 8px; color: var(--muted); }
.credential-item code { display: block; color: var(--muted); letter-spacing: .12em; }
.credential-actions { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: 8px; }
.credential-actions form { margin: 0; }
.copy-feedback { min-height: 24px; margin: 10px 0 0; color: var(--accent); font-weight: 700; }
.security-note { padding: 14px; border: 1px solid color-mix(in srgb, var(--accent) 35%, var(--border)); border-radius: 10px; background: var(--accent-soft); }
.security-note strong { color: var(--accent); }
.security-note p { margin: 4px 0 0; color: var(--muted); }
.mfa-qr-panel { text-align: center; }
.mfa-qr-panel .panel-header { text-align: left; }
.mfa-qr { width: min(280px, 100%); margin: 12px auto 0; padding: 12px; border-radius: 12px; background: #fff; }
.compact-auth-form { max-width: 560px; }
.recovery-code-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
.recovery-code-grid code { padding: 12px; border: 1px solid var(--border); border-radius: 8px; background: var(--surface-subtle); text-align: center; font-size: 1rem; letter-spacing: .08em; }
.compact-detail-list { margin-bottom: 16px; }
.revealed-secret { max-width: 760px; }
.revealed-secret > label { display: block; margin: 18px 0 6px; font-weight: 700; }
.revealed-secret textarea { font-family: "Cascadia Mono", Consolas, monospace; }

.step-list { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; margin: 0 0 20px; padding: 0; list-style: none; }
.step-list li { min-height: 54px; display: flex; align-items: center; gap: 10px; padding: 10px 12px; border: 1px solid var(--border); border-radius: 10px; color: var(--muted); background: var(--surface); }
.step-list li strong { width: 28px; height: 28px; display: inline-grid; place-items: center; flex: 0 0 auto; border-radius: 50%; background: var(--surface-subtle); font-variant-numeric: tabular-nums; }
.step-list li[aria-current="step"] { color: var(--text); border-color: color-mix(in srgb, var(--primary) 45%, var(--border)); }
.step-list li[aria-current="step"] strong { color: var(--on-primary); background: var(--primary); }
.import-layout { display: grid; grid-template-columns: minmax(0, 1fr) minmax(280px, .42fr); gap: 20px; align-items: start; }
.import-layout .form-panel { width: 100%; max-width: none; }
.import-guide ul { margin-bottom: 0; padding-left: 20px; color: var(--muted); }
.import-guide li + li { margin-top: 7px; }
.stack-actions { display: grid; gap: 8px; margin: 16px 0 24px; }
.import-error-summary { margin-bottom: 16px; }
.import-error-summary p { margin-top: 4px; }
.row-error { background: color-mix(in srgb, var(--danger-soft) 55%, var(--surface)); }
.import-row-error { display: block; margin-top: 5px; max-width: 300px; }
.confirm-bar { display: flex; align-items: center; justify-content: space-between; gap: 20px; padding: 16px 18px; border: 1px solid var(--border); border-radius: 12px; background: var(--surface); box-shadow: var(--shadow); }
.confirm-bar span { color: var(--muted); }
.handoff-selection { margin-top: 20px; }
.handoff-summary { max-width: 760px; }
.organization-layout { display: grid; grid-template-columns: minmax(0, 1fr) minmax(280px, .34fr); gap: 20px; align-items: start; }
.organization-layout > .panel { margin-bottom: 0; }
.organization-member-form { position: sticky; top: 92px; }
.organization-member-form .button { width: 100%; }
.member-actions { min-height: 44px; display: flex; flex-wrap: wrap; align-items: center; justify-content: flex-end; gap: 8px; }
.member-actions form { margin: 0; }
.member-actions .text-button, .member-actions .danger-link { min-height: 44px; display: inline-flex; align-items: center; }

.system-stats { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.system-section-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 16px; }
.system-section-card { min-height: 190px; display: flex; flex-direction: column; padding: 20px; border: 1px solid var(--border); border-radius: 12px; color: var(--text); background: var(--surface); box-shadow: var(--shadow); text-decoration: none; transition: border-color 160ms ease, background-color 160ms ease; }
.system-section-card:hover { border-color: color-mix(in srgb, var(--primary) 45%, var(--border)); background: color-mix(in srgb, var(--surface-subtle) 55%, var(--surface)); }
.system-section-card strong { font-size: 1.12rem; }
.system-section-card p { margin: 8px 0 18px; color: var(--muted); }
.system-section-card span { min-height: 44px; display: flex; align-items: center; margin-top: auto; color: var(--primary); font-weight: 700; }
.account-form { max-width: 820px; }
.form-section { display: grid; gap: 16px; margin: 0; padding: 18px; border: 1px solid var(--border); border-radius: 10px; background: var(--surface-subtle); }
.form-section legend { padding: 0 7px; color: var(--text); font-weight: 700; }
.compact-page-header { margin-bottom: 10px; }
.compact-account-form { gap: 10px; max-width: 860px; padding: 14px; }
.compact-form-section { gap: 10px; padding: 10px; }
.account-field-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px 16px; }
.account-field-grid .field { align-content: start; min-width: 0; }
.compact-form-note { padding-block: 10px; }
.role-form-section .field > div { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.role-summary-list { display: grid; gap: 12px; }
.role-summary-list > div { padding: 12px; border: 1px solid var(--border); border-radius: 9px; background: var(--surface-subtle); }
.role-summary-list small { display: block; margin-top: 3px; color: var(--muted); }
.role-boundary-note { margin-bottom: 20px; }
.role-card-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; }
.role-card { display: flex; flex-direction: column; margin-bottom: 0; }
.role-card-heading { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; }
.role-card-heading p { margin-bottom: 0; color: var(--muted); }
.role-card ul { margin: 18px 0; padding-left: 20px; color: var(--muted); }
.role-card li + li { margin-top: 6px; }
.role-card > .table-action { align-self: flex-start; margin-top: auto; }

.messages { display: grid; gap: 8px; margin-bottom: 20px; }
.message { padding: 12px 14px; border: 1px solid var(--border); border-radius: 8px; background: var(--surface); }
.message-success { color: var(--accent); border-color: color-mix(in srgb, var(--accent) 45%, var(--border)); background: var(--accent-soft); }
.auth-shell { min-height: 100dvh; display: grid; place-items: center; padding: 24px; background: radial-gradient(circle at 50% 0%, color-mix(in srgb, var(--primary) 13%, transparent), transparent 40%), var(--bg); }
.login-card { width: min(100%, 420px); padding: clamp(24px, 5vw, 38px); border: 1px solid var(--border); border-radius: 16px; background: var(--surface); box-shadow: var(--shadow); }
.login-brand { margin-bottom: 18px; }
.login-card h1 { margin-top: 6px; }
.login-note { margin: 22px 0 0; color: var(--muted); font-size: .82rem; text-align: center; }
.scan-panel { display: grid; grid-template-columns: minmax(0, 1.35fr) minmax(280px, .65fr); gap: 20px; max-width: 920px; }
.scan-form, .scan-help { padding: clamp(20px, 3vw, 28px); border: 1px solid var(--border); border-radius: 12px; background: var(--surface); box-shadow: var(--shadow); }
.scan-form { display: grid; gap: 18px; }
.scan-form input { min-height: 56px; font-family: "Cascadia Mono", Consolas, monospace; font-size: 1.05rem; }
.scan-help ul { margin-bottom: 0; padding-left: 20px; color: var(--muted); }
.scan-help li + li { margin-top: 8px; }
.scan-result-actions { margin-top: 20px; }
.inventory-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 16px; }
.inventory-card { padding: 18px; border: 1px solid var(--border); border-radius: 12px; color: var(--text); background: var(--surface); box-shadow: var(--shadow); text-decoration: none; }
.inventory-card:hover { border-color: color-mix(in srgb, var(--primary) 45%, var(--border)); }
.inventory-card-heading { display: flex; align-items: center; justify-content: space-between; gap: 12px; color: var(--muted); }
.inventory-card h2 { margin: 14px 0 2px; }
.inventory-card p { color: var(--muted); }
.inventory-card dl { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; margin: 0; }
.inventory-card dl div { padding: 8px; border-radius: 8px; background: var(--surface-subtle); }
.inventory-card dt { color: var(--muted); font-size: .75rem; }
.inventory-card dd { margin: 2px 0 0; font-size: 1.15rem; font-weight: 700; font-variant-numeric: tabular-nums; }
.inventory-scan-panel { margin-bottom: 20px; padding: 18px; border: 1px solid color-mix(in srgb, var(--primary) 28%, var(--border)); border-radius: 12px; background: var(--surface); }
.inventory-scan-panel p { margin: 10px 0 0; color: var(--muted); font-size: .85rem; }
.inventory-scan-form { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 12px; align-items: end; }
.inventory-scan-form input { min-height: 52px; font-family: "Cascadia Mono", Consolas, monospace; }
.inventory-table-header { padding: 18px 18px 0; }
.label-page { min-height: 100dvh; }
.label-workspace { max-width: 980px; margin: 0 auto; padding: clamp(20px, 4vw, 48px); }
.label-toolbar { display: grid; grid-template-columns: minmax(0, 1fr) 220px auto; gap: 20px; align-items: end; padding: 22px; border: 1px solid var(--border); border-radius: 12px; background: var(--surface); }
.label-toolbar p { margin-bottom: 0; color: var(--muted); }
.label-format-form { display: grid; gap: 6px; }
.label-format-form label { font-weight: 700; }
.label-toolbar-actions { display: flex; gap: 8px; }
.label-preview { min-height: 420px; display: grid; place-items: center; margin-top: 20px; padding: 40px; border: 1px solid var(--border); border-radius: 12px; background: var(--surface-subtle); }
.physical-label { width: 60mm; min-height: 40mm; display: grid; justify-items: center; align-content: center; gap: 1.5mm; padding: 3mm; border: .3mm solid #111827; border-radius: 2mm; color: #111827; background: #fff; font-family: "Segoe UI", "Microsoft YaHei", sans-serif; text-align: center; }
.physical-label img { display: block; max-width: 100%; }
.physical-label-qr img { width: 22mm; height: 22mm; }
.physical-label-code128 img { width: 50mm; height: 16mm; object-fit: contain; }
.physical-label-title { font-size: 8pt; font-weight: 700; letter-spacing: .08em; }
.physical-label strong { font: 700 9pt/1.1 "Cascadia Mono", Consolas, monospace; }
.physical-label small { max-width: 52mm; overflow: hidden; font-size: 7pt; text-overflow: ellipsis; white-space: nowrap; }

@media (max-width: 1024px) {
  .stats-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .detail-grid { grid-template-columns: 1fr; }
  .scan-panel { grid-template-columns: 1fr; }
  .dashboard-grid { grid-template-columns: 1fr; }
  .resource-operations-grid, .import-layout, .organization-layout { grid-template-columns: 1fr; }
  .system-section-grid { grid-template-columns: 1fr; }
  .organization-member-form { position: static; }
}

@media (max-width: 820px) {
  .app-shell { display: block; }
  .sidebar { position: static; height: auto; padding: 14px 16px 10px; gap: 12px; }
  .brand small, .sidebar-footer { display: none; }
  .nav-list { display: flex; gap: 6px; overflow-x: auto; padding-bottom: 4px; }
  .nav-list a { flex: 0 0 auto; }
  .nav-list a[aria-current="page"] { box-shadow: inset 0 -3px 0 #87c7a5; }
  .topbar { min-height: 64px; }
  .topbar .eyebrow { display: none; }
}

@media (max-width: 700px) {
  .main-content { padding: 20px 16px 32px; }
  .page-header { display: grid; gap: 14px; }
  .page-header > .button { width: 100%; }
  .page-actions { width: 100%; display: grid; grid-template-columns: 1fr; }
  .stats-grid, .stats-grid-small { grid-template-columns: 1fr 1fr; gap: 10px; }
  .stat-card { padding: 14px; }
  .filter-bar { display: grid; }
  .filter-bar .button { width: 100%; }
  .panel { padding: 16px; }
  .panel-flush { padding: 0; }
  table, thead, tbody, tr, th, td { display: block; }
  thead { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0, 0, 0, 0); }
  tbody tr { padding: 12px 14px; border-bottom: 1px solid var(--border); }
  tbody tr:last-child { border-bottom: 0; }
  td { display: grid; grid-template-columns: minmax(84px, .38fr) minmax(0, 1fr); gap: 10px; padding: 7px 0; border: 0; }
  td::before { content: attr(data-label); color: var(--muted); font-size: .82rem; }
  td:not([data-label]) { display: flex; justify-content: flex-end; }
  .detail-list > div { grid-template-columns: 105px minmax(0, 1fr); }
  .inventory-scan-form { grid-template-columns: 1fr; }
  .inventory-scan-form .button { width: 100%; }
  .shop-summary dl { grid-template-columns: 1fr; }
  .shop-summary dl div { border-right: 0; border-bottom: 1px solid var(--border); }
  .shop-summary dl div:last-child { border-bottom: 0; }
  .attachment-heading, .credential-item, .confirm-bar { display: grid; }
  .version-list > div { display: grid; }
  .version-actions { justify-content: flex-start; }
  .credential-actions { justify-content: flex-start; }
  .confirm-bar .button { width: 100%; }
  .member-actions { justify-content: flex-start; }
  .asset-type-field-grid { grid-template-columns: 1fr; }
  .asset-registration-form { grid-template-columns: 1fr; }
  .system-stats, .role-card-grid { grid-template-columns: 1fr; }
  .account-field-grid, .role-form-section .field > div { grid-template-columns: 1fr; }
  .compact-account-form { padding: 14px; }
  .recovery-code-grid { grid-template-columns: 1fr; }
}

@media (max-width: 760px) {
  .label-toolbar { grid-template-columns: 1fr; align-items: stretch; }
  .label-toolbar-actions { display: grid; grid-template-columns: 1fr 1fr; }
  .label-preview { min-height: 320px; padding: 18px; overflow: auto; }
}

@media print {
  @page { size: 60mm 40mm; margin: 0; }
  .label-page { width: 60mm; min-height: 40mm; margin: 0; background: #fff; }
  .label-workspace { width: 60mm; margin: 0; padding: 0; }
  .label-toolbar { display: none; }
  .label-preview { width: 60mm; min-height: 40mm; margin: 0; padding: 0; border: 0; background: #fff; }
  .physical-label { border: 0; border-radius: 0; box-shadow: none; }
}

@media (max-width: 430px) {
  .nav-list { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); overflow: visible; }
  .nav-list a { justify-content: center; padding-inline: 8px; font-size: .9rem; }
  .stats-grid, .stats-grid-small { grid-template-columns: 1fr; }
  .topbar { align-items: flex-start; }
  .theme-toggle { padding-inline: 10px; font-size: .85rem; }
  .form-actions { display: grid; grid-template-columns: 1fr; }
  .form-actions .button-primary { order: -1; }
  .step-list { grid-template-columns: 1fr; }
  .credential-actions { display: grid; grid-template-columns: 1fr 1fr; }
  .credential-actions .button, .credential-actions form, .credential-actions form .button { width: 100%; }
  .version-actions { display: grid; grid-template-columns: 1fr 1fr; }
  .version-actions .button, .version-actions form, .version-actions form .button { width: 100%; }
}

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