:root {
  color-scheme: light;
  --page: #f3f5f3;
  --surface: #ffffff;
  --surface-soft: #eef1ee;
  --text: #18201b;
  --muted: #69736c;
  --border: #d8ded9;
  --green: #176b4a;
  --green-dark: #0f5439;
  --green-soft: #e3f1e9;
  --amber: #a45f00;
  --amber-soft: #fff1d8;
  --red: #a73636;
  --red-soft: #fbe9e9;
  --shadow: 0 18px 45px rgba(24, 32, 27, 0.08);
  font-family: Inter, "Segoe UI", "Microsoft YaHei", sans-serif;
  letter-spacing: 0;
}

* { box-sizing: border-box; }
html { min-width: 320px; background: var(--page); }
body { margin: 0; color: var(--text); background: var(--page); font-size: 15px; line-height: 1.5; }
button, input, select { font: inherit; letter-spacing: 0; }
button { cursor: pointer; }
img { display: block; width: 20px; height: 20px; }
a { color: inherit; text-decoration: none; }

.topbar, .admin-topbar {
  min-height: 64px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 32px;
  border-bottom: 1px solid var(--border);
  background: rgba(255, 255, 255, 0.92);
}
.brand { display: inline-flex; align-items: center; gap: 10px; font-weight: 700; }
.brand-mark { width: 34px; height: 34px; display: grid; place-items: center; color: white; background: var(--green); border-radius: 7px; }
.brand-mark img { filter: brightness(0) invert(1); }

.public-main, .login-main { min-height: calc(100vh - 65px); display: grid; place-items: center; padding: 38px 20px 64px; }
.download-tool, .login-tool { width: min(100%, 560px); background: var(--surface); border: 1px solid var(--border); border-radius: 8px; box-shadow: var(--shadow); padding: 36px; }
.login-tool { width: min(100%, 420px); }
.file-heading { display: flex; align-items: center; gap: 16px; }
.file-icon { width: 54px; height: 54px; display: grid; place-items: center; background: var(--amber-soft); color: var(--amber); border-radius: 8px; }
.file-icon img { width: 28px; height: 28px; filter: invert(38%) sepia(75%) saturate(1012%) hue-rotate(3deg) brightness(91%); }
.eyebrow { margin: 0 0 3px; color: var(--green); font-size: 12px; font-weight: 800; text-transform: uppercase; }
h1, h2, p { letter-spacing: 0; }
h1 { margin: 0; font-size: 27px; line-height: 1.25; }
h2 { margin: 0; font-size: 18px; line-height: 1.3; }

.file-meta { margin: 30px 0; border-top: 1px solid var(--border); border-bottom: 1px solid var(--border); }
.file-meta div { display: grid; grid-template-columns: 70px minmax(0, 1fr); gap: 16px; padding: 12px 0; }
.file-meta div + div { border-top: 1px solid var(--border); }
.file-meta dt { color: var(--muted); }
.file-meta dd { margin: 0; font-weight: 650; overflow-wrap: anywhere; }

.download-form, .stack-form, .modal-form { display: grid; gap: 10px; }
label { color: #3d4740; font-size: 13px; font-weight: 700; }
input, select { width: 100%; min-width: 0; height: 44px; padding: 0 12px; color: var(--text); background: var(--surface); border: 1px solid #bec8c0; border-radius: 6px; outline: none; }
input:focus, select:focus, button:focus-visible { border-color: var(--green); box-shadow: 0 0 0 3px rgba(23, 107, 74, 0.15); }
.secret-field, .copy-field { display: grid; grid-template-columns: minmax(0, 1fr) 44px; }
.secret-field input, .copy-field input { border-radius: 6px 0 0 6px; }
.secret-field .icon-button, .copy-field .icon-button { border-left: 0; border-radius: 0 6px 6px 0; }

.primary-button, .secondary-button { height: 44px; display: inline-flex; align-items: center; justify-content: center; gap: 8px; padding: 0 18px; border-radius: 6px; font-weight: 750; }
.primary-button { margin-top: 6px; color: #fff; background: var(--green); border: 1px solid var(--green); }
.primary-button:hover { background: var(--green-dark); border-color: var(--green-dark); }
.primary-button img { filter: brightness(0) invert(1); }
.primary-button:disabled { cursor: wait; opacity: 0.65; }
.primary-button.compact { width: auto; margin: 0; }
.secondary-button { color: var(--text); background: var(--surface); border: 1px solid var(--border); }
.secondary-button:hover { background: var(--surface-soft); }
.icon-button { width: 44px; height: 44px; display: inline-grid; place-items: center; padding: 0; color: var(--text); background: var(--surface); border: 1px solid var(--border); border-radius: 6px; }
.icon-button:hover { background: var(--surface-soft); }
.icon-button.positive { color: var(--green); }
.icon-button.danger { color: var(--red); }
.icon-button.danger img { filter: invert(29%) sepia(67%) saturate(1297%) hue-rotate(325deg); }
.form-status { min-height: 24px; margin: 2px 0 0; color: var(--muted); font-size: 13px; }
.form-status.success { color: var(--green); }
.form-status.error, .page-message.error { color: var(--red); }

.login-tool h1 { margin-bottom: 26px; }
.stack-form { gap: 12px; }
.stack-form label:not(:first-of-type) { margin-top: 6px; }

.admin-page { background: #f7f8f7; }
.admin-topbar { position: sticky; top: 0; z-index: 10; }
.admin-account { display: flex; align-items: center; gap: 12px; color: var(--muted); font-size: 13px; }
.admin-account form { margin: 0; }
.admin-main { width: min(100% - 40px, 1240px); margin: 0 auto; padding: 34px 0 70px; }
.admin-heading, .section-heading, .modal-heading { display: flex; align-items: center; justify-content: space-between; gap: 20px; }
.metrics { display: grid; grid-template-columns: repeat(4, 1fr); margin: 28px 0 32px; border: 1px solid var(--border); border-radius: 8px; background: var(--surface); }
.metrics div { min-width: 0; padding: 18px 20px; }
.metrics div + div { border-left: 1px solid var(--border); }
.metrics span { display: block; color: var(--muted); font-size: 13px; }
.metrics strong { display: block; margin-top: 4px; font-size: 25px; }
.page-message { padding: 11px 14px; border: 1px solid #efcaca; border-radius: 6px; background: var(--red-soft); }
.data-section { margin-top: 28px; }
.section-heading { margin-bottom: 12px; }
.section-heading > span { color: var(--muted); font-size: 13px; }
.table-wrap { overflow-x: auto; border: 1px solid var(--border); border-radius: 8px; background: var(--surface); }
.data-table { width: 100%; border-collapse: collapse; font-size: 13px; }
.data-table th { padding: 11px 13px; color: var(--muted); background: var(--surface-soft); text-align: left; white-space: nowrap; }
.data-table td { padding: 12px 13px; border-top: 1px solid var(--border); vertical-align: middle; }
.data-table code { color: #445049; font-family: "Cascadia Mono", Consolas, monospace; font-size: 12px; }
.key-display { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.key-hint { color: var(--amber); font-size: 12px; white-space: nowrap; }
.status-pill { display: inline-flex; align-items: center; min-height: 26px; padding: 2px 9px; border-radius: 999px; font-size: 12px; font-weight: 750; white-space: nowrap; }
.status-pill.success { color: var(--green-dark); background: var(--green-soft); }
.status-pill.warning { color: var(--amber); background: var(--amber-soft); }
.status-pill.muted { color: #5e6861; background: #e8ebe9; }
.row-actions { display: flex; justify-content: flex-end; gap: 6px; white-space: nowrap; }
.row-actions form { margin: 0; }
.row-actions .icon-button { width: 34px; height: 34px; }
.row-actions img { width: 17px; height: 17px; }
.empty-state { padding: 32px !important; color: var(--muted); text-align: center; }
.filters { display: grid; grid-template-columns: 1.4fr 180px 180px auto; align-items: end; gap: 10px; margin-bottom: 12px; }
.filters label { display: grid; gap: 5px; }
.filters .secondary-button { width: auto; }

.modal { width: min(calc(100% - 28px), 470px); padding: 0; border: 1px solid var(--border); border-radius: 8px; box-shadow: var(--shadow); }
.modal::backdrop { background: rgba(13, 20, 16, 0.48); }
.modal-form { padding: 24px; gap: 11px; }
.modal-heading { margin-bottom: 8px; }
.modal-heading .icon-button { border: 0; font-size: 24px; }
.modal-actions { display: flex; justify-content: flex-end; gap: 10px; margin-top: 14px; }
.modal-context { margin: -2px 0 2px; color: var(--muted); font-size: 13px; }
.one-time-note { margin: 2px 0 0; color: var(--amber); font-size: 13px; }
.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; }

@media (max-width: 860px) {
  .metrics { grid-template-columns: repeat(2, 1fr); }
  .metrics div:nth-child(3) { border-left: 0; border-top: 1px solid var(--border); }
  .metrics div:nth-child(4) { border-top: 1px solid var(--border); }
  .filters { grid-template-columns: 1fr 1fr; }
}

@media (max-width: 720px) {
  .topbar, .admin-topbar { min-height: 58px; padding: 0 16px; }
  .admin-account > span { display: none; }
  .admin-main { width: min(100% - 24px, 1240px); padding-top: 24px; }
  .admin-heading { align-items: flex-end; }
  .data-table thead { display: none; }
  .data-table, .data-table tbody, .data-table tr, .data-table td { display: block; width: 100%; }
  .data-table tr { padding: 8px 12px; border-top: 1px solid var(--border); }
  .data-table tr:first-child { border-top: 0; }
  .data-table td { display: grid; grid-template-columns: minmax(92px, 35%) minmax(0, 1fr); gap: 12px; padding: 7px 0; border: 0; text-align: right; overflow-wrap: anywhere; }
  .data-table td::before { content: attr(data-label); color: var(--muted); text-align: left; }
  .data-table .row-actions { display: flex; justify-content: flex-end; padding-top: 10px; border-top: 1px solid var(--border); }
  .data-table .row-actions::before { margin-right: auto; }
  .empty-state { display: block !important; }
  .empty-state::before { display: none; }
}

@media (max-width: 520px) {
  .public-main, .login-main { display: block; min-height: auto; padding: 22px 12px 40px; }
  .download-tool, .login-tool { padding: 24px 20px; }
  .file-meta div { grid-template-columns: 58px minmax(0, 1fr); }
  .admin-heading { align-items: stretch; flex-direction: column; }
  .admin-heading .primary-button { width: 100%; }
  .metrics { grid-template-columns: 1fr 1fr; }
  .metrics div { padding: 15px; }
  .metrics strong { font-size: 22px; }
  .filters { grid-template-columns: 1fr; }
  .filters .secondary-button { width: 100%; }
  .modal-actions { flex-direction: column-reverse; }
  .modal-actions button { width: 100%; }
}

.page-message.success { color: var(--green-dark); border-color: #b9dcc9; background: var(--green-soft); }
.current-file { display: flex; align-items: center; gap: 14px; margin-bottom: 12px; padding: 14px 16px; border: 1px solid var(--border); border-radius: 8px; background: var(--surface); }
.current-file .file-icon { flex: none; width: 46px; height: 46px; display: grid; place-items: center; background: var(--green-soft); border-radius: 8px; }
.current-file .file-icon img { width: 22px; height: 22px; }
.current-file-info { min-width: 0; }
.current-file-info strong { display: block; font-size: 15px; overflow-wrap: anywhere; }
.current-file-note { color: var(--muted); font-size: 13px; }
.current-file .file-size { margin-left: auto; color: var(--muted); font-size: 13px; white-space: nowrap; }
.file-table code { display: inline-block; max-width: 170px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; vertical-align: bottom; }
.files-empty { margin-bottom: 12px; border: 1px dashed var(--border); border-radius: 8px; background: var(--surface); }

@media (max-width: 520px) {
  .current-file { flex-wrap: wrap; }
  .current-file .file-size { width: 100%; margin-left: 0; }
}
