:root {
    --bg: #f5f7fb;
    --card: #ffffff;
    --text: #132238;
    --muted: #64748b;
    --line: #e2e8f0;
    --primary: #0f766e;
    --primary-dark: #0f3d3e;
    --danger: #b42318;
    --danger-bg: #fff0f0;
    --success: #067647;
    --success-bg: #ecfdf3;
    --info: #175cd3;
    --info-bg: #eff8ff;
    --warning: #b54708;
    --warning-bg: #fffaeb;
    --radius: 22px;
    --shadow: 0 22px 55px rgba(15, 23, 42, .08);
}

* { box-sizing: border-box; }
body {
    margin: 0;
    font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
    background: radial-gradient(circle at top left, rgba(15,118,110,.12), transparent 34%), var(--bg);
    color: var(--text);
}
a { color: inherit; text-decoration: none; }
.admin-shell { display: flex; min-height: 100vh; }
.sidebar {
    width: 286px;
    padding: 24px;
    background: #071f22;
    color: #fff;
    position: fixed;
    inset: 0 auto 0 0;
    display: flex;
    flex-direction: column;
}
.brand { display: flex; align-items: center; gap: 14px; margin-bottom: 34px; }
.brand-mark {
    width: 52px; height: 52px; border-radius: 18px;
    display: grid; place-items: center;
    background: linear-gradient(135deg, #0f766e, #ffc857);
    font-weight: 900;
}
.brand strong { display: block; font-size: 18px; }
.brand span { display: block; color: rgba(255,255,255,.62); font-size: 13px; margin-top: 2px; }
.nav { display: grid; gap: 8px; }
.nav a {
    padding: 14px 16px;
    border-radius: 16px;
    color: rgba(255,255,255,.78);
    font-weight: 750;
}
.nav a:hover, .nav a.active { background: rgba(255,255,255,.10); color: #fff; }
.sidebar-footer {
    margin-top: auto;
    padding: 16px;
    border: 1px solid rgba(255,255,255,.12);
    border-radius: 18px;
    background: rgba(255,255,255,.06);
}
.sidebar-footer small { display: block; color: rgba(255,255,255,.60); }
.sidebar-footer strong { display: block; margin: 4px 0 10px; }
.sidebar-footer a { color: #ffc857; font-weight: 800; }
.main { margin-left: 286px; width: calc(100% - 286px); padding: 32px; }
.topbar {
    display: flex; justify-content: space-between; align-items: flex-start;
    gap: 20px; margin-bottom: 22px;
}
.topbar h1 { margin: 0; font-size: clamp(26px, 3vw, 38px); letter-spacing: -.03em; }
.topbar p { margin: 7px 0 0; color: var(--muted); }
.card {
    background: rgba(255,255,255,.92);
    border: 1px solid rgba(226,232,240,.9);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    padding: 22px;
}
.grid { display: grid; gap: 18px; }
.grid-4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.grid-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.stat { padding: 22px; }
.stat span { color: var(--muted); font-weight: 700; font-size: 13px; text-transform: uppercase; letter-spacing: .05em; }
.stat strong { display: block; font-size: 34px; margin-top: 8px; letter-spacing: -.04em; }
.actions { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.btn {
    display: inline-flex; align-items: center; justify-content: center; gap: 8px;
    min-height: 42px; padding: 0 16px;
    border: 0; border-radius: 14px; cursor: pointer;
    background: var(--primary-dark); color: #fff; font-weight: 850;
    box-shadow: 0 10px 22px rgba(15,61,62,.16);
}
.btn.secondary { background: #eef4f4; color: var(--primary-dark); box-shadow: none; }
.btn.danger { background: var(--danger); }
.btn.small { min-height: 34px; padding: 0 12px; border-radius: 12px; font-size: 13px; }
.btn:disabled { opacity: .65; cursor: not-allowed; }
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; min-width: 780px; }
th, td { padding: 14px 12px; border-bottom: 1px solid var(--line); text-align: left; vertical-align: middle; }
th { color: var(--muted); font-size: 12px; text-transform: uppercase; letter-spacing: .05em; }
td strong { display: block; }
td small { color: var(--muted); }
.badge { display: inline-flex; align-items: center; padding: 6px 10px; border-radius: 999px; font-weight: 850; font-size: 12px; }
.badge-success { background: var(--success-bg); color: var(--success); }
.badge-danger { background: var(--danger-bg); color: var(--danger); }
.badge-info { background: var(--info-bg); color: var(--info); }
.form { display: grid; gap: 16px; }
.form-row { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; }
label { display: grid; gap: 7px; font-weight: 800; }
input, select, textarea {
    width: 100%; min-height: 48px;
    border: 1px solid var(--line);
    background: #fff; border-radius: 14px;
    padding: 12px 14px;
    color: var(--text); font: inherit;
    outline: none;
}
textarea { min-height: 130px; resize: vertical; }
input:focus, select:focus, textarea:focus { border-color: var(--primary); box-shadow: 0 0 0 4px rgba(15,118,110,.10); }
.alert { border-radius: 16px; padding: 14px 16px; margin-bottom: 16px; font-weight: 800; }
.alert-success { background: var(--success-bg); color: var(--success); }
.alert-danger { background: var(--danger-bg); color: var(--danger); }
.alert-info { background: var(--info-bg); color: var(--info); }
.generated-key {
    display: flex; justify-content: space-between; align-items: center; gap: 14px;
    padding: 18px; border-radius: 18px;
    background: #071f22; color: #fff;
}
.generated-key code { font-size: clamp(20px, 3vw, 30px); font-weight: 950; letter-spacing: .08em; }
.searchbar { display: flex; gap: 10px; margin-bottom: 16px; }
.searchbar input { max-width: 380px; }
.login-page { min-height: 100vh; display: grid; place-items: center; padding: 24px; }
.login-card { width: min(460px, 100%); }
.login-card h1 { margin: 0 0 8px; font-size: 32px; letter-spacing: -.04em; }
.login-card p { color: var(--muted); margin: 0 0 22px; }
@media (max-width: 900px) {
    .admin-shell { display: block; }
    .sidebar { position: static; width: auto; border-radius: 0 0 28px 28px; }
    .main { margin-left: 0; width: 100%; padding: 20px; }
    .grid-4, .grid-2, .form-row { grid-template-columns: 1fr; }
    .topbar { display: block; }
}

.nav a { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.nav-count {
    min-width: 24px; height: 24px; padding: 0 7px;
    border-radius: 999px; display: inline-flex; align-items: center; justify-content: center;
    background: #ffc857; color: #071f22; font-size: 12px; font-weight: 950;
}
.badge-warning { background: var(--warning-bg); color: var(--warning); }
.banner-preview {
    width: 180px; max-height: 68px; object-fit: contain;
    background: #fff; border: 1px solid var(--line); border-radius: 12px; padding: 6px;
}
.muted-text { color: var(--muted); }


/* Login cleanup */
.login-card {
    width: min(460px, 100%);
}
.login-header {
    text-align: center;
    margin-bottom: 24px;
}
.login-panel-title {
    font-size: 15px;
    font-weight: 950;
    color: var(--primary-dark);
    text-transform: uppercase;
    letter-spacing: .08em;
}
.login-app-title {
    margin-top: 7px;
    color: var(--muted);
    font-weight: 800;
}
.login-header h1 {
    margin: 18px 0 0;
    text-align: center;
}
.remember-row {
    display: flex;
    grid-template-columns: unset;
    align-items: center;
    gap: 10px;
    font-weight: 800;
}
.remember-row input {
    width: 18px;
    min-height: 18px;
    height: 18px;
    margin: 0;
}

/* Request/admin table alignment */
.request-table {
    min-width: 1120px;
    table-layout: fixed;
}
.request-table th,
.request-table td {
    vertical-align: middle;
    padding-top: 16px;
    padding-bottom: 16px;
}
.request-table th:nth-child(1),
.request-table td:nth-child(1) { width: 165px; }
.request-table th:nth-child(2),
.request-table td:nth-child(2) { width: 230px; }
.request-table th:nth-child(3),
.request-table td:nth-child(3) { width: 220px; }
.request-table th:nth-child(4),
.request-table td:nth-child(4) { width: 72px; }
.request-table th:nth-child(5),
.request-table td:nth-child(5) { width: 120px; }
.request-table th:nth-child(6),
.request-table td:nth-child(6) { width: 170px; }
.request-table th:nth-child(7),
.request-table td:nth-child(7) { width: 330px; }
.cell-stack {
    display: grid;
    gap: 5px;
    align-content: center;
}
.cell-stack strong,
.cell-stack small {
    display: block;
    line-height: 1.35;
    overflow-wrap: anywhere;
}
.banner-cell {
    min-width: 220px;
}
.banner-preview {
    display: block;
    width: 190px;
    height: 72px;
    max-width: 100%;
    object-fit: contain;
    background: #fff;
    border: 1px solid var(--line);
    border-radius: 12px;
    padding: 6px;
}
td.request-actions {
    display: table-cell;
    vertical-align: middle;
}
.action-row {
    display: flex;
    align-items: center;
    justify-content: flex-start;
    gap: 8px;
    flex-wrap: nowrap;
}
.action-row form {
    margin: 0;
    display: inline-flex;
}
.action-row .btn.small {
    width: 94px;
    min-width: 94px;
    padding: 0 10px;
    white-space: nowrap;
}
.btn.delete-btn {
    background: #fff0f0;
    color: var(--danger);
    border: 1px solid rgba(180, 35, 24, .26);
    box-shadow: none;
}
.btn.delete-btn:hover {
    background: var(--danger);
    color: #fff;
}

/* General admin table actions */
.card-toolbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    flex-wrap: wrap;
    margin-bottom: 16px;
}
td.table-actions,
td.request-actions {
    display: table-cell;
    vertical-align: middle;
    white-space: nowrap;
}
.table-actions .action-row,
.request-actions .action-row {
    display: flex;
    align-items: center;
    justify-content: flex-start;
    gap: 8px;
    flex-wrap: nowrap;
}
.table-actions .action-row form,
.request-actions .action-row form {
    margin: 0;
    display: inline-flex;
}
.table-actions .btn.small,
.request-actions .btn.small {
    width: 94px;
    min-width: 94px;
    padding: 0 10px;
    white-space: nowrap;
}
.action-row-wide .btn.small {
    width: 82px;
    min-width: 82px;
}

.card-toolbar .searchbar {
    margin-bottom: 0;
}


/* Key generation email option */
.card-header.compact {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 14px;
    margin-bottom: 16px;
}
.card-header.compact h2 {
    margin: 0;
    font-size: 22px;
    letter-spacing: -.02em;
}
.card-header.compact p {
    margin: 5px 0 0;
    color: var(--muted);
    line-height: 1.55;
}
.section-card {
    margin-top: 18px;
}
.form-actions {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 10px;
}
.check-row {
    display: flex;
    grid-template-columns: unset;
    align-items: center;
    gap: 12px;
    padding: 14px 16px;
    border: 1px solid var(--line);
    border-radius: 16px;
    background: #fff;
    font-weight: 850;
}
.check-row input {
    width: 18px;
    min-height: 18px;
    height: 18px;
    margin: 0;
    flex: 0 0 auto;
}
.no-margin-bottom {
    margin-bottom: 0 !important;
}
.alert-warning {
    background: var(--warning-bg);
    color: var(--warning);
}

/* Email log */
.email-log-table {
    min-width: 980px;
}
.email-log-table td:nth-child(2) small {
    display: block;
    margin-top: 4px;
    overflow-wrap: anywhere;
}
