:root {
  color-scheme: light;
  --bg: oklch(1 0 0);
  --surface: oklch(0.972 0.006 235);
  --surface-strong: oklch(0.935 0.011 230);
  --surface-soft: oklch(0.986 0.003 235);
  --ink: oklch(0.215 0.025 242);
  --muted: oklch(0.46 0.026 242);
  --line: oklch(0.875 0.012 235);
  --line-strong: oklch(0.78 0.018 235);
  --primary: oklch(0.64 0.125 204);
  --primary-dark: oklch(0.45 0.105 212);
  --primary-soft: oklch(0.94 0.04 204);
  --accent: oklch(0.65 0.145 58);
  --accent-soft: oklch(0.965 0.052 70);
  --lime: oklch(0.75 0.17 128);
  --lime-soft: oklch(0.94 0.08 128);
  --warning: oklch(0.72 0.155 72);
  --warning-soft: oklch(0.96 0.06 78);
  --danger: oklch(0.58 0.185 28);
  --danger-soft: oklch(0.96 0.045 28);
  --success: oklch(0.58 0.14 145);
  --success-soft: oklch(0.94 0.055 145);
  --radius: 8px;
  --radius-sm: 6px;
  --font-sans: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont,
    "Noto Sans TC", "Microsoft JhengHei", sans-serif;
  --font-mono: "SFMono-Regular", Consolas, "Liberation Mono", ui-monospace, monospace;
  --shadow-tight: 0 2px 8px color-mix(in oklch, var(--ink) 8%, transparent);
  --focus: 0 0 0 3px color-mix(in oklch, var(--primary) 28%, transparent);
}

* {
  box-sizing: border-box;
}

html {
  min-height: 100%;
  scroll-behavior: smooth;
}

body {
  min-height: 100%;
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--font-sans);
  font-size: 15px;
  line-height: 1.5;
}

body,
button,
input,
select,
textarea {
  font: inherit;
}

button,
input,
select,
textarea {
  color: inherit;
}

button {
  border: 0;
}

a {
  color: inherit;
  text-decoration: none;
}

img {
  display: block;
  max-width: 100%;
}

::selection {
  background: color-mix(in oklch, var(--primary) 24%, var(--bg));
}

.app-shell {
  display: grid;
  grid-template-columns: 280px minmax(0, 1fr);
  min-height: 100dvh;
}

.sidebar {
  position: sticky;
  top: 0;
  display: flex;
  flex-direction: column;
  gap: 22px;
  height: 100dvh;
  padding: 22px 16px;
  overflow: auto;
  background:
    linear-gradient(180deg, color-mix(in oklch, var(--surface) 92%, var(--primary-soft)), var(--surface) 210px),
    var(--surface);
  border-right: 1px solid var(--line);
}

.brand {
  display: grid;
  grid-template-columns: 62px minmax(0, 1fr);
  gap: 13px;
  align-items: center;
  min-height: 66px;
  padding: 9px;
  border-radius: var(--radius);
  transition: background 160ms ease, box-shadow 160ms ease;
}

.brand:hover {
  background: color-mix(in oklch, var(--bg) 62%, transparent);
}

.brand:focus-visible,
.nav-button:focus-visible,
.btn:focus-visible,
.icon-btn:focus-visible,
select:focus-visible,
input:focus-visible,
textarea:focus-visible {
  outline: none;
  box-shadow: var(--focus);
}

.brand-mark {
  display: grid;
  place-items: center;
  width: 62px;
  height: 54px;
  overflow: hidden;
  background: var(--bg);
  border: 1px solid color-mix(in oklch, var(--primary) 16%, var(--line));
  border-radius: var(--radius);
  box-shadow: 0 10px 20px color-mix(in oklch, var(--ink) 7%, transparent);
}

.brand-mark img {
  width: 76px;
  max-width: none;
  height: 64px;
  object-fit: cover;
  object-position: center top;
}

.brand-copy {
  display: grid;
  gap: 2px;
  min-width: 0;
}

.brand-copy strong {
  overflow: hidden;
  color: var(--ink);
  font-size: 15px;
  font-weight: 850;
  letter-spacing: 0;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.brand-copy span {
  color: var(--muted);
  font-size: 13px;
  font-weight: 650;
}

.nav-list {
  display: flex;
  flex: 1;
  flex-direction: column;
  gap: 7px;
}

.nav-button[data-route="purchase"] {
  margin-top: auto;
}

.nav-button {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 100%;
  min-height: 46px;
  padding: 8px 12px 8px 10px;
  color: var(--muted);
  background: transparent;
  border: 1px solid transparent;
  border-radius: 10px;
  cursor: pointer;
  font-size: 15px;
  font-weight: 760;
  text-align: left;
  transition:
    background 160ms ease,
    border-color 160ms ease,
    box-shadow 160ms ease,
    color 160ms ease,
    transform 160ms ease;
}

.nav-button::before {
  position: absolute;
  inset: 9px auto 9px 0;
  width: 3px;
  content: "";
  background: transparent;
  border-radius: 999px;
  transition: background 160ms ease, opacity 160ms ease;
}

.nav-button:hover {
  background: color-mix(in oklch, var(--bg) 72%, var(--surface-strong));
  border-color: color-mix(in oklch, var(--primary) 10%, var(--line));
  color: var(--ink);
  transform: translateX(1px);
}

.nav-button.is-active {
  color: var(--primary-dark);
  background:
    linear-gradient(90deg, color-mix(in oklch, var(--primary-soft) 72%, var(--bg)), var(--bg) 82%);
  border-color: color-mix(in oklch, var(--primary) 20%, var(--line));
  box-shadow: 0 10px 24px color-mix(in oklch, var(--ink) 8%, transparent);
}

.nav-button.is-active::before {
  background: var(--primary);
}

.nav-button > span:first-child {
  display: inline-flex;
  gap: 11px;
  align-items: center;
  min-width: 0;
}

.nav-icon {
  display: inline-grid;
  place-items: center;
  flex: 0 0 auto;
  width: 30px;
  height: 30px;
  line-height: 1;
  text-align: center;
  color: var(--primary-dark);
  font-family: var(--font-mono);
  font-size: 12px;
  font-weight: 850;
  background: color-mix(in oklch, var(--bg) 88%, var(--primary-soft));
  border: 1px solid color-mix(in oklch, var(--primary) 18%, var(--line));
  border-radius: 9px;
}

.nav-button.is-active .nav-icon {
  color: var(--bg);
  background: var(--primary);
  border-color: color-mix(in oklch, var(--primary) 70%, var(--line));
}

.nav-count {
  display: inline-grid;
  place-items: center;
  min-width: 28px;
  height: 24px;
  padding: 0 8px;
  color: var(--primary-dark);
  font-size: 12px;
  font-weight: 850;
  text-align: center;
  background: color-mix(in oklch, var(--primary-soft) 82%, var(--bg));
  border: 1px solid color-mix(in oklch, var(--primary) 16%, var(--primary-soft));
  border-radius: 999px;
}

.sidebar-note {
  display: grid;
  gap: 5px;
  margin-top: auto;
  padding: 12px;
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: var(--radius);
}

.sidebar-note span {
  color: var(--muted);
  font-size: 12px;
}

.sidebar-note strong {
  font-size: 14px;
}

.workspace {
  display: flex;
  flex-direction: column;
  min-width: 0;
  min-height: 100dvh;
  background: var(--bg);
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  gap: 16px;
  align-items: center;
  justify-content: space-between;
  min-height: 78px;
  padding: 16px 28px;
  background: var(--bg);
  border-bottom: 1px solid var(--line);
}

.context-label {
  margin: 0 0 2px;
  color: var(--muted);
  font-size: 12px;
}

.topbar h1 {
  margin: 0;
  font-size: 22px;
  line-height: 1.2;
  text-wrap: balance;
}

.topbar-actions {
  display: flex;
  gap: 12px;
  align-items: center;
  color: var(--muted);
  font-size: 13px;
}

#tutorialEntry {
  display: inline-flex;
  align-items: center;
}

.tutorial-entry-button.is-active {
  color: color-mix(in oklch, var(--warning) 72%, var(--ink));
  background: var(--warning-soft);
  border-color: color-mix(in oklch, var(--warning) 38%, var(--line));
}

.sync-status {
  display: inline-flex;
  align-items: center;
  min-height: 28px;
  padding: 3px 8px;
  border: 1px solid var(--line);
  border-radius: 999px;
  font-size: 12px;
  font-weight: 750;
}

.sync-ok {
  color: var(--success);
  background: var(--success-soft);
}

.sync-pending {
  color: oklch(0.42 0.115 72);
  background: var(--warning-soft);
}

.sync-error {
  color: var(--danger);
  background: var(--danger-soft);
}

.role-select {
  display: flex;
  gap: 8px;
  align-items: center;
}

.user-chip {
  display: flex;
  align-items: center;
  min-height: 34px;
}

.account-button {
  display: inline-grid;
  grid-template-columns: 30px minmax(0, 1fr);
  gap: 8px;
  align-items: center;
  min-height: 40px;
  padding: 5px 10px 5px 6px;
  color: var(--ink);
  background: var(--bg);
  border: 1px solid var(--line-strong);
  border-radius: var(--radius);
  box-shadow: var(--shadow-tight);
  cursor: pointer;
}

.account-button:hover {
  background: var(--surface-soft);
}

.account-button-avatar {
  display: grid;
  place-items: center;
  width: 30px;
  height: 30px;
  color: var(--primary-dark);
  font-size: 13px;
  font-weight: 900;
  background: var(--primary-soft);
  border: 1px solid color-mix(in oklch, var(--primary) 25%, var(--line));
  border-radius: 50%;
}

.account-button-copy {
  display: grid;
  gap: 1px;
  min-width: 0;
  text-align: left;
}

.account-button-copy strong {
  color: var(--ink);
  font-size: 13px;
  line-height: 1.15;
}

.account-button-copy small {
  color: var(--muted);
  font-size: 12px;
  line-height: 1.15;
}

.btn-small {
  min-height: 32px;
  padding: 6px 10px;
  font-size: 12px;
}

select,
input,
textarea {
  width: 100%;
  min-height: 38px;
  padding: 8px 10px;
  background: var(--bg);
  border: 1px solid var(--line-strong);
  border-radius: var(--radius-sm);
}

textarea {
  min-height: 86px;
  resize: vertical;
}

input::placeholder,
textarea::placeholder {
  color: color-mix(in oklch, var(--muted) 78%, var(--ink));
}

select {
  cursor: pointer;
}

#app {
  flex: 1;
  padding: 24px 28px 36px;
}

.workspace-footer {
  display: flex;
  gap: 20px;
  align-items: center;
  justify-content: space-between;
  margin: 0 28px;
  padding: 18px 0 22px;
  color: var(--muted);
  border-top: 1px solid var(--line);
}

.footer-brand {
  display: grid;
  grid-template-columns: 44px minmax(0, 1fr);
  gap: 11px;
  align-items: center;
  min-width: 280px;
}

.footer-mark {
  display: grid;
  place-items: center;
  width: 44px;
  height: 38px;
  overflow: hidden;
  background: var(--surface-soft);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
}

.footer-mark img {
  width: 54px;
  max-width: none;
  height: 46px;
  object-fit: cover;
  object-position: center top;
}

.footer-copy,
.footer-legal {
  display: grid;
  gap: 3px;
  min-width: 0;
}

.footer-copy strong {
  overflow: hidden;
  color: var(--ink);
  font-size: 14px;
  font-weight: 850;
  line-height: 1.25;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.footer-copy span,
.footer-legal span {
  font-size: 12px;
  font-weight: 650;
  line-height: 1.35;
}

.footer-legal {
  justify-items: end;
  text-align: right;
}

.auth-layout {
  display: grid;
  min-height: calc(100dvh - 150px);
  place-items: center;
}

.auth-card {
  display: grid;
  gap: 20px;
  width: min(460px, 100%);
  padding: 24px;
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow-tight);
}

.auth-copy {
  display: grid;
  gap: 8px;
}

.auth-copy h2 {
  margin: 0;
  font-size: 24px;
  line-height: 1.2;
}

.auth-copy p {
  margin: 0;
  color: var(--muted);
}

.quick-login {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
}

.view-stack {
  display: grid;
  gap: 20px;
}

.page-header {
  display: flex;
  gap: 16px;
  align-items: flex-start;
  justify-content: space-between;
}

.page-title {
  display: grid;
  flex: 1 1 auto;
  gap: 6px;
  min-width: 0;
}

.page-title h2 {
  margin: 0;
  font-size: 24px;
  line-height: 1.2;
  text-wrap: balance;
}

.page-title p {
  max-width: none;
  margin: 0;
  color: var(--muted);
}

.page-actions {
  display: flex;
  flex: 0 0 auto;
  gap: 8px;
  align-items: center;
  justify-content: flex-end;
}

.toolbar,
.button-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
}

.metric-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 12px;
}

.compact-metrics {
  grid-template-columns: repeat(3, minmax(150px, 1fr));
}

.machine-summary-grid {
  grid-template-columns: repeat(4, minmax(150px, 1fr));
}

.metric-card {
  display: grid;
  gap: 8px;
  min-height: 112px;
  padding: 14px;
  background: var(--surface-soft);
  border: 1px solid var(--line);
  border-radius: var(--radius);
}

.metric-card span {
  color: var(--muted);
  font-size: 13px;
}

.metric-card strong {
  font-size: 27px;
  line-height: 1;
}

.metric-card small {
  color: var(--muted);
}

.grid-2 {
  display: grid;
  grid-template-columns: minmax(0, 1.35fr) minmax(360px, 0.65fr);
  gap: 16px;
}

.rules-reference-grid {
  grid-template-columns: 460px minmax(760px, 1fr);
  align-items: start;
}

.rules-method-body {
  overflow: hidden;
}

.rules-method-table {
  min-width: 0;
  table-layout: fixed;
}

.rules-method-table th:nth-child(1),
.rules-method-table td:nth-child(1) {
  width: 56px;
}

.rules-method-table th:nth-child(2),
.rules-method-table td:nth-child(2) {
  width: 92px;
}

.rules-method-table td:nth-child(3) {
  white-space: normal;
  overflow-wrap: anywhere;
}

.numbering-page {
  gap: 18px;
}

.numbering-workbench {
  display: grid;
  grid-template-columns: minmax(0, 1.16fr) minmax(390px, 0.84fr);
  gap: 18px;
  align-items: stretch;
}

.numbering-workbench > .panel {
  height: 100%;
}

.purchase-page {
  gap: 18px;
}

.purchase-workbench {
  display: grid;
  grid-template-columns: minmax(520px, 0.95fr) minmax(620px, 1.05fr);
  gap: 18px;
  align-items: start;
}

.vendor-summary {
  grid-template-columns: repeat(2, minmax(0, 1fr));
  margin-top: 14px;
  padding-top: 4px;
}

.vendor-summary .definition-row {
  grid-template-columns: 96px minmax(0, 1fr);
}

.purchase-line-table {
  min-width: 1180px;
  table-layout: fixed;
}

.purchase-line-table th:nth-child(1),
.purchase-line-table td:nth-child(1) {
  width: 54px;
}

.purchase-line-table th:last-child,
.purchase-line-table td:last-child {
  width: 72px;
  text-align: center;
}

.purchase-line-table input,
.purchase-line-table select {
  width: 100%;
  min-width: 0;
}

.purchase-submit-panel {
  background: linear-gradient(180deg, var(--surface), var(--surface-soft));
}

.purchase-submit-row {
  display: flex;
  gap: 16px;
  align-items: center;
  justify-content: space-between;
}

.purchase-submit-row > div {
  display: grid;
  gap: 4px;
}

.purchase-submit-row span {
  color: var(--muted);
  font-size: 13px;
}

.number-form-panel,
.number-context-panel {
  display: flex;
  min-width: 0;
  overflow: hidden;
  flex-direction: column;
}

.number-form-panel .panel-body,
.number-context-panel .panel-body {
  flex: 1;
}

.number-panel-header {
  min-height: 76px;
  background:
    linear-gradient(180deg, color-mix(in oklch, var(--surface-soft) 78%, var(--bg)), var(--bg));
}

.numbering-section {
  display: grid;
  gap: 14px;
  padding-top: 18px;
  border-top: 1px solid var(--line);
}

.numbering-section:first-child {
  padding-top: 0;
  border-top: 0;
}

.section-heading {
  display: grid;
  grid-template-columns: 36px minmax(0, 1fr);
  gap: 12px;
  align-items: start;
}

.section-heading > span {
  display: grid;
  place-items: center;
  width: 36px;
  height: 36px;
  color: var(--primary-dark);
  font-family: var(--font-mono);
  font-size: 13px;
  font-weight: 800;
  background: var(--primary-soft);
  border: 1px solid color-mix(in oklch, var(--primary) 25%, var(--line));
  border-radius: var(--radius-sm);
}

.section-heading h3 {
  margin: 0;
  font-size: 15px;
  line-height: 1.25;
}

.section-heading p {
  margin: 3px 0 0;
  color: var(--muted);
  font-size: 13px;
}

.numbering-submit-row {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  align-items: center;
  padding-top: 18px;
  border-top: 1px solid var(--line);
}

.numbering-submit-row .btn-primary {
  min-width: 144px;
}

.number-rule-block {
  display: grid;
  gap: 10px;
}

.issued-panel {
  display: grid;
  gap: 18px;
  padding: 18px;
  overflow: hidden;
  background:
    linear-gradient(135deg, color-mix(in oklch, var(--success-soft) 62%, var(--bg)), var(--bg) 54%),
    linear-gradient(90deg, color-mix(in oklch, var(--accent-soft) 72%, transparent), transparent);
  border: 1px solid color-mix(in oklch, var(--success) 26%, var(--line));
  border-radius: var(--radius);
  box-shadow: var(--shadow-tight);
  animation: issued-in 220ms ease-out;
}

.issued-hero {
  display: grid;
  grid-template-columns: 108px minmax(0, 1fr);
  gap: 18px;
  align-items: center;
}

.issued-stamp {
  position: relative;
  display: grid;
  place-items: center;
  width: 108px;
  height: 108px;
  color: color-mix(in oklch, var(--success) 78%, var(--ink));
  font-size: 16px;
  font-weight: 900;
  text-align: center;
  background: color-mix(in oklch, var(--bg) 82%, var(--success-soft));
  border: 3px solid color-mix(in oklch, var(--success) 58%, var(--line));
  border-radius: 50%;
  transform: rotate(-7deg);
  animation: issued-stamp-pop 520ms cubic-bezier(.18, .9, .3, 1.2) 80ms both;
}

.issued-stamp::after {
  position: absolute;
  right: 8px;
  bottom: 12px;
  display: grid;
  place-items: center;
  width: 26px;
  height: 26px;
  color: var(--bg);
  font-size: 16px;
  line-height: 1;
  content: "✓";
  background: color-mix(in oklch, var(--success) 84%, var(--primary-dark));
  border: 2px solid var(--bg);
  border-radius: 50%;
  box-shadow: 0 6px 14px color-mix(in oklch, var(--success) 24%, transparent);
  animation: issued-check-pop 420ms cubic-bezier(.2, .92, .3, 1.24) 360ms both;
}

.issued-title {
  display: grid;
  gap: 5px;
  min-width: 0;
}

.issued-title span {
  color: var(--success);
  font-size: 13px;
  font-weight: 850;
}

.issued-title strong {
  overflow-wrap: anywhere;
  color: var(--primary-dark);
  font-family: var(--font-mono);
  font-size: 46px;
  line-height: 1;
  animation: issued-number-reveal 560ms ease-out 170ms both;
}

.issued-ding {
  justify-self: start;
  min-height: 24px;
  padding: 4px 9px;
  color: color-mix(in oklch, var(--success) 78%, var(--ink));
  font-size: 12px;
  font-weight: 850;
  line-height: 1.25;
  background: color-mix(in oklch, var(--success-soft) 76%, var(--bg));
  border: 1px solid color-mix(in oklch, var(--success) 26%, var(--line));
  border-radius: 999px;
  animation: issued-ding-in 420ms ease-out 520ms both;
}

.issued-title p {
  margin: 0;
  color: var(--muted);
  font-size: 16px;
}

.completion-steps {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
}

.completion-steps span {
  min-height: 36px;
  padding: 8px 10px;
  color: color-mix(in oklch, var(--success) 82%, var(--ink));
  font-weight: 800;
  text-align: center;
  background: color-mix(in oklch, var(--success-soft) 76%, var(--bg));
  border: 1px solid color-mix(in oklch, var(--success) 24%, var(--line));
  border-radius: var(--radius-sm);
}

.issued-detail-grid {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 10px;
}

.issued-detail {
  display: grid;
  gap: 8px;
  min-width: 0;
  min-height: 104px;
  padding: 12px;
  background: color-mix(in oklch, var(--bg) 92%, var(--surface-soft));
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
}

.issued-detail > span {
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}

.issued-detail strong {
  overflow-wrap: anywhere;
  font-size: 14px;
  line-height: 1.35;
}

.issued-detail .btn {
  width: 100%;
  min-height: 32px;
  padding: 6px 9px;
  font-size: 12px;
}

.issued-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  align-items: center;
  padding-top: 2px;
}

.action-dialog.issue-result-dialog {
  width: min(1040px, calc(100vw - 32px));
  max-height: min(88vh, 820px);
  overflow: auto;
  background: transparent;
}

.action-dialog.issue-result-dialog::backdrop {
  background:
    linear-gradient(135deg, color-mix(in oklch, var(--ink) 35%, transparent), color-mix(in oklch, var(--primary-dark) 24%, transparent)),
    color-mix(in oklch, var(--ink) 28%, transparent);
}

.issue-dialog-shell {
  position: relative;
  padding: 0;
}

.issue-dialog-close {
  position: absolute;
  top: 14px;
  right: 14px;
  z-index: 2;
  background: color-mix(in oklch, var(--bg) 88%, transparent);
}

.issue-error-panel {
  display: grid;
  gap: 18px;
  padding: 20px;
  background:
    linear-gradient(135deg, color-mix(in oklch, var(--danger-soft) 68%, var(--bg)), var(--bg) 55%),
    linear-gradient(90deg, color-mix(in oklch, var(--warning-soft) 55%, transparent), transparent);
  border: 1px solid color-mix(in oklch, var(--danger) 28%, var(--line));
  border-radius: var(--radius);
  box-shadow: 0 18px 42px color-mix(in oklch, var(--ink) 18%, transparent);
  animation: issued-in 220ms ease-out;
}

.issue-error-hero {
  display: grid;
  grid-template-columns: 74px minmax(0, 1fr);
  gap: 16px;
  align-items: center;
  padding-right: 44px;
}

.issue-error-mark {
  display: grid;
  place-items: center;
  width: 74px;
  height: 74px;
  color: var(--danger);
  font-family: var(--font-mono);
  font-size: 34px;
  font-weight: 900;
  background: color-mix(in oklch, var(--bg) 80%, var(--danger-soft));
  border: 3px solid color-mix(in oklch, var(--danger) 46%, var(--line));
  border-radius: 50%;
}

.issue-error-title {
  display: grid;
  gap: 5px;
  min-width: 0;
}

.issue-error-title span {
  color: var(--danger);
  font-size: 13px;
  font-weight: 850;
}

.issue-error-title strong {
  font-size: 28px;
  line-height: 1.15;
}

.issue-error-title p {
  margin: 0;
  color: var(--muted);
  font-size: 15px;
}

.issue-error-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 10px;
}

.issue-error-detail {
  display: grid;
  gap: 8px;
  min-width: 0;
  padding: 12px;
  background: color-mix(in oklch, var(--bg) 92%, var(--surface-soft));
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
}

.issue-error-detail span {
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}

.issue-error-detail strong {
  overflow-wrap: anywhere;
  font-size: 14px;
}

.issue-error-checks {
  display: grid;
  gap: 10px;
}

.grid-3 {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 16px;
}

.panel {
  min-width: 0;
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: var(--radius);
}

.panel-header {
  display: flex;
  gap: 12px;
  align-items: center;
  justify-content: space-between;
  padding: 14px 16px;
  border-bottom: 1px solid var(--line);
}

.panel-header h3 {
  margin: 0;
  font-size: 16px;
  line-height: 1.2;
}

.panel-header p {
  margin: 4px 0 0;
  color: var(--muted);
  font-size: 13px;
}

.panel-body {
  padding: 16px;
}

.panel-body.compact {
  padding: 0;
}

.rule-strip {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
  padding: 12px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
}

.rule-token,
.code-chip,
.number-cell {
  font-family: var(--font-mono);
  font-weight: 700;
  letter-spacing: 0;
}

.rule-token {
  display: inline-flex;
  min-height: 30px;
  padding: 5px 8px;
  align-items: center;
  color: var(--primary-dark);
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: 6px;
}

.rule-separator {
  color: var(--muted);
  font-family: var(--font-mono);
  font-weight: 700;
}

.form-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
}

.form-grid.three {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

.field {
  display: grid;
  gap: 6px;
}

.field label,
.field-label {
  color: var(--ink);
  font-size: 13px;
  font-weight: 700;
}

.field small {
  color: var(--muted);
}

.checkline {
  display: flex;
  gap: 10px;
  align-items: center;
  min-height: 38px;
  padding: 8px 10px;
  background: var(--surface-soft);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
}

.checkline input {
  width: 16px;
  min-height: 16px;
  accent-color: var(--primary);
}

.preview-box {
  display: grid;
  gap: 14px;
  padding: 18px;
  background:
    linear-gradient(180deg, color-mix(in oklch, var(--primary-soft) 42%, var(--bg)), var(--surface-soft));
  border: 1px solid color-mix(in oklch, var(--primary) 18%, var(--line));
  border-radius: var(--radius);
}

.preview-number {
  overflow-wrap: anywhere;
  font-family: var(--font-mono);
  font-size: 32px;
  font-weight: 800;
  line-height: 1.2;
  color: var(--primary-dark);
}

.preview-number-hidden {
  font-family: var(--font-sans);
  font-size: 24px;
  letter-spacing: 0;
}

.preview-meta {
  display: grid;
  gap: 8px;
  color: var(--muted);
  font-size: 13px;
}

.preview-meta div {
  display: flex;
  gap: 10px;
  align-items: baseline;
  justify-content: space-between;
  padding-bottom: 7px;
  border-bottom: 1px solid var(--line);
}

.preview-meta strong {
  color: var(--ink);
  text-align: right;
}

.validation-list {
  display: grid;
  gap: 8px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.validation-list li {
  display: flex;
  gap: 8px;
  align-items: flex-start;
  padding: 8px 10px;
  border-radius: var(--radius-sm);
}

.validation-list .ok {
  color: var(--success);
  background: var(--success-soft);
}

.validation-list .warn {
  color: oklch(0.42 0.115 72);
  background: var(--warning-soft);
}

.validation-list .bad {
  color: var(--danger);
  background: var(--danger-soft);
}

.btn,
.icon-btn {
  display: inline-flex;
  gap: 8px;
  align-items: center;
  justify-content: center;
  min-height: 38px;
  padding: 8px 12px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  font-weight: 750;
  transition: background 160ms ease, color 160ms ease, border-color 160ms ease,
    transform 160ms ease;
}

.btn:active,
.icon-btn:active {
  transform: translateY(1px);
}

.btn-primary {
  color: var(--bg);
  background: var(--primary-dark);
}

.btn-primary:hover {
  background: color-mix(in oklch, var(--primary-dark) 86%, var(--ink));
}

.btn-secondary {
  color: var(--ink);
  background: var(--surface);
  border: 1px solid var(--line-strong);
}

.btn-secondary:hover {
  background: var(--surface-strong);
}

.btn-danger {
  color: var(--bg);
  background: var(--danger);
}

.btn-ghost {
  color: var(--primary-dark);
  background: transparent;
}

.btn-ghost:hover {
  background: var(--primary-soft);
}

.icon-btn {
  width: 34px;
  min-height: 34px;
  padding: 0;
  color: var(--primary-dark);
  background: var(--bg);
  border: 1px solid var(--line);
}

.icon-btn:hover {
  background: var(--primary-soft);
}

.btn:disabled,
.icon-btn:disabled,
button:disabled {
  cursor: not-allowed;
  opacity: 0.58;
  transform: none;
}

.btn-primary:disabled:hover {
  background: var(--primary-dark);
}

.btn-secondary:disabled:hover {
  background: var(--surface);
}

.btn-ghost:disabled:hover {
  background: transparent;
}

.icon-btn:disabled:hover {
  background: var(--bg);
}

.table-wrap {
  max-width: 100%;
  overflow: auto;
}

table {
  width: 100%;
  min-width: 920px;
  border-collapse: collapse;
  font-size: 14px;
}

.compact-table {
  min-width: 600px;
}

th,
td {
  padding: 10px 11px;
  vertical-align: top;
  border-bottom: 1px solid var(--line);
  text-align: left;
}

th {
  position: sticky;
  top: 0;
  z-index: 1;
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
  background: var(--surface);
}

tr:hover td {
  background: var(--surface-soft);
}

.number-cell {
  white-space: nowrap;
  color: var(--primary-dark);
}

.text-muted {
  color: var(--muted);
}

.nowrap {
  white-space: nowrap;
}

.status-pill,
.mini-pill {
  display: inline-flex;
  gap: 6px;
  align-items: center;
  width: max-content;
  min-height: 24px;
  padding: 3px 8px;
  border: 1px solid transparent;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 750;
}

.mini-pill {
  min-height: 22px;
  padding: 2px 7px;
}

.status-active {
  color: var(--success);
  background: var(--success-soft);
  border-color: color-mix(in oklch, var(--success) 22%, var(--success-soft));
}

.status-reserved {
  color: var(--primary-dark);
  background: var(--primary-soft);
  border-color: color-mix(in oklch, var(--primary) 26%, var(--primary-soft));
}

.status-pending {
  color: oklch(0.42 0.115 72);
  background: var(--warning-soft);
  border-color: color-mix(in oklch, var(--warning) 35%, var(--warning-soft));
}

.status-needs-review {
  color: var(--danger);
  background: var(--danger-soft);
  border-color: color-mix(in oklch, var(--danger) 22%, var(--danger-soft));
}

.status-void,
.status-rejected {
  color: var(--muted);
  background: var(--surface);
  border-color: var(--line);
}

.split-list {
  display: grid;
  gap: 10px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.split-list li {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 10px;
  align-items: start;
  padding: 10px 0;
  border-bottom: 1px solid var(--line);
}

.split-list li:last-child {
  border-bottom: 0;
}

.activity-title {
  display: grid;
  gap: 2px;
}

.activity-title strong {
  font-family: var(--font-mono);
}

.definition-grid {
  display: grid;
  gap: 10px;
}

.definition-row {
  display: grid;
  grid-template-columns: 160px minmax(0, 1fr);
  gap: 12px;
  padding: 10px 0;
  border-bottom: 1px solid var(--line);
}

.definition-row:last-child {
  border-bottom: 0;
}

.definition-row dt {
  margin: 0;
  color: var(--muted);
  font-weight: 750;
}

.definition-row dd {
  margin: 0;
}

.empty-state {
  display: grid;
  gap: 8px;
  place-items: center;
  min-height: 180px;
  padding: 24px;
  color: var(--muted);
  text-align: center;
}

.empty-state strong {
  color: var(--ink);
  font-size: 16px;
}

.filter-bar {
  display: grid;
  grid-template-columns: minmax(180px, 1.25fr) minmax(130px, 0.62fr) minmax(150px, 0.8fr) minmax(150px, 0.8fr) auto;
  gap: 10px;
  align-items: end;
}

.compact-filter {
  grid-template-columns: minmax(220px, 1fr) auto;
}

.danger-zone {
  border-color: color-mix(in oklch, var(--danger) 35%, var(--line));
}

.tutorial-layer {
  position: fixed;
  inset: 0;
  z-index: 80;
  pointer-events: none;
}

.tutorial-spotlight {
  position: fixed;
  left: 24px;
  top: 24px;
  width: 120px;
  height: 56px;
  border: 3px solid color-mix(in oklch, var(--warning) 88%, var(--bg));
  border-radius: var(--radius);
  box-shadow:
    0 0 0 9999px color-mix(in oklch, var(--ink) 62%, transparent),
    0 0 0 8px color-mix(in oklch, var(--warning) 26%, transparent),
    0 0 34px color-mix(in oklch, var(--warning) 74%, transparent);
  transition: left 180ms ease, top 180ms ease, width 180ms ease, height 180ms ease;
}

.tutorial-spotlight.is-missing {
  left: 50%;
  top: 96px;
  width: 0;
  height: 0;
  border: 0;
  border-radius: 50%;
}

.is-tutorial-target {
  position: relative;
  z-index: 81;
  outline: 3px solid color-mix(in oklch, var(--warning) 92%, var(--bg));
  outline-offset: 3px;
  box-shadow:
    0 0 0 8px color-mix(in oklch, var(--warning) 22%, transparent),
    0 12px 26px color-mix(in oklch, var(--ink) 18%, transparent);
}

.tutorial-target-pulse {
  animation: tutorial-target-pulse 520ms ease-out;
}

.tutorial-popover {
  position: fixed;
  left: 320px;
  top: 96px;
  z-index: 82;
  display: grid;
  gap: 12px;
  width: min(380px, calc(100vw - 32px));
  padding: 16px;
  color: var(--ink);
  background: var(--bg);
  border: 1px solid color-mix(in oklch, var(--warning) 32%, var(--line));
  border-radius: var(--radius);
  box-shadow: 0 20px 58px color-mix(in oklch, var(--ink) 28%, transparent);
  pointer-events: auto;
}

.tutorial-popover-head {
  display: flex;
  gap: 10px;
  align-items: center;
  justify-content: space-between;
}

.tutorial-popover-head span {
  min-height: 26px;
  padding: 4px 9px;
  color: color-mix(in oklch, var(--warning) 58%, var(--ink));
  font-size: 12px;
  font-weight: 850;
  background: var(--warning-soft);
  border: 1px solid color-mix(in oklch, var(--warning) 30%, var(--line));
  border-radius: 999px;
}

.tutorial-popover > strong {
  font-size: 18px;
  line-height: 1.2;
}

.tutorial-popover p {
  margin: 0;
  color: var(--muted);
}

.tutorial-progress {
  display: grid;
  gap: 8px;
}

.tutorial-progress span,
.tutorial-popover-footer > span {
  color: var(--muted);
  font-size: 12px;
  font-weight: 750;
}

.tutorial-progress meter {
  width: 100%;
  height: 10px;
}

.tutorial-progress meter::-webkit-meter-bar {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 999px;
}

.tutorial-progress meter::-webkit-meter-optimum-value {
  background: linear-gradient(90deg, var(--warning), var(--accent));
  border-radius: 999px;
}

.tutorial-popover-footer {
  display: grid;
  gap: 10px;
  padding-top: 10px;
  border-top: 1px solid var(--line);
}

.tutorial-popover-footer .button-row {
  justify-content: flex-end;
}

.toast-region {
  position: fixed;
  right: 18px;
  bottom: 18px;
  z-index: 90;
  display: grid;
  gap: 8px;
  width: min(380px, calc(100vw - 36px));
}

.toast {
  padding: 12px 14px;
  color: var(--ink);
  background: var(--bg);
  border: 1px solid var(--line-strong);
  border-radius: var(--radius);
  box-shadow: var(--shadow-tight);
  animation: toast-in 180ms ease-out;
}

.toast strong {
  display: block;
  margin-bottom: 2px;
}

.toast p {
  margin: 0;
  color: var(--muted);
}

.kbd {
  display: inline-flex;
  min-width: 22px;
  min-height: 22px;
  align-items: center;
  justify-content: center;
  padding: 1px 6px;
  font-family: var(--font-mono);
  font-size: 12px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 5px;
}

.segment-list {
  display: grid;
  gap: 8px;
}

.segment-item {
  display: grid;
  grid-template-columns: 68px minmax(0, 1fr);
  gap: 10px;
  align-items: center;
  padding: 10px;
  background: var(--surface-soft);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
}

.segment-item strong {
  font-family: var(--font-mono);
  color: var(--primary-dark);
}

.rules-segment-list .segment-item {
  grid-template-columns: 92px minmax(max-content, 1fr);
}

.rules-segment-list .segment-item span {
  white-space: nowrap;
}

.permission-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
}

.permission-card {
  display: grid;
  gap: 14px;
  min-width: 0;
  padding: 14px;
  background: var(--surface-soft);
  border: 1px solid var(--line);
  border-radius: var(--radius);
}

.permission-card-head {
  display: grid;
  gap: 4px;
}

.permission-card-head strong {
  font-size: 17px;
}

.permission-card-head span {
  color: var(--muted);
  font-size: 13px;
}

.permission-section {
  display: grid;
  gap: 7px;
}

.permission-list {
  display: grid;
  gap: 7px;
  margin: 0;
  padding: 0 0 0 18px;
}

.permission-list li {
  padding-left: 2px;
}

.muted-list {
  color: var(--muted);
}

.record-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.machine-picker {
  display: grid;
  gap: 8px;
  max-height: 360px;
  overflow: auto;
  padding: 8px;
  background: var(--surface-soft);
  border: 1px solid var(--line);
  border-radius: var(--radius);
}

.machine-candidate {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 10px;
  align-items: center;
  padding: 10px;
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
}

.machine-candidate.is-selected {
  border-color: color-mix(in oklch, var(--primary) 34%, var(--line));
  background: var(--primary-soft);
}

.machine-candidate div {
  display: grid;
  gap: 2px;
  min-width: 0;
}

.machine-candidate small {
  color: var(--muted);
}

.chip-list {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.machine-chip {
  display: inline-flex;
  gap: 7px;
  align-items: center;
  max-width: 100%;
  min-height: 30px;
  padding: 4px 7px 4px 9px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 999px;
}

.machine-chip button {
  display: inline-grid;
  place-items: center;
  width: 20px;
  height: 20px;
  color: var(--muted);
  background: transparent;
  border-radius: 999px;
  cursor: pointer;
}

.machine-chip button:hover {
  color: var(--danger);
  background: var(--danger-soft);
}

.mini-stack {
  display: grid;
  gap: 2px;
}

.machine-link-list {
  display: flex;
  flex-wrap: wrap;
  gap: 7px;
  align-items: center;
}

.machine-link-chip {
  display: inline-flex;
  max-width: 100%;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--surface-soft);
}

.machine-link-chip button {
  min-height: 30px;
  padding: 4px 9px;
  background: transparent;
  cursor: pointer;
  font-size: 13px;
}

.machine-link-chip button:first-child {
  display: inline-flex;
  gap: 6px;
  align-items: center;
  min-width: 0;
}

.machine-link-chip button:first-child:hover,
.machine-link-mini:hover {
  color: var(--primary-dark);
  background: var(--primary-soft);
}

.machine-link-mini {
  color: var(--muted);
  border-left: 1px solid var(--line);
  font-weight: 750;
}

.detail-panel {
  border-color: color-mix(in oklch, var(--primary) 22%, var(--line));
}

.detail-layout {
  display: grid;
  grid-template-columns: minmax(0, 1.15fr) minmax(300px, 0.85fr);
  gap: 18px;
  align-items: start;
  min-height: 0;
}

.detail-file {
  overflow-wrap: anywhere;
  font-family: var(--font-mono);
  font-size: 13px;
}

.history-panel {
  display: grid;
  grid-template-rows: auto minmax(0, 1fr);
  gap: 10px;
  min-width: 0;
  min-height: 0;
  max-height: var(--record-version-panel-height, 360px);
  overflow: hidden;
}

.history-panel > .version-list {
  min-height: 0;
  overflow: auto;
  padding-right: 6px;
}

.history-list {
  display: grid;
  gap: 10px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.history-list li {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 4px 12px;
  padding: 10px;
  background: var(--surface-soft);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
}

.history-list strong {
  display: block;
}

.history-list span,
.history-list small,
.history-list time {
  color: var(--muted);
  font-size: 12px;
}

.history-list small {
  grid-column: 1 / -1;
}

.version-list li.is-current {
  background: color-mix(in oklch, var(--primary) 8%, var(--surface-soft));
  border-color: color-mix(in oklch, var(--primary) 28%, var(--line));
}

.version-list small {
  display: flex;
  gap: 8px;
  align-items: center;
}

.version-reason {
  display: block;
  margin-top: 8px;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.45;
  overflow-wrap: anywhere;
}

.record-history-disclosure {
  padding: 0;
}

.record-history-disclosure summary {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 14px;
  cursor: pointer;
  list-style: none;
}

.record-history-disclosure summary::-webkit-details-marker {
  display: none;
}

.record-history-disclosure summary::after {
  content: "+";
  color: var(--primary-dark);
  font-size: 22px;
  font-weight: 850;
}

.record-history-disclosure[open] summary::after {
  content: "-";
}

.record-history-disclosure summary span {
  display: grid;
  gap: 3px;
}

.record-history-disclosure summary small {
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

.record-history-body {
  padding: 0 14px 14px;
}

.related-history-list {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.hidden-file-input {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
}

.action-dialog {
  width: min(520px, calc(100vw - 32px));
  padding: 0;
  color: var(--ink);
  background: var(--bg);
  border: 0;
  border-radius: var(--radius);
  box-shadow: 0 12px 32px color-mix(in oklch, var(--ink) 18%, transparent);
}

.action-dialog::backdrop {
  background: color-mix(in oklch, var(--ink) 28%, transparent);
}

.account-popover-dialog {
  width: min(820px, calc(100vw - 40px));
  max-height: min(84vh, 760px);
  margin: 88px 28px auto auto;
  overflow: auto;
}

.account-popover-dialog::backdrop {
  background: color-mix(in oklch, var(--ink) 12%, transparent);
}

.account-popover-card {
  display: grid;
  gap: 16px;
  padding: 18px;
}

.account-popover-head {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 14px;
  align-items: start;
  padding-bottom: 14px;
  border-bottom: 1px solid var(--line);
}

.account-popover-head h3,
.account-popover-section h4 {
  margin: 0;
}

.account-popover-head p,
.account-popover-section p {
  margin: 0;
  color: var(--muted);
}

.account-popover-grid {
  grid-template-columns: minmax(0, 1.2fr) minmax(320px, .8fr);
}

.account-popover-section {
  display: grid;
  gap: 14px;
  align-content: start;
  min-width: 0;
  padding: 14px;
  background: var(--surface-soft);
  border: 1px solid var(--line);
  border-radius: var(--radius);
}

.account-popover-foot {
  display: flex;
  justify-content: flex-end;
  padding-top: 2px;
}

.review-dialog {
  width: min(760px, calc(100vw - 32px));
}

.review-dialog-card {
  gap: 18px;
}

.review-summary {
  padding: 2px 12px;
  background: var(--surface-soft);
  border: 1px solid var(--line);
  border-radius: var(--radius);
}

.review-reason {
  display: block;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  color: var(--ink);
  font-weight: 750;
}

.action-dialog-card {
  display: grid;
  gap: 16px;
  padding: 18px;
}

.action-dialog-copy {
  display: grid;
  gap: 6px;
}

.action-dialog-copy strong {
  font-size: 17px;
}

.action-dialog-copy p {
  margin: 0;
  color: var(--muted);
}

.master-editor-dialog {
  width: min(760px, calc(100vw - 32px));
  max-height: min(86vh, 780px);
  overflow: auto;
}

.master-editor-card {
  display: grid;
  gap: 16px;
  padding: 18px;
}

.machine-detail-dialog,
.project-detail-dialog,
.record-detail-dialog {
  width: min(1080px, calc(100vw - 32px));
  max-height: min(88vh, 860px);
  overflow: auto;
}

.machine-detail-card,
.record-detail-card {
  display: grid;
  gap: 16px;
  padding: 18px;
}

.machine-detail-grid {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.master-editor-head {
  display: flex;
  gap: 14px;
  align-items: flex-start;
  justify-content: space-between;
  padding-bottom: 14px;
  border-bottom: 1px solid var(--line);
}

.master-editor-footer {
  justify-content: flex-end;
  padding-top: 14px;
  border-top: 1px solid var(--line);
}

.editor-subsection {
  display: grid;
  gap: 10px;
  padding: 12px;
  background: var(--surface-soft);
  border: 1px solid var(--line);
  border-radius: var(--radius);
}

.editor-subsection-head {
  display: flex;
  gap: 12px;
  align-items: center;
  justify-content: space-between;
}

.editor-subsection-head div {
  display: grid;
  gap: 2px;
}

.editor-subsection-head span {
  color: var(--muted);
  font-size: 13px;
}

@keyframes issued-in {
  from {
    opacity: 0;
    transform: translateY(8px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes issued-stamp-pop {
  0% {
    opacity: 0;
    transform: rotate(-7deg) scale(.86);
  }
  72% {
    opacity: 1;
    transform: rotate(-7deg) scale(1.04);
  }
  100% {
    opacity: 1;
    transform: rotate(-7deg) scale(1);
  }
}

@keyframes issued-check-pop {
  0% {
    opacity: 0;
    transform: scale(.3) rotate(-18deg);
  }
  78% {
    opacity: 1;
    transform: scale(1.12) rotate(4deg);
  }
  100% {
    opacity: 1;
    transform: scale(1) rotate(0);
  }
}

@keyframes issued-number-reveal {
  0% {
    opacity: 0;
    transform: translateY(5px);
    filter: blur(3px);
  }
  100% {
    opacity: 1;
    transform: translateY(0);
    filter: blur(0);
  }
}

@keyframes issued-ding-in {
  0% {
    opacity: 0;
    transform: translateY(-3px) scale(.95);
  }
  100% {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

@keyframes tutorial-target-pulse {
  0% {
    transform: scale(1);
  }
  45% {
    transform: scale(1.025);
  }
  100% {
    transform: scale(1);
  }
}

@keyframes toast-in {
  from {
    opacity: 0;
    transform: translateY(8px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

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

@media (max-width: 1320px) {
  .issued-detail-grid,
  .issue-error-grid {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }
}

@media (max-width: 1180px) {
  .metric-grid {
    grid-template-columns: repeat(3, minmax(150px, 1fr));
  }

  .grid-2,
  .grid-3,
  .numbering-workbench,
  .account-popover-grid,
  .permission-grid,
  .detail-layout {
    grid-template-columns: 1fr;
  }

  .issued-title strong {
    font-size: 40px;
  }

  .issue-error-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 860px) {
  .app-shell {
    grid-template-columns: 1fr;
  }

  .sidebar {
    position: static;
    height: auto;
    padding: 12px;
    border-right: 0;
    border-bottom: 1px solid var(--line);
  }

  .brand {
    grid-template-columns: 58px minmax(0, 1fr);
  }

  .brand-mark {
    width: 58px;
    height: 46px;
  }

  .nav-list {
    display: flex;
    flex: 0 0 auto;
    flex-direction: row;
    gap: 8px;
    overflow-x: auto;
    padding-bottom: 2px;
  }

  .nav-button {
    flex: 0 0 auto;
    width: auto;
  }

  .nav-button[data-route="purchase"] {
    margin-top: 0;
  }

  .sidebar-note {
    display: none;
  }

  .topbar {
    position: static;
    align-items: flex-start;
    padding: 16px;
  }

  .topbar-actions {
    flex-direction: column;
    align-items: flex-end;
  }

  .account-popover-dialog {
    margin: 16px auto auto;
  }

  #app {
    padding: 16px;
  }

  .page-header {
    flex-direction: column;
  }

  .page-actions {
    width: 100%;
    justify-content: stretch;
  }

  .page-actions .btn {
    width: 100%;
  }

  .issued-panel {
    padding: 14px;
  }

  .issued-hero {
    grid-template-columns: 1fr;
  }

  .issue-error-hero {
    grid-template-columns: 1fr;
    padding-right: 42px;
  }

  .issued-stamp {
    width: 86px;
    height: 86px;
    font-size: 14px;
  }

  .completion-steps,
  .issued-detail-grid,
  .issue-error-grid {
    grid-template-columns: 1fr;
  }

  .metric-grid,
  .form-grid,
  .form-grid.three,
  .purchase-workbench,
  .vendor-summary,
  .filter-bar,
  .compact-filter {
    grid-template-columns: 1fr;
  }

  .purchase-submit-row {
    align-items: stretch;
    flex-direction: column;
  }

  .machine-candidate {
    grid-template-columns: 1fr;
  }

  .master-editor-head,
  .editor-subsection-head {
    align-items: stretch;
    flex-direction: column;
  }

  .definition-row {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 560px) {
  body {
    font-size: 14px;
  }

  .topbar {
    flex-direction: column;
  }

  .topbar-actions {
    align-items: stretch;
    width: 100%;
  }

  .role-select {
    display: grid;
  }

  .quick-login {
    grid-template-columns: 1fr;
  }

  .metric-grid {
    grid-template-columns: 1fr;
  }

  .issued-title strong {
    font-size: 30px;
  }

  .issue-error-title strong {
    font-size: 24px;
  }

  .issued-actions .btn,
  .numbering-submit-row .btn {
    width: 100%;
  }

  .master-editor-footer .btn {
    width: 100%;
  }

  .preview-number {
    font-size: 22px;
  }
}
