:root {
    --bg: #f4efe7;
    --bg-deep: #efe3d2;
    --surface: rgba(255, 252, 246, 0.84);
    --surface-strong: #fffdf8;
    --surface-muted: #f7f1e8;
    --ink: #17212b;
    --ink-soft: #5f6b76;
    --line: rgba(23, 33, 43, 0.08);
    --accent: #0e7c66;
    --accent-strong: #0a5f4f;
    --accent-soft: rgba(14, 124, 102, 0.12);
    --gold: #d18f34;
    --danger: #bb4a4a;
    --warning: #b77713;
    --success: #187257;
    --radius-xl: 28px;
    --radius-lg: 20px;
    --radius-md: 14px;
    --shadow: 0 24px 80px rgba(40, 32, 23, 0.10);
}

* {
    box-sizing: border-box;
}

html {
    scroll-behavior: smooth;
}

body {
    margin: 0;
    color: var(--ink);
    background:
        radial-gradient(circle at top left, rgba(209, 143, 52, 0.16), transparent 32%),
        radial-gradient(circle at top right, rgba(14, 124, 102, 0.18), transparent 28%),
        linear-gradient(180deg, #fcf8f1 0%, var(--bg) 48%, #f2eadf 100%);
    font-family: "Avenir Next", "Trebuchet MS", "Segoe UI", sans-serif;
    min-height: 100vh;
    overflow-x: hidden;
}

a {
    color: inherit;
}

button,
input,
select,
textarea {
    font: inherit;
}

.background-orb {
    position: fixed;
    width: 320px;
    height: 320px;
    border-radius: 50%;
    filter: blur(16px);
    opacity: 0.45;
    pointer-events: none;
    z-index: 0;
}

.orb-left {
    top: -80px;
    left: -80px;
    background: rgba(209, 143, 52, 0.18);
}

.orb-right {
    right: -110px;
    bottom: 12%;
    background: rgba(14, 124, 102, 0.18);
}

.app-shell {
    position: relative;
    z-index: 1;
    width: min(1440px, calc(100vw - 32px));
    margin: 0 auto;
    padding: 22px 0 42px;
}

.topbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    padding: 10px 4px 18px;
}

.brand {
    display: inline-flex;
    align-items: center;
    gap: 14px;
    text-decoration: none;
}

.brand strong,
.brand small {
    display: block;
}

.brand small {
    color: var(--ink-soft);
    font-size: 0.88rem;
    margin-top: 2px;
}

.brand-mark {
    width: 48px;
    height: 48px;
    border-radius: 16px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, var(--accent) 0%, #1c9f83 100%);
    color: #fff;
    font-weight: 800;
    letter-spacing: 0.08em;
    box-shadow: 0 16px 32px rgba(14, 124, 102, 0.25);
}

.topbar-actions {
    display: flex;
    align-items: center;
    gap: 12px;
}

.user-chip {
    padding: 10px 14px;
    border-radius: 999px;
    background: rgba(255, 253, 248, 0.7);
    border: 1px solid var(--line);
    color: var(--ink-soft);
}

.workspace {
    display: grid;
    gap: 18px;
}

.hero-card,
.sidebar-card,
.main-panel,
.auth-card,
.auth-copy,
.flash,
.tab-strip,
.stat-card,
.empty-state {
    backdrop-filter: blur(14px);
}

.hero-card,
.sidebar-card,
.main-panel,
.auth-card,
.auth-copy,
.empty-state {
    background: var(--surface);
    border: 1px solid rgba(255, 255, 255, 0.72);
    border-radius: var(--radius-xl);
    box-shadow: var(--shadow);
}

.hero-card {
    display: flex;
    justify-content: space-between;
    gap: 22px;
    padding: 28px 30px;
    align-items: flex-start;
    animation: rise-in 0.45s ease;
}

.hero-card h1,
.auth-copy h1,
.auth-card h2,
.section-heading h2 {
    margin: 0;
    line-height: 1.05;
}

.hero-card h1 {
    font-size: clamp(1.9rem, 3vw, 3rem);
    max-width: 760px;
}

.hero-card p,
.auth-copy p,
.sidebar-tip,
.table-empty,
.empty-state p {
    color: var(--ink-soft);
}

.hero-note {
    min-width: 220px;
    padding: 18px 20px;
    border-radius: var(--radius-lg);
    background: linear-gradient(135deg, rgba(14, 124, 102, 0.12), rgba(209, 143, 52, 0.12));
    border: 1px solid rgba(14, 124, 102, 0.12);
}

.hero-note-label,
.eyebrow {
    display: inline-block;
    text-transform: uppercase;
    letter-spacing: 0.14em;
    font-size: 0.72rem;
    font-weight: 700;
    color: var(--accent-strong);
}

.tab-strip {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 12px;
}

.tab-link {
    text-decoration: none;
    padding: 18px 20px;
    border-radius: 22px;
    background: rgba(255, 252, 246, 0.54);
    border: 1px solid var(--line);
    transition: transform 0.18s ease, background 0.18s ease, border-color 0.18s ease;
}

.tab-link span,
.tab-link small {
    display: block;
}

.tab-link span {
    font-weight: 700;
}

.tab-link small {
    margin-top: 6px;
    color: var(--ink-soft);
}

.tab-link:hover,
.tab-link.is-active {
    transform: translateY(-2px);
    background: linear-gradient(135deg, rgba(14, 124, 102, 0.10), rgba(255, 252, 246, 0.92));
    border-color: rgba(14, 124, 102, 0.20);
}

.tab-link.is-active {
    box-shadow: 0 18px 36px rgba(14, 124, 102, 0.10);
}

.content-grid {
    display: grid;
    grid-template-columns: 330px minmax(0, 1fr);
    gap: 18px;
    align-items: start;
}

.sidebar-card,
.main-panel {
    padding: 24px;
}

.section-heading {
    margin-bottom: 18px;
}

.section-heading h2 {
    font-size: 1.4rem;
    margin-top: 6px;
}

.stack-form {
    display: grid;
    gap: 14px;
}

.filter-bar {
    display: flex;
    gap: 12px;
    flex-wrap: wrap;
    align-items: end;
    margin-bottom: 18px;
}

.field {
    display: grid;
    gap: 7px;
}

.field span {
    font-size: 0.92rem;
    font-weight: 600;
}

.compact-field span {
    font-size: 0.84rem;
}

input[type="text"],
input[type="password"],
input[type="number"],
select,
textarea {
    width: 100%;
    border: 1px solid rgba(23, 33, 43, 0.12);
    background: rgba(255, 255, 255, 0.88);
    border-radius: var(--radius-md);
    padding: 12px 14px;
    color: var(--ink);
    transition: border-color 0.18s ease, box-shadow 0.18s ease, transform 0.18s ease;
}

textarea {
    min-height: 92px;
    resize: vertical;
}

input:focus,
select:focus,
textarea:focus {
    outline: none;
    border-color: rgba(14, 124, 102, 0.42);
    box-shadow: 0 0 0 4px rgba(14, 124, 102, 0.10);
}

.primary-button,
.secondary-button,
.ghost-link {
    border-radius: 999px;
    border: 0;
    text-decoration: none;
    cursor: pointer;
    transition: transform 0.18s ease, box-shadow 0.18s ease, background 0.18s ease;
}

.primary-button,
.secondary-button {
    padding: 12px 18px;
    font-weight: 700;
}

.wide-button {
    width: 100%;
    justify-content: center;
}

.primary-button {
    color: #fff;
    background: linear-gradient(135deg, var(--accent) 0%, #1f9178 100%);
    box-shadow: 0 16px 28px rgba(14, 124, 102, 0.18);
}

.secondary-button {
    background: rgba(23, 33, 43, 0.08);
    color: var(--ink);
}

.primary-button:hover,
.secondary-button:hover,
.ghost-link:hover {
    transform: translateY(-1px);
}

.ghost-link {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 10px 14px;
    background: rgba(255, 255, 255, 0.74);
    border: 1px solid var(--line);
}

.ghost-link.is-disabled {
    pointer-events: none;
    opacity: 0.45;
}

.sidebar-tip {
    margin-top: 18px;
    padding: 16px 18px;
    border-radius: var(--radius-lg);
    background: rgba(209, 143, 52, 0.10);
    border: 1px dashed rgba(209, 143, 52, 0.24);
    font-size: 0.95rem;
}

.stats-row {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 12px;
    margin-bottom: 18px;
}

.stat-card {
    padding: 18px;
    background: linear-gradient(180deg, rgba(255, 255, 255, 0.86), rgba(247, 241, 232, 0.94));
    border-radius: var(--radius-lg);
    border: 1px solid var(--line);
}

.stat-card span,
.stat-card small {
    display: block;
}

.stat-card span {
    color: var(--ink-soft);
    font-size: 0.88rem;
}

.stat-card strong {
    display: block;
    margin: 10px 0 6px;
    font-size: 2rem;
    line-height: 1;
}

.stat-card small,
.micro-copy {
    color: var(--ink-soft);
    font-size: 0.84rem;
}

.empty-state {
    padding: 34px;
    text-align: center;
}

.action-bar {
    display: flex;
    justify-content: space-between;
    gap: 16px;
    align-items: center;
    margin-bottom: 14px;
    padding: 16px 18px;
    border-radius: var(--radius-lg);
    background: rgba(14, 124, 102, 0.08);
    border: 1px solid rgba(14, 124, 102, 0.12);
}

.action-bar-meta {
    display: flex;
    align-items: center;
    gap: 16px;
}

.checkbox-inline {
    display: inline-flex;
    align-items: center;
    gap: 10px;
    font-weight: 600;
}

.checkbox-column {
    width: 74px;
}

.table-shell {
    overflow: hidden;
    border-radius: 24px;
    border: 1px solid var(--line);
    background: rgba(255, 255, 255, 0.56);
}

.event-card-list {
    display: grid;
    gap: 16px;
    padding: 18px;
}

.event-card {
    border-radius: 22px;
    background: rgba(255, 255, 255, 0.76);
    border: 1px solid rgba(23, 33, 43, 0.08);
    overflow: hidden;
}

.event-card-row {
    display: grid;
    grid-template-columns: 230px minmax(0, 1fr);
    gap: 18px;
    padding: 18px 20px;
    border-bottom: 1px solid rgba(23, 33, 43, 0.08);
}

.event-card-row:last-child {
    border-bottom: 0;
}

.event-card-row:nth-child(odd) {
    background: rgba(247, 241, 232, 0.38);
}

.event-card-row-select {
    background: rgba(14, 124, 102, 0.08);
}

.event-card-label {
    font-size: 0.84rem;
    font-weight: 800;
    letter-spacing: 0.04em;
    text-transform: uppercase;
    color: var(--ink-soft);
}

.event-card-value {
    min-width: 0;
}

.data-table {
    width: 100%;
    min-width: 1040px;
    border-collapse: collapse;
}

.data-table th,
.data-table td {
    padding: 16px 14px;
    vertical-align: top;
    border-bottom: 1px solid rgba(23, 33, 43, 0.08);
    text-align: left;
}

.data-table thead th {
    position: sticky;
    top: 0;
    background: rgba(247, 241, 232, 0.94);
    z-index: 1;
    font-size: 0.85rem;
    letter-spacing: 0.04em;
    text-transform: uppercase;
}

.data-table tbody tr:nth-child(even) {
    background: rgba(255, 255, 255, 0.42);
}

.mono {
    font-family: "SFMono-Regular", "Consolas", monospace;
    font-size: 0.95rem;
}

.coeff-list {
    display: grid;
    gap: 8px;
    min-width: 240px;
    max-width: 320px;
}

.coeff-card {
    padding: 10px 12px;
    border-radius: 14px;
    background: rgba(14, 124, 102, 0.06);
    border: 1px solid rgba(14, 124, 102, 0.10);
}

.coeff-card-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    margin-bottom: 6px;
}

.coeff-pill {
    display: inline-flex;
    align-items: center;
    padding: 6px 10px;
    border-radius: 999px;
    background: rgba(14, 124, 102, 0.10);
    color: var(--accent-strong);
    font-size: 0.82rem;
    font-weight: 700;
    white-space: nowrap;
}

.coeff-value {
    font-size: 0.86rem;
    font-weight: 700;
    color: var(--ink);
}

.event-editor-grid {
    display: grid;
    grid-template-columns: 1fr;
    gap: 12px;
    align-items: start;
    min-width: 240px;
}

.event-editor-grid textarea {
    min-height: 108px;
}

.pager-row,
.flash-stack {
    display: flex;
    gap: 12px;
    flex-wrap: wrap;
}

.pager-row {
    justify-content: space-between;
    align-items: center;
    margin-top: 18px;
}

.pager {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
}

.flash-stack {
    margin-bottom: 18px;
}

.flash {
    padding: 15px 18px;
    border-radius: 18px;
    border: 1px solid transparent;
}

.flash-success {
    background: rgba(24, 114, 87, 0.12);
    border-color: rgba(24, 114, 87, 0.18);
}

.flash-error {
    background: rgba(187, 74, 74, 0.12);
    border-color: rgba(187, 74, 74, 0.18);
}

.flash-warning {
    background: rgba(183, 119, 19, 0.12);
    border-color: rgba(183, 119, 19, 0.18);
}

.status-badge {
    display: inline-flex;
    align-items: center;
    padding: 8px 12px;
    border-radius: 999px;
    font-size: 0.85rem;
    font-weight: 700;
}

.status-success {
    color: var(--success);
    background: rgba(24, 114, 87, 0.12);
}

.status-warning {
    color: var(--warning);
    background: rgba(183, 119, 19, 0.12);
}

.status-muted {
    color: var(--ink-soft);
    background: rgba(23, 33, 43, 0.08);
}

.error-cell {
    max-width: 360px;
    color: var(--ink-soft);
    overflow-wrap: anywhere;
}

.table-empty {
    padding: 22px 18px;
}

.auth-body {
    display: flex;
    align-items: center;
}

.auth-layout {
    position: relative;
    z-index: 1;
    width: min(1180px, calc(100vw - 32px));
    margin: auto;
    display: grid;
    grid-template-columns: 1.1fr 420px;
    gap: 20px;
    padding: 28px 0;
}

.auth-copy,
.auth-card {
    padding: 34px 32px;
}

.auth-copy h1 {
    font-size: clamp(2rem, 4vw, 3.6rem);
    margin-top: 10px;
    max-width: 680px;
}

.auth-points {
    margin: 22px 0 0;
    padding-left: 20px;
    color: var(--ink-soft);
    display: grid;
    gap: 10px;
}

.auth-card-header {
    margin-bottom: 20px;
}

.auth-card h2 {
    margin-top: 8px;
    font-size: 1.7rem;
}

.auth-form {
    display: grid;
    gap: 14px;
}

@keyframes rise-in {
    from {
        opacity: 0;
        transform: translateY(10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@media (max-width: 1120px) {
    .content-grid,
    .auth-layout {
        grid-template-columns: 1fr;
    }

    .stats-row {
        grid-template-columns: 1fr;
    }

    .hero-card {
        flex-direction: column;
    }

    .hero-note {
        min-width: 0;
        width: 100%;
    }
}

@media (max-width: 720px) {
    .app-shell {
        width: min(100vw - 20px, 1440px);
        padding-top: 16px;
    }

    .topbar,
    .action-bar,
    .pager-row,
    .filter-bar {
        flex-direction: column;
        align-items: stretch;
    }

    .tab-strip {
        grid-template-columns: 1fr;
    }

    .event-card-row {
        grid-template-columns: 1fr;
        gap: 10px;
        padding: 16px;
    }

    .event-editor-grid {
        grid-template-columns: 1fr;
        min-width: 0;
    }

    .hero-card,
    .sidebar-card,
    .main-panel,
    .auth-card,
    .auth-copy,
    .empty-state {
        padding: 22px 18px;
        border-radius: 22px;
    }

    .hero-card h1,
    .auth-copy h1 {
        font-size: 2.25rem;
    }

    .action-bar-meta {
        justify-content: space-between;
    }
}
