/* Voucher admin design system. Bootstrap 5.3 supplies the components; this
   sheet sets its variables from the tokens below, in both themes, and adds the
   app shell and the few components Bootstrap lacks. base.html keeps
   data-theme and data-bs-theme in step and switches to light for printing. */

/* 1. Tokens -------------------------------------------------------------- */
:root {
    color-scheme: light;
    --font: -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI", system-ui, sans-serif;
    --font-mono: ui-monospace, "SF Mono", Menlo, Consolas, monospace;
    --radius: 14px;
    --radius-btn: 10px;
    --radius-sm: 8px;

    --accent: #0071e3;
    --accent-hover: #0064ca;
    --accent-active: #0058b0;
    --focus: rgba(0, 113, 227, .35);

    --bg: #f5f5f7;
    --side: #ebebef;
    --line: #dcdce1;
    --line-soft: #f0f0f3;
    --card: #ffffff;
    --shadow: 0 1px 2px rgba(0, 0, 0, .05), 0 0 0 1px rgba(0, 0, 0, .04);
    --shadow-pop: 0 8px 28px rgba(0, 0, 0, .14), 0 0 0 1px rgba(0, 0, 0, .05);
    --text: #1d1d1f;
    --sub: #6e6e73;
    --side-sub: #5c5c62;    /* secondary text on the sidebar grey: 4.5:1 or more */
    --soon-sub: var(--sub);
    --mono: #3a3a3c;
    --search: #dcdce1;
    --nav-hover: rgba(0, 0, 0, .045);
    --nav-on: #d4d4da;
    --icon: var(--accent);
    --track: #e3e3e8;
    --seg-on: #ffffff;
    --btn2: #e8e8ed;
    --btn2-hover: #dddde3;
    --btn2-active: #d2d2d8;
    --inset: #f5f5f7;
    --avatar: #c7c7cc;
    --row-on: rgba(0, 113, 227, .09);
    --row-hover: rgba(0, 0, 0, .025);
    --dot: var(--accent);
    --link: #0066cc;
    --link-rgb: 0, 102, 204;
    --link-hover: #004f9e;
    --link-hover-rgb: 0, 79, 158;
    --field: #ffffff;
    --field-border: #c9c9cf;

    /* Status: valid green, partial / expiring orange, redeemed blue, expired grey */
    --green: #34c759;
    --blue: #0a84ff;
    --orange: #ff9500;
    --ring-g: rgba(52, 199, 89, .18);
    --ring-b: rgba(10, 132, 255, .18);
    --ring-o: rgba(255, 149, 0, .2);
    --green-text: #1b7a34;
    --blue-text: #0058b0;
    --orange-text: #a14a00;
    --grey-text: #5c5c62;
    --pill-valid: rgba(52, 199, 89, .15);
    --pill-soon: rgba(255, 149, 0, .16);
    --pill-redeemed: rgba(0, 113, 227, .12);
    --pill-expired: rgba(120, 120, 128, .14);
    --soon-bg: #fff4e5;

    /* Destructive actions only */
    --red: #d70015;
    --red-hover: #bb0012;
    --red-text: #c4000f;
    --red-soft: rgba(215, 0, 21, .09);

    /* Charts (3:1 or more on the card): status series and categories */
    --chart-valid: #248a3d;
    --chart-redeemed: #0071e3;
    --chart-soon: #c25e00;
    --chart-expired: #8e8e93;
    /* Categories avoid the status hues (green, orange, blue, grey) */
    --chart-1: #8944ab;
    --chart-2: #00808a;
    --chart-3: #c2185b;
    --chart-4: #3634a3;
    --chart-5: #7f6545;
    --chart-6: #5b7a00;
    --chart-7: #b5179e;
    --chart-8: #4a6b8a;
    --chart-neutral: #8e8e93;
}

:root[data-theme="dark"] {
    color-scheme: dark;
    --accent-hover: #0a7cf0;
    --accent-active: #0062c4;
    --focus: rgba(10, 132, 255, .5);

    --bg: #1c1c1e;
    --side: #242426;
    --line: #38383a;
    --line-soft: #38383a;
    --card: #2c2c2e;
    --shadow: 0 0 0 1px rgba(255, 255, 255, .06);
    --shadow-pop: 0 10px 30px rgba(0, 0, 0, .5), 0 0 0 1px rgba(255, 255, 255, .08);
    --text: #f5f5f7;
    --sub: #a1a1a6;
    --side-sub: #aeaeb2;
    --soon-sub: #c7c7cc;
    --mono: #d1d1d6;
    --search: #3a3a3c;
    --nav-hover: rgba(255, 255, 255, .06);
    --nav-on: #3a3a3c;
    --icon: #6cb6ff;
    --track: #1c1c1e;
    --seg-on: #48484a;
    --btn2: #3a3a3c;
    --btn2-hover: #444446;
    --btn2-active: #4f4f52;
    --inset: #1c1c1e;
    --avatar: #48484a;
    --row-on: rgba(10, 132, 255, .22);
    --row-hover: rgba(255, 255, 255, .035);
    --dot: #6cb6ff;
    --link: #6cb6ff;
    --link-rgb: 108, 182, 255;
    --link-hover: #9fd0ff;
    --link-hover-rgb: 159, 208, 255;
    --field: #1c1c1e;
    --field-border: #545458;

    --green: #30d158;
    --orange: #ff9f0a;
    --ring-g: rgba(48, 209, 88, .2);
    --ring-b: rgba(10, 132, 255, .24);
    --ring-o: rgba(255, 159, 10, .22);
    --green-text: #5ee08a;
    --blue-text: #6cb6ff;
    --orange-text: #ffb340;
    --grey-text: #c7c7cc;
    --pill-valid: rgba(48, 209, 88, .18);
    --pill-soon: rgba(255, 159, 10, .18);
    --pill-redeemed: rgba(10, 132, 255, .22);
    --pill-expired: rgba(152, 152, 157, .2);
    --soon-bg: rgba(255, 159, 10, .16);

    --red: #d70015;
    --red-hover: #e5202f;
    --red-text: #ff8a80;
    --red-soft: rgba(255, 69, 58, .16);

    --chart-valid: #30d158;
    --chart-redeemed: #0a84ff;
    --chart-soon: #ff9f0a;
    --chart-expired: #8e8e93;
    --chart-1: #bf5af2;
    --chart-2: #40c8e0;
    --chart-3: #ff6b9a;
    --chart-4: #8e8cff;
    --chart-5: #ac8e68;
    --chart-6: #a8d14f;
    --chart-7: #f07bdc;
    --chart-8: #8fb3d9;
    --chart-neutral: #98989d;
}

/* 2. Bootstrap variables from the tokens --------------------------------- */
:root,
:root[data-theme="dark"] {
    --bs-body-font-family: var(--font);
    --bs-body-font-size: .875rem;
    --bs-body-line-height: 1.45;
    --bs-body-bg: var(--bg);
    --bs-body-color: var(--text);
    --bs-emphasis-color: var(--text);
    --bs-heading-color: var(--text);
    --bs-secondary-color: var(--sub);
    --bs-tertiary-color: var(--sub);
    --bs-secondary-bg: var(--btn2);
    --bs-tertiary-bg: var(--inset);
    --bs-border-color: var(--line);
    --bs-border-color-translucent: var(--line);
    --bs-border-radius: var(--radius-btn);
    --bs-border-radius-sm: 7px;
    --bs-border-radius-lg: var(--radius);
    --bs-link-color: var(--link);
    --bs-link-color-rgb: var(--link-rgb);
    --bs-link-hover-color: var(--link-hover);
    --bs-link-hover-color-rgb: var(--link-hover-rgb);
    --bs-code-color: var(--mono);
    --bs-focus-ring-color: var(--focus);
    --bs-form-valid-color: var(--green-text);
    --bs-form-valid-border-color: var(--green-text);
    --bs-form-invalid-color: var(--red-text);
    --bs-form-invalid-border-color: var(--red-text);
}

body {
    background: var(--bg);
    color: var(--text);
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

h1, h2, h3, h4, h5, h6 { letter-spacing: -.01em; font-weight: 600; }
code, .font-monospace { font-family: var(--font-mono); }
code { font-size: .92em; }
hr { border-color: var(--line); opacity: 1; }

.card {
    --bs-card-bg: var(--card);
    --bs-card-color: var(--text);
    --bs-card-title-color: var(--text);
    --bs-card-border-width: 0;
    --bs-card-border-radius: var(--radius);
    --bs-card-inner-border-radius: var(--radius);
    --bs-card-cap-bg: transparent;
    --bs-card-cap-padding-y: 14px;
    --bs-card-cap-padding-x: 16px;
    --bs-card-spacer-y: 18px;
    --bs-card-spacer-x: 20px;
    box-shadow: var(--shadow);
}
.card-header { border-bottom: 1px solid var(--line); }
.card-footer { border-top: 1px solid var(--line); color: var(--sub); font-size: 13px; }
.card-title { font-size: 17px; font-weight: 600; margin-bottom: 12px; }

.table {
    --bs-table-bg: transparent;
    --bs-table-color: var(--text);
    --bs-table-border-color: var(--line-soft);
    --bs-table-hover-bg: var(--row-hover);
    --bs-table-hover-color: var(--text);
    --bs-table-striped-bg: var(--row-hover);
    margin-bottom: 0;
    vertical-align: middle;
}
.table > :not(caption) > * > * { padding: 11px 16px; }
.table-sm > :not(caption) > * > * { padding: 7px 12px; }
.table > thead > tr > th {
    font-size: 12px;
    font-weight: 500;
    color: var(--sub);
    border-bottom-color: var(--line);
    white-space: nowrap;
}
.table > tbody > tr:last-child > * { border-bottom-width: 0; }
.table tr.is-selected,
.table-hover > tbody > tr.is-selected:hover > * { --bs-table-bg-state: var(--row-on); }
tr[data-href] { cursor: pointer; }
tr.is-selected .row-sub, .table-cards tr.is-selected td { color: var(--mono); }

.btn {
    --bs-btn-padding-y: 7px;
    --bs-btn-padding-x: 14px;
    --bs-btn-font-size: 14px;
    --bs-btn-font-weight: 500;
    --bs-btn-line-height: 1.43;
    --bs-btn-border-radius: var(--radius-btn);
    --bs-btn-border-width: 0;
    --bs-btn-focus-box-shadow: 0 0 0 3px var(--focus);
    --bs-btn-disabled-opacity: .45;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
}
.btn-sm {
    --bs-btn-padding-y: 4px;
    --bs-btn-padding-x: 10px;
    --bs-btn-font-size: 13px;
    --bs-btn-border-radius: var(--radius-sm);
}
.btn-lg {
    --bs-btn-padding-y: 10px;
    --bs-btn-padding-x: 18px;
    --bs-btn-font-size: 15px;
    --bs-btn-border-radius: 12px;
}
/* The one main action of a page */
.btn-primary {
    --bs-btn-color: #fff;
    --bs-btn-bg: var(--accent);
    --bs-btn-hover-color: #fff;
    --bs-btn-hover-bg: var(--accent-hover);
    --bs-btn-active-color: #fff;
    --bs-btn-active-bg: var(--accent-active);
    --bs-btn-disabled-color: #fff;
    --bs-btn-disabled-bg: var(--accent);
}
/* Everything else: grey fill. The outline and colour variants map here too. */
.btn-secondary, .btn-light, .btn-outline-primary, .btn-outline-secondary,
.btn-outline-success, .btn-outline-info, .btn-outline-warning, .btn-outline-light,
.btn-success, .btn-info, .btn-warning {
    --bs-btn-color: var(--text);
    --bs-btn-bg: var(--btn2);
    --bs-btn-hover-color: var(--text);
    --bs-btn-hover-bg: var(--btn2-hover);
    --bs-btn-active-color: var(--text);
    --bs-btn-active-bg: var(--btn2-active);
    --bs-btn-disabled-color: var(--text);
    --bs-btn-disabled-bg: var(--btn2);
}
.btn-danger {
    --bs-btn-color: #fff;
    --bs-btn-bg: var(--red);
    --bs-btn-hover-color: #fff;
    --bs-btn-hover-bg: var(--red-hover);
    --bs-btn-active-color: #fff;
    --bs-btn-active-bg: var(--red-hover);
    --bs-btn-disabled-color: #fff;
    --bs-btn-disabled-bg: var(--red);
}
/* Destructive but secondary: red label on the grey fill */
.btn-outline-danger {
    --bs-btn-color: var(--red-text);
    --bs-btn-bg: var(--btn2);
    --bs-btn-hover-color: var(--red-text);
    --bs-btn-hover-bg: var(--red-soft);
    --bs-btn-active-color: var(--red-text);
    --bs-btn-active-bg: var(--red-soft);
    --bs-btn-disabled-color: var(--red-text);
    --bs-btn-disabled-bg: var(--btn2);
}
.btn-link {
    --bs-btn-color: var(--link);
    --bs-btn-hover-color: var(--link-hover);
    --bs-btn-active-color: var(--link-hover);
    --bs-btn-padding-x: 4px;
    text-decoration: none;
}
.btn-icon { --bs-btn-padding-x: 0; width: 44px; letter-spacing: 1px; }
.btn-sm.btn-icon { width: 32px; }

.form-label { font-size: 13px; font-weight: 500; margin-bottom: 6px; }
.form-text { color: var(--sub); font-size: 12px; }
.form-control, .form-select {
    background-color: var(--field);
    border-color: var(--field-border);
    color: var(--text);
    border-radius: var(--radius-sm);
    padding: 7px 11px;
    font-size: 14px;
}
.form-select { padding-right: 34px; }
.form-control-lg { padding: 10px 14px; font-size: 17px; border-radius: var(--radius-btn); }
.form-control::placeholder { color: var(--sub); opacity: .8; }
.form-control:focus, .form-select:focus, .form-check-input:focus {
    border-color: var(--accent);
    box-shadow: 0 0 0 3px var(--focus);
    background-color: var(--field);
    color: var(--text);
}
.form-control:disabled, .form-control[readonly] { background-color: var(--inset); }
.form-check-input {
    --bs-form-check-bg: var(--field);
    border-color: var(--field-border);
}
.form-check-input:checked { background-color: var(--accent); border-color: var(--accent); }
.input-group-text { background-color: var(--btn2); border-color: var(--field-border); color: var(--mono); }

.alert {
    --bs-alert-padding-x: 16px;
    --bs-alert-padding-y: 12px;
    --bs-alert-border-radius: 12px;
    --bs-alert-border-color: transparent;
    --bs-alert-bg: var(--card);
    --bs-alert-color: var(--text);
    --bs-alert-link-color: inherit;
    box-shadow: var(--shadow);
}
.alert-success { --bs-alert-bg: var(--pill-valid); --bs-alert-color: var(--green-text); box-shadow: none; }
.alert-warning { --bs-alert-bg: var(--pill-soon); --bs-alert-color: var(--orange-text); box-shadow: none; }
.alert-danger { --bs-alert-bg: var(--red-soft); --bs-alert-color: var(--red-text); box-shadow: none; }
.alert-heading { color: inherit; font-size: 15px; }

.dropdown-menu {
    --bs-dropdown-bg: var(--card);
    --bs-dropdown-color: var(--text);
    --bs-dropdown-border-color: transparent;
    --bs-dropdown-border-radius: 12px;
    --bs-dropdown-box-shadow: var(--shadow-pop);
    --bs-dropdown-link-color: var(--text);
    --bs-dropdown-link-hover-color: var(--text);
    --bs-dropdown-link-hover-bg: var(--btn2);
    --bs-dropdown-link-active-color: #fff;
    --bs-dropdown-link-active-bg: var(--accent);
    --bs-dropdown-item-border-radius: 7px;
    --bs-dropdown-padding-x: 5px;
    --bs-dropdown-font-size: 14px;
    box-shadow: var(--bs-dropdown-box-shadow);
}

.progress { --bs-progress-bg: var(--track); --bs-progress-bar-bg: var(--chart-valid); --bs-progress-border-radius: 999px; }

.offcanvas-lg { --bs-offcanvas-bg: var(--side); --bs-offcanvas-color: var(--text); --bs-offcanvas-width: 284px; }

/* 3. App shell ------------------------------------------------------------ */
.app { display: flex; min-height: 100vh; }
.app-main { flex: 1 1 auto; min-width: 0; padding: 28px 32px 48px; }
.app-topbar { display: none; --sub: var(--side-sub); }

.sidebar-body {
    --sub: var(--side-sub);
    display: flex;
    flex-direction: column;
    gap: 20px;
    padding: 20px 12px;
    width: 100%;
}
.brand { display: flex; align-items: center; gap: 10px; padding: 0 8px; color: var(--text); text-decoration: none; }
.brand:hover { color: var(--text); }
.brand-mark {
    width: 32px; height: 32px; border-radius: 8px; flex: none;
    background: var(--accent); color: #fff;
    display: flex; align-items: center; justify-content: center;
}
.brand-name { display: flex; flex-direction: column; line-height: 1.25; }
.brand-name strong { font-weight: 600; font-size: 15px; }
.brand-name span { font-size: 12px; color: var(--sub); }

.side-search {
    display: flex; align-items: center; gap: 8px; margin: 0 8px; padding: 7px 10px;
    background: var(--search); border-radius: 8px; color: var(--sub);
}
.side-search:focus-within { box-shadow: 0 0 0 3px var(--focus); }
.side-search input {
    border: 0; background: transparent; outline: none; flex: 1; min-width: 0;
    color: var(--text); font-size: 13px;
}
.side-search input::placeholder { color: var(--sub); }

.side-nav { display: flex; flex-direction: column; gap: 2px; }
.side-nav-title { padding: 0 10px 4px; font-size: 11px; font-weight: 600; color: var(--sub); }
.side-nav a {
    display: flex; align-items: center; gap: 10px; padding: 7px 10px;
    border-radius: 7px; color: var(--text); text-decoration: none;
}
.side-nav a:hover { background: var(--nav-hover); color: var(--text); }
.side-nav a[aria-current="page"] { background: var(--nav-on); font-weight: 500; }
.side-nav a:focus-visible { outline: 0; box-shadow: 0 0 0 3px var(--focus); }
.side-nav svg { width: 17px; height: 17px; flex: none; stroke: var(--icon); fill: none; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.side-nav-sec svg { stroke: var(--sub); }
.side-nav .count { margin-left: auto; font-size: 12px; color: var(--sub); font-variant-numeric: tabular-nums; }
.side-nav a.sub { padding-left: 37px; font-size: 13px; color: var(--sub); }
.side-nav a.sub[aria-current="page"] { color: var(--text); }

.side-foot {
    margin-top: auto; display: flex; flex-direction: column; gap: 12px;
    padding: 12px 10px 0; border-top: 1px solid var(--line);
}
.user-chip { display: flex; align-items: center; gap: 10px; min-width: 0; }
.avatar {
    width: 28px; height: 28px; border-radius: 50%; flex: none;
    background: var(--avatar); color: var(--text); font-size: 12px; font-weight: 600;
    display: flex; align-items: center; justify-content: center;
}
.user-chip .who { display: flex; flex-direction: column; min-width: 0; line-height: 1.3; }
.user-chip .who strong { font-size: 13px; font-weight: 500; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.user-chip .who span { font-size: 12px; color: var(--sub); }
.side-links { display: flex; flex-wrap: wrap; gap: 4px 14px; font-size: 13px; }
.side-links a { color: var(--sub); text-decoration: none; }
.side-links a:hover { color: var(--text); }

@media (min-width: 992px) {
    .app-sidebar { flex: 0 0 248px; background: var(--side); border-right: 1px solid var(--line); }
    .app-sidebar > .offcanvas-lg {
        position: sticky; top: 0; height: 100vh; overflow-y: auto;
        display: flex; flex-direction: column;
    }
    .app-sidebar .offcanvas-body { flex-grow: 1; }
}
@media (max-width: 991.98px) {
    .app { flex-direction: column; }
    .app-topbar {
        display: flex; align-items: center; gap: 8px;
        position: sticky; top: 0; z-index: 1030;
        padding: 8px 12px; background: var(--side); border-bottom: 1px solid var(--line);
    }
    .app-topbar .brand { padding: 0; margin-right: auto; }
    .app-topbar .brand-mark { width: 28px; height: 28px; }
    .app-main { padding: 20px 16px 40px; }
    .app-sidebar .offcanvas-header { padding: 12px 12px 0 20px; justify-content: flex-end; }
    .app-sidebar .offcanvas-body { padding: 0; display: flex; }
}
.icon-btn {
    width: 38px; height: 38px; border: 0; border-radius: 9px; flex: none;
    background: transparent; color: var(--text);
    display: inline-flex; align-items: center; justify-content: center;
}
.icon-btn:hover { background: var(--nav-hover); color: var(--text); }
.icon-btn:focus-visible { outline: 0; box-shadow: 0 0 0 3px var(--focus); }

/* Signed-out pages (login, 2FA) */
.auth { min-height: 100vh; display: flex; flex-direction: column; align-items: center; justify-content: center; padding: 56px 16px; }
.auth-theme { position: fixed; top: 14px; right: 14px; }
.auth-card { width: 100%; max-width: 380px; }
.auth .brand { justify-content: center; margin-bottom: 20px; }

/* 4. Page frame ----------------------------------------------------------- */
.page { max-width: 1320px; margin: 0 auto; display: flex; flex-direction: column; gap: 20px; }
.page-narrow { max-width: 760px; }
.page-header { display: flex; flex-wrap: wrap; align-items: flex-end; justify-content: space-between; gap: 12px 16px; }
.page-header .titles { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.page-header .eyebrow { font-size: 13px; color: var(--sub); }
.page-header .eyebrow a { color: var(--sub); text-decoration: none; }
.page-header .eyebrow a:hover { color: var(--text); }
.page-header h1 { margin: 0; font-size: 28px; font-weight: 700; letter-spacing: -.02em; overflow-wrap: anywhere; }
.page-header .subtitle { color: var(--sub); font-size: 14px; margin: 0; }
.page-actions { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
@media (max-width: 575.98px) {
    .page-header h1 { font-size: 24px; }
}

.card-head {
    display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between;
    gap: 10px 12px; padding: 14px 16px; border-bottom: 1px solid var(--line);
}
.card-head h2, .card-head h3 { margin: 0; font-size: 17px; font-weight: 600; }
.card-head .hint { font-size: 13px; color: var(--sub); }
.card-foot { padding: 10px 16px; border-top: 1px solid var(--line-soft); font-size: 13px; }
.card-foot a { text-decoration: none; }
.card-table { overflow: hidden; }
.section-title { font-size: 13px; font-weight: 600; color: var(--sub); margin: 0 0 10px; }

.flex-row-wrap { display: flex; flex-wrap: wrap; gap: 16px; align-items: stretch; }
.split { display: flex; flex-wrap: wrap; gap: 16px; align-items: flex-start; }
.split > .grow { flex: 999 1 520px; min-width: 0; }
.split > .side { flex: 1 1 300px; min-width: 0; }
.form-card { max-width: 760px; }
.form-actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 8px; }
.form-section { padding-top: 16px; margin-top: 16px; border-top: 1px solid var(--line); }

/* Segmented control (filters, theme) */
.segmented { display: inline-flex; flex-wrap: wrap; gap: 2px; padding: 2px; background: var(--track); border-radius: 9px; max-width: 100%; }
.segmented > a, .segmented > button {
    border: 0; min-height: 28px; padding: 0 12px; border-radius: 7px;
    font-size: 13px; color: var(--text); background: transparent; text-decoration: none;
    display: inline-flex; align-items: center; justify-content: center; gap: 6px; white-space: nowrap;
}
.segmented > a:hover, .segmented > button:hover { color: var(--text); background: var(--nav-hover); }
.segmented > [aria-pressed="true"], .segmented > [aria-current] {
    background: var(--seg-on); box-shadow: 0 1px 2px rgba(0, 0, 0, .14); font-weight: 500;
}
.segmented > :focus-visible { outline: 0; box-shadow: 0 0 0 3px var(--focus); }
.segmented-block { display: flex; }
.segmented.segmented-block > * { flex: 1 1 0; font-size: 12px; }
@media (max-width: 575.98px) {
    .segmented-fill { display: flex; width: 100%; }
    .segmented.segmented-fill > * { flex: 1 1 auto; padding: 0 4px; font-size: 12px; }
}

/* Status pills and neutral tags */
.pill {
    display: inline-block; padding: 3px 9px; border-radius: 999px;
    font-size: 12px; font-weight: 500; line-height: 1.35; white-space: nowrap;
    background: var(--pill-bg, var(--btn2)); color: var(--pill-fg, var(--mono));
}
.pill-valid { --pill-bg: var(--pill-valid); --pill-fg: var(--green-text); }
.pill-soon { --pill-bg: var(--pill-soon); --pill-fg: var(--orange-text); }
.pill-redeemed { --pill-bg: var(--pill-redeemed); --pill-fg: var(--blue-text); }
.pill-expired { --pill-bg: var(--pill-expired); --pill-fg: var(--grey-text); }
.pill-danger { --pill-bg: var(--red-soft); --pill-fg: var(--red-text); }
.text-green { color: var(--green-text); }
.text-blue { color: var(--blue-text); }
.text-orange { color: var(--orange-text); }
.text-red { color: var(--red-text); }

/* List rows */
.row-title { font-weight: 500; color: var(--text); text-decoration: none; }
a.row-title:hover { color: var(--text); text-decoration: underline; }
.row-sub { font-size: 13px; color: var(--sub); }
.code { font-family: var(--font-mono); font-size: 13px; color: var(--mono); letter-spacing: .02em; }
.num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.nowrap { white-space: nowrap; }
.actions-cell { white-space: nowrap; text-align: right; }
.actions-cell form { display: inline; }

/* Tables that become a card list on phones */
@media (max-width: 767.98px) {
    .table-cards thead { display: none; }
    .table-cards, .table-cards tbody { display: block; width: 100%; }
    .table-cards tr {
        display: flex; flex-wrap: wrap; align-items: center; gap: 4px 10px;
        padding: 12px 16px; border-bottom: 1px solid var(--line-soft);
    }
    .table-cards tbody tr:last-child { border-bottom: 0; }
    .table-cards > :not(caption) > * > * { padding: 0; border: 0; }
    /* Line 1: main cell and status; the ::after breaks the line; then the other
       cells as small meta text, and the actions on a line of their own */
    .table-cards td { display: block; order: 4; font-size: 13px; color: var(--sub); text-align: left; }
    .table-cards .c-main { flex: 1 1 0; min-width: 0; order: 1; font-size: 14px; color: var(--text); }
    .table-cards .c-status { flex: none; order: 2; text-align: right; }
    .table-cards tr::after { content: ""; order: 3; flex-basis: 100%; height: 0; }
    .table-cards td[data-label]::before { content: attr(data-label) " "; }
    .table-cards .c-actions { order: 5; flex-basis: 100%; text-align: left; padding-top: 6px; }
    .table-cards tr.is-selected { --bs-table-bg-state: transparent; background: var(--row-on); }
    .table-cards .c-hide { display: none; }
}

/* Empty states */
.empty { text-align: center; padding: 36px 16px; color: var(--sub); }
.empty svg { width: 30px; height: 30px; margin-bottom: 8px; stroke: var(--sub); fill: none; stroke-width: 1.6; }
.empty strong { display: block; color: var(--text); font-size: 15px; font-weight: 600; margin-bottom: 4px; }
.empty .btn { margin-top: 14px; }

/* 5. Dashboard ------------------------------------------------------------ */
.rings-card { flex: 1 1 340px; flex-direction: row; flex-wrap: wrap; gap: 20px; align-items: center; padding: 18px 20px; }
.rings-card svg { flex: none; }
.rings-legend { flex: 1 1 130px; display: flex; flex-direction: column; gap: 10px; }
.rings-legend .lbl { display: block; font-size: 13px; font-weight: 600; }
.kpi-value { font-size: 24px; font-weight: 600; letter-spacing: -.02em; font-variant-numeric: tabular-nums; line-height: 1.2; }
.kpi-value small { font-size: 14px; font-weight: 500; color: var(--sub); }
.ring-track-g { stroke: var(--ring-g); }
.ring-track-b { stroke: var(--ring-b); }
.ring-track-o { stroke: var(--ring-o); }
.ring-g { stroke: var(--green); }
.ring-b { stroke: var(--blue); }
.ring-o { stroke: var(--orange); }

.verify-card {
    flex: 1 1 300px; display: flex; flex-direction: column; gap: 12px;
    padding: 18px 20px; border-radius: var(--radius); background: var(--accent); color: #fff;
}
.verify-card h2 { margin: 0; font-size: 19px; font-weight: 600; color: #fff; }
.verify-card p { margin: 0; font-size: 13px; color: #fff; }
.verify-field {
    display: flex; align-items: center; gap: 8px; height: 42px; padding: 0 5px 0 12px;
    background: #fff; border-radius: var(--radius-btn);
}
.verify-field:focus-within { box-shadow: 0 0 0 3px rgba(255, 255, 255, .55); }
.verify-field input {
    flex: 1; min-width: 0; border: 0; outline: none; background: transparent;
    font-size: 15px; letter-spacing: .04em; color: #1d1d1f;
}
.verify-field input::placeholder { color: #6e6e73; letter-spacing: 0; }
.verify-field button {
    height: 32px; padding: 0 14px; border: 0; border-radius: 7px;
    background: #1d1d1f; color: #fff; font-size: 13px; font-weight: 600;
}
.verify-field button:focus-visible { outline: 2px solid #1d1d1f; outline-offset: 2px; }
.btn-on-accent {
    align-self: flex-start; height: 32px; padding: 0 12px; display: inline-flex; align-items: center;
    border: 1px solid rgba(255, 255, 255, .7); border-radius: 8px;
    color: #fff; font-size: 13px; font-weight: 500; text-decoration: none;
}
.btn-on-accent:hover { background: rgba(255, 255, 255, .14); color: #fff; }
.btn-on-accent:focus-visible { outline: 0; box-shadow: 0 0 0 3px rgba(255, 255, 255, .55); }

.soon-card { flex: 1 1 260px; display: flex; flex-direction: column; gap: 10px; padding: 18px 20px; }
.soon-card h2 { margin: 0 0 2px; font-size: 17px; font-weight: 600; }
.soon-item {
    display: flex; align-items: center; gap: 12px; padding: 10px 12px; border-radius: var(--radius-btn);
    background: var(--soon-bg); color: var(--text); text-decoration: none;
}
.soon-item:hover { color: var(--text); filter: brightness(.98); }
.soon-item:focus-visible { outline: 0; box-shadow: 0 0 0 3px var(--focus); }
.soon-days { width: 40px; flex: none; text-align: center; font-size: 20px; font-weight: 700; line-height: 1; color: var(--orange-text); }
.soon-days small { display: block; font-size: 11px; font-weight: 600; margin-top: 2px; }
.soon-text { display: flex; flex-direction: column; min-width: 0; }
.soon-text strong { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.soon-text span { font-size: 13px; color: var(--soon-sub); }
.soon-note { font-size: 13px; color: var(--sub); margin: 0; }

/* Voucher detail panel (dashboard aside, detail page, scan result) */
.vpanel { display: flex; flex-direction: column; gap: 18px; padding: 20px; }
.vpanel-head { display: flex; justify-content: space-between; gap: 12px; align-items: flex-start; }
.vpanel-head .titles { display: flex; flex-direction: column; gap: 4px; min-width: 0; }
.vpanel-head .cat { font-size: 12px; color: var(--sub); }
.vpanel-head h2 { margin: 0; font-size: 20px; font-weight: 600; letter-spacing: -.01em; overflow-wrap: anywhere; }
.vpanel-head .name { font-size: 14px; color: var(--mono); }
.vpanel-inset { display: flex; gap: 16px; align-items: center; padding: 16px; background: var(--inset); border-radius: 12px; }
.vpanel-inset img { width: 84px; height: 84px; flex: none; border-radius: 6px; background: #fff; padding: 4px; image-rendering: pixelated; }
.vpanel-inset .lbl { font-size: 12px; color: var(--sub); }
.vpanel-inset .big { font-size: 26px; font-weight: 600; letter-spacing: -.02em; font-variant-numeric: tabular-nums; line-height: 1.2; }
.vpanel-inset .of { font-size: 13px; color: var(--sub); }
.dl-grid { margin: 0; display: grid; grid-template-columns: auto 1fr; gap: 10px 16px; font-size: 14px; }
.dl-grid dt { color: var(--sub); font-weight: 400; }
.dl-grid dd { margin: 0; min-width: 0; overflow-wrap: anywhere; }
.vpanel-actions { display: flex; flex-direction: column; gap: 8px; }
.vpanel-actions .btn-main { height: 40px; font-size: 15px; width: 100%; }
.btn-row { display: flex; flex-wrap: wrap; gap: 8px; }
.btn-row > .btn, .btn-row > form, .btn-row > .dropdown { flex: 1 1 auto; white-space: nowrap; }
.btn-row > .btn-icon, .btn-row > .dropdown { flex: 0 0 44px; }
.btn-row form .btn, .btn-row .dropdown .btn { width: 100%; }
.btn-row .btn { height: 36px; }
.partial-form { display: flex; gap: 8px; padding: 12px; background: var(--inset); border-radius: 12px; }
.partial-form .input-group { flex: 1; min-width: 0; }

.timeline { display: flex; flex-direction: column; gap: 10px; }
.timeline-item { display: flex; gap: 10px; align-items: baseline; }
.timeline-dot { width: 7px; height: 7px; border-radius: 50%; background: var(--dot); flex: none; transform: translateY(-1px); }
.timeline-item .t { display: flex; flex-direction: column; gap: 1px; }
.timeline-item .t span:last-child { font-size: 12px; color: var(--sub); }

/* Scan verdict */
.verdict { flex-direction: row; gap: 14px; align-items: center; padding: 18px 20px; }
.verdict-icon {
    width: 44px; height: 44px; border-radius: 50%; flex: none;
    display: flex; align-items: center; justify-content: center;
}
.verdict-icon svg { width: 22px; height: 22px; fill: none; stroke: currentColor; stroke-width: 2.4; stroke-linecap: round; stroke-linejoin: round; }
.verdict-valid .verdict-icon { background: var(--pill-valid); color: var(--green-text); }
.verdict-redeemed .verdict-icon { background: var(--pill-redeemed); color: var(--blue-text); }
.verdict-expired .verdict-icon { background: var(--pill-expired); color: var(--grey-text); }
.verdict-unknown .verdict-icon { background: var(--red-soft); color: var(--red-text); }
.verdict h2 { margin: 0; font-size: 19px; font-weight: 600; }
.verdict p { margin: 2px 0 0; color: var(--sub); }
.scan-input { font-family: var(--font-mono); letter-spacing: .06em; text-align: center; text-transform: uppercase; }
#qr-reader { border-radius: 12px; overflow: hidden; }

/* Reports and other KPI tiles */
.kpi-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 16px; }
.kpi { padding: 16px 18px; }
.kpi .lbl { font-size: 13px; font-weight: 600; color: var(--sub); }
.kpi .note { font-size: 12px; color: var(--sub); margin-top: 4px; }
/* Box for a Chart.js canvas with maintainAspectRatio: false */
.chart-box { position: relative; height: 280px; }
.chart-box-short { height: 240px; }

/* Template and package cards */
.tpl-preview {
    height: 190px; border-radius: 10px; overflow: hidden; margin-bottom: 14px;
    display: flex; align-items: center; justify-content: center; background: var(--inset);
}
.tpl-preview img { max-width: 100%; max-height: 100%; object-fit: contain; }
.secret-box {
    font-family: var(--font-mono); font-size: 17px; padding: 12px 14px; border-radius: 10px;
    background: var(--inset); user-select: all; overflow-wrap: anywhere;
}
.qr-setup { max-width: 220px; width: 100%; border-radius: 10px; background: #fff; padding: 8px; }

.print-only { display: none; }

/* 6. FFJ vouchers: types, terms, generation, the Funkce matrix, print ------ */
.min-w-0 { min-width: 0; }
.code-big { font-family: var(--font-mono); font-size: 22px; letter-spacing: .06em; overflow-wrap: anywhere; }
.terms { margin: 0; padding: 0; list-style: none; display: flex; flex-direction: column; gap: 2px; }
.terms li { font-size: 12px; color: var(--sub); }
.link-line { overflow-wrap: anywhere; }
.link-line .code { font-size: 12px; }

.type-choices { display: flex; flex-direction: column; gap: 10px; }
.type-choice {
    display: flex; gap: 12px; align-items: flex-start; padding: 14px 16px; margin: 0;
    border: 1px solid var(--line); border-radius: 12px; cursor: pointer;
}
.type-choice:hover { background: var(--nav-hover); }
.type-choice:has(input:checked) { border-color: var(--accent); box-shadow: 0 0 0 1px var(--accent); }
.type-choice input { flex: none; margin-top: 3px; }
.type-body { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.type-body strong { font-size: 16px; font-weight: 600; }
.type-terms { font-size: 12px; color: var(--sub); }

.matrix { margin: 0; }
.matrix th[scope="row"] { font-weight: 400; }
.matrix thead th:first-child { font-size: 15px; font-weight: 600; color: var(--text); }
.matrix-name { font-weight: 500; }
.matrix-role { width: 120px; text-align: center; vertical-align: middle; }
.matrix-role .form-check-input { float: none; margin: 0; width: 1.25em; height: 1.25em; }
@media (max-width: 575.98px) {
    .matrix-role { width: 76px; padding-left: 4px !important; padding-right: 4px !important; font-size: 12px; }
    .matrix > :not(caption) > * > th:first-child { padding-right: 4px; }
}

.pv { display: flex; gap: 20px; align-items: center; padding: 20px; }
.pv-qr { width: 132px; height: 132px; flex: none; background: #fff; padding: 6px; border-radius: 8px; image-rendering: pixelated; }
.pv-body { display: flex; flex-direction: column; gap: 8px; min-width: 0; }
.pv-brand { font-size: 11px; letter-spacing: .24em; text-transform: uppercase; color: var(--sub); font-weight: 600; }
.pv-type { margin: 0; font-size: 24px; font-weight: 700; letter-spacing: -.01em; }
.pv-meta { display: flex; flex-wrap: wrap; gap: 4px 18px; font-size: 14px; }
.pv-link { font-size: 11px; overflow-wrap: anywhere; }
@media (max-width: 575.98px) {
    .pv { flex-direction: column; align-items: flex-start; }
}

/* 7. Voucher designs: picker, preview, Nastavení -> Designy voucherů ------ */
.page-gen { max-width: 1120px; }
.gen-layout { display: grid; grid-template-columns: minmax(0, 1fr) 300px; gap: 16px; align-items: start; }
.gen-layout-single { grid-template-columns: minmax(0, 1fr); max-width: 760px; }
.gen-main { display: flex; flex-direction: column; gap: 16px; min-width: 0; }
.gen-side { position: sticky; top: 16px; }
@media (max-width: 991.98px) {
    .gen-layout { display: flex; flex-direction: column; }
    .gen-main { display: contents; }
    .gen-type { order: 1; }
    .gen-design { order: 2; }
    .gen-side { order: 3; position: static; }
    .gen-details { order: 4; }
}
.card-head a.hint { text-decoration: none; color: var(--link); }

.design-tools { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; margin-bottom: 12px; }
.design-tools[hidden] { display: none; }
.design-search { position: relative; flex: 1 1 200px; min-width: 0; }
.design-search svg { position: absolute; left: 11px; top: 50%; transform: translateY(-50%); color: var(--sub); pointer-events: none; }
.design-search input { padding-left: 32px; }
.design-options {
    display: grid; grid-template-columns: repeat(auto-fill, minmax(104px, 1fr)); gap: 12px 10px;
    max-height: 560px; overflow-y: auto; padding: 3px; margin: -3px; overscroll-behavior: contain;
}
.design-option { position: relative; display: flex; flex-direction: column; gap: 5px; margin: 0; cursor: pointer; min-width: 0; }
.design-option[hidden] { display: none; }
.design-thumb {
    position: relative; display: block; border-radius: 10px; overflow: hidden; background: var(--inset);
    aspect-ratio: 223 / 450; box-shadow: 0 0 0 1px var(--line);
}
.design-thumb img { display: block; width: 100%; height: 100%; object-fit: cover; }
.design-option:hover .design-thumb { box-shadow: 0 0 0 1px var(--sub); }
.design-option:has(input:checked) .design-thumb { box-shadow: 0 0 0 3px var(--accent); }
.design-option:has(input:focus-visible) .design-thumb { box-shadow: 0 0 0 3px var(--accent), 0 0 0 6px var(--focus); }
.design-check {
    position: absolute; top: 6px; right: 6px; width: 22px; height: 22px; border-radius: 50%;
    display: none; align-items: center; justify-content: center; background: var(--accent); color: #fff;
}
.design-option:has(input:checked) .design-check { display: flex; }
.design-name { font-size: 12px; line-height: 1.3; color: var(--text); overflow-wrap: anywhere;
    display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.design-option:has(input:checked) .design-name { font-weight: 600; }
.design-option .pill { align-self: flex-start; font-size: 11px; padding: 1px 7px; }
/* the type's texts do not fit this design (app/designs/capacity.py, or its preview said so) */
.design-option.is-unfit .design-thumb img { opacity: .45; }
.design-option .pill[hidden] { display: none; }
.design-empty { grid-column: 1 / -1; margin: 8px 0; }
@media (max-width: 575.98px) {
    .design-options { grid-template-columns: repeat(3, minmax(0, 1fr)); max-height: 480px; gap: 10px 8px; }
}

/* The preview iframe shows the 446 x 900 design scaled to the column */
.design-preview { --s: .6; display: flex; flex-direction: column; align-items: center; gap: 10px; }
.design-preview-box {
    width: calc(446px * var(--s)); height: calc(900px * var(--s)); overflow: hidden; border-radius: 12px;
    background: var(--inset); box-shadow: 0 0 0 1px var(--line); flex: none;
}
.design-preview-box iframe { display: block; width: 446px; height: 900px; border: 0; transform: scale(var(--s)); transform-origin: 0 0; }

/* Settings: grid of cards (desktop), rows (phones) */
.design-settings { display: flex; flex-direction: column; gap: 16px; }
.design-toolbar { display: flex; flex-wrap: wrap; gap: 14px 24px; align-items: flex-end; }
.design-toolbar-group { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.design-bulk { flex-direction: row; flex-wrap: wrap; align-items: center; gap: 8px; margin-left: auto; }
.seg-count { color: var(--sub); font-size: 11px; font-variant-numeric: tabular-nums; }
.design-grid {
    list-style: none; margin: 0; padding: 0;
    display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 16px;
}
.design-card {
    position: relative; display: flex; flex-direction: column; min-width: 0;
    background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow); overflow: hidden;
}
.design-card-thumb { position: relative; aspect-ratio: 223 / 450; background: var(--inset); }
.design-card-thumb img { display: block; width: 100%; height: 100%; object-fit: cover; }
.design-card.is-off .design-card-thumb img { opacity: .35; filter: grayscale(.6); }
.drag-handle {
    position: absolute; top: 6px; left: 6px; width: 30px; height: 30px; border-radius: 8px;
    display: none; align-items: center; justify-content: center; cursor: grab; touch-action: none;
    background: var(--card); color: var(--text); box-shadow: var(--shadow-pop);
}
.js-designs .drag-handle { display: flex; }
.design-card-body { display: flex; flex-direction: column; gap: 4px; padding: 10px 10px 12px; min-width: 0; flex: 1; }
.design-card-title { display: flex; gap: 6px; align-items: baseline; min-width: 0; }
.design-card-title strong { font-size: 13px; font-weight: 600; line-height: 1.3; overflow-wrap: anywhere; }
.design-pos {
    flex: none; min-width: 24px; padding: 0 5px; border-radius: 6px; text-align: center;
    font-size: 11px; font-weight: 600; font-variant-numeric: tabular-nums; background: var(--btn2); color: var(--mono);
}
.design-card-section { font-size: 12px; }
.design-card-ctrl { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 6px; margin-top: auto; padding-top: 6px; }
.design-card-ctrl .form-check-label { font-size: 13px; }
.design-move { display: flex; gap: 4px; }
.design-move .btn-icon { width: 30px; height: 30px; padding: 0; display: inline-flex; align-items: center; justify-content: center; }
.design-card.is-dragging { opacity: .5; box-shadow: 0 0 0 2px var(--accent); }
.design-card.is-moved { box-shadow: 0 0 0 2px var(--accent); }
body.is-dragging-design, body.is-dragging-design * { cursor: grabbing !important; user-select: none; }
.save-bar {
    position: sticky; bottom: 0; z-index: 5; display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between;
    gap: 10px; padding: 12px 16px; margin: 0 -4px; border-radius: var(--radius);
    background: var(--card); box-shadow: var(--shadow-pop);
}
.save-bar-actions { display: flex; gap: 8px; margin-left: auto; }
.save-bar.is-dirty [data-dirty] { color: var(--orange-text); font-weight: 500; }
@media (max-width: 575.98px) {
    .design-toolbar { flex-direction: column; align-items: stretch; }
    .design-toolbar .segmented { display: flex; }
    .design-toolbar .segmented > * { flex: 1 1 auto; padding: 0 6px; font-size: 12px; }
    .design-bulk { margin-left: 0; }
    .design-grid { grid-template-columns: minmax(0, 1fr); gap: 8px; }
    .design-card { flex-direction: row; align-items: stretch; }
    .design-card-thumb { flex: none; width: 64px; }
    .drag-handle { top: auto; bottom: 4px; left: 50%; transform: translateX(-50%); width: 28px; height: 28px; }
    .design-card-body { padding: 8px 10px; }
    .save-bar { margin: 0; }
}
