*,
*::before,
*::after {
    box-sizing: border-box;
}

/*
 * Tom Select “bootstrap5” theme expects Bootstrap 5 CSS variables.
 * This app does not load Bootstrap, so we define the ones Tom Select uses
 * and add solid fallbacks below.
 */
:root {
    --bs-body-bg: #ffffff;
    --bs-body-color: #0f172a;
    --bs-border-color: #cbd5e1;
    --bs-border-width: 1px;
    --bs-border-radius: 8px;
    --bs-secondary-bg: #f8fafc;
    --bs-tertiary-bg: #f1f5f9;
    --bs-emphasis-color: #0f172a;
    --bs-secondary-color: #64748b;
}

body {
    margin: 0;
    font-family: system-ui, -apple-system, Segoe UI, Roboto, Ubuntu, Cantarell, sans-serif;
    line-height: 1.5;
    color: #0f172a;
    background: linear-gradient(160deg, #f8fafc 0%, #e2e8f0 100%);
    min-height: 100vh;
}

a {
    color: #2563eb;
}

a:hover {
    text-decoration: underline;
}

.site-header {
    background: rgba(255, 255, 255, 0.9);
    border-bottom: 1px solid #e2e8f0;
    backdrop-filter: blur(8px);
}

.site-header__inner {
    max-width: 960px;
    margin: 0 auto;
    padding: 0.75rem 1rem;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
}

.site-logo {
    display: inline-flex;
    align-items: center;
    gap: 0.6rem;
    font-weight: 700;
    text-decoration: none;
    color: #0f172a;
}

.site-logo__text {
    font-size: 1.125rem;
    letter-spacing: -0.02em;
    white-space: nowrap;
}

.site-logo:hover {
    text-decoration: none;
}

.site-logo__img {
    display: block;
    height: 2.25rem;
    width: auto;
    max-width: min(200px, 45vw);
    object-fit: contain;
}

.site-nav {
    display: flex;
    align-items: center;
    gap: 1rem;
}

.site-nav__form {
    margin: 0;
    display: inline;
}

.site-main {
    max-width: 960px;
    margin: 0 auto;
    padding: 2rem 1rem 4rem;
}

.site-footer {
    max-width: 960px;
    margin: 0 auto;
    padding: 1rem;
    color: #64748b;
    font-size: 0.875rem;
}

.site-footer p {
    margin: 0;
}

.hero {
    text-align: center;
    padding: 2rem 0;
}

.hero h1 {
    font-size: clamp(1.75rem, 4vw, 2.25rem);
    margin: 0 0 0.5rem;
}

.hero__lead {
    max-width: 36rem;
    margin: 0 auto 1.5rem;
    color: #475569;
}

.hero__actions {
    display: flex;
    gap: 0.75rem;
    justify-content: center;
    flex-wrap: wrap;
}

.card {
    background: #fff;
    border-radius: 12px;
    padding: 1.5rem;
    box-shadow: 0 1px 3px rgba(15, 23, 42, 0.08);
    margin-bottom: 1.5rem;
}

.card--narrow {
    max-width: 28rem;
    margin-left: auto;
    margin-right: auto;
}

.card--danger {
    border: 1px solid #fecaca;
    background: #fef2f2;
}

.card__head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    flex-wrap: wrap;
    margin-bottom: 1rem;
}

.card__head h1 {
    margin: 0;
}

.card__head-actions {
    display: flex;
    gap: 0.5rem;
    flex-wrap: wrap;
}

.stack label {
    display: block;
    margin-bottom: 1rem;
}

.stack input[type="text"],
.stack input[type="email"],
.stack input[type="url"],
.stack input[type="password"],
.stack textarea {
    width: 100%;
    margin-top: 0.25rem;
    padding: 0.5rem 0.6rem;
    border: 1px solid #cbd5e1;
    border-radius: 8px;
    font: inherit;
}

.fieldset {
    border: 1px solid #e2e8f0;
    border-radius: 8px;
    padding: 1rem;
    margin: 0 0 1rem;
}

.fieldset legend {
    padding: 0 0.25rem;
}

.button {
    display: inline-block;
    padding: 0.5rem 1rem;
    border: none;
    border-radius: 8px;
    background: #2563eb;
    color: #fff;
    font: inherit;
    font-weight: 600;
    cursor: pointer;
    text-decoration: none;
}

.button:hover {
    background: #1d4ed8;
    text-decoration: none;
}

.button--small {
    padding: 0.35rem 0.75rem;
    font-size: 0.875rem;
}

.button--ghost {
    background: transparent;
    color: #2563eb;
    border: 1px solid #bfdbfe;
}

.button--ghost:hover {
    background: #eff6ff;
}

.button--danger {
    background: #dc2626;
}

.button--danger:hover {
    background: #b91c1c;
}

.link-button {
    background: none;
    border: none;
    padding: 0;
    color: #2563eb;
    font: inherit;
    cursor: pointer;
    text-decoration: underline;
}

.link-button--danger {
    color: #dc2626;
}

.message {
    padding: 0.75rem 1rem;
    border-radius: 8px;
}

.message--error {
    background: #fef2f2;
    color: #991b1b;
    border: 1px solid #fecaca;
}

.message--ok {
    background: #ecfdf5;
    color: #065f46;
    border: 1px solid #a7f3d0;
}

.muted {
    color: #64748b;
    font-size: 0.9375rem;
}

.hint {
    font-size: 0.875rem;
    color: #64748b;
    margin: -0.5rem 0 1rem;
}

.checkbox {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.checkbox input {
    width: auto;
}

.action-list {
    padding-left: 1.25rem;
}

.table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.9375rem;
}

.table th,
.table td {
    text-align: left;
    padding: 0.5rem 0.75rem;
    border-bottom: 1px solid #e2e8f0;
    vertical-align: top;
}

.table__actions {
    white-space: nowrap;
    text-align: right;
}

.table__actions a,
.table__actions form {
    display: inline-block;
    margin-left: 0.5rem;
}

.inline-form {
    display: inline;
    margin: 0;
}

.link-admin-list {
    list-style: none;
    padding: 0;
    margin: 0;
}

.link-admin-list__item {
    display: flex;
    flex-wrap: wrap;
    justify-content: space-between;
    gap: 0.75rem;
    padding: 0.75rem 0;
    border-bottom: 1px solid #e2e8f0;
}

.link-admin-list__main {
    display: flex;
    flex-direction: column;
    gap: 0.15rem;
    min-width: 0;
}

.link-admin-list__title {
    font-weight: 600;
}

.link-admin-list__url {
    font-size: 0.8125rem;
    word-break: break-all;
}

.link-admin-list__actions {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    flex-shrink: 0;
}

.public-page {
    display: flex;
    justify-content: center;
    padding: 1rem 0;
}

.public-page__card {
    width: 100%;
    max-width: 28rem;
    background: #fff;
    border-radius: 16px;
    padding: 2rem 1.5rem;
    box-shadow: 0 10px 40px rgba(15, 23, 42, 0.12);
    text-align: center;
}

.public-page__avatar {
    border-radius: 50%;
    object-fit: cover;
    margin-bottom: 1rem;
}

.public-page__title {
    margin: 0 0 0.25rem;
    font-size: 1.5rem;
}

.public-page__byline {
    margin: 0 0 0.5rem;
    color: #64748b;
    font-size: 0.9375rem;
}

.public-page__subtitle {
    margin: 0 0 1.5rem;
    color: #475569;
}

.public-links {
    list-style: none;
    padding: 0;
    margin: 0;
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

.public-links__a {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    padding: 0.75rem 1rem;
    border-radius: 999px;
    background: #0f172a;
    color: #fff;
    text-decoration: none;
    font-weight: 600;
}

.public-links__icon {
    flex-shrink: 0;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 1.25rem;
    height: 1.25rem;
    opacity: 0.92;
}

.public-links__icon svg {
    display: block;
    width: 100%;
    height: 100%;
}

.public-links__text {
    min-width: 0;
}

.public-links__a:hover {
    background: #1e293b;
    text-decoration: none;
}

code {
    font-size: 0.875em;
    background: #f1f5f9;
    padding: 0.1rem 0.35rem;
    border-radius: 4px;
}

.h-as-label {
    font-size: 1rem;
    font-weight: 600;
    margin: 1.25rem 0 0.5rem;
}

.stack--spaced-top {
    margin-top: 1rem;
}

.stack-inline {
    display: flex;
    flex-wrap: wrap;
    gap: 1rem;
    align-items: flex-end;
    margin-bottom: 1rem;
}

.stack-inline label {
    margin-bottom: 0;
}

.ts-wrapper {
    width: 100%;
    max-width: 100%;
}

.stack label .ts-wrapper,
.fieldset label .ts-wrapper {
    margin-top: 0.25rem;
}

.analytics-filters .ts-wrapper {
    min-width: 12rem;
}

.ts-wrapper .ts-control,
.ts-wrapper.single .ts-control {
    background-color: #fff;
    background-image: none;
    border: 1px solid #cbd5e1;
    border-radius: 8px;
    min-height: 2.5rem;
    color: #0f172a;
    box-shadow: none;
}

.ts-wrapper.focus .ts-control {
    border-color: #2563eb;
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.15);
}

.ts-wrapper.dropdown-active .ts-control {
    border-color: #2563eb;
}

.ts-dropdown {
    background-color: #fff;
    border: 1px solid #cbd5e1;
    border-radius: 8px;
    box-shadow: 0 12px 32px rgba(15, 23, 42, 0.12);
    z-index: 50;
}

.ts-dropdown .ts-dropdown-content {
    background-color: #fff;
}

.ts-dropdown .option {
    color: #0f172a;
    background-color: #fff;
}

.ts-dropdown .option:hover,
.ts-dropdown .option.active {
    background-color: #eff6ff;
    color: #1e40af;
}

.ts-dropdown .optgroup-header {
    color: #64748b;
    background-color: #f8fafc;
}

.ts-dropdown .dropdown-input-wrap {
    background-color: #fff;
    border-bottom: 1px solid #e2e8f0;
    padding: 0.35rem 0.5rem;
}

.ts-dropdown input.dropdown-input {
    background-color: #f8fafc;
    border: 1px solid #e2e8f0;
    border-radius: 6px;
    color: #0f172a;
}

.ts-wrapper .item {
    color: #0f172a;
}

.analytics-filters select {
    min-width: 10rem;
}

.analytics-kpis {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(9rem, 1fr));
    gap: 1rem;
    margin-top: 1rem;
}

.analytics-kpi {
    background: #f8fafc;
    border: 1px solid #e2e8f0;
    border-radius: 8px;
    padding: 0.75rem 1rem;
}

.analytics-kpi__label {
    display: block;
    font-size: 0.8125rem;
    color: #64748b;
}

.analytics-kpi__value {
    font-size: 1.25rem;
}

.analytics-bars {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.analytics-bar {
    display: grid;
    grid-template-columns: 6.5rem 1fr 2.5rem;
    gap: 0.5rem;
    align-items: center;
    font-size: 0.875rem;
}

.analytics-bar__label {
    color: #64748b;
}

.analytics-bar__track {
    height: 0.5rem;
    background: #e2e8f0;
    border-radius: 999px;
    overflow: hidden;
}

.analytics-bar__fill {
    height: 100%;
    border-radius: 999px;
}

.analytics-bar__fill--views {
    background: #2563eb;
}

.analytics-bar__fill--clicks {
    background: #059669;
}

.analytics-bar__count {
    text-align: right;
    font-variant-numeric: tabular-nums;
}

.public-share {
    margin: 0 0 1rem;
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    justify-content: center;
    align-items: center;
}

.public-links__item--featured {
    list-style: none;
}

.public-links__a--featured {
    background: linear-gradient(135deg, #7c3aed 0%, #2563eb 100%);
    box-shadow: 0 4px 14px rgba(37, 99, 235, 0.35);
}

.public-links__a--featured:hover {
    filter: brightness(1.05);
}

body.public-theme--dark {
    background: linear-gradient(160deg, #0c1222 0%, #152a4a 45%, #1e3a5f 100%);
    color: #e2e8f0;
}

body.public-theme--dark .site-header {
    background: rgba(12, 18, 34, 0.94);
    border-bottom-color: #2d4a6f;
}

body.public-theme--dark .site-logo {
    color: #f1f5f9;
}

body.public-theme--dark .site-footer {
    color: #94a3b8;
}

body.public-theme--dark .public-page__card {
    background: #152a45;
    color: #f1f5f9;
    box-shadow: 0 10px 40px rgba(0, 20, 50, 0.45);
    border: 1px solid rgba(96, 165, 250, 0.12);
}

body.public-theme--dark .public-page__byline,
body.public-theme--dark .public-page__subtitle {
    color: #93c5fd;
}

body.public-theme--dark .public-links__a {
    background: #2563eb;
}

body.public-theme--dark .public-links__a:hover {
    background: #1d4ed8;
}

body.public-theme--dark .public-links__a--featured {
    background: linear-gradient(135deg, #3b82f6 0%, #6366f1 100%);
    box-shadow: 0 4px 18px rgba(37, 99, 235, 0.45);
}

body.public-theme--dark .button--ghost {
    color: #93c5fd;
    border-color: rgba(147, 197, 253, 0.45);
}

body.public-theme--dark .button--ghost:hover {
    background: rgba(37, 99, 235, 0.2);
}

body.public-theme--minimal {
    background: #fafafa;
}

body.public-theme--minimal .public-page__card {
    box-shadow: none;
    border: 1px solid #e5e5e5;
}

body.public-theme--minimal .public-links__a {
    border-radius: 8px;
    background: #fff;
    color: #171717;
    border: 1px solid #e5e5e5;
}

body.public-theme--blue-light {
    background: linear-gradient(165deg, #f0f7ff 0%, #dbeafe 42%, #e0f2fe 100%);
    color: #0f172a;
}

body.public-theme--blue-light .site-header {
    background: rgba(255, 255, 255, 0.88);
    border-bottom-color: #bfdbfe;
}

body.public-theme--blue-light .site-logo {
    color: #1e3a8a;
}

body.public-theme--blue-light .site-footer {
    color: #475569;
}

body.public-theme--blue-light .public-page__card {
    background: #fff;
    color: #0f172a;
    box-shadow: 0 12px 40px rgba(30, 64, 175, 0.12);
    border: 1px solid #dbeafe;
}

body.public-theme--blue-light .public-page__byline,
body.public-theme--blue-light .public-page__subtitle {
    color: #475569;
}

body.public-theme--blue-light .public-links__a {
    background: #1d4ed8;
}

body.public-theme--blue-light .public-links__a:hover {
    background: #1e40af;
}

body.public-theme--blue-light .public-links__a--featured {
    background: linear-gradient(135deg, #2563eb 0%, #4f46e5 100%);
    box-shadow: 0 4px 16px rgba(37, 99, 235, 0.35);
}

body.public-theme--blue-light .button--ghost {
    color: #1d4ed8;
    border-color: #93c5fd;
}

body.public-theme--blue-light .button--ghost:hover {
    background: #eff6ff;
}

body.public-theme--blue-dark {
    background: linear-gradient(160deg, #020617 0%, #0c1e3d 38%, #132447 100%);
    color: #e2e8f0;
}

body.public-theme--blue-dark .site-header {
    background: rgba(2, 6, 23, 0.92);
    border-bottom-color: #1e3a5f;
}

body.public-theme--blue-dark .site-logo {
    color: #f8fafc;
}

body.public-theme--blue-dark .site-footer {
    color: #7dd3fc;
}

body.public-theme--blue-dark .public-page__card {
    background: linear-gradient(180deg, #0f2140 0%, #0c1929 100%);
    color: #f1f5f9;
    box-shadow: 0 16px 48px rgba(0, 0, 0, 0.55);
    border: 1px solid rgba(56, 189, 248, 0.18);
}

body.public-theme--blue-dark .public-page__byline,
body.public-theme--blue-dark .public-page__subtitle {
    color: #7dd3fc;
}

body.public-theme--blue-dark .public-links__a {
    background: #0284c7;
}

body.public-theme--blue-dark .public-links__a:hover {
    background: #0369a1;
}

body.public-theme--blue-dark .public-links__a--featured {
    background: linear-gradient(135deg, #0ea5e9 0%, #2563eb 100%);
    box-shadow: 0 4px 20px rgba(14, 165, 233, 0.4);
}

body.public-theme--blue-dark .button--ghost {
    color: #7dd3fc;
    border-color: rgba(125, 211, 252, 0.45);
}

body.public-theme--blue-dark .button--ghost:hover {
    background: rgba(14, 165, 233, 0.15);
}
