:root {
  color-scheme: light;
  --ink: #172337;
  --muted: #68758a;
  --line: #e2e7ee;
  --paper: #fff;
  --page: #f5f7fa;
  --navy: #101b2e;
  --accent: #127d70;
  --accent-dark: #0b665c;
  --accent-soft: #e7f5f0;
  --red: #b42339;
  --red-soft: #fff0f1;
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Noto Sans JP', Meiryo, sans-serif;
  font-synthesis: none;
  text-rendering: optimizeLegibility;
}

*, *::before, *::after { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body { margin: 0; min-height: 100vh; color: var(--ink); background: var(--page); font-size: 14px; line-height: 1.7; }
button, input, textarea { font: inherit; }
button { cursor: pointer; }
button:disabled, input:disabled { opacity: .55; cursor: not-allowed; }
a { color: inherit; }
[hidden] { display: none !important; }
:focus-visible { outline: 3px solid rgba(18, 125, 112, .45); outline-offset: 3px; }

.site-topbar { height: 80px; max-width: 1200px; margin: 0 auto; padding: 0 32px; display: flex; justify-content: space-between; align-items: center; }
.brand { font-size: 17px; letter-spacing: .015em; display: inline-flex; align-items: center; gap: 10px; text-decoration: none; font-weight: 800; color: var(--navy); }
.brand-icon { width: 34px; height: 34px; border-radius: 10px; background: var(--navy); color: #c3f5e5; display: grid; place-items: center; font-size: 26px; line-height: 1; }
.brand-secondary { font-size: 12px; letter-spacing: .19em; font-weight: 600; color: #6c788b; }
.topbar-link { text-decoration: none; font-size: 12px; color: #536278; font-weight: 700; border-bottom: 1px solid transparent; }
.topbar-link:hover { color: var(--accent); border-bottom-color: var(--accent); }
.site-footer { text-align: center; padding: 44px 20px 26px; color: #8a97a8; letter-spacing: .08em; font-size: 11px; }
.site-footer span { padding: 0 12px; }

.access-page { background: radial-gradient(circle at 50% 20%, #e4f3ee 0, transparent 36%), var(--page); }
.access-main { width: min(100% - 40px, 554px); margin: 48px auto 0; }
.access-lead { text-align: center; margin-bottom: 35px; }
.eyebrow { letter-spacing: .16em; font-size: 10px; color: var(--accent-dark); font-weight: 800; }
.status-dot, .success-dot { display: inline-block; width: 8px; height: 8px; background: #19a687; border-radius: 50%; margin-right: 6px; box-shadow: 0 0 0 4px rgba(25,166,135,.1); vertical-align: middle; }
.access-lead h1 { font-size: clamp(30px, 5.2vw, 42px); letter-spacing: -.035em; line-height: 1.4; margin: 20px 0 14px; font-weight: 800; }
.text-accent { color: var(--accent); }
.access-lead p { color: var(--muted); max-width: 430px; margin: 0 auto; line-height: 1.85; }
.totp-update-status { display: flex; align-items: flex-start; gap: 14px; border: 1px solid #c6e4dc; border-left: 4px solid var(--accent); border-radius: 12px; background: #f0faf6; padding: 16px 19px; margin: 0 0 19px; box-shadow: 0 7px 20px rgba(15, 87, 71, .045); }
.totp-update-status.is-updated { background: #e4f7ed; border-color: #6fbe9d; border-left-color: #0e876c; }
.update-status-symbol { color: #0d7366; background: #d7f0e8; border-radius: 9px; width: 33px; height: 33px; flex-shrink: 0; display: grid; place-items: center; font-size: 22px; font-weight: 700; line-height: 1; }
.update-status-details { min-width: 0; }
.update-status-label { display: block; color: #31756a; font-size: 10px; letter-spacing: .09em; font-weight: 800; }
.update-status-date { display: block; color: #163b36; font-size: clamp(16px, 3.2vw, 19px); line-height: 1.45; font-weight: 800; margin-top: 3px; font-variant-numeric: tabular-nums; }
.update-status-details p { color: #56776f; margin: 5px 0 0; font-size: 12px; line-height: 1.6; }
.card { border: 1px solid var(--line); border-radius: 19px; background: var(--paper); box-shadow: 0 14px 40px rgba(28,49,75,.045); }
.access-card { padding: 36px 39px 34px; }
.step-pill { color: var(--accent); background: var(--accent-soft); border: 1px solid #d0ebe2; border-radius: 5px; font-size: 10px; letter-spacing: .12em; font-weight: 800; display: inline-block; padding: 5px 9px; line-height: 1.5; }
.card-heading h2 { margin: 18px 0 2px; font-size: 21px; letter-spacing: -.02em; }
.card-heading p { margin: 0 0 27px; color: var(--muted); font-size: 13px; }
.field-stack { display: flex; flex-direction: column; align-items: stretch; gap: 9px; }
.field-stack label { font-size: 13px; font-weight: 700; }
.control { border-radius: 9px; border: 1px solid #d6dde6; background: #fff; padding: 13px 14px; width: 100%; color: var(--navy); min-height: 47px; transition: border-color .15s, box-shadow .15s; }
.control::placeholder { color: #9eacba; }
.control:focus { outline: none; border-color: #168e7b; box-shadow: 0 0 0 3px rgba(22,142,123,.13); }
.code-input { font-family: ui-monospace, SFMono-Regular, Consolas, monospace; font-size: 14px; letter-spacing: .04em; }
.field-hint { font-size: 11px; color: #8591a3; line-height: 1.65; }
.button { min-height: 42px; border-radius: 9px; padding: 10px 16px; display: inline-flex; gap: 10px; justify-content: center; align-items: center; font-weight: 700; border: 1px solid transparent; transition: background .15s, transform .15s, border-color .15s; text-decoration: none; white-space: nowrap; }
.button:not(:disabled):active { transform: translateY(1px); }
.button-primary { color: #fff; background: var(--accent); border-color: var(--accent); }
.button-primary:hover:not(:disabled) { background: var(--accent-dark); border-color: var(--accent-dark); }
.button-light { color: var(--accent-dark); background: #e8f5f1; border-color: #d2e9e2; }
.button-light:hover:not(:disabled) { background: #d4ebe3; }
.button-outline { color: #42536a; background: white; border-color: #dbe2e9; }
.button-outline:hover:not(:disabled) { border-color: var(--accent); color: var(--accent-dark); }
.button-danger-outline { color: #ae3449; border-color: #f0cbd1; }
.button-danger-outline:hover:not(:disabled) { border-color: #ae3449; background: var(--red-soft); color: #992b3f; }
.button-danger { color: #fff; background: #b82e43; }
.button-danger:hover:not(:disabled) { background: #9e2337; }
.button-small { min-height: 36px; padding: 6px 11px; font-size: 12px; }
.button-full { width: 100%; margin-top: 12px; padding: 15px; font-size: 14px; }
.notice { padding: 12px 15px; border: 1px solid #bedfd5; background: #eff9f5; color: #165e50; border-radius: 9px; margin: 14px 0; }
.error-notice { border-color: #f1bdc3; background: var(--red-soft); color: var(--red); }
.result-divider { height: 1px; background: var(--line); margin: 27px 0 23px; }
.result-top { color: #16846f; font-size: 12px; font-weight: 700; }
.otp-row { display: flex; justify-content: space-between; align-items: center; gap: 14px; margin: 15px 0 12px; }
.otp-number { font-size: clamp(38px, 8vw, 52px); font-weight: 800; letter-spacing: .12em; font-family: ui-monospace, SFMono-Regular, Consolas, monospace; color: var(--navy); line-height: 1.3; font-variant-numeric: tabular-nums; }
.timer-row { display: flex; justify-content: space-between; gap: 12px; color: #657389; font-size: 12px; }
progress { border: 0; width: 100%; height: 5px; accent-color: var(--accent); margin: 10px 0; }
progress::-webkit-progress-bar { background: #e6eaf0; border-radius: 20px; }
progress::-webkit-progress-value { background: var(--accent); border-radius: 20px; }
progress::-moz-progress-bar { background: var(--accent); border-radius: 20px; }
.expiry-note { color: var(--accent-dark); font-size: 12px; font-weight: 700; margin: 3px 0 12px; }
.access-guidance { display: flex; gap: 12px; margin: 22px 2px 0; padding: 19px 14px 10px; align-items: flex-start; }
.guidance-icon { border-radius: 50%; display: grid; place-items: center; font-family: Georgia, serif; font-weight: 700; color: #60738b; background: #e9eef3; width: 22px; height: 22px; flex-shrink: 0; }
.access-guidance h3 { font-size: 13px; margin: 0 0 3px; }
.access-guidance p { font-size: 12px; color: #7b899a; margin: 0; line-height: 1.8; }

.admin-page { background: #f6f8fb; }
.admin-topbar { max-width: 1160px; }
.login-main { width: min(100% - 32px, 440px); margin: 95px auto 0; }
.login-intro { text-align: center; margin-bottom: 30px; }
.login-intro h1 { margin: 15px 0 4px; font-size: 31px; }
.login-intro p { color: var(--muted); margin: 0; }
.login-card { padding: 35px; }
.dashboard { max-width: 1160px; margin: 32px auto 80px; padding: 0 28px; }
.dashboard-header { display: flex; justify-content: space-between; align-items: center; gap: 24px; }
.dashboard-header h1 { margin: 14px 0 0; font-size: clamp(26px, 4vw, 36px); letter-spacing: -.025em; }
.dashboard-header p { margin: 4px 0 0; color: #7b8798; }
.section-nav { display: flex; gap: 25px; flex-wrap: wrap; border-bottom: 1px solid var(--line); margin: 25px 0 35px; padding-bottom: 16px; }
.section-nav a { font-size: 13px; font-weight: 700; text-decoration: none; color: #637187; }
.section-nav a:hover { color: var(--accent); }
.section-block { margin-bottom: 43px; scroll-margin-top: 24px; }
.section-heading { display: flex; justify-content: space-between; align-items: flex-end; gap: 16px; margin-bottom: 16px; }
.section-heading h2 { font-size: 24px; margin: 4px 0 0; letter-spacing: -.025em; }
.section-heading p { margin: 1px 0 0; color: #8490a0; }
.admin-eyebrow { display: block; font-size: 10px; }
.stats-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 15px; }
.stat-card { background: white; border: 1px solid var(--line); border-radius: 13px; padding: 21px 24px 20px; display: flex; flex-direction: column; box-shadow: 0 8px 20px rgba(28,49,75,.025); }
.stat-card > span { color: #728095; font-size: 12px; font-weight: 700; }
.stat-card strong { font-size: 36px; line-height: 1.4; color: var(--navy); font-variant-numeric: tabular-nums; }
.stat-card small { font-size: 11px; color: #9aa6b3; }
.section-card { padding: 26px 30px; }
.section-card > h3 { margin: 0 0 15px; font-size: 16px; }
.totp-status { display: flex; align-items: center; flex-wrap: wrap; gap: 11px; font-size: 13px; color: #627086; margin-bottom: 19px; }
.status-chip { border-radius: 20px; font-size: 11px; font-weight: 800; padding: 4px 10px; color: #076954; background: #e5f5ee; display: inline-flex; align-items: center; white-space: nowrap; }
.status-chip.muted { background: #e9edf2; color: #708096; }
.status-chip.expired, .status-chip.exhausted { background: #fff0e9; color: #a24d1d; }
.status-chip.disabled { background: var(--red-soft); color: var(--red); }
.alert-soft { padding: 13px 15px; border-radius: 9px; background: #f1f6fa; color: #64758b; border: 1px solid #e1eaf1; font-size: 12px; line-height: 1.8; margin: 0 0 24px; }
.upload-area { display: flex; cursor: pointer; flex-direction: column; align-items: center; justify-content: center; border: 1px dashed #b9cdd0; border-radius: 11px; min-height: 126px; gap: 4px; background: #f9fcfb; padding: 18px; color: #496574; text-align: center; }
.upload-area:hover, .upload-area:focus-within { background: #f1f9f6; border-color: var(--accent); }
.upload-area small { color: #93a2ad; font-size: 11px; }
.upload-icon { font-size: 26px; color: var(--accent); line-height: 1.2; }
.field-separator { color: #97a3b2; display: flex; gap: 12px; align-items: center; justify-content: center; padding: 7px 0 3px; font-size: 11px; }
.field-separator::before, .field-separator::after { content: ''; height: 1px; background: var(--line); flex: 1; }
.visually-hidden { position: absolute !important; overflow: hidden; clip: rect(0 0 0 0); width: 1px; height: 1px; padding: 0; margin: -1px; border: 0; white-space: nowrap; }
.create-grid { display: grid; grid-template-columns: minmax(0,1.35fr) minmax(0,1fr) minmax(0,.7fr) auto; align-items: end; gap: 16px; }
.create-grid .field-stack { align-self: stretch; }
.create-grid .create-button { min-height: 47px; }
.keys-heading { display: flex; justify-content: space-between; align-items: baseline; gap: 14px; margin: 22px 0 13px; }
.keys-heading h3 { font-size: 16px; margin: 0; }
.keys-heading h3 span { color: #929eac; font-size: 13px; }
.key-list { display: flex; flex-direction: column; gap: 12px; }
.key-entry { background: #fff; border: 1px solid var(--line); border-radius: 14px; padding: 21px 23px; box-shadow: 0 8px 23px rgba(28,49,75,.02); }
.key-entry-header { display: flex; justify-content: space-between; align-items: center; gap: 16px; }
.key-entry-header h4 { margin: 0; font-size: 16px; letter-spacing: -.02em; overflow-wrap: anywhere; }
.key-entry-header small { display: block; color: #8996a5; font-size: 11px; margin-top: 1px; }
.key-metadata { display: grid; grid-template-columns: repeat(4, minmax(0,1fr)); gap: 15px; margin: 20px 0; }
.key-metadata .meta-label { display: block; font-size: 11px; color: #8897a8; }
.key-metadata strong { display: block; font-size: 12px; color: #415269; overflow-wrap: anywhere; }
.key-edit { display: grid; grid-template-columns: minmax(0,1.6fr) minmax(0,1fr) auto; align-items: end; gap: 10px; border-top: 1px solid #eff1f5; padding-top: 17px; }
.key-edit .field-stack { gap: 4px; }
.key-edit label { color: #67758a; font-size: 11px; }
.key-edit .control { min-height: 39px; padding: 8px 10px; font-size: 12px; }
.key-actions { display: flex; flex-wrap: wrap; justify-content: flex-start; gap: 8px; margin-top: 13px; }
.key-actions .button { min-height: 34px; padding: 7px 11px; font-size: 11px; }
.key-actions .button-copy { color: var(--accent-dark); background: #e7f6f0; border-color: #c2e2d7; }
.key-actions .button-copy:hover:not(:disabled) { background: #d6eee5; }
.legacy-key-hint { color: #a35a27; font-size: 11px; margin: 8px 0 0; }
.empty-state { margin: 0; border: 1px dashed #d4dce5; border-radius: 12px; background: #fff; text-align: center; padding: 32px; color: #96a1b1; }
.events-list { list-style: none; padding: 0; margin: 0; }
.events-list li:not(.empty-state) { border-bottom: 1px solid #ecf0f3; display: flex; gap: 20px; padding: 12px 0; justify-content: space-between; }
.events-list li:last-child { border-bottom: 0; }
.event-name { color: #3d4d63; font-size: 13px; font-weight: 600; }
.event-time { color: #99a4b4; font-size: 11px; white-space: nowrap; }
.dashboard-footer { text-align: center; color: #a1acba; font-size: 11px; padding-top: 30px; }
.issued-dialog { border: 1px solid #e0e6eb; border-radius: 20px; box-shadow: 0 25px 75px rgba(15,28,45,.2); max-width: min(500px, calc(100vw - 28px)); width: 100%; padding: 34px; text-align: center; color: var(--ink); }
.issued-dialog::backdrop { background: rgba(10,20,35,.62); backdrop-filter: blur(4px); }
.dialog-icon { margin: 0 auto; width: 46px; height: 46px; border-radius: 50%; background: var(--accent-soft); color: var(--accent-dark); display: grid; place-items: center; font-size: 22px; font-weight: 700; }
.issued-dialog h2 { font-size: 21px; margin: 12px 0 5px; }
.issued-dialog p { color: #7a8799; font-size: 12px; margin: 0; }
.issued-value { margin: 21px 0; padding: 19px 12px; background: #f4f8f7; border: 1px dashed #9ac6b9; border-radius: 9px; font-weight: 800; color: var(--accent-dark); letter-spacing: .06em; font-family: ui-monospace, SFMono-Regular, Consolas, monospace; font-size: clamp(13px, 3vw, 19px); overflow-wrap: anywhere; }
.issued-list { max-height: min(54vh, 480px); overflow-y: auto; margin: 18px 0; display: grid; gap: 8px; text-align: left; }
.issued-list[hidden] { display: none; }
.issued-entry { display: flex; align-items: center; gap: 12px; padding: 10px 12px; border: 1px solid var(--line); border-radius: 9px; background: #f8fafb; }
.issued-entry-details { flex: 1; min-width: 0; }
.issued-entry-label { display: block; font-size: 11px; color: #68758a; }
.issued-entry-code { font: 700 13px/1.6 ui-monospace, SFMono-Regular, Consolas, monospace; color: var(--accent-dark); word-break: break-all; }
.issued-entry .button { flex-shrink: 0; }
.dialog-actions { display: flex; flex-wrap: wrap; justify-content: center; gap: 10px; }

@media (max-width: 880px) {
  .stats-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .key-metadata { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .create-grid { grid-template-columns: repeat(2,minmax(0,1fr)); }
  .create-button { grid-column: 1 / -1; }
}

@media (max-width: 620px) {
  .site-topbar { height: 68px; padding: 0 18px; }
  .access-main { width: min(100% - 24px, 480px); margin-top: 31px; }
  .access-lead { margin-bottom: 28px; }
  .access-lead h1 { font-size: 30px; }
  .access-lead p { font-size: 12px; }
  .totp-update-status { padding: 14px 12px; gap: 10px; }
  .update-status-date { font-size: 16px; }
  .access-card { padding: 27px 20px; }
  .access-card .button-light { padding: 8px 10px; min-width: 62px; }
  .otp-number { letter-spacing: .075em; }
  .dashboard { padding: 0 13px; margin-top: 28px; }
  .dashboard-header { align-items: flex-start; }
  .dashboard-header h1 { font-size: 25px; }
  .section-nav { gap: 16px; margin-bottom: 26px; }
  .section-heading { align-items: flex-start; }
  .section-heading h2 { font-size: 20px; }
  .section-card { padding: 20px 17px; }
  .stat-card { padding: 16px; }
  .stat-card strong { font-size: 30px; }
  .create-grid { grid-template-columns: minmax(0,1fr); }
  .create-button { grid-column: auto; }
  .keys-heading { align-items: flex-start; flex-direction: column; gap: 2px; }
  .key-entry { padding: 18px 15px; }
  .key-edit { grid-template-columns: minmax(0,1fr); }
  .key-metadata { gap: 12px; }
  .section-heading .button { font-size: 11px; white-space: normal; text-align: center; }
  .issued-dialog { padding: 24px 14px; }
  .issued-value { letter-spacing: .025em; }
}

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