:root {
    color-scheme: dark;
    --bg: #0a0a0f;
    --bg2: #111118;
    --bg3: #17171f;
    --bg4: #1e1e28;
    --border: rgba(255, 255, 255, 0.07);
    --border-strong: rgba(255, 255, 255, 0.12);
    --text: #f0f0f8;
    --muted: #6b6b88;
    --muted2: #9898b8;
    --accent: #5b6cff;
    --accent2: #8b5cf6;
    --green: #22d4a0;
    --red: #ff4d6a;
    --amber: #f5a623;
    --blue: #38bdf8;
    --mono: "DM Mono", monospace;
    --sans: "Syne", sans-serif;
    --shadow: 0 30px 60px rgba(1, 8, 20, 0.35);
}

* { box-sizing: border-box; }
html, body { min-height: 100%; }
body {
    margin: 0;
    background: var(--bg);
    color: var(--text);
    font-family: var(--sans);
    font-size: 16px;
    line-height: 1.4;
    overflow-x: hidden;
}
a { color: inherit; }

.app-shell { display: grid; grid-template-columns: 240px minmax(0, 1fr); min-height: 100vh; }
.guest-shell { display: block; }
.app-sidebar {
    position: sticky;
    top: 0;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    background: var(--bg2);
    border-right: 1px solid var(--border);
    height: 100vh;
    overflow-y: auto;
}
.brand-block, .app-topbar, .table-head { display: flex; align-items: center; justify-content: space-between; gap: 1rem; }
.brand-block { padding: 28px 24px 20px; border-bottom: 1px solid var(--border); justify-content: flex-start; }
.brand-mark {
    width: 32px;
    height: 32px;
    border-radius: 8px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, var(--accent), var(--accent2));
    font-size: 14px;
    font-weight: 800;
    color: #fff;
}
.brand-mark img {
    width: 18px;
    height: 18px;
    display: block;
    filter: brightness(0) invert(1);
}
.brand-title { font-size: 14px; font-weight: 700; letter-spacing: 0.05em; color: var(--text); }
.brand-subtitle, .page-subtitle, .muted-copy, .soft-note, .service-meta, .auth-footer, .validation-block {
    color: var(--muted);
    font-family: var(--mono);
    font-size: 12px;
}
.brand-subtitle { margin-top: 1px; }
.sidebar-group { padding: 16px 12px 8px; }
.sidebar-stack { display: grid; gap: 10px; }
.sidebar-editor-group {
    border-top: 1px solid var(--border);
    border-bottom: 1px solid var(--border);
    margin: 8px 12px 0;
    padding: 16px 0;
}
.sidebar-settings-title {
    padding: 0 12px 12px;
    color: var(--text);
    font-size: 13px;
    font-weight: 700;
}
.sidebar-link-static {
    margin: 0 12px 12px;
    cursor: default;
}
.sidebar-link-static:hover {
    color: var(--accent);
    background: rgba(79, 124, 255, 0.18);
}
.themed-input-sm, .themed-select-sm {
    padding: 7px 10px;
    font-size: 12px;
}
.sidebar-btn { width: 100%; }
.sidebar-parameter-list .slider-output {
    min-width: 44px;
    font-size: 12px;
}
.dashboard-notes-textarea { min-height: 240px; }
.dashboard-notes-compact { min-height: 92px; }
.note-item {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 12px;
}
.note-item .activity-title {
    flex: 1;
    line-height: 1.6;
}
.sidebar-label, .section-kicker, .stat-label, .field-label, .theme-table th {
    color: var(--muted);
    font-family: var(--mono);
    text-transform: uppercase;
}
.sidebar-label { font-size: 10px; letter-spacing: 0.12em; padding: 0 12px 8px; }
.section-kicker, .stat-label { letter-spacing: 0.08em; font-size: 10px; }
.sidebar-link, .sidebar-static {
    display: flex;
    align-items: center;
    gap: 10px;
    text-decoration: none;
    color: var(--muted2);
    padding: 9px 12px;
    border-radius: 8px;
    margin-bottom: 2px;
    transition: 0.18s ease;
    font-size: 13px;
    font-weight: 500;
}
.sidebar-link:hover, .sidebar-static:hover { color: var(--text); background: var(--bg3); }
.sidebar-link.active {
    color: var(--accent);
    background: rgba(79, 124, 255, 0.18);
    border: none;
}
.sidebar-icon { width: 18px; height: 18px; opacity: 0.7; flex-shrink: 0; }
.sidebar-footer { margin-top: auto; padding: 16px; border-top: 1px solid var(--border); }
.status-pill {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    color: var(--muted2);
    font-family: var(--mono);
    font-size: 11px;
}
.status-pill::before {
    content: "";
    width: 7px;
    height: 7px;
    border-radius: 999px;
    background: var(--green);
    box-shadow: 0 0 6px var(--green);
}
.app-topbar {
    position: sticky;
    top: 0;
    z-index: 20;
    padding: 20px 32px;
    border-bottom: 1px solid var(--border);
    background: var(--bg);
    backdrop-filter: blur(10px);
}
.page-title { margin: 0; font-size: 18px; font-weight: 700; color: var(--text); }
.page-subtitle { margin: 2px 0 0; }
.topbar-actions, .tier-tabs { display: flex; align-items: center; gap: 0.75rem; flex-wrap: wrap; }
.page-wrap { padding: 28px 32px; }
.surface-panel, .surface-card, .stat-card, .table-shell, .login-panel, .hero-panel {
    background: var(--bg2);
    border: 1px solid var(--border);
    border-radius: 14px;
    box-shadow: var(--shadow);
}
.surface-panel, .surface-card, .login-panel, .hero-panel { padding: 22px; }
.section-kicker { display: flex; align-items: center; gap: 6px; margin-bottom: 16px; }
.section-kicker::before { content: ""; width: 4px; height: 4px; border-radius: 999px; background: var(--accent); }
.panel-title { margin: 0 0 10px; font-size: 14px; font-weight: 700; }
.stats-grid { display: grid; gap: 1rem; grid-template-columns: repeat(4, minmax(0, 1fr)); }
.stat-card { padding: 18px; position: relative; overflow: hidden; border-radius: 12px; }
.stat-card::after { content: ""; position: absolute; inset: 0 auto auto 0; width: 100%; height: 2px; }
.stat-card.blue::after { background: linear-gradient(90deg, var(--accent), var(--blue)); }
.stat-card.green::after { background: linear-gradient(90deg, var(--green), #10b981); }
.stat-card.amber::after { background: linear-gradient(90deg, var(--amber), #f97316); }
.stat-card.purple::after { background: linear-gradient(90deg, var(--accent2), #ec4899); }
.stat-value { font-family: var(--mono); font-size: 22px; font-weight: 700; line-height: 1.15; color: var(--text); }
.stat-subtitle { color: var(--muted); font-family: var(--mono); font-size: 12px; margin-top: 4px; }
.mini-bar { height: 4px; background: var(--bg4); border-radius: 2px; overflow: hidden; margin-top: 6px; }
.mini-bar > span { display: block; height: 100%; border-radius: inherit; background: linear-gradient(90deg, var(--accent), var(--accent2)); }
.panel-grid, .form-grid, .helper-grid, .offer-builder-layout, .login-grid, .hero-metrics { display: grid; gap: 1rem; }
.stack-gap { display: grid; gap: 1rem; }
.offer-builder-layout { grid-template-columns: minmax(0, 1.7fr) minmax(300px, 0.92fr); gap: 20px; }
.dashboard-layout { align-items: start; }
.offer-create-stack {
    width: 100%;
    max-width: 100%;
}
.dashboard-panels-wide {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 20px;
    align-items: start;
}
.panel-half-muted,
.panel-half-strong {
    min-height: 360px;
}
.compact-stack {
    gap: 12px;
}
.checkbox-row {
    display: grid;
    align-content: end;
}
.checkbox-label {
    display: inline-flex;
    align-items: center;
    gap: 10px;
    font-family: var(--mono);
    font-size: 12px;
    color: var(--muted2);
}
.checkbox-label input[type="checkbox"] {
    width: 14px;
    height: 14px;
    accent-color: var(--accent);
}
.form-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
.offer-create-stack .surface-panel:first-of-type .form-grid > div:nth-child(6) {
    grid-column: 1 / -1;
    order: -2;
}
.offer-create-stack .surface-panel:first-of-type .form-grid > div:nth-child(7) { order: -1; }
.offer-create-stack .surface-panel:first-of-type .form-grid > div:nth-child(1) { order: 0; }
.offer-create-stack .surface-panel:first-of-type .form-grid > div:nth-child(2) { order: 1; }
.offer-create-stack .surface-panel:first-of-type .form-grid > div:nth-child(3) { order: 2; }
.offer-create-stack .surface-panel:first-of-type .form-grid > div:nth-child(4) { order: 3; }
.offer-create-stack .surface-panel:first-of-type .form-grid > div:nth-child(5) { order: 4; }
.helper-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 0.8rem; }
.helper-grid-single { grid-template-columns: 1fr; }
.full-span { grid-column: 1 / -1; }
.field-label { display: block; margin-bottom: 5px; font-size: 11px; letter-spacing: 0.08em; }
.themed-input, .themed-select, .themed-textarea {
    width: 100%;
    border-radius: 7px;
    border: 1px solid var(--border);
    background: var(--bg3);
    color: var(--text);
    padding: 8px 12px;
    font-family: var(--mono);
    font-size: 13px;
    outline: none;
    transition: border-color 0.18s ease, box-shadow 0.18s ease;
}
.compact-input { max-width: 110px; justify-self: end; }
.themed-input:focus, .themed-select:focus, .themed-textarea:focus { border-color: var(--accent); box-shadow: none; }
.themed-textarea { min-height: 120px; resize: vertical; }
.btn-theme, .btn-theme-secondary, .btn-theme-danger {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.45rem;
    border: none;
    border-radius: 8px;
    padding: 8px 18px;
    font-weight: 600;
    font-size: 12px;
    text-decoration: none;
    transition: transform 0.16s ease, background 0.16s ease, color 0.16s ease;
    cursor: pointer;
    letter-spacing: 0.04em;
}
.btn-theme { background: var(--accent); color: #fff; }
.btn-theme:hover { transform: translateY(-1px); background: #426cf2; }
.btn-theme-secondary { background: var(--bg3); color: var(--muted2); border: 1px solid var(--border-strong); }
.btn-theme-secondary:hover { color: var(--text); background: var(--bg4); }
.btn-theme-danger { background: rgba(251, 113, 133, 0.14); color: #ffb1bf; border: 1px solid rgba(251, 113, 133, 0.22); }
.action-group {
    display: inline-flex;
    align-items: center;
    justify-content: flex-end;
    gap: 8px;
    flex-wrap: wrap;
}
.icon-action {
    width: 34px;
    height: 34px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: 10px;
    border: 1px solid var(--border-strong);
    background: var(--bg3);
    color: var(--muted2);
    text-decoration: none;
    transition: transform 0.16s ease, background 0.16s ease, color 0.16s ease, border-color 0.16s ease;
}
.icon-action:hover {
    transform: translateY(-1px);
    background: var(--bg4);
    color: var(--text);
}
.icon-action svg {
    width: 16px;
    height: 16px;
    stroke: currentColor;
    fill: none;
    stroke-width: 1.8;
    stroke-linecap: round;
    stroke-linejoin: round;
}
.icon-action-danger {
    background: rgba(251, 113, 133, 0.12);
    color: #ff9eb0;
    border-color: rgba(251, 113, 133, 0.24);
}
.icon-action-danger:hover {
    background: rgba(251, 113, 133, 0.18);
    color: #ffd1da;
}
.icon-action-form {
    display: inline-flex;
    margin: 0;
}
.info-chip, .table-badge, .status-badge, .tier-tab, .profile-pill {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: 999px;
    padding: 4px 10px;
    font-family: var(--mono);
    font-size: 10px;
    letter-spacing: 0.05em;
}
.info-chip, .table-badge, .profile-pill { background: rgba(79, 124, 255, 0.14); color: #cdddff; }
.status-ok { background: rgba(52, 211, 153, 0.12); color: var(--green); }
.status-caution { background: rgba(245, 158, 11, 0.14); color: var(--amber); }
.status-danger { background: rgba(251, 113, 133, 0.14); color: var(--red); }
.tier-tab { background: transparent; color: var(--muted2); border: 1px solid transparent; cursor: pointer; font-family: var(--sans); font-size: 12px; font-weight: 600; padding: 7px 16px; border-radius: 8px; }
.tier-tab.active { background: var(--bg3); color: var(--text); border-color: var(--border-strong); }
.table-shell { overflow: hidden; }
.manual-items-panel {
    margin-top: 16px;
    padding: 16px 22px 20px;
    border-top: 1px solid var(--border);
}
.manual-items-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    margin-bottom: 12px;
}
.manual-items-list { display: grid; gap: 10px; }
.manual-item-row {
    display: grid;
    grid-template-columns: minmax(0, 1.8fr) 110px 140px 44px;
    gap: 10px;
    align-items: center;
}
.manual-empty-state {
    padding: 14px 16px;
    border: 1px dashed var(--border);
    border-radius: 10px;
    color: var(--muted);
    font-family: var(--mono);
    font-size: 12px;
}
.table-head { padding: 18px 22px; border-bottom: 1px solid var(--border); }
.table-title {
    font-size: 14px;
    font-weight: 700;
    color: var(--text);
    margin: 0;
}
.table-scroll { overflow-x: auto; }
.theme-table { width: 100%; border-collapse: collapse; }
.theme-table th {
    padding: 10px 16px;
    text-align: left;
    background: var(--bg3);
    border-bottom: 1px solid var(--border);
    font-size: 10px;
    letter-spacing: 0.1em;
    color: #7f88ba;
    text-transform: uppercase;
}
.theme-table td {
    padding: 11px 16px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.04);
    vertical-align: middle;
    font-size: 13px;
    background: rgba(255,255,255,0.01);
}
.theme-table tr:last-child td { border-bottom: none; }
.theme-table tbody tr:hover td { background: rgba(255, 255, 255, 0.02); }
.service-cell { display: flex; align-items: center; gap: 12px; }
.service-icon {
    width: 34px;
    height: 34px;
    border-radius: 9px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 15px;
    flex-shrink: 0;
}
.service-title { font-weight: 600; font-size: 13px; color: var(--text); }
.service-meta { font-size: 11px; margin-top: 1px; color: #7f88ba; }
.selection-list { display: grid; gap: 0.75rem; }
.selection-item {
    display: grid;
    align-items: center;
    gap: 0.85rem;
    grid-template-columns: auto minmax(0, 1fr) 90px 110px;
    padding: 12px;
    border: 1px solid var(--border);
    border-radius: 10px;
    background: rgba(255, 255, 255, 0.02);
}
.service-item .form-check-input { width: 1.15rem; height: 1.15rem; margin-top: 0; background-color: var(--bg4); border-color: var(--border-strong); }
.service-item .form-check-input:checked { background-color: var(--accent); border-color: var(--accent); }
.selection-amount, .mono-text, .theme-table td.text-end, .theme-table th.text-end { font-family: var(--mono); text-align: right; }
.selection-price { font-family: var(--mono); font-size: 13px; margin-bottom: 4px; }
.price-min { color: #b4bcf6; font-family: var(--mono); }
.price-base { color: #27b0ff; font-family: var(--mono); font-weight: 500; }
.price-rec { color: #22d4a0; font-family: var(--mono); font-weight: 600; }
.price-max { color: #ffb020; font-family: var(--mono); font-weight: 600; }
.price-override-input {
    min-width: 120px;
    text-align: right;
    margin-bottom: 6px;
    padding-top: 6px;
    padding-bottom: 6px;
    font-size: 12px;
}
.alert-theme {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 12px 16px;
    border-radius: 10px;
    border: 1px solid rgba(251, 113, 133, 0.22);
    background: rgba(251, 113, 133, 0.1);
    color: #ffb1bf;
    font-family: var(--mono);
    font-size: 12px;
}
.hidden { display: none !important; }
.helper-row { color: var(--muted2); font-family: var(--mono); font-size: 12px; line-height: 1.9; }
.parameter-list, .parameter-editor-list { display: grid; gap: 0.8rem; }
.parameter-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    padding: 0.75rem 0.85rem;
    border: 1px solid var(--border);
    border-radius: 0.85rem;
    background: rgba(255, 255, 255, 0.02);
}
.parameter-row span { color: var(--muted2); font-size: 13px; }
.parameter-row strong { font-family: var(--mono); font-size: 13px; }
.compact-form-grid { gap: 12px; }
.slider-field { display: grid; gap: 5px; }
.slider-row {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    gap: 10px;
    align-items: center;
}
.slider-row input[type="range"] {
    width: 100%;
    padding: 4px 0;
    cursor: pointer;
    accent-color: var(--accent);
}
.slider-output {
    min-width: 36px;
    text-align: right;
    color: var(--accent);
    font-family: var(--mono);
    font-size: 13px;
    font-weight: 500;
}
.recent-offer-item { padding: 14px 0; border-bottom: 1px solid rgba(255, 255, 255, 0.06); }
.recent-offer-item:last-child { border-bottom: none; padding-bottom: 0; }
.login-shell { min-height: 100vh; display: grid; place-items: center; padding: 2rem; }
.login-grid { width: min(1120px, 100%); grid-template-columns: minmax(0, 1.15fr) minmax(380px, 0.85fr); gap: 1.25rem; }
.hero-panel {
    background:
        radial-gradient(circle at 20% 20%, rgba(79, 124, 255, 0.18), transparent 30%),
        radial-gradient(circle at 80% 20%, rgba(16, 185, 129, 0.14), transparent 26%),
        rgba(18, 24, 38, 0.92);
}
.hero-title { font-size: clamp(2.2rem, 5vw, 4rem); line-height: 0.95; margin: 0; }
.hero-copy { max-width: 36rem; color: var(--muted2); margin-top: 1rem; font-size: 12px; line-height: 1.9; font-family: var(--mono); }
.hero-metrics { grid-template-columns: repeat(3, minmax(0, 1fr)); margin-top: 2rem; gap: 0.85rem; }
.metric-box { padding: 1rem; border-radius: 1rem; background: rgba(255, 255, 255, 0.03); border: 1px solid rgba(255, 255, 255, 0.06); }
.metric-box strong { display: block; font-family: var(--mono); font-size: 1.1rem; margin-bottom: 0.25rem; }
.auth-footer { font-size: 0.72rem; text-align: center; margin-top: 1rem; }
.validation-block { margin-top: 0.4rem; font-size: 0.72rem; color: #ffb1bf; }
.logout-form { margin-top: 0.5rem; }
.logout-form .btn-theme-secondary { width: 100%; }
.empty-state { padding: 2.5rem 1rem; text-align: center; color: var(--muted); font-family: var(--mono); }
.toast-success {
    padding: 12px 16px;
    border-radius: 10px;
    border: 1px solid rgba(52, 211, 153, 0.22);
    background: rgba(52, 211, 153, 0.08);
    color: var(--green);
    font-family: var(--mono);
    font-size: 12px;
}
.mt-3 { margin-top: 1rem; }
.activity-card {
    display: grid;
    gap: 10px;
}
.activity-item {
    padding: 12px 14px;
    border-radius: 10px;
    border: 1px solid var(--border);
    background: rgba(255, 255, 255, 0.02);
}
.activity-title {
    font-size: 13px;
    font-weight: 700;
    color: var(--text);
}
.activity-meta {
    margin-top: 4px;
    color: var(--muted2);
    font-family: var(--mono);
    font-size: 11px;
}
.activity-empty {
    padding: 18px;
    border-radius: 10px;
    border: 1px dashed var(--border-strong);
    color: var(--muted);
    font-family: var(--mono);
    font-size: 12px;
    text-align: center;
}
.public-actions {
    display: flex;
    gap: 12px;
    flex-wrap: wrap;
}
.public-actions form {
    margin: 0;
}

@media (max-width: 1200px) {
    .offer-builder-layout { grid-template-columns: 1fr; }
    .dashboard-panels-wide { grid-template-columns: 1fr; }
}

@media (max-width: 992px) {
    .app-shell { grid-template-columns: 1fr; }
    .app-sidebar { position: static; min-height: auto; }
    .stats-grid, .form-grid, .helper-grid, .hero-metrics, .login-grid { grid-template-columns: 1fr; }
    .page-wrap, .app-topbar { padding-left: 16px; padding-right: 16px; }
    .selection-item { grid-template-columns: auto minmax(0, 1fr); }
    .compact-input { max-width: none; justify-self: stretch; }
    .theme-table th, .theme-table td { padding: 9px 10px; font-size: 12px; }
    .service-cell { align-items: flex-start; }
    .service-icon { width: 30px; height: 30px; font-size: 13px; }
    .action-group { gap: 6px; }
    .icon-action { width: 30px; height: 30px; border-radius: 8px; }
    .icon-action svg { width: 14px; height: 14px; }
    .table-scroll { overflow-x: auto; -webkit-overflow-scrolling: touch; }
    .price-override-input { min-width: 92px; }
    .manual-items-head { align-items: stretch; flex-direction: column; }
    .manual-item-row { grid-template-columns: 1fr; }
    .public-actions { flex-direction: column; }
}
