:root {
  --ink-950: oklch(20% 0.026 257);
  --ink-900: oklch(25% 0.025 257);
  --ink-700: oklch(43% 0.022 257);
  --ink-500: oklch(58% 0.018 257);
  --ink-300: oklch(76% 0.015 257);
  --ink-150: oklch(90% 0.009 257);
  --ink-75: oklch(95% 0.007 257);
  --paper: oklch(98.3% 0.006 78);
  --surface: oklch(99.2% 0.004 78);
  --blue-700: oklch(50% 0.19 260);
  --blue-600: oklch(57% 0.19 260);
  --blue-100: oklch(94% 0.035 260);
  --green-700: oklch(44% 0.12 163);
  --green-100: oklch(94% 0.035 163);
  --amber-700: oklch(48% 0.12 72);
  --amber-100: oklch(95% 0.04 82);
  --red-700: oklch(48% 0.17 27);
  --red-100: oklch(94% 0.035 27);
  --shadow-float: 0 22px 70px oklch(25% 0.025 257 / 0.16);
  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 18px;
  --sidebar: 248px;
  font-family: "Segoe UI Variable Text", "Microsoft YaHei UI", "PingFang SC", sans-serif;
  color: var(--ink-950);
  background: var(--paper);
  font-synthesis: none;
}

* { box-sizing: border-box; }

html, body { min-height: 100%; margin: 0; }

body {
  min-width: 320px;
  background:
    linear-gradient(90deg, var(--ink-950) 0 var(--sidebar), transparent var(--sidebar)),
    var(--paper);
  font-size: 1rem;
  line-height: 1.5;
  text-rendering: optimizeLegibility;
}

button, input, select, textarea { font: inherit; }
button { cursor: pointer; }
button:disabled { cursor: wait; opacity: .58; }

:focus-visible {
  outline: 3px solid oklch(67% 0.17 260 / .48);
  outline-offset: 2px;
}

.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: 12px;
  left: 12px;
  padding: 10px 14px;
  color: var(--surface);
  background: var(--blue-700);
  border-radius: var(--radius-sm);
  transform: translateY(-160%);
}
.skip-link:focus { transform: translateY(0); }

[hidden] { display: none !important; }

.eyebrow {
  margin: 0 0 8px;
  color: var(--ink-500);
  font-size: .75rem;
  font-weight: 700;
  letter-spacing: .12em;
}

.muted { margin: 0; color: var(--ink-500); font-size: .875rem; }

h1, h2, h3, p { text-wrap: pretty; }
h1, h2, h3 { margin: 0; letter-spacing: -.025em; }

.brand-mark {
  display: grid;
  grid-template-columns: repeat(3, 14px);
  gap: 5px;
  width: max-content;
  margin-bottom: 48px;
}
.brand-mark span {
  width: 14px;
  height: 36px;
  background: var(--blue-600);
  border-radius: 3px;
}
.brand-mark span:nth-child(2) { height: 26px; margin-top: 10px; }
.brand-mark span:nth-child(3) { height: 16px; margin-top: 20px; }
.brand-mark.small {
  grid-template-columns: repeat(3, 5px);
  gap: 3px;
  margin: 0;
}
.brand-mark.small span { width: 5px; height: 20px; border-radius: 1px; }
.brand-mark.small span:nth-child(2) { height: 14px; margin-top: 6px; }
.brand-mark.small span:nth-child(3) { height: 8px; margin-top: 12px; }

.login-shell {
  min-height: 100vh;
  display: grid;
  grid-template-columns: minmax(380px, 1.12fr) minmax(360px, .88fr);
  background: var(--paper);
}
.login-brand {
  position: relative;
  overflow: hidden;
  padding: clamp(48px, 7vw, 112px);
  color: var(--surface);
  background:
    radial-gradient(circle at 82% 18%, oklch(57% .19 260 / .36), transparent 28%),
    var(--ink-950);
}
.login-brand::after {
  content: "";
  position: absolute;
  right: -90px;
  bottom: -110px;
  width: 350px;
  height: 350px;
  border: 1px solid oklch(76% .05 260 / .18);
  border-radius: 50%;
  box-shadow:
    0 0 0 64px oklch(76% .05 260 / .06),
    0 0 0 128px oklch(76% .05 260 / .035);
}
.login-brand .eyebrow { color: oklch(82% .04 260); }
.login-brand h1 {
  max-width: 10ch;
  font-size: clamp(2.6rem, 5.8vw, 5.6rem);
  line-height: .98;
}
.login-lead {
  max-width: 39ch;
  margin: 32px 0 72px;
  color: oklch(86% .018 257);
  font-size: 1.05rem;
}
.security-notes {
  position: relative;
  z-index: 1;
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  max-width: 560px;
  margin: 0;
  border-top: 1px solid oklch(76% .02 257 / .22);
}
.security-notes div { padding-top: 18px; }
.security-notes dt { color: oklch(72% .018 257); font-size: .75rem; }
.security-notes dd { margin: 4px 0 0; font-weight: 650; }
.login-panel {
  align-self: center;
  width: min(420px, calc(100% - 64px));
  margin: 0 auto;
}
.login-panel h2 { font-size: 1.75rem; }
.login-panel form { display: grid; gap: 10px; margin-top: 40px; }
.login-panel label, .field-row label {
  color: var(--ink-700);
  font-size: .875rem;
  font-weight: 650;
}

input, select, textarea {
  width: 100%;
  color: var(--ink-950);
  background: var(--surface);
  border: 1px solid var(--ink-300);
  border-radius: var(--radius-sm);
  min-height: 44px;
  padding: 10px 12px;
  transition: border-color 140ms ease-out, box-shadow 140ms ease-out;
}
textarea { resize: vertical; }
input::placeholder, textarea::placeholder { color: var(--ink-500); }
input:focus, select:focus, textarea:focus {
  border-color: var(--blue-600);
  box-shadow: 0 0 0 3px var(--blue-100);
  outline: none;
}

.button {
  min-height: 42px;
  padding: 9px 16px;
  border: 1px solid transparent;
  border-radius: var(--radius-sm);
  font-weight: 650;
  transition: background-color 140ms ease-out, border-color 140ms ease-out, transform 120ms ease-out;
}
.button:active { transform: scale(.975); }
.button.primary { color: var(--surface); background: var(--blue-700); }
.button.secondary { color: var(--ink-900); background: var(--surface); border-color: var(--ink-300); }
.button.danger { color: var(--surface); background: var(--red-700); }
.button.wide { width: 100%; margin-top: 14px; }
.text-button {
  padding: 6px 0;
  color: oklch(80% .025 257);
  background: none;
  border: 0;
}
.icon-button {
  width: 40px;
  height: 40px;
  color: var(--ink-700);
  background: var(--ink-75);
  border: 0;
  border-radius: 50%;
  font-size: 1.4rem;
}
.form-message { margin: 4px 0 0; font-size: .875rem; }
.error-message { color: var(--red-700); }

.app-shell { min-height: 100vh; }
.sidebar {
  position: fixed;
  inset: 0 auto 0 0;
  z-index: 10;
  display: flex;
  flex-direction: column;
  width: var(--sidebar);
  padding: 30px 20px 24px;
  color: var(--surface);
  background: var(--ink-950);
}
.sidebar-brand { display: flex; align-items: center; gap: 14px; padding: 0 8px 36px; }
.sidebar-brand div:last-child { display: grid; }
.sidebar-brand strong { font-size: .95rem; }
.sidebar-brand span { color: oklch(72% .02 257); font-size: .75rem; }
.sidebar nav { display: grid; gap: 6px; }
.nav-item {
  display: grid;
  grid-template-columns: 32px 1fr;
  align-items: center;
  min-height: 46px;
  padding: 8px 12px;
  color: oklch(82% .018 257);
  text-align: left;
  background: transparent;
  border: 0;
  border-radius: var(--radius-sm);
}
.nav-item.active { color: var(--surface); background: oklch(32% .035 257); }
.nav-index { color: oklch(65% .025 257); font-size: .7rem; font-variant-numeric: tabular-nums; }
.sidebar-foot {
  display: grid;
  gap: 4px;
  margin-top: auto;
  padding: 18px 8px 0;
  border-top: 1px solid oklch(40% .025 257);
}
.sidebar-foot > span { font-size: .875rem; font-weight: 600; }

.workspace { min-height: 100vh; margin-left: var(--sidebar); padding: 36px clamp(28px, 4.5vw, 72px) 64px; }
.topbar {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 24px;
  padding-bottom: 28px;
  border-bottom: 1px solid var(--ink-150);
}
.topbar h1 { font-size: 2rem; }
.topbar-actions { display: flex; align-items: center; gap: 18px; }
.service-status { display: inline-flex; align-items: center; gap: 8px; color: var(--green-700); font-size: .8rem; font-weight: 650; }
.service-status i { width: 7px; height: 7px; background: var(--green-700); border-radius: 50%; }

.view-section { padding-top: 36px; }
.section-toolbar {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 24px;
  margin-bottom: 20px;
}
.section-toolbar h2 { margin-bottom: 4px; font-size: 1.25rem; }
.search-field { display: grid; grid-template-columns: auto minmax(180px, 260px); align-items: center; gap: 10px; color: var(--ink-500); font-size: .8rem; }
.search-field input { min-height: 38px; }

.table-frame {
  overflow: hidden;
  background: var(--surface);
  border: 1px solid var(--ink-150);
  border-radius: var(--radius-md);
}
table { width: 100%; border-collapse: collapse; font-variant-numeric: tabular-nums; }
th, td { padding: 16px 18px; text-align: left; border-bottom: 1px solid var(--ink-150); }
th { color: var(--ink-500); background: var(--ink-75); font-size: .75rem; font-weight: 650; }
td { color: var(--ink-700); font-size: .875rem; }
tbody tr:last-child td { border-bottom: 0; }
.account-identity { display: grid; gap: 3px; }
.account-identity strong { color: var(--ink-950); font-size: .92rem; }
.account-identity span { color: var(--ink-500); font-size: .78rem; }
.status-badge {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  color: var(--ink-700);
  font-size: .78rem;
  font-weight: 650;
}
.status-badge::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: var(--ink-500); }
.status-badge.active { color: var(--green-700); }
.status-badge.active::before { background: var(--green-700); }
.status-badge.scheduled { color: var(--blue-700); }
.status-badge.scheduled::before { background: var(--blue-700); }
.status-badge.expired { color: var(--amber-700); }
.status-badge.expired::before { background: var(--amber-700); }
.status-badge.disabled { color: var(--red-700); }
.status-badge.disabled::before { background: var(--red-700); }
.row-actions { display: flex; justify-content: flex-end; gap: 8px; }
.row-button {
  min-height: 34px;
  padding: 6px 10px;
  color: var(--ink-700);
  background: var(--surface);
  border: 1px solid var(--ink-300);
  border-radius: 7px;
  font-size: .78rem;
}
.row-button.danger { color: var(--red-700); }
.empty-state { padding: 72px 24px; text-align: center; }
.empty-state h3 { margin: 4px 0 8px; font-size: 1.2rem; }
.empty-state p:not(.empty-kicker) { max-width: 42ch; margin: 0 auto 24px; color: var(--ink-500); }
.empty-kicker { margin: 0; color: var(--blue-700); font-size: .75rem; font-weight: 700; letter-spacing: .08em; }

.asset-scope-guide {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  margin-bottom: 20px;
  padding: 18px 20px;
  background: var(--ink-75);
  border: 1px solid var(--ink-150);
  border-radius: var(--radius-md);
}
.permission-guide {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 1px;
  margin-bottom: 20px;
  overflow: hidden;
  background: var(--ink-150);
  border: 1px solid var(--ink-150);
  border-radius: var(--radius-md);
}
.permission-guide div {
  display: grid;
  gap: 4px;
  padding: 18px 20px;
  background: var(--ink-75);
}
.permission-guide strong { font-size: .85rem; }
.permission-guide span { color: var(--ink-500); font-size: .76rem; line-height: 1.55; }
.asset-scope-guide div { display: grid; gap: 3px; padding: 0 18px; border-right: 1px solid var(--ink-150); }
.asset-scope-guide div:first-child { padding-left: 0; }
.asset-scope-guide div:last-child { padding-right: 0; border-right: 0; }
.asset-scope-guide strong { font-size: .84rem; }
.asset-scope-guide span { color: var(--ink-500); font-size: .76rem; }
.asset-type {
  color: var(--ink-700);
  font-size: .78rem;
}
.asset-file-meta {
  display: grid;
  gap: 2px;
}
.asset-file-meta strong { color: var(--ink-950); }
.asset-file-meta span { color: var(--ink-500); font-size: .75rem; }

.scope-fieldset, .account-scope {
  display: grid;
  gap: 10px;
  margin: 0;
  padding: 0;
  border: 0;
}
.scope-fieldset legend, .account-scope legend {
  margin-bottom: 7px;
  color: var(--ink-700);
  font-size: .875rem;
  font-weight: 650;
}
.choice-row {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  min-height: 58px;
  padding: 12px 14px;
  background: var(--surface);
  border: 1px solid var(--ink-300);
  border-radius: var(--radius-sm);
}
.choice-row:has(input:checked) {
  background: var(--blue-100);
  border-color: var(--blue-600);
}
.choice-row input, .account-option input {
  flex: none;
  width: 18px;
  min-height: 18px;
  margin: 3px 0 0;
}
.choice-row span { display: grid; gap: 2px; }
.choice-row strong { color: var(--ink-900); font-size: .86rem; }
.choice-row small { color: var(--ink-500); font-size: .75rem; }
.account-options {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
}
.account-option {
  display: flex;
  align-items: center;
  gap: 9px;
  min-height: 42px;
  padding: 8px 10px;
  background: var(--ink-75);
  border-radius: 7px;
  font-size: .8rem;
}
.font-license-fields {
  display: grid;
  gap: 16px;
  padding: 18px;
  background: var(--amber-100);
  border-radius: var(--radius-sm);
}
.upload-progress {
  display: grid;
  gap: 8px;
  padding: 14px;
  background: var(--ink-75);
  border-radius: var(--radius-sm);
}
.upload-progress > div { display: flex; justify-content: space-between; gap: 16px; font-size: .8rem; }
.upload-progress strong { font-variant-numeric: tabular-nums; }
.upload-progress progress {
  width: 100%;
  height: 7px;
  overflow: hidden;
  accent-color: var(--blue-700);
  border: 0;
  border-radius: 99px;
}

.audit-list { display: grid; gap: 0; margin: 0; padding: 0; list-style: none; border-top: 1px solid var(--ink-150); }
.audit-item { display: grid; grid-template-columns: 150px minmax(180px, 1fr) 1.6fr; gap: 24px; padding: 18px 2px; border-bottom: 1px solid var(--ink-150); }
.audit-item time { color: var(--ink-500); font-size: .78rem; font-variant-numeric: tabular-nums; }
.audit-item strong { font-size: .875rem; }
.audit-item span { color: var(--ink-500); font-size: .82rem; }

dialog { padding: 0; border: 0; }
dialog::backdrop { background: oklch(20% .026 257 / .42); }
.drawer-dialog { width: min(520px, 100vw); height: 100vh; max-width: none; max-height: none; margin: 0 0 0 auto; background: var(--surface); }
.drawer { display: grid; grid-template-rows: auto 1fr auto; min-height: 100%; }
.drawer-header, .drawer-footer { display: flex; align-items: flex-start; justify-content: space-between; gap: 20px; padding: 28px 32px; }
.drawer-header { border-bottom: 1px solid var(--ink-150); }
.drawer-header h2 { font-size: 1.45rem; }
.drawer-header p:last-child { max-width: 48ch; margin: 8px 0 0; color: var(--ink-500); font-size: .85rem; }
.drawer-body { display: grid; align-content: start; gap: 20px; overflow: auto; padding: 28px 32px; }
.drawer-footer { align-items: center; justify-content: flex-end; border-top: 1px solid var(--ink-150); }
.field-row { display: grid; gap: 7px; }
.field-row small { color: var(--ink-500); font-size: .75rem; }
.field-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; }
.quick-extend {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 12px 14px;
  background: var(--ink-75);
  border-radius: var(--radius-sm);
}
.quick-extend > span { margin-right: auto; color: var(--ink-500); font-size: .78rem; }
.device-section {
  display: grid;
  gap: 12px;
  padding-top: 20px;
  border-top: 1px solid var(--ink-150);
}
.device-section h3 { margin: 0; font-size: 1rem; }
.device-section p { margin: 4px 0 0; font-size: .78rem; }
.device-list { display: grid; gap: 8px; }
.device-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 12px 14px;
  background: var(--ink-75);
  border-radius: var(--radius-sm);
}
.device-item > div { display: grid; gap: 2px; }
.device-item strong { font-size: .84rem; }
.device-item span { color: var(--ink-500); font-size: .74rem; }

.credential-dialog, .confirm-dialog { width: min(460px, calc(100vw - 32px)); border-radius: var(--radius-lg); box-shadow: var(--shadow-float); }
.credential-sheet, .confirm-sheet { padding: 32px; }
.credential-sheet h2, .confirm-sheet h2 { font-size: 1.45rem; }
.credential-sheet > p:not(.eyebrow), .confirm-sheet > p:not(.eyebrow) { margin: 10px 0 24px; color: var(--ink-500); font-size: .9rem; }
.credential-value { display: grid; gap: 6px; padding: 16px 0; border-top: 1px solid var(--ink-150); }
.credential-value span { color: var(--ink-500); font-size: .75rem; }
.credential-value strong { overflow-wrap: anywhere; font-size: 1.05rem; letter-spacing: .02em; }
.credential-actions, .confirm-actions { display: flex; justify-content: flex-end; gap: 10px; margin-top: 26px; }

.toast {
  position: fixed;
  z-index: 500;
  right: 24px;
  bottom: 24px;
  max-width: 360px;
  padding: 13px 16px;
  color: var(--surface);
  background: var(--ink-900);
  border-radius: var(--radius-sm);
  box-shadow: var(--shadow-float);
  font-size: .875rem;
}

@media (hover: hover) and (pointer: fine) {
  .button.primary:hover { background: var(--blue-600); }
  .button.secondary:hover, .row-button:hover { border-color: var(--ink-500); background: var(--ink-75); }
  .nav-item:hover:not(.active) { background: oklch(28% .028 257); }
  .text-button:hover { color: var(--surface); }
}

@media (max-width: 920px) {
  :root { --sidebar: 84px; }
  .sidebar { padding-inline: 14px; }
  .sidebar-brand > div:last-child, .nav-item > span:last-child, .sidebar-foot > span { display: none; }
  .sidebar-brand { justify-content: center; padding-inline: 0; }
  .nav-item { grid-template-columns: 1fr; text-align: center; }
  .sidebar-foot { text-align: center; }
  .table-frame { overflow-x: auto; }
  table { min-width: 820px; }
}

@media (max-width: 720px) {
  body { background: var(--paper); }
  .login-shell { grid-template-columns: 1fr; }
  .login-brand { min-height: 330px; padding: 42px 30px; }
  .brand-mark { margin-bottom: 34px; }
  .login-brand h1 { font-size: 3rem; }
  .login-lead { margin: 20px 0 36px; }
  .security-notes { grid-template-columns: 1fr; gap: 12px; }
  .security-notes div { padding-top: 10px; }
  .login-panel { width: calc(100% - 48px); padding: 48px 0 64px; }
  .sidebar { position: static; width: 100%; height: 70px; flex-direction: row; align-items: center; padding: 12px 18px; }
  .sidebar-brand { padding: 0; }
  .sidebar nav { display: flex; margin-left: auto; }
  .nav-item { width: 44px; padding: 8px; }
  .sidebar-foot { margin: 0 0 0 8px; padding: 0; border: 0; }
  .workspace { margin: 0; padding: 28px 20px 48px; }
  .topbar, .section-toolbar { align-items: flex-start; flex-direction: column; }
  .topbar-actions { width: 100%; justify-content: space-between; }
  .search-field { width: 100%; grid-template-columns: auto 1fr; }
  .field-grid { grid-template-columns: 1fr; }
  .asset-scope-guide { grid-template-columns: 1fr; }
  .permission-guide { grid-template-columns: 1fr; }
  .asset-scope-guide div { padding: 12px 0; border-right: 0; border-bottom: 1px solid var(--ink-150); }
  .asset-scope-guide div:last-child { border-bottom: 0; }
  .account-options { grid-template-columns: 1fr; }
  .drawer-dialog { width: 100vw; }
}

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