:root {
  color-scheme: light;
  --surface: #f3f6f9;
  --panel: #ffffff;
  --panel-soft: #f8fafc;
  --ink: #12263a;
  --muted: #5d7083;
  --line: #d8e1e8;
  --line-strong: #b7c5d1;
  --navy: #102a43;
  --navy-deep: #091d30;
  --blue: #0866d9;
  --blue-dark: #0752ad;
  --cyan: #008da1;
  --cyan-soft: #e4f6f7;
  --success: #11765c;
  --success-bg: #e5f6ef;
  --warning: #95620b;
  --warning-bg: #fff5d9;
  --danger: #b42318;
  --danger-dark: #8f1d14;
  --danger-bg: #fff0ee;
  --radius: 8px;
  --sidebar-width: 248px;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Microsoft YaHei", Helvetica, Arial, sans-serif;
  font-size: 16px;
  letter-spacing: 0;
}

* { box-sizing: border-box; }
html { min-width: 320px; background: var(--surface); }
body { margin: 0; min-width: 320px; overflow-x: hidden; background: var(--surface); color: var(--ink); }
a { color: var(--blue); text-decoration: none; }
a:hover { text-decoration: underline; }
button, input, textarea { font: inherit; letter-spacing: 0; }
button, a, input, textarea { -webkit-tap-highlight-color: transparent; }
button:focus-visible, a:focus-visible, input:focus-visible, textarea:focus-visible {
  outline: 3px solid rgba(0, 141, 161, .32);
  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; }

.app-frame { min-height: 100vh; }
.sidebar {
  position: fixed;
  inset: 0 auto 0 0;
  z-index: 40;
  width: var(--sidebar-width);
  display: flex;
  flex-direction: column;
  overflow-y: auto;
  background: var(--navy-deep);
  color: #fff;
  border-right: 1px solid #1e3f5e;
}
.brand { min-height: 84px; display: flex; align-items: center; gap: 12px; padding: 17px 20px; color: #fff; border-bottom: 1px solid rgba(255, 255, 255, .12); }
.brand:hover { text-decoration: none; background: rgba(255, 255, 255, .04); }
.brand-mark { width: 42px; height: 42px; display: grid; flex: 0 0 42px; place-items: center; border-radius: 7px; background: var(--cyan); color: #fff; font-size: 1.25rem; font-weight: 800; }
.brand-copy { min-width: 0; display: grid; gap: 3px; }
.brand-copy strong { font-size: 1.05rem; line-height: 1.25; }
.brand-copy small { color: #a8bfd2; font-size: .75rem; }
.side-nav { padding: 18px 12px; }
.nav-label { margin: 15px 11px 7px; color: #7694ae; font-size: .7rem; font-weight: 750; text-transform: uppercase; }
.nav-label:first-child { margin-top: 0; }
.side-nav a { min-height: 44px; display: flex; align-items: center; gap: 11px; margin: 3px 0; padding: 8px 11px; border-radius: 6px; color: #c7d8e6; font-size: .9rem; font-weight: 600; }
.side-nav a:hover { color: #fff; background: rgba(255, 255, 255, .07); text-decoration: none; }
.side-nav a.is-active { color: #fff; background: #173c5d; box-shadow: inset 3px 0 0 var(--cyan); }
.nav-symbol { width: 25px; height: 25px; display: grid; place-items: center; flex: 0 0 25px; color: #9ed9df; font-size: 1rem; font-weight: 700; }
.side-nav a.is-active .nav-symbol { color: #d8fbff; }
.sidebar-footer { margin-top: auto; display: flex; align-items: center; gap: 10px; padding: 16px; border-top: 1px solid rgba(255, 255, 255, .12); }
.operator-avatar { width: 34px; height: 34px; display: grid; flex: 0 0 34px; place-items: center; border-radius: 50%; background: #214d70; color: #fff; font-size: .8rem; font-weight: 750; }
.operator-copy { min-width: 0; display: grid; flex: 1; gap: 2px; }
.operator-copy strong { overflow: hidden; color: #f4f8fb; font-size: .82rem; text-overflow: ellipsis; }
.operator-copy small { color: #8fa9bf; font-size: .7rem; }
.sidebar-footer form { margin: 0; }
.icon-button { width: 34px; height: 34px; display: grid; place-items: center; border: 1px solid rgba(255, 255, 255, .15); border-radius: 5px; background: transparent; color: #d7e4ee; cursor: pointer; }
.icon-button:hover { border-color: #7ebbc2; color: #fff; background: rgba(255, 255, 255, .07); }
.sidebar-scrim { display: none; }

.workspace { min-width: 0; min-height: 100vh; margin-left: var(--sidebar-width); }
.topbar { position: sticky; top: 0; z-index: 25; height: 64px; display: flex; align-items: center; gap: 14px; padding: 0 30px; background: rgba(255, 255, 255, .96); border-bottom: 1px solid var(--line); }
.topbar::after { content: ""; position: absolute; right: 0; bottom: -1px; left: 0; height: 2px; background: var(--cyan); opacity: .72; }
.topbar-title { min-width: 0; display: grid; gap: 2px; }
.topbar-title strong { font-size: .95rem; }
.topbar-title span { color: var(--muted); font-size: .72rem; }
.topbar-user { margin-left: auto; display: flex; align-items: center; gap: 9px; color: var(--muted); font-size: .8rem; }
.online-dot { width: 8px; height: 8px; border-radius: 50%; background: #20a67a; box-shadow: 0 0 0 3px #dff5ed; }
.menu-button { width: 40px; height: 40px; display: none; place-content: center; gap: 4px; border: 1px solid var(--line); border-radius: 6px; background: #fff; cursor: pointer; }
.menu-button > span:not(.sr-only) { width: 18px; height: 2px; display: block; background: var(--navy); }

.page-shell { width: min(1540px, 100%); margin: 0 auto; padding: 30px 30px 56px; }
.page-heading { display: flex; align-items: flex-end; justify-content: space-between; gap: 24px; margin-bottom: 24px; }
.page-heading h1 { margin: 0 0 6px; font-size: 1.7rem; line-height: 1.2; }
.page-heading p { max-width: 840px; margin: 0; color: var(--muted); font-size: .9rem; line-height: 1.55; }
.section-heading { display: flex; align-items: center; justify-content: space-between; gap: 16px; margin-bottom: 16px; }
.section-heading h2 { margin: 0; font-size: 1.03rem; }
.section-heading p { margin: 4px 0 0; color: var(--muted); font-size: .78rem; }
.inline-link { font-size: .84rem; font-weight: 650; white-space: nowrap; }
.package-badge { display: inline-flex; align-items: center; min-height: 32px; padding: 5px 10px; border: 1px solid #9dd0d5; border-radius: 5px; background: var(--cyan-soft); color: #075965; font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: .78rem; font-weight: 700; }

.primary-button, .secondary-button, .danger-button {
  min-height: 40px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 9px 15px;
  border: 1px solid transparent;
  border-radius: 6px;
  font-weight: 700;
  line-height: 1.2;
  cursor: pointer;
  text-decoration: none;
}
.primary-button { color: #fff; background: var(--blue); border-color: var(--blue); }
.primary-button:hover { color: #fff; background: var(--blue-dark); border-color: var(--blue-dark); text-decoration: none; }
.secondary-button { color: var(--ink); background: #fff; border-color: #9fb1c0; }
.secondary-button:hover { border-color: var(--blue); color: var(--blue-dark); text-decoration: none; }
.danger-button { color: #fff; background: var(--danger); border-color: var(--danger); }
.danger-button:hover { background: var(--danger-dark); border-color: var(--danger-dark); }
.primary-button:disabled, .secondary-button:disabled, .danger-button:disabled, button:disabled { cursor: wait; opacity: .62; }
.compact-button { min-height: 32px; padding: 6px 11px; font-size: .78rem; }
.text-link { align-self: end; padding: 10px 4px; font-size: .86rem; }

.metric-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 14px; margin-bottom: 24px; }
.metric-grid article { min-height: 116px; display: flex; align-items: flex-end; justify-content: space-between; gap: 18px; padding: 19px 20px; border: 1px solid var(--line); border-top: 3px solid var(--blue); border-radius: var(--radius); background: var(--panel); }
.metric-grid article.metric-active { border-top-color: var(--success); }
.metric-grid article.metric-reissue { border-top-color: var(--cyan); }
.metric-grid article > div { display: grid; gap: 5px; }
.metric-grid span { color: #314b63; font-size: .88rem; font-weight: 700; }
.metric-grid small { color: var(--muted); font-size: .72rem; }
.metric-grid strong { color: var(--navy); font-size: 2rem; font-variant-numeric: tabular-nums; line-height: 1; }

.section-block, .form-panel, .confirmation-panel, .detail-main, .reissue-panel, .filter-band, .release-summary {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
}
.section-block { padding: 20px; }
.form-panel, .confirmation-panel { max-width: 940px; padding: 24px; }
.result-slot:not(:empty) { margin-top: 24px; }
.result-slot .confirmation-panel { max-width: none; padding: 24px 0 0; border: 0; border-top: 1px solid var(--line); border-radius: 0; background: transparent; }

.stack-form { display: grid; gap: 17px; }
.stack-form label, .filter-form label { min-width: 0; display: grid; gap: 7px; color: #334e68; font-size: .84rem; font-weight: 700; }
input, textarea {
  width: 100%;
  min-width: 0;
  border: 1px solid #9fb1c0;
  border-radius: 5px;
  background: #fff;
  color: var(--ink);
  padding: 10px 11px;
  outline: none;
}
input:hover, textarea:hover { border-color: #71899d; }
input:focus, textarea:focus { border-color: var(--blue); box-shadow: 0 0 0 3px rgba(8, 102, 217, .13); }
input::placeholder, textarea::placeholder { color: #8293a3; }
textarea { resize: vertical; font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: .82rem; line-height: 1.55; }
.form-actions { display: flex; gap: 10px; justify-content: flex-end; }
.form-row { display: grid; grid-template-columns: minmax(0, 1fr) minmax(160px, .55fr); gap: 14px; }
.confirmation-form { margin-top: 24px; grid-template-columns: minmax(240px, 1fr) 220px; align-items: end; }
.confirmation-form .form-actions { align-self: end; }
.confirmation-form .validity-field, .confirmation-form fieldset { grid-column: 1 / -1; }
fieldset { min-width: 0; padding: 14px; border: 1px solid var(--line); border-radius: 6px; }
fieldset legend { padding: 0 6px; color: #334e68; font-size: .84rem; font-weight: 700; }
fieldset label { display: inline-flex !important; align-items: center; gap: 7px !important; margin: 4px 22px 4px 0; font-weight: 600 !important; }
fieldset input[type="checkbox"] { width: 17px; height: 17px; margin: 0; accent-color: var(--blue); }
.validity-field { display: grid; gap: 8px; }
.validity-field > label { color: #334e68; font-size: .84rem; font-weight: 700; }
.validity-presets { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 8px; }
.validity-presets button { min-height: 38px; border: 1px solid #9fb1c0; border-radius: 5px; background: #fff; color: var(--ink); cursor: pointer; font-weight: 700; }
.validity-presets button:hover { border-color: var(--blue); color: var(--blue-dark); }
.validity-presets button[aria-pressed="true"] { color: #fff; background: var(--blue); border-color: var(--blue); }
.validity-summary { min-height: 20px; margin: 0; color: var(--muted); font-size: .78rem; }

.detail-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 0; margin: 0; overflow: hidden; border: 1px solid var(--line); border-radius: 6px; }
.detail-grid > div { min-width: 0; padding: 14px 15px; border-bottom: 1px solid var(--line); }
.detail-grid > div:nth-child(odd) { border-right: 1px solid var(--line); }
.detail-grid dt { margin-bottom: 6px; color: var(--muted); font-size: .72rem; font-weight: 750; text-transform: uppercase; }
.detail-grid dd { margin: 0; overflow-wrap: anywhere; font-size: .88rem; }
.identity-rail { border-left: 4px solid var(--blue); }
.vin-value, .vin-link { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-weight: 750; letter-spacing: 0; }

.filter-band { padding: 17px; margin-bottom: 18px; }
.filter-title { display: flex; align-items: baseline; gap: 10px; margin-bottom: 13px; }
.filter-title h2 { margin: 0; font-size: .92rem; }
.filter-title span { color: var(--muted); font-size: .75rem; }
.filter-form { display: grid; grid-template-columns: 1fr 1.35fr 1.35fr 1.35fr auto auto; gap: 10px; align-items: end; }
.compact-filter { grid-template-columns: minmax(280px, 560px) auto auto; justify-content: start; }

.table-wrap { width: 100%; min-width: 0; overflow-x: auto; border: 1px solid var(--line); border-radius: 6px; }
table { width: 100%; border-collapse: collapse; font-size: .82rem; }
th { padding: 10px 11px; background: #e9f0f5; color: #39536b; text-align: left; white-space: nowrap; font-size: .74rem; text-transform: uppercase; }
td { padding: 12px 11px; border-bottom: 1px solid var(--line); vertical-align: top; }
tbody tr:last-child td { border-bottom: 0; }
tbody tr:hover { background: #f7fafc; }
.mono { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-variant-numeric: tabular-nums; }
.compact-date { white-space: nowrap; font-size: .76rem; }
.duration-cell { min-width: 126px; white-space: nowrap; }
.duration-cell span, .duration-cell small { display: block; }
.duration-cell small, .release-file + small { margin-top: 3px; color: var(--muted); font-size: .7rem; }
.status { min-height: 24px; display: inline-flex; align-items: center; padding: 3px 8px; border: 1px solid transparent; border-radius: 4px; font-size: .72rem; font-weight: 750; white-space: nowrap; }
.status-active { color: var(--success); background: var(--success-bg); border-color: #b5e2d1; }
.status-expired { color: var(--danger); background: var(--danger-bg); border-color: #f0c2bd; }
.status-draft { color: var(--warning); background: var(--warning-bg); border-color: #efd998; }
.empty-state { min-height: 150px; display: grid; place-content: center; gap: 6px; padding: 32px 18px; color: var(--muted); text-align: center; border: 1px dashed #aebecb; border-radius: 6px; }
.empty-state strong { color: #3c556c; font-size: .92rem; }
.empty-state span { font-size: .78rem; }

.detail-layout { display: grid; grid-template-columns: minmax(0, 1fr) 340px; gap: 18px; align-items: start; margin-bottom: 22px; }
.detail-main, .reissue-panel { padding: 20px; }
.reissue-panel { border-top: 3px solid var(--danger); }
.reissue-panel h2 { margin: 0 0 17px; font-size: 1.03rem; }
.code-block { margin-top: 22px; }
.code-block textarea { min-height: 190px; background: var(--panel-soft); }
.audit-json { display: block; max-width: 520px; color: #334e68; white-space: normal; overflow-wrap: anywhere; }
.audit-count { display: inline-block; margin-top: 5px; color: var(--muted); font-size: .72rem; }

.alert { padding: 11px 13px; border: 1px solid; border-radius: 5px; margin-bottom: 17px; font-size: .86rem; }
.alert-error { color: var(--danger-dark); background: var(--danger-bg); border-color: #efb4ad; }
.alert-info { color: #07515b; background: #e8f7f8; border-color: #9bd6dc; }
.alert-success { color: #0d664e; background: var(--success-bg); border-color: #a9ddca; }

.update-layout { display: grid; grid-template-columns: minmax(0, 1fr) 280px; gap: 18px; align-items: start; margin-bottom: 24px; }
.update-upload-panel { max-width: none; }
.release-summary { padding: 20px; border-top: 3px solid var(--cyan); }
.release-summary h2 { margin: 0 0 16px; font-size: 1rem; }
.release-summary dl { display: grid; gap: 0; margin: 0; }
.release-summary dl > div { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 12px 0; border-bottom: 1px solid var(--line); }
.release-summary dt { color: var(--muted); font-size: .8rem; }
.release-summary dd { margin: 0; color: var(--navy); font-size: 1.15rem; font-weight: 750; font-variant-numeric: tabular-nums; }
.release-summary p { margin: 16px 0 0; color: var(--muted); font-size: .75rem; line-height: 1.55; }
.file-field input[type="file"] { padding: 7px; background: var(--panel-soft); }
.file-field input[type="file"]::file-selector-button { margin-right: 10px; padding: 7px 10px; border: 1px solid #9fb1c0; border-radius: 4px; background: #fff; color: var(--ink); cursor: pointer; font-weight: 650; }
.file-field > span { color: var(--muted); font-size: .75rem; font-weight: 500; }
.release-file { display: block; max-width: 190px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.action-column { text-align: right; }
.action-cell { text-align: right; }
.action-cell form { margin: 0; }

.login-body { min-height: 100vh; display: grid; place-items: center; padding: 28px; background: var(--navy-deep); }
.login-shell { width: min(850px, 100%); display: grid; grid-template-columns: .9fr 1.1fr; overflow: hidden; border: 1px solid #31506a; border-radius: var(--radius); background: #fff; box-shadow: 0 18px 48px rgba(0, 0, 0, .24); }
.login-brand { min-height: 490px; display: flex; flex-direction: column; justify-content: flex-end; padding: 38px; color: #fff; background: #123858; border-right: 5px solid var(--cyan); }
.login-brand-mark { width: 52px; height: 52px; display: grid; place-items: center; margin-bottom: auto; border-radius: 7px; background: var(--cyan); font-size: 1.45rem; font-weight: 800; }
.login-brand h1 { margin: 0 0 8px; font-size: 2.35rem; }
.login-brand span { color: #c7dceb; }
.login-panel { padding: 50px 42px; align-self: center; }
.login-panel h2 { margin: 0 0 24px; font-size: 1.45rem; }
.login-panel .primary-button { width: 100%; margin-top: 4px; }
.message-shell { width: min(520px, 100%); padding: 34px; border: 1px solid var(--line); border-radius: var(--radius); background: #fff; }
.message-shell h1 { margin-top: 0; }
.message-shell p { color: var(--muted); margin-bottom: 24px; }

@media (min-width: 1280px) {
  .page-shell { padding-right: 38px; padding-left: 38px; }
  .metric-grid { gap: 18px; }
}

@media (max-width: 1120px) {
  .sidebar { transform: translateX(-100%); transition: transform .2s ease; }
  body.sidebar-open .sidebar { transform: translateX(0); box-shadow: 12px 0 32px rgba(9, 29, 48, .24); }
  .sidebar-scrim { position: fixed; inset: 0; z-index: 35; width: 100%; height: 100%; border: 0; background: rgba(9, 29, 48, .46); }
  body.sidebar-open .sidebar-scrim { display: block; }
  .workspace { margin-left: 0; }
  .menu-button { display: grid; }
  .detail-layout { grid-template-columns: 1fr; }
  .filter-form { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .filter-form .secondary-button, .filter-form .text-link { justify-self: start; }
}

@media (max-width: 820px) {
  .topbar { padding: 0 18px; }
  .page-shell { padding: 25px 18px 44px; }
  .metric-grid { grid-template-columns: 1fr; gap: 10px; }
  .metric-grid article { min-height: 92px; }
  .update-layout { grid-template-columns: 1fr; }
  .release-summary dl { grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 10px; }
  .release-summary dl > div { display: grid; justify-items: start; padding: 10px; border: 1px solid var(--line); border-radius: 5px; }
}

@media (max-width: 680px) {
  .topbar { height: 58px; padding: 0 13px; }
  .topbar-title span, .topbar-user > span:first-child { display: none; }
  .page-shell { padding: 21px 13px 36px; }
  .page-heading { align-items: stretch; flex-direction: column; gap: 14px; margin-bottom: 20px; }
  .page-heading h1 { font-size: 1.45rem; }
  .page-heading .primary-button, .page-heading .secondary-button { width: 100%; }
  .package-badge { align-self: flex-start; }
  .section-block { padding: 0; border: 0; background: transparent; }
  .form-panel, .confirmation-panel, .detail-main, .reissue-panel, .filter-band, .release-summary { padding: 17px; }
  .section-heading { align-items: flex-start; }
  .metric-grid article { padding: 16px; }
  .detail-grid { grid-template-columns: 1fr; }
  .detail-grid > div:nth-child(odd) { border-right: 0; }
  .confirmation-form, .filter-form, .compact-filter, .form-row { grid-template-columns: 1fr; }
  .validity-presets { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .form-actions { justify-content: stretch; }
  .form-actions .primary-button, .form-actions .secondary-button, .form-actions .danger-button { width: 100%; }
  fieldset label { display: flex !important; margin-right: 0; }
  .release-summary dl { grid-template-columns: 1fr; }

  .table-wrap { overflow: visible; border: 0; border-radius: 0; }
  table, tbody { display: block; width: 100%; }
  thead { display: none; }
  tbody { display: grid; gap: 10px; }
  tbody tr { display: block; overflow: hidden; border: 1px solid var(--line); border-radius: 6px; background: #fff; }
  tbody tr:hover { background: #fff; }
  td, tbody tr:last-child td { min-width: 0; display: grid; grid-template-columns: 104px minmax(0, 1fr); gap: 10px; align-items: start; padding: 10px 12px; border-bottom: 1px solid var(--line); text-align: left; white-space: normal; overflow-wrap: anywhere; }
  td::before { content: attr(data-label); color: var(--muted); font-size: .72rem; font-weight: 700; }
  tbody tr td:last-child { border-bottom: 0; }
  .duration-cell { min-width: 0; }
  .release-file { max-width: 100%; }
  .action-cell form { justify-self: start; }

  .login-body { padding: 13px; }
  .login-shell { grid-template-columns: 1fr; }
  .login-brand { min-height: 178px; padding: 25px; border-right: 0; border-bottom: 5px solid var(--cyan); }
  .login-brand-mark { width: 42px; height: 42px; margin-bottom: 30px; font-size: 1.2rem; }
  .login-brand h1 { font-size: 1.8rem; }
  .login-panel { padding: 30px 24px; }
  .message-shell { padding: 26px 22px; }
}

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