:root {
  --navy: #12304a;
  --blue: #0b6aa8;
  --pale: #eef4f7;
  --ink: #17212b;
  --muted: #657586;
  --danger: #a12a2a;
  --border: #dbe4ea;
  --radius: 14px;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  min-width: 320px;
  background: var(--pale);
  color: var(--ink);
  font: 16px/1.5 system-ui, -apple-system, "Segoe UI", sans-serif;
  overflow-wrap: anywhere;
}

header {
  min-height: 72px;
  background: #fff;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  padding: 16px max(24px, calc((100% - 1120px) / 2));
}

.brand { flex: 0 0 auto; color: var(--navy); font-size: 1.2rem; font-weight: 750; text-decoration: none; }
nav { display: flex; align-items: center; gap: 22px; flex-wrap: wrap; }
nav a, .link { color: var(--navy); text-decoration: none; background: none; border: 0; font: inherit; cursor: pointer; padding: 0; }
nav form { margin: 0; }

main { width: min(100%, 1168px); margin: 36px auto; padding: 0 24px; }
.hero { display: flex; justify-content: space-between; align-items: flex-end; gap: 20px; margin-bottom: 24px; }
h1 { color: var(--navy); font-size: clamp(1.8rem, 3vw, 2.5rem); line-height: 1.15; margin: 0 0 8px; }
h2 { color: var(--navy); margin-top: 0; }
p { margin: 6px 0; }
.muted, .field-hint { color: var(--muted); }
.field-hint { font-size: .9rem; margin-top: 7px; }

.card {
  min-width: 0;
  background: #fff;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: 0 8px 28px rgba(18, 48, 74, .05);
  margin-bottom: 20px;
  padding: 24px;
  overflow-x: auto;
}

.grid, .form-grid, .date-range { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 18px; }
.grid { grid-template-columns: repeat(auto-fit, minmax(min(260px, 100%), 1fr)); }
.date-range { margin-top: 2px; }
.validity-notice { margin: 12px 0 2px; border: 1px solid #e3bc69; border-radius: 10px; background: #fff8e7; color: #684c0b; padding: 12px 14px; font-size: .92rem; font-weight: 650; }
.stats { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 12px; }
.stat { min-width: 0; padding: 18px; background: #f7fafb; border-radius: 10px; }
.stat strong { display: block; color: var(--navy); font-size: 1.6rem; }
.storage-summary { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 14px; margin-bottom: 20px; }
.storage-stat { display: flex; align-items: center; justify-content: space-between; gap: 18px; padding: 18px 20px; border: 1px solid var(--border); border-radius: 12px; background: #fff; box-shadow: 0 6px 20px rgba(18, 48, 74, .04); }
.storage-stat span { color: var(--muted); font-weight: 650; }
.storage-stat strong { color: var(--navy); font-size: 1.25rem; white-space: nowrap; }
.admin-menu { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 18px; }
.admin-menu-card { position: relative; min-height: 210px; border: 1px solid var(--border); border-radius: var(--radius); background: #fff; box-shadow: 0 8px 28px rgba(18, 48, 74, .05); color: inherit; padding: 26px; text-decoration: none; transition: border-color .15s ease, box-shadow .15s ease, transform .15s ease; }
.admin-menu-card:hover { border-color: #9bb8c9; box-shadow: 0 14px 34px rgba(18, 48, 74, .11); transform: translateY(-2px); }
.admin-menu-card h2 { margin: 28px 0 6px; }
.admin-menu-number { color: var(--blue); font-size: .78rem; font-weight: 800; letter-spacing: .12em; }
.admin-menu-open { position: absolute; right: 26px; bottom: 24px; color: var(--blue); font-weight: 700; }
.admin-kicker { display: block; margin-bottom: 5px; color: var(--blue); font-size: .8rem; font-weight: 750; letter-spacing: .08em; text-transform: uppercase; }
.admin-subheader .actions { margin-top: 0; }
.admin-notice { border-color: #b7d8c0; background: #f0f8f2; color: #236c34; }
.admin-form-card { max-width: 620px; }
.admin-form-section { margin-top: 34px; padding-top: 28px; border-top: 1px solid var(--border); }
.security-option { margin: 22px 0 18px; border: 1px solid #b8d5e5; border-radius: 12px; background: #f4f9fb; padding: 18px; }
.security-toggle { align-items: flex-start; gap: 13px; margin: 0; }
.security-toggle > input { margin-top: 4px; }
.security-copy { display: inline-block; line-height: 1.35; }
.security-toggle small { display: inline-block; margin-top: 6px; color: var(--muted); font-weight: 400; }
.security-option [data-recipient-field] { display: none; margin-top: 18px; padding-top: 16px; border-top: 1px solid #d5e5ed; }
.security-option:has([data-security-toggle]:checked) [data-recipient-field] { display: block; }
.required-mark { margin-left: 6px; color: var(--danger); font-size: .75rem; font-weight: 700; }
.security-label { display: block; margin-top: 7px; color: #315d76; font-size: .78rem; font-weight: 700; }
.guide-hero { margin-bottom: 18px; }
.guide-intro { margin-bottom: 24px; border: 1px solid #b8d5e5; border-radius: 12px; background: #f2f8fb; padding: 16px 18px; color: #27495e; }
.guide-steps { display: grid; gap: 22px; }
.guide-step { display: grid; grid-template-columns: minmax(240px, .8fr) minmax(0, 1.45fr); align-items: center; gap: clamp(24px, 5vw, 56px); border: 1px solid var(--border); border-radius: var(--radius); background: #fff; box-shadow: 0 8px 28px rgba(18, 48, 74, .05); padding: clamp(20px, 3vw, 34px); }
.guide-step:nth-child(even) { grid-template-columns: minmax(0, 1.45fr) minmax(240px, .8fr); }
.guide-step:nth-child(even) .guide-copy { order: 2; }
.guide-number { display: inline-block; margin-bottom: 10px; color: var(--blue); font-size: .78rem; font-weight: 800; letter-spacing: .1em; text-transform: uppercase; }
.guide-copy h2 { margin-bottom: 10px; }
.guide-copy p { color: #455765; }
.guide-figure { min-width: 0; margin: 0; }
.guide-figure img { display: block; width: 100%; height: auto; border: 1px solid #d7e0e6; border-radius: 12px; background: #eef4f7; box-shadow: 0 8px 24px rgba(18, 48, 74, .09); }
.guide-figure figcaption { margin-top: 8px; color: var(--muted); font-size: .8rem; text-align: center; }
.guide-tips { margin-top: 22px; }
.guide-tips ul { margin: 0; padding-left: 22px; }
.guide-tips li + li { margin-top: 7px; }

label { display: block; font-weight: 650; margin: 14px 0 6px; }
input, select, textarea {
  width: 100%;
  max-width: 100%;
  min-width: 0;
  border: 1px solid #b9c8d2;
  border-radius: 8px;
  background: #fff;
  padding: 10px 12px;
  color: inherit;
  font: inherit;
}
textarea { min-height: 100px; resize: vertical; }
input[type="color"] { height: 44px; padding: 4px; }
input[type="file"] { overflow: hidden; }
.check-label { display: flex; align-items: center; gap: 9px; }
.check-label input, label input[type="checkbox"] { width: auto; flex: 0 0 auto; }

.button, button.primary {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 42px;
  border: 0;
  border-radius: 8px;
  background: var(--blue);
  color: #fff;
  cursor: pointer;
  font: inherit;
  font-weight: 650;
  padding: 10px 16px;
  text-align: center;
  text-decoration: none;
}
.button.secondary { background: #e4edf2; color: var(--navy); }
.button.danger { background: var(--danger); }
.danger-zone { border-color: #e4b8b8; }
.danger-zone h2 { color: var(--danger); }
.actions { display: flex; align-items: center; flex-wrap: wrap; gap: 10px; margin-top: 18px; }
td > .actions { margin-top: 0; }

table { width: 100%; min-width: 720px; border-collapse: collapse; }
th, td { border-bottom: 1px solid #e2e9ed; padding: 12px 10px; text-align: left; vertical-align: top; }
th { color: var(--muted); font-size: .85rem; }
.badge { display: inline-block; border-radius: 99px; background: #e4f4e8; color: #236c34; font-size: .85rem; padding: 3px 9px; }
.badge.off { background: #f5e4e4; color: #8a2929; }
.error { background: #fbeaea; color: #8a2020; border-radius: 8px; margin-bottom: 16px; padding: 12px; }
.upload-error { margin-top: 10px; border-radius: 8px; background: #fbeaea; color: #8a2020; padding: 10px 12px; font-weight: 650; }
.upload-running { overflow: hidden; }
.upload-overlay { position: fixed; inset: 0; z-index: 1000; display: grid; place-items: center; padding: 20px; background: rgba(8, 28, 44, .68); backdrop-filter: blur(3px); }
.upload-dialog { width: min(520px, 100%); padding: clamp(24px, 5vw, 38px); border-radius: 18px; background: #fff; box-shadow: 0 24px 80px rgba(0, 0, 0, .28); text-align: center; }
.upload-dialog h2 { margin: 8px 0; }
.upload-icon { display: grid; place-items: center; width: 58px; height: 58px; margin: 0 auto 12px; border-radius: 50%; background: #e4f1f8; color: var(--blue); font-size: 2rem; font-weight: 800; }
.upload-phase { min-height: 24px; color: var(--muted); }
.upload-track { height: 14px; margin-top: 24px; overflow: hidden; border-radius: 99px; background: #e4edf2; }
.upload-progress { width: 0; height: 100%; border-radius: inherit; background: linear-gradient(90deg, #0b6aa8, #19a3c7); transition: width .15s ease-out; }
.upload-numbers { display: flex; justify-content: space-between; gap: 16px; margin-top: 10px; color: var(--muted); font-variant-numeric: tabular-nums; }
.upload-numbers strong { color: var(--navy); }
.upload-error-message { margin: 18px 0 0; border-radius: 8px; background: #fbeaea; color: #8a2020; padding: 12px; text-align: left; }
.upload-cancel { margin-top: 24px; }
.login { max-width: 440px; margin: 8vh auto; }
.copy { max-width: 360px; margin-top: 8px; font-family: ui-monospace, monospace; font-size: .8rem; word-break: break-all; }

.release-card { overflow: visible; }
.release-table { min-width: 0; table-layout: fixed; }
.release-table .col-title { width: 20%; }
.release-table .col-validity { width: 15%; }
.release-table .col-files { width: 7%; }
.release-table .col-size { width: 11%; }
.release-table .col-downloads { width: 11%; }
.release-table .col-status { width: 10%; }
.release-table .col-actions { width: 26%; }
.release-table th { white-space: nowrap; }
.release-table .center, .release-number { text-align: center; }
.release-size { white-space: nowrap; font-variant-numeric: tabular-nums; }
.release-title strong, .release-title span, .release-validity span { display: block; }
.release-title .muted { margin-top: 3px; }
.release-validity { white-space: nowrap; }
.release-status .badge { white-space: nowrap; }
.release-actions .actions { flex-wrap: wrap; }
.release-actions .button { min-height: 38px; padding: 8px 12px; white-space: nowrap; }
.open-link { display: inline-block; margin-top: 8px; color: var(--blue); font-size: .88rem; font-weight: 650; text-decoration: none; }
.open-link:hover { text-decoration: underline; }

.download-body { min-height: 100vh; display: grid; place-items: center; padding: 24px; }
.download-body main { margin: 0; }
.download-body .download-card { width: min(720px, 100%); border-radius: 18px; padding: clamp(32px, 5vw, 48px) clamp(28px, 6vw, 56px); box-shadow: 0 20px 55px rgba(0, 0, 0, .12); }
.download-logo { display: block; max-width: min(220px, 100%); max-height: 90px; margin-bottom: 24px; object-fit: contain; }
.file-row { display: flex; align-items: center; justify-content: space-between; gap: 16px; border-top: 1px solid rgba(127, 127, 127, .25); padding: 16px 0; }
.file-row > div { min-width: 0; }
.file-row .button { flex: 0 0 auto; min-width: 166px; white-space: nowrap; overflow-wrap: normal; text-align: center; }
.code-gate { margin-top: 24px; border-top: 1px solid rgba(127,127,127,.25); padding-top: 24px; }
.code-gate h2 { margin-bottom: 8px; color: inherit; }
.code-lock { display: grid; place-items: center; width: 52px; height: 52px; margin-bottom: 14px; border: 2px solid currentColor; border-radius: 50%; font-size: 30px; font-weight: 800; }
.code-form { display: grid; grid-template-columns: minmax(0, 1fr) auto; align-items: end; gap: 12px; margin-top: 22px; }
.code-form label { grid-column: 1 / -1; margin: 0; }
.code-input { min-height: 48px; font-size: 1.35rem; font-weight: 750; letter-spacing: .28em; text-align: center; }
.code-request { margin-top: 14px; }
.code-request form { margin: 0; }
.code-notice { margin-top: 16px; border-radius: 8px; padding: 12px; }
.code-notice.success { background: #e8f5eb; color: #236c34; }
.code-notice.error { background: #fbeaea; color: #8a2020; }
.missing-download-body { background: linear-gradient(145deg, #f3f6f8 0%, #e7edf1 100%); color: #263746; }
.download-body .missing-download-card { width: min(600px, 100%); border: 1px solid #d8e1e7; background: #fff; text-align: center; }
.missing-download-icon { display: grid; place-items: center; width: 74px; height: 74px; margin: 0 auto 20px; border-radius: 50%; background: #edf2f5; color: #526b7c; }
.missing-download-icon svg { width: 36px; height: 36px; fill: none; stroke: currentColor; stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; }
.missing-download-code { display: inline-block; margin-bottom: 10px; color: #657586; font-size: .78rem; font-weight: 750; letter-spacing: .1em; text-transform: uppercase; }
.missing-download-card h1 { margin-bottom: 14px; color: #263746; }
.missing-download-card p { max-width: 470px; margin: 8px auto; }

@media (max-width: 760px) {
  header { align-items: flex-start; padding: 16px 20px; }
  nav { justify-content: flex-end; gap: 8px 16px; }
  main { margin: 24px auto; padding: 0 16px; }
  .hero { align-items: flex-start; flex-direction: column; }
  .hero > .actions { margin-top: 0; }
  .card { padding: 18px; }
  .stats { grid-template-columns: 1fr; }
  .admin-menu { grid-template-columns: 1fr; }
  .guide-step, .guide-step:nth-child(even) { grid-template-columns: 1fr; }
  .guide-step:nth-child(even) .guide-copy { order: initial; }
  .code-form { grid-template-columns: 1fr; }
  .code-form .button, .code-request .button { width: 100%; }
  table:not(.release-table) { min-width: 680px; }
  .release-card { padding: 0; border: 0; background: transparent; box-shadow: none; }
  .release-table, .release-table tbody { display: block; }
  .release-table colgroup, .release-table thead { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
  .release-table tbody { display: grid; gap: 14px; }
  .release-table tr { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px 18px; padding: 18px; background: #fff; border: 1px solid var(--border); border-radius: var(--radius); box-shadow: 0 6px 20px rgba(18, 48, 74, .05); }
  .release-table td { display: block; min-width: 0; padding: 0; border: 0; text-align: left; }
  .release-table td::before { content: attr(data-label); display: block; margin-bottom: 4px; color: var(--muted); font-size: .75rem; font-weight: 700; text-transform: uppercase; letter-spacing: .03em; }
  .release-table .release-title, .release-table .release-actions { grid-column: 1 / -1; }
  .release-actions .actions { align-items: center; flex-direction: row; }
  .release-actions .button { width: auto; }
}

@media (max-width: 560px) {
  body { font-size: 15px; }
  header { align-items: stretch; flex-direction: column; gap: 12px; }
  nav { align-items: flex-start; justify-content: flex-start; }
  .form-grid, .date-range { grid-template-columns: 1fr; gap: 0; }
  .actions { align-items: stretch; flex-direction: column; }
  .actions .button, .actions button { width: 100%; }
  td > .actions { min-width: 190px; }
  .file-row { align-items: stretch; flex-direction: column; }
  .file-row .button { width: 100%; min-width: 0; }
  .download-body { padding: 12px; }
  .download-body .download-card { border-radius: 12px; padding: 24px 20px; }
  .upload-overlay { padding: 12px; }
  .upload-dialog { border-radius: 12px; padding: 24px 18px; }
  .upload-numbers { align-items: center; flex-direction: column; gap: 2px; }
  .release-table tr { grid-template-columns: 1fr; }
  .release-table .release-title, .release-table .release-actions { grid-column: auto; }
  .release-actions .actions { align-items: stretch; flex-direction: column; }
  .release-actions .button { width: 100%; }
}
