:root {
    --bg: #f4efe7;
    --surface: rgba(255, 255, 255, 0.84);
    --surface-strong: #ffffff;
    --ink: #17324d;
    --muted: #617487;
    --line: rgba(23, 50, 77, 0.12);
    --brand: #c45b34;
    --brand-deep: #8b3d20;
    --accent: #d8c39f;
    --success: #1f7a4d;
    --danger: #b64646;
    --warning: #8a6316;
    --shadow: 0 20px 70px rgba(27, 39, 51, 0.12);
    --radius: 26px;
}

* { box-sizing: border-box; }
body {
    margin: 0;
    font-family: "Trebuchet MS", "Gill Sans", sans-serif;
    color: var(--ink);
    background:
        radial-gradient(circle at top left, rgba(212, 166, 121, 0.35), transparent 28%),
        radial-gradient(circle at bottom right, rgba(95, 128, 153, 0.26), transparent 24%),
        linear-gradient(135deg, #f7f2eb, #eef4f8 55%, #f2e9db);
    min-height: 100vh;
}
a { color: inherit; text-decoration: none; }
code { background: rgba(23, 50, 77, 0.06); padding: 2px 6px; border-radius: 6px; }
h1, h2, h3 { font-family: Georgia, "Times New Roman", serif; margin: 0 0 10px; }
p { margin: 0; }
input, select, button { font: inherit; }
input, select {
    width: 100%;
    border: 1px solid var(--line);
    border-radius: 16px;
    padding: 14px 16px;
    background: rgba(255,255,255,0.9);
    color: var(--ink);
}
/* Keep checkboxes and radios from inheriting the full-width field styling. */
input[type="checkbox"], input[type="radio"] {
    width: auto;
    min-width: 0;
    margin: 0;
    accent-color: var(--brand);
    cursor: pointer;
}
select[multiple] { padding: 8px; min-height: 132px; }
select[multiple] option { padding: 8px 10px; border-radius: 8px; }
select[multiple] option:checked { background: rgba(196, 91, 52, 0.18); font-weight: 700; }
hr { border: 0; border-top: 1px solid var(--line); margin: 6px 0; }
label { display: grid; gap: 8px; }
label span { font-size: 14px; color: var(--muted); font-weight: 700; }
.eyebrow {
    text-transform: uppercase;
    letter-spacing: 0.12em;
    font-size: 12px;
    color: var(--brand);
    font-weight: 800;
    margin-bottom: 10px;
}
.lede, .muted-copy { color: var(--muted); line-height: 1.6; }
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    border-radius: 999px;
    padding: 13px 20px;
    border: 1px solid transparent;
    font-weight: 700;
}
.btn-primary { background: linear-gradient(135deg, var(--brand), var(--brand-deep)); color: #fff; box-shadow: 0 12px 28px rgba(139, 61, 32, 0.25); }
.btn-secondary { background: rgba(255,255,255,0.82); border-color: var(--line); }
.btn-disabled { background: rgba(23, 50, 77, 0.08); color: var(--muted); cursor: not-allowed; }
.btn-full { width: 100%; }
.alert {
    padding: 14px 16px;
    border-radius: 16px;
    margin-bottom: 18px;
    border: 1px solid transparent;
}
.alert-success { color: var(--success); background: rgba(31, 122, 77, 0.08); border-color: rgba(31, 122, 77, 0.18); }
.alert-danger { color: var(--danger); background: rgba(182, 70, 70, 0.08); border-color: rgba(182, 70, 70, 0.16); }
.alert-warning { color: var(--warning); background: rgba(138, 99, 22, 0.1); border-color: rgba(138, 99, 22, 0.16); }
/* Inline explanation shown next to a control (e.g. an access-mode warning). */
.notice {
    padding: 14px 16px;
    border-radius: 16px;
    background: rgba(138, 99, 22, 0.1);
    border: 1px solid rgba(138, 99, 22, 0.22);
    color: var(--warning);
}
.notice strong { display: block; margin-bottom: 4px; }
.notice p { color: inherit; line-height: 1.6; }
.notice-text {
    margin-top: 8px;
    font-weight: 600;
    color: var(--warning);
}
.notice-text a { text-decoration: underline; }
/* A section that is present but not currently in effect. */
.is-disabled { opacity: 0.5; filter: grayscale(0.35); pointer-events: none; }
.compact-list { margin: 10px 0 0; padding-left: 18px; }
.compact-list li { margin-bottom: 6px; }
.stack-form { display: grid; gap: 18px; }
/* Collapsible sections on the certificate/user forms. */
[data-access-panel], [data-source-panel], [data-grant-panel] { display: grid; gap: 18px; }
[data-access-panel][hidden], [data-source-panel][hidden], [data-grant-panel][hidden] { display: none; }
.split-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; }
.inline-check { display: flex; align-items: center; gap: 10px; }
.inline-check input { width: auto; }
.hero-wrap, .auth-wrap { min-height: 100vh; display: grid; place-items: center; padding: 32px; }
.hero-card, .auth-card {
    width: min(1120px, 100%);
    background: var(--surface);
    backdrop-filter: blur(18px);
    border: 1px solid rgba(255,255,255,0.42);
    border-radius: 34px;
    box-shadow: var(--shadow);
}
.hero-card {
    padding: 36px;
    display: grid;
    grid-template-columns: 1.2fr 0.9fr;
    gap: 28px;
}
.hero-copy {
    min-height: 520px;
    padding: 34px;
    border-radius: 28px;
    background: linear-gradient(160deg, rgba(23, 50, 77, 0.94), rgba(55, 88, 111, 0.88));
    color: #fff;
    display: flex;
    flex-direction: column;
    justify-content: end;
}
.hero-copy .eyebrow { color: #ffd3b3; }
.hero-copy .lede { color: rgba(255,255,255,0.8); }
.hero-copy h1 { font-size: clamp(2.5rem, 5vw, 4.6rem); line-height: 1; max-width: 10ch; }
.lookup-panel { padding: 30px; display: grid; align-content: center; gap: 22px; }
.result-card, .hint-box {
    padding: 18px;
    border-radius: 20px;
    background: rgba(255,255,255,0.72);
    border: 1px solid var(--line);
}
/* One flat card per event instead of a card nested inside a card. */
.result-card { display: grid; gap: 16px; }
.event-group { display: grid; gap: 10px; padding-top: 16px; border-top: 1px solid var(--line); }
.event-group:first-of-type { padding-top: 0; border-top: 0; }
.event-group .event-name { font-family: Georgia, "Times New Roman", serif; font-size: 1.05rem; }
.event-group .action-row { justify-content: flex-start; }
.result-card > .status-pill { justify-self: start; }
.action-row, .form-actions, .toolbar, .panel-heading, .list-card, .sidebar-footer { display: flex; align-items: center; justify-content: space-between; gap: 14px; flex-wrap: wrap; }
.admin-shell { display: grid; grid-template-columns: 300px 1fr; align-items: start; min-height: 100vh; }
.admin-sidebar {
    position: sticky;
    top: 0;
    height: 100vh;
    overflow-y: auto;
    padding: 28px;
    background: linear-gradient(180deg, rgba(23,50,77,0.98), rgba(43,74,96,0.92));
    color: #fff;
    display: flex;
    flex-direction: column;
}
.admin-sidebar h1 { font-size: 2.2rem; }
.sidebar-copy { color: rgba(255,255,255,0.76); line-height: 1.6; }
.admin-nav { display: grid; gap: 8px; margin-top: 26px; }
.admin-nav-label {
    margin: 16px 0 2px;
    font-size: 11px;
    letter-spacing: 0.12em;
    text-transform: uppercase;
    font-weight: 800;
    color: rgba(255,255,255,0.5);
}
.admin-nav-label:first-child { margin-top: 0; }
.admin-nav a {
    padding: 14px 16px;
    border-radius: 16px;
    color: rgba(255,255,255,0.84);
    border: 1px solid rgba(255,255,255,0.08);
}
.admin-nav a.sub { margin-left: 16px; font-size: 14px; padding: 11px 16px; }
.admin-nav a.active, .admin-nav a:hover { background: rgba(255,255,255,0.12); color: #fff; }
.sidebar-footer { margin-top: auto; padding-top: 18px; border-top: 1px solid rgba(255,255,255,0.16); }
.sidebar-footer span { color: rgba(255,255,255,0.72); font-size: 14px; }
.sidebar-footer a { font-weight: 700; text-decoration: underline; }
.admin-main { padding: 34px; }
.admin-header { margin-bottom: 20px; }
.stats-grid, .panel-grid { display: grid; gap: 18px; margin-bottom: 22px; }
.stats-grid { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.panel-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); align-items: start; }
.stat-card, .panel {
    background: var(--surface);
    border: 1px solid rgba(255,255,255,0.4);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
}
.stat-card { padding: 24px; display: grid; gap: 10px; }
.stat-card span { color: var(--muted); font-weight: 700; }
.stat-card strong { font-size: 2.2rem; }
.panel { padding: 24px; }
.ordered-list { margin: 12px 0 0; padding-left: 20px; color: var(--muted); line-height: 1.9; }
.table-wrap { overflow-x: auto; }
.data-table { width: 100%; border-collapse: collapse; }
.data-table th, .data-table td { padding: 14px 10px; border-bottom: 1px solid var(--line); text-align: left; }
.data-table tbody tr:hover { background: rgba(255,255,255,0.55); }
.data-table input[type="checkbox"] { width: 18px; height: 18px; }
.stack-list { display: grid; gap: 14px; }
.list-card { padding: 16px; background: rgba(255,255,255,0.72); border: 1px solid var(--line); border-radius: 18px; }
.list-card p { color: var(--muted); }
.status-pill {
    display: inline-flex;
    padding: 8px 12px;
    border-radius: 999px;
    background: rgba(23, 50, 77, 0.08);
    color: var(--muted);
    font-size: 13px;
    font-weight: 700;
}
.status-pill.active { background: rgba(31, 122, 77, 0.12); color: var(--success); }
.pager-wrap { margin-top: 18px; }
.pagination { display: flex; gap: 8px; list-style: none; padding: 0; }
.pagination a, .pagination span {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 40px;
    padding: 10px 12px;
    border-radius: 12px;
    border: 1px solid var(--line);
    background: rgba(255,255,255,0.8);
}
.actions { display: flex; gap: 12px; flex-wrap: wrap; }
.toolbar { margin: 18px 0; }
.toolbar input:not([type="checkbox"]):not([type="radio"]) { flex: 1 1 240px; min-width: 180px; }
.toolbar select { flex: 0 1 200px; width: auto; min-width: 150px; }
.toolbar .btn { flex: 0 0 auto; }
.auth-card { max-width: 520px; padding: 34px; }
.template-preview-shell {
    margin-top: 22px;
    overflow: auto;
    padding: 18px;
    border-radius: 22px;
    background: rgba(23, 50, 77, 0.05);
    border: 1px solid var(--line);
}
.template-preview-stage {
    position: relative;
    width: 100%;
}
.template-preview-image {
    display: block;
    width: 100%;
    height: auto;
    border-radius: 18px;
    box-shadow: var(--shadow);
}
.template-preview-name {
    position: absolute;
    line-height: 1.15;
    text-wrap: balance;
    pointer-events: none;
}

@media (max-width: 980px) {
    .hero-card, .panel-grid, .split-grid {
        grid-template-columns: 1fr;
    }
    .hero-copy { min-height: auto; }
    .admin-shell { grid-template-columns: 1fr; }
    .admin-sidebar {
        position: static;
        height: auto;
        overflow: visible;
    }
    .admin-nav { grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); }
    .admin-nav-label { grid-column: 1 / -1; margin-top: 10px; }
    .admin-nav a.sub { margin-left: 0; }
    .sidebar-footer { margin-top: 22px; }
    .stats-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .admin-main { padding: 22px; }
}

@media (max-width: 640px) {
    .hero-wrap, .auth-wrap, .admin-main { padding: 18px; }
    .hero-card, .auth-card, .panel, .stat-card { padding: 20px; }
    .stats-grid { grid-template-columns: 1fr; }
    .action-row, .form-actions, .toolbar, .panel-heading, .list-card, .sidebar-footer { flex-direction: column; align-items: stretch; }
    .toolbar input:not([type="checkbox"]):not([type="radio"]), .toolbar select { flex: 1 1 auto; min-width: 0; width: 100%; }
}
