:root {
    --bg: #f3f7fb;
    --panel: rgba(255, 255, 255, 0.84);
    --panel-light: rgba(255, 255, 255, 0.92);
    --line: rgba(15, 23, 42, 0.08);
    --text: #0f172a;
    --muted: #64748b;
    --shadow: 0 18px 60px rgba(15, 23, 42, 0.08);
    --shadow-sm: 0 10px 30px rgba(15, 23, 42, 0.05);
    --success: #15803d;
    --success-soft: rgba(34, 197, 94, 0.12);
    --danger: #dc2626;
    --danger-soft: rgba(239, 68, 68, 0.10);
    --info: #1d4ed8;
    --info-soft: rgba(59, 130, 246, 0.10);
    --radius-xl: 26px;
    --radius-lg: 20px;
    --radius-md: 16px;
}

* {
    box-sizing: border-box;
}

body {
    margin: 0;
    font-family: "Inter", sans-serif;
    color: var(--text);
    background:
        radial-gradient(circle at top left, rgba(51, 102, 255, 0.08), transparent 20%),
        radial-gradient(circle at bottom right, rgba(20, 184, 166, 0.06), transparent 18%),
        var(--bg);
}

a {
    color: inherit;
    text-decoration: none;
}

.page-shell {
    max-width: 1380px;
    margin: 0 auto;
    padding: 24px;
    display: flex;
    flex-direction: column;
    gap: 24px;
}

.topbar {
    position: sticky;
    top: 0;
    z-index: 20;
    padding: 16px 18px;
    border-radius: 22px;
    backdrop-filter: blur(16px);
    background: var(--panel);
    border: 1px solid var(--line);
    box-shadow: var(--shadow-sm);
}

.topbar-inner,
.brand-wrap,
.top-actions,
.hero-topline,
.hero-actions,
.panel-header,
.panel-header-tight,
.page-hero,
.eyebrow-row,
.inline-actions {
    display: flex;
    align-items: center;
    gap: 14px;
}

.topbar-inner,
.hero-topline,
.panel-header,
.page-hero {
    justify-content: space-between;
}

.topbar-inner,
.hero-topline,
.panel-header,
.page-hero,
.hero-actions,
.inline-actions {
    flex-wrap: wrap;
}

.brand-wrap {
    color: inherit;
    min-width: 0;
}

.brand-icon {
    width: 46px;
    height: 46px;
    border-radius: 16px;
    background: linear-gradient(135deg, #3366ff, #23c7d9);
    color: white;
    font-size: 18px;
    font-weight: 800;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 18px 40px rgba(51, 102, 255, 0.24);
    flex: 0 0 auto;
}

.brand-copy h1,
.page-hero-copy h2,
.panel h3,
.hero-card h2,
.login-card h2 {
    margin: 0;
}

.brand-copy h1 {
    font-size: 22px;
    font-weight: 800;
    letter-spacing: -0.03em;
}

.brand-copy p,
.page-hero-copy p,
.panel-header p,
.hero-card p,
.login-card p,
.helper-note,
.feature-card p,
.live-note {
    margin: 4px 0 0;
    color: var(--muted);
}

.top-actions {
    flex-wrap: wrap;
    justify-content: flex-end;
}

.user-chip,
.pill,
.status-pill,
.eyebrow {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 34px;
    padding: 0 12px;
    border-radius: 999px;
    font-size: 12px;
    font-weight: 800;
    letter-spacing: 0.04em;
}

.user-chip,
.pill,
.status-pill {
    border: 1px solid var(--line);
    background: var(--panel-light);
    color: var(--muted);
}

.eyebrow {
    text-transform: uppercase;
    color: #3056d3;
    background: rgba(59, 130, 246, 0.10);
    border: 1px solid rgba(59, 130, 246, 0.14);
}

.btn {
    appearance: none;
    border: 0;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    border-radius: 14px;
    padding: 11px 15px;
    font-size: 14px;
    font-weight: 700;
    transition: transform .2s ease, box-shadow .2s ease, background .2s ease, border-color .2s ease;
}

.btn:hover {
    transform: translateY(-1px);
}

.btn-primary {
    color: white;
    background: linear-gradient(135deg, #3366ff, #5b8cff);
    box-shadow: 0 14px 30px rgba(51, 102, 255, 0.20);
}

.btn-secondary {
    color: var(--text);
    background: var(--panel-light);
    border: 1px solid var(--line);
}

.btn-danger {
    color: #7f1d1d;
    background: var(--panel-light);
    border: 1px solid rgba(220, 38, 38, 0.14);
}

.btn-danger-soft {
    color: #b91c1c;
    background: rgba(239, 68, 68, 0.08);
    border: 1px solid rgba(239, 68, 68, 0.14);
}

.btn-sm {
    padding: 8px 11px;
    font-size: 13px;
    border-radius: 12px;
}

.flash {
    padding: 16px 18px;
    border-radius: 18px;
    font-size: 14px;
    border: 1px solid transparent;
}

.flash-success {
    color: var(--success);
    background: var(--success-soft);
    border-color: rgba(34, 197, 94, 0.22);
}

.flash-error {
    color: var(--danger);
    background: rgba(239, 68, 68, 0.08);
    border-color: rgba(239, 68, 68, 0.18);
}

.flash-info {
    color: var(--info);
    background: var(--info-soft);
    border-color: rgba(59, 130, 246, 0.22);
}

.hero,
.layout-single {
    display: grid;
    gap: 24px;
}

.hero {
    grid-template-columns: 1.2fr .8fr;
}

.panel,
.hero-card,
.stats-card,
.page-hero,
.login-card,
.feature-card {
    background: var(--panel);
    border: 1px solid rgba(255, 255, 255, 0.5);
    backdrop-filter: blur(12px);
    box-shadow: var(--shadow);
    border-radius: var(--radius-xl);
}

.hero-card,
.stats-card,
.panel,
.page-hero,
.login-card {
    padding: 24px;
}

.hero-card h2,
.page-hero-copy h2,
.login-card h2 {
    font-size: clamp(1.8rem, 3vw, 2.5rem);
    line-height: 1.04;
    letter-spacing: -0.04em;
    font-weight: 800;
}

.hero-card p,
.page-hero-copy p {
    max-width: 72ch;
    line-height: 1.7;
}

.stats-card {
    display: grid;
    gap: 16px;
}

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

.stat-box {
    border-radius: 18px;
    padding: 16px;
    background: var(--panel-light);
    border: 1px solid var(--line);
}

.stat-label {
    color: var(--muted);
    font-size: 13px;
    font-weight: 600;
    margin-bottom: 8px;
}

.stat-value {
    font-size: 28px;
    line-height: 1;
    font-weight: 800;
    letter-spacing: -0.04em;
}

.layout-single {
    align-items: start;
}

.panel-header {
    margin-bottom: 18px;
}

.page-hero {
    align-items: flex-start;
}

.table-wrap {
    overflow-x: auto;
    border-radius: 18px;
}

table {
    width: 100%;
    border-collapse: collapse;
}

th,
td {
    text-align: left;
    padding: 14px 12px;
    border-bottom: 1px solid var(--line);
    vertical-align: top;
    font-size: 14px;
}

th {
    color: var(--muted);
    font-size: 12px;
    text-transform: uppercase;
    letter-spacing: 0.04em;
}

.badge {
    display: inline-flex;
    align-items: center;
    min-height: 30px;
    padding: 0 10px;
    border-radius: 999px;
    font-size: 12px;
    font-weight: 700;
}

.badge-success {
    color: var(--success);
    background: var(--success-soft);
}

.badge-muted {
    color: var(--muted);
    background: rgba(148, 163, 184, 0.12);
}

.rule-form,
.stack-form,
.feature-grid {
    display: grid;
    gap: 16px;
}

.rule-form {
    grid-template-columns: repeat(2, minmax(0, 1fr));
}

.feature-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    margin-top: 18px;
}

.feature-card {
    padding: 18px;
}

.feature-card h3 {
    margin: 0 0 6px;
    font-size: 16px;
}

.field {
    display: grid;
    gap: 8px;
    position: relative;
}

.field span {
    color: var(--muted);
    font-size: 13px;
    font-weight: 700;
}

input {
    width: 100%;
    border: 1px solid var(--line);
    background: var(--panel-light);
    color: var(--text);
    border-radius: 14px;
    padding: 12px 14px;
    font: inherit;
    outline: none;
}

input:focus {
    border-color: rgba(59, 130, 246, 0.35);
    box-shadow: 0 0 0 4px rgba(59, 130, 246, 0.08);
}

.checkbox-field {
    grid-column: 1 / -1;
    display: flex;
    align-items: center;
    gap: 10px;
}

.checkbox-field input {
    width: auto;
}

.autocomplete-menu {
    position: absolute;
    top: calc(100% + 6px);
    left: 0;
    right: 0;
    z-index: 30;
    display: grid;
    gap: 6px;
    padding: 8px;
    border-radius: 16px;
    background: var(--panel-light);
    border: 1px solid var(--line);
    box-shadow: var(--shadow-sm);
    max-height: 280px;
    overflow-y: auto;
}

.autocomplete-menu[hidden] {
    display: none;
}

.autocomplete-option {
    width: 100%;
    padding: 10px 12px;
    border-radius: 12px;
    border: 1px solid transparent;
    background: transparent;
    color: var(--text);
    display: flex;
    gap: 12px;
    align-items: flex-start;
    text-align: left;
}

.autocomplete-option:hover,
.autocomplete-option.is-active {
    background: rgba(59, 130, 246, 0.08);
    border-color: rgba(59, 130, 246, 0.16);
}

.autocomplete-option-code {
    min-width: 42px;
    font-size: 12px;
    font-weight: 800;
    color: #3056d3;
    padding-top: 2px;
}

.autocomplete-option-copy {
    display: grid;
    gap: 2px;
}

.autocomplete-option-copy strong {
    font-size: 14px;
}

.autocomplete-option-copy span {
    color: var(--muted);
    font-size: 12px;
    line-height: 1.4;
}

.form-actions {
    grid-column: 1 / -1;
    display: flex;
    gap: 12px;
    flex-wrap: wrap;
}

.m-0 {
    margin: 0;
}

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

.table-actions {
    display: flex;
    gap: 0.55rem;
    align-items: center;
    flex-wrap: nowrap;
    white-space: nowrap;
}

.table-actions .btn,
.table-actions .inline-form {
    flex: 0 0 auto;
}

.btn-small {
    min-height: 36px;
    padding: 0.55rem 0.8rem;
    font-size: 0.84rem;
}

.detail-grid {
    margin-bottom: 1rem;
}

.break-all {
    word-break: break-all;
}

.quote-shell {
    display: grid;
    gap: 24px;
}

.quote-hero-card {
    background:
        radial-gradient(circle at top right, rgba(51, 102, 255, 0.12), transparent 28%),
        radial-gradient(circle at bottom left, rgba(35, 199, 217, 0.10), transparent 26%),
        var(--panel);
    border: 1px solid rgba(255, 255, 255, 0.5);
    backdrop-filter: blur(12px);
    box-shadow: var(--shadow);
    border-radius: var(--radius-xl);
    padding: 28px;
}

.quote-hero-header,
.quote-detail-grid,
.quote-info-grid,
.quote-mini-list,
.quote-link-card {
    display: grid;
    gap: 16px;
}

.quote-hero-header {
    grid-template-columns: minmax(0, 1fr) auto;
    align-items: start;
    margin: 8px 0 22px;
}

.quote-hero-header h2 {
    margin: 0;
    font-size: clamp(30px, 4vw, 42px);
    letter-spacing: -0.04em;
}

.quote-hero-header p {
    margin: 8px 0 0;
    color: var(--muted);
    font-size: 15px;
}

.quote-kpi-grid {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 16px;
}

.quote-kpi,
.quote-info-card,
.quote-eval-card,
.quote-link-card {
    border-radius: 20px;
    background: rgba(255, 255, 255, 0.78);
    border: 1px solid rgba(15, 23, 42, 0.06);
    box-shadow: var(--shadow-sm);
}

.quote-kpi,
.quote-info-card {
    padding: 18px;
    display: grid;
    gap: 8px;
}

.quote-kpi span,
.quote-info-label,
.quote-mini-list span,
.quote-eval-label {
    color: var(--muted);
    font-size: 12px;
    font-weight: 800;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.quote-kpi strong,
.quote-info-card strong,
.quote-mini-list strong {
    font-size: 24px;
    line-height: 1.1;
    letter-spacing: -0.03em;
}

.quote-kpi small,
.quote-info-card small {
    color: var(--muted);
    font-size: 13px;
    line-height: 1.5;
}

.quote-detail-grid {
    grid-template-columns: minmax(0, 1.35fr) minmax(300px, 0.8fr);
    align-items: start;
}

.quote-panel-main,
.quote-sidebar {
    display: grid;
    gap: 24px;
}

.quote-info-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
}

.quote-raw-card {
    margin-top: 22px;
}

.quote-raw-text {
    margin: 0;
    padding: 18px;
    border-radius: 18px;
    background: rgba(15, 23, 42, 0.04);
    border: 1px solid rgba(15, 23, 42, 0.06);
    color: var(--text);
    font: 500 13px/1.65 "SFMono-Regular", Consolas, "Liberation Mono", Menlo, monospace;
    white-space: pre-wrap;
    word-break: break-word;
}

.quote-eval-card {
    padding: 18px;
    display: grid;
    gap: 8px;
}

.quote-eval-card p {
    margin: 0;
    font-size: 14px;
    line-height: 1.6;
}

.quote-eval-good {
    background: linear-gradient(180deg, rgba(34, 197, 94, 0.10), rgba(255, 255, 255, 0.9));
    border-color: rgba(34, 197, 94, 0.16);
}

.quote-eval-bad {
    background: linear-gradient(180deg, rgba(239, 68, 68, 0.08), rgba(255, 255, 255, 0.9));
    border-color: rgba(239, 68, 68, 0.14);
}

.quote-mini-list > div {
    display: grid;
    gap: 6px;
    padding: 14px 0;
    border-bottom: 1px solid var(--line);
}

.quote-mini-list > div:first-child {
    padding-top: 0;
}

.quote-mini-list > div:last-child {
    padding-bottom: 0;
    border-bottom: 0;
}

.quote-link-card {
    padding: 18px;
    transition: transform .2s ease, box-shadow .2s ease;
}

.quote-link-card:hover {
    transform: translateY(-1px);
    box-shadow: 0 16px 32px rgba(15, 23, 42, 0.08);
}

.quote-link-card strong {
    font-size: 15px;
}

.quote-link-card span {
    color: var(--muted);
    font-size: 13px;
    line-height: 1.55;
}

.login-shell {
    min-height: 100vh;
    display: grid;
    grid-template-columns: 1.15fr .85fr;
    gap: 24px;
    padding: 24px;
}

.login-hero,
.login-panel {
    display: flex;
    align-items: center;
}

.login-hero {
    flex-direction: column;
    align-items: flex-start;
    justify-content: center;
    gap: 18px;
    padding: 28px;
}

.login-brand {
    display: inline-flex;
    align-items: center;
    gap: 12px;
    font-weight: 800;
}

.hero-copy h1 {
    margin: 10px 0;
    font-size: clamp(2.4rem, 4vw, 4.3rem);
    line-height: 0.96;
    letter-spacing: -0.05em;
}

.hero-copy p {
    max-width: 62ch;
    color: var(--muted);
    line-height: 1.8;
}

.login-panel {
    justify-content: center;
}

.login-card {
    width: min(480px, 100%);
}

.status-pill {
    color: var(--info);
}

.login-submit {
    width: 100%;
}

.helper-note {
    margin-top: 16px;
    font-size: 13px;
    line-height: 1.7;
}

@media (max-width: 1100px) {
    .hero,
    .login-shell {
        grid-template-columns: 1fr;
    }

    .quote-hero-header,
    .quote-detail-grid {
        grid-template-columns: 1fr;
    }
}

@media (max-width: 820px) {
    .page-shell {
        padding: 16px;
    }

    .topbar-inner,
    .top-actions,
    .panel-header,
    .page-hero,
    .hero-topline,
    .form-actions {
        flex-direction: column;
        align-items: flex-start;
    }

    .rule-form,
    .feature-grid,
    .stats-grid,
    .quote-kpi-grid,
    .quote-info-grid {
        grid-template-columns: 1fr;
    }

    .inline-actions {
        flex-direction: column;
        align-items: stretch;
    }
}
