:root {
  --ink: #17201e;
  --ink-soft: #52605d;
  --paper: #f7f7f4;
  --surface: #ffffff;
  --line: #d9dedb;
  --line-strong: #b7c0bc;
  --accent: #087f72;
  --accent-dark: #05665c;
  --accent-soft: #e4f2ef;
  --danger: #b53b35;
  --danger-soft: #f9e8e6;
  --success: #16764e;
  --success-soft: #e3f2e9;
  --warning: #936513;
  --warning-soft: #f7efd9;
  --radius: 10px;
  --shadow: 0 18px 50px rgba(28, 42, 38, 0.08);
  font-family: Inter, ui-sans-serif, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  color: var(--ink);
  background: var(--paper);
  font-synthesis: none;
}

* { box-sizing: border-box; }
html { min-width: 320px; background: var(--paper); }
body { margin: 0; min-height: 100vh; background: var(--paper); }
button, input, textarea { font: inherit; }
button, a { -webkit-tap-highlight-color: transparent; }
a { color: inherit; }
button { cursor: pointer; }
button:disabled { cursor: wait; opacity: 0.6; }

.mono,
input[spellcheck="false"],
textarea[spellcheck="false"] {
  font-family: "SFMono-Regular", Consolas, "Liberation Mono", monospace;
}

.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;
}

.product-header,
.admin-header {
  height: 76px;
  padding: 0 clamp(22px, 4vw, 64px);
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: 1px solid var(--line);
  background: rgba(247, 247, 244, 0.94);
}

.product-mark,
.admin-brand {
  display: flex;
  align-items: center;
  gap: 13px;
  color: var(--ink);
  text-decoration: none;
}

.product-mark > span:last-child,
.admin-brand > span:last-child {
  display: grid;
  gap: 1px;
}

.product-mark strong,
.admin-brand strong { font-size: 15px; font-weight: 720; }
.product-mark small,
.admin-brand small { font-size: 11px; color: var(--ink-soft); }

.mark-cube {
  position: relative;
  display: block;
  width: 34px;
  height: 34px;
  transform: rotate(30deg) skewY(-8deg);
}

.mark-cube.compact { width: 29px; height: 29px; }
.mark-cube i { position: absolute; display: block; background: var(--accent); }
.mark-cube i:nth-child(1) { inset: 2px 11px 16px 2px; }
.mark-cube i:nth-child(2) { inset: 9px 2px 2px 17px; background: #0b6e64; }
.mark-cube i:nth-child(3) { inset: 18px 13px 2px 5px; background: #4aa99e; }

.service-state {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-size: 12px;
  color: var(--ink-soft);
}

.service-state i {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--success);
  box-shadow: 0 0 0 4px var(--success-soft);
}

.claim-shell {
  min-height: calc(100vh - 128px);
  width: min(1180px, calc(100% - 44px));
  margin: 0 auto;
  padding: clamp(52px, 8vh, 96px) 0 60px;
  display: grid;
  grid-template-columns: minmax(0, 0.9fr) minmax(480px, 1.1fr);
  gap: clamp(58px, 8vw, 118px);
  align-items: start;
}

.claim-context { padding-top: 20px; }
.section-index {
  margin: 0 0 18px;
  color: var(--accent);
  font-size: 11px;
  font-weight: 760;
  text-transform: uppercase;
}

.claim-context h1,
.admin-title-row h1,
.login-brand h1 {
  margin: 0;
  font-size: clamp(42px, 6vw, 72px);
  line-height: 0.98;
  font-weight: 730;
}

.claim-summary {
  max-width: 470px;
  margin: 24px 0 38px;
  font-size: 18px;
  line-height: 1.75;
  color: var(--ink-soft);
}

.license-terms,
.inventory-stats,
.detail-list { margin: 0; }

.license-terms > div {
  display: grid;
  grid-template-columns: 110px 1fr;
  gap: 20px;
  padding: 14px 0;
  border-top: 1px solid var(--line);
}

.license-terms > div:last-child { border-bottom: 1px solid var(--line); }
.license-terms dt { color: var(--ink-soft); font-size: 13px; }
.license-terms dd { margin: 0; font-size: 14px; font-weight: 650; }

.context-note {
  max-width: 430px;
  margin: 24px 0 0;
  color: var(--ink-soft);
  font-size: 12px;
  line-height: 1.7;
}

.claim-tool {
  padding: clamp(28px, 4vw, 46px);
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

.field-group { display: grid; gap: 8px; margin-bottom: 22px; }
.field-group label,
.license-result > label,
.stored-license > label {
  font-size: 12px;
  font-weight: 700;
}

.field-group input,
.field-group textarea,
.search-bar input,
.license-result textarea,
.stored-license textarea {
  width: 100%;
  border: 1px solid var(--line-strong);
  border-radius: 7px;
  color: var(--ink);
  background: var(--surface);
  outline: 0;
  transition: border-color 160ms ease, box-shadow 160ms ease, background-color 160ms ease;
}

.field-group input,
.search-bar input { height: 48px; padding: 0 14px; }
.field-group textarea { min-height: 96px; padding: 12px 14px; resize: vertical; }
.field-group input:focus,
.field-group textarea:focus,
.search-bar input:focus,
.license-result textarea:focus,
.stored-license textarea:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}

.field-hint { margin: 0; color: var(--ink-soft); font-size: 11px; }
.trap-field { position: absolute; left: -9999px; width: 1px; height: 1px; overflow: hidden; }

.primary-action,
.secondary-action,
.danger-action {
  border-radius: 7px;
  min-height: 46px;
  padding: 0 17px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 20px;
  border: 1px solid transparent;
  font-weight: 680;
  transition: transform 150ms ease, background-color 150ms ease, border-color 150ms ease;
}

.primary-action {
  width: 100%;
  background: var(--accent);
  color: white;
}

.primary-action:hover { background: var(--accent-dark); transform: translateY(-1px); }
.primary-action i { font-style: normal; font-size: 20px; font-weight: 400; }
.compact-action { width: auto; min-width: 190px; }
.secondary-action { color: var(--ink); background: var(--surface); border-color: var(--line-strong); }
.secondary-action:hover { border-color: var(--accent); color: var(--accent-dark); }
.danger-action { color: white; background: var(--danger); }
.danger-action:hover { background: #96302b; }

.form-status { min-height: 20px; margin: 14px 0 0; font-size: 12px; color: var(--ink-soft); }
.form-status.is-error { color: var(--danger); }
.form-status.is-success { color: var(--success); }

.license-result {
  margin-top: 30px;
  padding-top: 28px;
  border-top: 1px solid var(--line);
  animation: result-in 320ms ease both;
}

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

.result-heading { margin-bottom: 18px; display: flex; align-items: center; justify-content: space-between; gap: 16px; }
.result-heading > div { display: flex; align-items: center; gap: 10px; }
.result-heading h2 { margin: 0; font-size: 18px; }
.result-heading > span { color: var(--ink-soft); font-family: monospace; font-size: 11px; }
.success-signal {
  width: 25px;
  height: 25px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  color: white;
  background: var(--success);
  font-size: 13px;
}

.license-result textarea,
.stored-license textarea {
  min-height: 118px;
  margin: 8px 0 12px;
  padding: 12px;
  resize: vertical;
  font-family: "SFMono-Regular", Consolas, monospace;
  font-size: 11px;
  line-height: 1.55;
}

.result-machine { margin: 12px 0 0; font-family: monospace; font-size: 10px; color: var(--ink-soft); word-break: break-all; }

.claim-footer {
  height: 52px;
  padding: 0 clamp(22px, 4vw, 64px);
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-top: 1px solid var(--line);
  color: var(--ink-soft);
  font-size: 10px;
}

/* Admin */
.admin-header { position: sticky; top: 0; z-index: 10; height: 68px; background: rgba(247, 247, 244, 0.96); backdrop-filter: blur(12px); }
.admin-header nav { display: flex; align-items: center; gap: 22px; font-size: 13px; }
.admin-header nav a { text-decoration: none; font-weight: 650; }
.admin-header nav form { margin: 0; }
.admin-header nav button { padding: 0; border: 0; color: var(--ink-soft); background: transparent; }
.admin-main { width: min(1320px, calc(100% - 48px)); margin: 0 auto; padding: 58px 0 90px; }

.admin-title-row {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 30px;
  margin-bottom: 38px;
}

.admin-title-row h1 { font-size: clamp(38px, 5vw, 58px); }
.admin-title-row > p { max-width: 360px; margin: 0 0 5px; color: var(--ink-soft); font-size: 12px; line-height: 1.7; text-align: right; }
.detail-title { align-items: center; }
.back-link { display: inline-block; margin-bottom: 18px; color: var(--ink-soft); text-decoration: none; font-size: 12px; }

.inventory-stats {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  border-top: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
}

.inventory-stats > div { padding: 22px 26px; border-right: 1px solid var(--line); }
.inventory-stats > div:first-child { padding-left: 0; }
.inventory-stats > div:last-child { border-right: 0; }
.inventory-stats dt { color: var(--ink-soft); font-size: 11px; }
.inventory-stats dd { margin: 8px 0 0; font-size: 28px; font-weight: 720; }

.admin-workspace {
  margin-top: 46px;
  display: grid;
  grid-template-columns: 320px minmax(0, 1fr);
  gap: 42px;
  align-items: start;
}

.generation-tool,
.detail-actions > section {
  padding: 24px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
}

.generation-tool header { margin-bottom: 22px; display: flex; justify-content: space-between; align-items: baseline; }
.generation-tool h2,
.detail-actions h2,
.history-section h2 { margin: 0; font-size: 18px; }
.generation-tool header span { color: var(--ink-soft); font-size: 10px; }
.field-pair { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.field-pair .field-group { min-width: 0; }

.search-bar { display: grid; grid-template-columns: 1fr auto; margin-bottom: 14px; }
.search-bar input { border-radius: 7px 0 0 7px; }
.search-bar button {
  min-width: 72px;
  border: 1px solid var(--ink);
  border-left: 0;
  border-radius: 0 7px 7px 0;
  color: white;
  background: var(--ink);
}

.table-wrap { overflow: auto; border-top: 1px solid var(--line); }
table { width: 100%; border-collapse: collapse; font-size: 12px; }
th { padding: 13px 12px; color: var(--ink-soft); font-size: 10px; font-weight: 650; text-align: left; white-space: nowrap; }
td { padding: 15px 12px; border-top: 1px solid var(--line); vertical-align: middle; }
tbody tr { transition: background-color 120ms ease; }
tbody tr:hover { background: rgba(8, 127, 114, 0.035); }
.machine-cell { max-width: 240px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 10px; }
.row-action { color: var(--accent-dark); font-weight: 700; text-decoration: none; }
.empty-state { height: 120px; color: var(--ink-soft); text-align: center; }

.status-tag {
  display: inline-flex;
  align-items: center;
  min-height: 24px;
  padding: 0 8px;
  border-radius: 5px;
  font-size: 10px;
  font-weight: 700;
}

.status-unused { color: var(--accent-dark); background: var(--accent-soft); }
.status-used { color: var(--success); background: var(--success-soft); }
.status-disabled { color: var(--danger); background: var(--danger-soft); }
.status-expired { color: var(--warning); background: var(--warning-soft); }

.inline-alert { padding: 12px 14px; border-radius: 7px; font-size: 12px; }
.inline-alert.error { color: var(--danger); background: var(--danger-soft); }
.inline-alert.success { color: var(--success); background: var(--success-soft); }

.voucher-detail-grid { display: grid; grid-template-columns: minmax(0, 1fr) 350px; gap: 54px; align-items: start; }
.detail-list > div { display: grid; grid-template-columns: 150px minmax(0, 1fr); gap: 24px; padding: 15px 0; border-top: 1px solid var(--line); }
.detail-list > div:last-child { border-bottom: 1px solid var(--line); }
.detail-list dt { color: var(--ink-soft); font-size: 11px; }
.detail-list dd { margin: 0; font-size: 12px; overflow-wrap: anywhere; }
.stored-license { margin-top: 30px; }
.detail-actions { display: grid; gap: 20px; }
.detail-actions p { color: var(--ink-soft); font-size: 11px; line-height: 1.7; }
.history-section { margin-top: 56px; }
.history-section h2 { margin-bottom: 18px; }

/* Login */
.login-page { background: var(--ink); }
.login-shell {
  min-height: 100vh;
  width: min(920px, calc(100% - 44px));
  margin: 0 auto;
  display: grid;
  grid-template-columns: 1fr 400px;
  gap: 100px;
  align-items: center;
}

.login-brand { color: white; }
.login-brand .mark-cube { margin-bottom: 40px; }
.login-brand p { margin: 0 0 14px; color: #8fc9c2; font-size: 11px; font-weight: 700; }
.login-brand h1 { font-size: clamp(48px, 7vw, 78px); }
.login-form { padding: 34px; border-radius: var(--radius); background: var(--surface); }

@media (max-width: 900px) {
  .claim-shell { grid-template-columns: 1fr; gap: 42px; padding-top: 50px; }
  .claim-context { max-width: 620px; padding-top: 0; }
  .claim-summary { margin-bottom: 24px; }
  .admin-workspace { grid-template-columns: 1fr; }
  .generation-tool { max-width: 520px; }
  .voucher-detail-grid { grid-template-columns: 1fr; }
  .detail-actions { max-width: 520px; }
  .login-shell { grid-template-columns: 1fr; gap: 40px; padding: 60px 0; }
  .login-brand h1 { font-size: 54px; }
  .login-form { max-width: 480px; width: 100%; }
}

@media (max-width: 620px) {
  .product-header { height: 66px; padding: 0 18px; }
  .service-state { display: none; }
  .claim-shell { width: min(100% - 28px, 560px); padding: 38px 0 44px; }
  .claim-context h1 { font-size: 44px; }
  .claim-summary { font-size: 16px; }
  .claim-tool { padding: 24px 18px; }
  .claim-footer { padding: 0 18px; }
  .claim-footer span:last-child { display: none; }
  .admin-header { padding: 0 16px; }
  .admin-brand small { display: none; }
  .admin-main { width: min(100% - 28px, 560px); padding-top: 36px; }
  .admin-title-row { align-items: flex-start; flex-direction: column; margin-bottom: 28px; }
  .admin-title-row > p { text-align: left; }
  .inventory-stats { grid-template-columns: 1fr 1fr; }
  .inventory-stats > div { padding: 16px; border-bottom: 1px solid var(--line); }
  .inventory-stats > div:nth-child(2) { border-right: 0; }
  .inventory-stats > div:first-child { padding-left: 16px; }
  .inventory-stats > div:nth-child(3), .inventory-stats > div:nth-child(4) { border-bottom: 0; }
  .admin-workspace { margin-top: 30px; gap: 30px; }
  .field-pair { grid-template-columns: 1fr; gap: 0; }
  .machine-cell { max-width: 150px; }
  .detail-list > div { grid-template-columns: 1fr; gap: 7px; }
  .login-shell { width: min(100% - 28px, 480px); }
  .login-brand { display: none; }
  .login-form { padding: 26px 20px; }
}

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