:root {
  --ink: #12212c;
  --muted: #68747d;
  --green: #0b6b50;
  --green-dark: #07523e;
  --paper: #f3f5f1;
  --surface: #fff;
  --line: #d9e0da;
  --danger: #a33b2f;
}

* { box-sizing: border-box; }
body { margin: 0; background: var(--paper); color: var(--ink); font-family: "Segoe UI", Arial, sans-serif; }
button, input, select { font: inherit; }
button { cursor: pointer; }

.brand { display: inline-flex; align-items: center; gap: 11px; color: var(--ink); font-size: 15px; font-weight: 680; text-decoration: none; }
.brand-mark { display: grid; width: 32px; height: 32px; place-items: center; border-radius: 9px; background: var(--green); color: white; font-weight: 750; }
.eyebrow { margin: 0 0 8px; color: var(--green); font-size: 11px; font-weight: 750; letter-spacing: .12em; text-transform: uppercase; }
.subtle { margin: 8px 0 0; color: var(--muted); font-size: 14px; line-height: 1.5; }

.admin-header { display: flex; align-items: center; justify-content: space-between; min-height: 76px; padding: 0 max(24px, calc((100% - 1120px) / 2)); border-bottom: 1px solid var(--line); background: rgba(255,255,255,.86); }
.header-actions { display: flex; align-items: center; gap: 18px; font-size: 13px; }
.header-actions a { color: var(--muted); text-decoration: none; }
.header-actions a:hover { color: var(--green); }
.header-actions form { margin: 0; }

.admin-main { width: min(1120px, calc(100% - 48px)); margin: 0 auto; padding: 50px 0 72px; }
.title-row { margin-bottom: 30px; }
h1 { margin: 0; font-size: clamp(2rem, 5vw, 3.15rem); line-height: 1; letter-spacing: -.045em; }
h2 { margin: 0; font-size: 18px; letter-spacing: -.02em; }

.panel { margin-top: 22px; overflow: hidden; border: 1px solid var(--line); border-radius: 16px; background: var(--surface); box-shadow: 0 12px 36px rgba(22,46,38,.055); }
.panel-heading { display: flex; justify-content: space-between; padding: 22px 24px; border-bottom: 1px solid #e6ebe7; }
.panel-heading p { margin: 5px 0 0; color: var(--muted); font-size: 13px; }
.create-form { display: grid; grid-template-columns: repeat(3, 1fr); gap: 20px; padding: 24px; }
.field { min-width: 0; }
.field-wide { grid-column: 1 / -1; }
.field label { display: block; margin-bottom: 8px; color: #293a34; font-size: 12px; font-weight: 700; }
.field > span { display: block; margin-top: 7px; color: #7b8780; font-size: 11px; }
.field input, .field select, .login-card input { width: 100%; min-height: 44px; padding: 0 12px; border: 1px solid #ccd5ce; border-radius: 9px; outline: none; background: #fbfcfa; color: var(--ink); }
.field input:focus, .field select:focus, .login-card input:focus { border-color: var(--green); box-shadow: 0 0 0 3px rgba(11,107,80,.1); background: white; }
.field input:disabled { cursor: not-allowed; opacity: .55; }
.field .checkbox-option { display: flex; align-items: center; gap: 8px; margin: 9px 0 0; color: #536159; font-size: 12px; font-weight: 500; cursor: pointer; }
.field .checkbox-option input { width: 16px; min-height: 16px; margin: 0; accent-color: var(--green); }
.file-picker-row { display: grid; grid-template-columns: 1fr auto; }
.file-picker-row input { min-width: 0; border-radius: 9px 0 0 9px; }
.browse-button { min-width: 112px; padding: 0 14px; border: 1px solid #ccd5ce; border-left: 0; border-radius: 0 9px 9px 0; background: #f1f5f2; color: var(--green); font-size: 12px; font-weight: 700; }
.browse-button:hover { background: #e7f0eb; }
.joined-fields { display: grid; grid-template-columns: 1fr 110px; }
.joined-fields input { border-radius: 9px 0 0 9px; }
.joined-fields select { border-left: 0; border-radius: 0 9px 9px 0; }
.form-action { display: flex; align-items: end; }
.primary-button { min-height: 44px; padding: 0 18px; border: 0; border-radius: 9px; background: var(--green); color: white; font-size: 13px; font-weight: 700; box-shadow: 0 7px 18px rgba(11,107,80,.16); }
.primary-button:hover { background: var(--green-dark); }
.text-button { padding: 0; border: 0; background: transparent; color: #78837d; font-size: 12px; }
.text-button:hover { color: var(--danger); text-decoration: underline; }

.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 13px; }
th { padding: 12px 18px; background: #fafbf9; color: #77827c; text-align: left; font-size: 10px; letter-spacing: .08em; text-transform: uppercase; }
td { padding: 15px 18px; border-top: 1px solid #edf0ed; color: #445149; }
td:first-child { min-width: 230px; }
td strong, td span { display: block; }
td strong { color: var(--ink); font-weight: 650; }
td:first-child span { margin-top: 3px; color: #89928d; font-size: 11px; }
td:last-child { width: 1%; text-align: right; }
.code-entry { width: 100%; padding: 0; border: 0; background: transparent; color: inherit; text-align: left; }
.code-entry strong, .code-entry span, .code-entry small { display: block; }
.code-entry small { margin-top: 6px; color: var(--green); font-size: 10px; font-weight: 700; }
.code-entry:hover strong, .code-entry:focus-visible strong { color: var(--green); }
.code-entry:focus-visible { outline: 2px solid rgba(11,107,80,.28); outline-offset: 5px; border-radius: 2px; }
.status { display: inline-block; width: max-content; padding: 4px 8px; border-radius: 999px; font-size: 10px; font-weight: 750; text-transform: uppercase; }
.status.active { background: #e5f4ed; color: #08704e; }
.status.expired, .status.used { background: #f0f1ef; color: #6f7772; }
.empty-state { padding: 32px; color: var(--muted); text-align: center; }

.code-result { display: grid; grid-template-columns: 1fr minmax(280px, 520px); align-items: center; gap: 24px; margin: 22px 0; padding: 18px 20px; border: 1px solid #b9ddcd; border-radius: 13px; background: #edf8f3; }
.code-result span, .code-result strong { display: block; }
.code-result span { color: var(--green); font-size: 11px; font-weight: 750; letter-spacing: .08em; text-transform: uppercase; }
.code-result strong { margin-top: 4px; font-size: 13px; }
.copy-row { display: grid; grid-template-columns: 1fr auto; }
.copy-row input { min-width: 0; height: 42px; padding: 0 12px; border: 1px solid #b8d3c7; border-radius: 8px 0 0 8px; background: white; font-family: Consolas, monospace; }
.copy-row button { border: 0; border-radius: 0 8px 8px 0; padding: 0 15px; background: var(--green); color: white; font-size: 12px; font-weight: 700; }
.notice { margin: 22px 0; padding: 13px 16px; border: 1px solid #cbded5; border-radius: 10px; background: #f2f8f5; color: var(--green); font-size: 13px; }

.file-browser { width: min(680px, calc(100% - 28px)); max-height: min(680px, calc(100svh - 40px)); padding: 0; overflow: hidden; border: 1px solid var(--line); border-radius: 16px; background: white; color: var(--ink); box-shadow: 0 28px 90px rgba(12,32,41,.22); }
.file-browser::backdrop { background: rgba(12,32,41,.38); backdrop-filter: blur(2px); }
.file-browser-header { display: flex; align-items: center; justify-content: space-between; padding: 20px 22px; border-bottom: 1px solid var(--line); }
.dialog-close { width: 36px; height: 36px; border: 0; border-radius: 8px; background: transparent; color: #78837d; font-size: 24px; line-height: 1; }
.dialog-close:hover { background: #f1f4f1; color: var(--ink); }
.browser-location { display: flex; align-items: center; gap: 14px; min-height: 48px; padding: 0 20px; border-bottom: 1px solid #e8ece9; background: #fafbf9; }
.browser-location span { overflow: hidden; color: #536159; font-family: Consolas, monospace; font-size: 12px; text-overflow: ellipsis; white-space: nowrap; }
.up-button { padding: 6px 9px; border: 1px solid #d6ddd7; border-radius: 7px; background: white; color: var(--green); font-size: 11px; font-weight: 700; }
.up-button:disabled { cursor: default; opacity: .42; }
.file-list { min-height: 260px; max-height: 430px; overflow-y: auto; padding: 8px; }
.file-entry { display: grid; width: 100%; grid-template-columns: 28px 1fr auto; align-items: center; min-height: 44px; padding: 7px 10px; border: 0; border-radius: 8px; background: transparent; color: var(--ink); text-align: left; }
.file-entry:hover, .file-entry:focus-visible { outline: none; background: #edf5f1; }
.file-entry-icon { color: var(--green); font-size: 17px; }
.file-entry-name { overflow: hidden; font-size: 13px; text-overflow: ellipsis; white-space: nowrap; }
.file-entry-type { color: #8a948e; font-size: 10px; text-transform: uppercase; }
.browser-message { min-height: 36px; margin: 0; padding: 9px 18px; border-top: 1px solid #edf0ed; color: var(--muted); font-size: 12px; }

.activity-dialog { width: min(980px, calc(100% - 28px)); max-height: min(760px, calc(100svh - 40px)); padding: 0; overflow: hidden; border: 1px solid var(--line); border-radius: 16px; background: white; color: var(--ink); box-shadow: 0 28px 90px rgba(12,32,41,.22); }
.activity-dialog::backdrop { background: rgba(12,32,41,.38); backdrop-filter: blur(2px); }
.activity-path { overflow: hidden; margin: 0; padding: 12px 22px; border-bottom: 1px solid #e8ece9; background: #fafbf9; color: #68756e; font-family: Consolas, monospace; font-size: 11px; text-overflow: ellipsis; white-space: nowrap; }
.activity-table-wrap { min-height: 190px; max-height: 520px; overflow: auto; }
.activity-table { min-width: 790px; }
.activity-table th { position: sticky; top: 0; z-index: 1; }
.activity-table td { vertical-align: top; }
.activity-table td:first-child { min-width: 160px; }
.activity-table td:last-child { width: auto; min-width: 150px; text-align: left; }
.activity-table td strong, .activity-table td small { display: block; }
.activity-table td small { margin-top: 5px; color: #7c8781; font-size: 10px; line-height: 1.35; }
.progress-line { display: flex; align-items: center; gap: 9px; min-width: 190px; }
.progress-line progress { width: 128px; height: 8px; overflow: hidden; border: 0; border-radius: 999px; background: #e6ece8; accent-color: var(--green); }
.progress-line progress::-webkit-progress-bar { border-radius: 999px; background: #e6ece8; }
.progress-line progress::-webkit-progress-value { border-radius: 999px; background: var(--green); }
.progress-line progress::-moz-progress-bar { border-radius: 999px; background: var(--green); }
.progress-line strong { min-width: 34px; font-size: 11px; }

.login-body { display: grid; min-height: 100svh; place-items: center; background: radial-gradient(circle at 50% 40%, white 0, var(--paper) 60%); }
.login-shell { width: min(390px, calc(100% - 36px)); }
.login-shell > .brand { margin: 0 0 24px 4px; }
.login-card { padding: 28px; border: 1px solid var(--line); border-radius: 16px; background: white; box-shadow: 0 18px 56px rgba(22,46,38,.08); }
.login-card h1 { font-size: 2rem; }
.login-card form { margin-top: 24px; }
.login-card label { display: block; margin-bottom: 8px; font-size: 12px; font-weight: 700; }
.login-card .primary-button { width: 100%; margin-top: 14px; }
.form-error { min-height: 18px; margin: 12px 0 0; color: var(--danger); font-size: 12px; text-align: center; }

@media (max-width: 760px) {
  .admin-header { min-height: 66px; padding: 0 18px; }
  .header-actions { gap: 12px; }
  .admin-main { width: calc(100% - 28px); padding: 34px 0 54px; }
  .create-form { grid-template-columns: 1fr; padding: 18px; }
  .field-wide { grid-column: auto; }
  .form-action .primary-button { width: 100%; }
  .file-picker-row { grid-template-columns: 1fr; gap: 8px; }
  .file-picker-row input, .browse-button { min-height: 44px; border: 1px solid #ccd5ce; border-radius: 9px; }
  .code-result { grid-template-columns: 1fr; }
  .panel-heading { padding: 18px; }
}
