:root {
    --primary: #3157d5;
    --primary-dark: #243f9f;
    --accent: #0f9f8f;
    --green: #117a4a;
    --red: #c2410c;
    --amber: #a45a05;
    --bg: #f4f7fb;
    --surface: #ffffff;
    --soft: #f7f9fc;
    --border: #d7dfeb;
    --text: #182033;
    --muted: #5d6b82;
    --ink-soft: #334155;
    --focus: rgba(49, 87, 213, 0.18);
}

* { box-sizing: border-box; }

body {
    margin: 0;
    min-height: 100vh;
    background: var(--bg);
    color: var(--text);
    font-family: "Plus Jakarta Sans", "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    -webkit-font-smoothing: antialiased;
}

.center-page {
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 100vh;
    padding: 20px;
}

.public-body {
    background:
        linear-gradient(135deg, rgba(49, 87, 213, 0.08), transparent 36%),
        linear-gradient(315deg, rgba(15, 159, 143, 0.1), transparent 38%),
        var(--bg);
}

.public-page {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 32px 20px;
}

.public-shell {
    width: min(1080px, 100%);
    display: grid;
    grid-template-columns: minmax(280px, 0.82fr) minmax(420px, 1fr);
    gap: 18px;
    align-items: stretch;
}

.hero-panel,
.request-panel {
    border: 1px solid rgba(148, 163, 184, 0.28);
    border-radius: 8px;
    background: rgba(255, 255, 255, 0.92);
    box-shadow: 0 22px 55px rgba(27, 38, 64, 0.13);
}

.hero-panel {
    position: relative;
    overflow: hidden;
    padding: 28px;
    color: #fff;
    background:
        linear-gradient(160deg, rgba(24, 32, 51, 0.96), rgba(30, 54, 105, 0.94)),
        #182033;
}

.hero-panel::after {
    content: "";
    position: absolute;
    inset: auto 0 0 0;
    height: 156px;
    opacity: 0.26;
    background-image:
        linear-gradient(90deg, rgba(255,255,255,0.18) 1px, transparent 1px),
        linear-gradient(0deg, rgba(255,255,255,0.18) 1px, transparent 1px);
    background-size: 28px 28px;
    pointer-events: none;
}

.brand-row {
    position: relative;
    z-index: 1;
    display: flex;
    align-items: center;
    gap: 10px;
    color: rgba(255, 255, 255, 0.94);
    font-size: 15px;
    font-weight: 800;
}

.brand-mark {
    display: inline-flex;
    width: 34px;
    height: 34px;
    align-items: center;
    justify-content: center;
    border-radius: 8px;
    background: #ffffff;
    color: var(--primary-dark);
}

.brand-mark svg,
button svg,
.btn-link svg {
    width: 18px;
    height: 18px;
    fill: currentColor;
}

.hero-copy {
    position: relative;
    z-index: 1;
    margin-top: 42px;
}

.eyebrow {
    margin: 0 0 8px;
    color: var(--accent);
    font-size: 12px;
    font-weight: 800;
    letter-spacing: 0.08em;
    text-transform: uppercase;
}

.hero-copy .eyebrow {
    color: #74e0d2;
}

.hero-copy h1 {
    margin: 0;
    font-size: clamp(32px, 5vw, 50px);
    line-height: 1.03;
    letter-spacing: 0;
}

.hero-copy p {
    max-width: 390px;
    margin: 16px 0 0;
    color: rgba(255, 255, 255, 0.78);
    font-size: 15px;
    line-height: 1.75;
}

.compact-note {
    position: relative;
    z-index: 1;
    display: inline-flex;
    margin-top: 22px;
    padding: 9px 11px;
    border: 1px solid rgba(255, 255, 255, 0.18);
    border-radius: 8px;
    background: rgba(255, 255, 255, 0.1);
    color: rgba(255, 255, 255, 0.82);
    font-size: 13px;
}

.request-panel {
    display: flex;
    flex-direction: column;
    min-width: 0;
    overflow: hidden;
}

.panel-heading {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 14px;
    padding: 24px 24px 16px;
    border-bottom: 1px solid var(--border);
}

.panel-heading h2 {
    margin: 0;
    color: var(--text);
    font-size: 25px;
    line-height: 1.2;
}

.app-shell {
    width: min(980px, calc(100vw - 32px));
    margin: 32px auto;
}

.admin-body {
    background:
        linear-gradient(135deg, rgba(49, 87, 213, 0.08), transparent 32%),
        linear-gradient(315deg, rgba(15, 159, 143, 0.08), transparent 36%),
        #f5f7fb;
}

.admin-shell {
    width: min(1180px, calc(100vw - 32px));
    margin: 28px auto;
}

.admin-login-card,
.admin-console {
    border: 1px solid rgba(148, 163, 184, 0.28);
    border-radius: 8px;
    background: rgba(255, 255, 255, 0.94);
    box-shadow: 0 22px 55px rgba(27, 38, 64, 0.12);
}

.admin-login-card {
    width: min(440px, 100%);
    margin: min(12vh, 96px) auto;
    padding: 26px;
}

.admin-console {
    overflow: hidden;
}

.admin-topbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 18px;
    padding: 16px 20px;
    border-bottom: 1px solid var(--border);
    background: rgba(255, 255, 255, 0.88);
}

.admin-brand {
    display: flex;
    align-items: center;
    gap: 11px;
}

.admin-brand strong,
.admin-brand span {
    display: block;
}

.admin-brand strong {
    color: var(--text);
    font-size: 15px;
    font-weight: 900;
}

.admin-brand span {
    margin-top: 2px;
    color: var(--muted);
    font-size: 12px;
}

.admin-mark {
    display: inline-flex;
    width: 38px;
    height: 38px;
    flex: 0 0 38px;
    align-items: center;
    justify-content: center;
    border-radius: 8px;
    background: var(--primary);
    color: #fff;
    box-shadow: 0 12px 24px rgba(49, 87, 213, 0.24);
}

.admin-mark svg,
.metric-card svg {
    width: 19px;
    height: 19px;
    fill: currentColor;
}

.login-copy {
    margin: 32px 0 22px;
}

.login-copy h1,
.admin-hero h1 {
    margin: 0;
    color: var(--text);
    font-size: 30px;
    line-height: 1.12;
    letter-spacing: 0;
}

.login-copy p:not(.eyebrow),
.admin-hero p:not(.eyebrow),
.card-head p,
.table-title p {
    margin: 8px 0 0;
    color: var(--muted);
    font-size: 13px;
    line-height: 1.55;
}

.admin-hero {
    display: grid;
    grid-template-columns: minmax(220px, 1fr) minmax(360px, 0.9fr);
    gap: 20px;
    align-items: end;
    padding: 24px 24px 20px;
    background:
        linear-gradient(135deg, rgba(49, 87, 213, 0.09), transparent 48%),
        var(--soft);
    border-bottom: 1px solid var(--border);
}

.metric-grid {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 10px;
}

.metric-card {
    min-height: 78px;
    padding: 13px 14px;
    border: 1px solid rgba(148, 163, 184, 0.28);
    border-radius: 8px;
    background: rgba(255, 255, 255, 0.82);
}

.metric-card span {
    display: block;
    color: var(--muted);
    font-size: 12px;
    font-weight: 700;
}

.metric-card strong {
    display: block;
    margin-top: 8px;
    color: var(--text);
    font-size: 27px;
    line-height: 1;
}

.topbar-actions {
    flex-wrap: nowrap;
}

.admin-console > .admin-grid,
.admin-console > .table-card {
    margin-left: 20px;
    margin-right: 20px;
}

.admin-console > .admin-grid {
    margin-top: 20px;
}

.control-card {
    display: flex;
    flex-direction: column;
    min-height: 246px;
}

.card-head,
.table-title {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 14px;
    margin-bottom: 14px;
}

.card-head label,
.table-title label {
    margin-bottom: 0;
}

.form-grid {
    display: grid;
    grid-template-columns: 0.8fr 1fr;
    gap: 12px;
}

.form-span-2 {
    grid-column: 1 / -1;
}

.container, .panel {
    background: var(--surface);
    border: 1px solid rgba(148, 163, 184, 0.24);
    border-radius: 8px;
    box-shadow: 0 18px 45px rgba(15, 23, 42, 0.12);
    overflow: hidden;
}

.container { width: min(560px, 100%); }

.head {
    background: #1e40af;
    color: #fff;
    padding: 16px 18px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 12px;
    font-weight: 700;
}

.head-title {
    display: flex;
    align-items: center;
    gap: 8px;
}

.head svg {
    width: 18px;
    height: 18px;
    fill: currentColor;
}

.version {
    background: rgba(255,255,255,0.18);
    border-radius: 999px;
    padding: 3px 9px;
    font-size: 11px;
    font-weight: 500;
    white-space: nowrap;
}

.section {
    padding: 18px;
    border-bottom: 1px solid var(--border);
}

.field-section {
    padding: 18px 24px;
}

.action-section {
    margin-top: auto;
    padding: 18px 24px 24px;
    background: var(--soft);
}

.section:last-child { border-bottom: 0; }

label {
    display: block;
    color: var(--ink-soft);
    font-size: 12px;
    font-weight: 700;
    letter-spacing: 0.04em;
    margin-bottom: 7px;
    text-transform: uppercase;
}

.label-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
}

.label-row label {
    margin-bottom: 7px;
}

.btn-link {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 7px;
    border-radius: 6px;
    background: #e9effb;
    color: var(--primary-dark);
    font-size: 13px;
    font-weight: 700;
    padding: 8px 12px;
    text-decoration: none;
    white-space: nowrap;
    transition: background 180ms ease, color 180ms ease, border-color 180ms ease;
}

.btn-link:hover {
    background: #dce7fb;
}

input, textarea, select {
    width: 100%;
    border: 1px solid var(--border);
    border-radius: 6px;
    padding: 12px 13px;
    color: var(--text);
    background: #fff;
    font-size: 14px;
    transition: border-color 180ms ease, box-shadow 180ms ease, background 180ms ease;
}

textarea {
    min-height: 210px;
    resize: vertical;
    font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
    line-height: 1.45;
}

.workspace-list-input {
    min-height: 116px;
}

input:focus, textarea:focus, select:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px var(--focus);
}

.fixed-ws {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 12px;
    border: 1px solid var(--border);
    background: var(--soft);
    border-radius: 6px;
    padding: 10px 12px;
    font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
    font-size: 13px;
    word-break: break-all;
}

.hint {
    color: var(--muted);
    font-size: 12px;
    line-height: 1.55;
    margin-top: 8px;
}

.inline-link {
    color: var(--primary-dark);
    font-weight: 800;
    text-decoration: none;
    white-space: nowrap;
}

.inline-link:hover {
    text-decoration: underline;
}

.buttons {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    align-items: center;
}

button {
    border: 0;
    border-radius: 6px;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    font-size: 13px;
    font-weight: 700;
    min-height: 42px;
    padding: 10px 16px;
    transition: background 180ms ease, color 180ms ease, box-shadow 180ms ease;
}

button:disabled {
    opacity: 0.52;
    cursor: not-allowed;
}

.btn-primary {
    background: var(--primary);
    color: #fff;
    box-shadow: 0 10px 22px rgba(49, 87, 213, 0.24);
}
.btn-primary:hover { background: var(--primary-dark); }
.btn-green { background: var(--green); color: #fff; }
.btn-red { background: var(--red); color: #fff; }
.btn-ghost { background: #e7edf6; color: var(--ink-soft); }
.btn-ghost:hover { background: #dbe4f0; }

.log-area, .result-box {
    margin-top: 12px;
    border: 1px solid var(--border);
    border-radius: 6px;
    background: var(--soft);
    padding: 10px 12px;
    max-height: 240px;
    min-height: 92px;
    overflow-y: auto;
    font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
    font-size: 12px;
    line-height: 1.5;
}

.status-box {
    display: grid;
    gap: 4px;
    margin-top: 12px;
    border: 1px solid var(--border);
    border-radius: 8px;
    background: #fff;
    padding: 13px 14px;
    color: var(--ink-soft);
    font-size: 13px;
    line-height: 1.5;
}

.status-box strong {
    color: var(--text);
    font-size: 15px;
}

.status-box.ok {
    border-color: #9bd8bd;
    background: #f0fbf5;
}

.status-box.ok strong { color: var(--green); }

.status-box.err {
    border-color: #f2b8a2;
    background: #fff5f1;
}

.status-box.err strong { color: var(--red); }

.status-box.info {
    border-color: #b9c9f2;
    background: #f2f6ff;
}

.status-box.info strong { color: var(--primary-dark); }

.key-output {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-wrap: wrap;
}

.key-output textarea {
    flex: 1 1 100%;
    min-height: 120px;
    border: 1px solid var(--border);
    border-radius: 6px;
    background: #fff;
    padding: 8px 10px;
    word-break: break-all;
}

.copy-status {
    min-width: 120px;
}

.log-line { padding: 2px 0; border-bottom: 1px dashed #e2e8f0; word-break: break-word; }
.log-line:last-child { border-bottom: 0; }
.ok { color: var(--green); }
.warn { color: var(--amber); }
.err { color: var(--red); }
.info { color: var(--primary-dark); }

.admin-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 16px;
}

.card {
    border: 1px solid var(--border);
    border-radius: 8px;
    background: #fff;
    padding: 16px;
}

.toolbar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 12px;
    margin-bottom: 16px;
}

.table-wrap {
    overflow-x: auto;
    border: 1px solid var(--border);
    border-radius: 8px;
}

.scroll-table {
    overflow: auto;
}

.key-table-wrap {
    max-height: 440px;
}

.table-footer {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 10px;
    padding-top: 12px;
    color: var(--muted);
    font-size: 13px;
}

.table-footer button {
    min-height: 36px;
    padding: 8px 12px;
}

table {
    width: 100%;
    border-collapse: collapse;
    font-size: 13px;
}

th, td {
    border-bottom: 1px solid var(--border);
    padding: 11px 10px;
    text-align: left;
    vertical-align: middle;
}

th {
    position: sticky;
    top: 0;
    z-index: 1;
    color: var(--ink-soft);
    background: var(--soft);
    font-size: 12px;
    text-transform: uppercase;
    letter-spacing: 0.3px;
}

tbody tr:hover td {
    background: #fbfdff;
}

tbody tr:last-child td {
    border-bottom: 0;
}

.empty-cell {
    height: 78px;
    color: var(--muted);
    text-align: center;
}

.pill {
    display: inline-flex;
    align-items: center;
    border-radius: 999px;
    padding: 2px 8px;
    font-size: 12px;
    font-weight: 700;
    background: #e2e8f0;
    color: #334155;
}

.pill.unused { background: #dcfce7; color: #166534; }
.pill.used { background: #dbeafe; color: #1d4ed8; }
.pill.pending { background: #fef3c7; color: #92400e; }
.pill.revoked, .pill.expired { background: #fee2e2; color: #991b1b; }

.hidden { display: none !important; }
.mt { margin-top: 14px; }
.mono { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; }

@media (max-width: 760px) {
    .public-page { padding: 16px; align-items: flex-start; }
    .public-shell { grid-template-columns: 1fr; }
    .hero-panel { padding: 22px; }
    .hero-copy { margin-top: 28px; }
    .hero-copy h1 { font-size: 34px; }
    .panel-heading { flex-direction: column; }
    .btn-link { width: 100%; }
    .field-section,
    .action-section { padding-left: 18px; padding-right: 18px; }
    .admin-shell { width: 100%; margin: 0; }
    .admin-login-card,
    .admin-console {
        border-left: 0;
        border-right: 0;
        border-radius: 0;
    }
    .admin-login-card {
        min-height: 100vh;
        margin: 0;
        padding: 22px 18px;
    }
    .admin-topbar {
        align-items: stretch;
        flex-direction: column;
    }
    .topbar-actions { flex-wrap: wrap; }
    .admin-hero { grid-template-columns: 1fr; padding: 20px 18px; }
    .metric-grid { grid-template-columns: repeat(3, minmax(92px, 1fr)); overflow-x: auto; }
    .table-footer {
        align-items: stretch;
        flex-direction: column;
    }
    .table-footer button {
        width: 100%;
    }
    .admin-console > .admin-grid,
    .admin-console > .table-card {
        margin-left: 12px;
        margin-right: 12px;
    }
    .form-grid { grid-template-columns: 1fr; }
    .form-span-2 { grid-column: auto; }
    .admin-grid { grid-template-columns: 1fr; }
    .toolbar { align-items: stretch; flex-direction: column; }
    .buttons button { flex: 1 1 auto; }
    .label-row { align-items: flex-start; flex-direction: column; }
}

@media (max-width: 460px) {
    .public-page { padding: 0; }
    .public-shell { gap: 0; }
    .hero-panel,
    .request-panel {
        border-left: 0;
        border-right: 0;
        border-radius: 0;
    }
    textarea { min-height: 180px; }
}

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