:root {
    --bg: #f5f7fa;
    --bg-elevated: #ffffff;
    --bg-soft: #eef2f7;
    --fg: #16202e;
    --fg-muted: #5b6472;
    --border: #dfe4ea;
    --accent: #0d3b66;
    --accent-2: #1d7cf2;
    --accent-fg: #ffffff;
    --gold: #f4b942;
    --danger: #c53030;
    --danger-bg: #fdecec;
    --success: #1a7f4b;
    --success-bg: #e7f7ee;
    --info: #1a5c96;
    --info-bg: #e5f0fb;
    --warn: #9a6a12;
    --warn-bg: #fbf0da;
    --radius: 10px;
    --shadow: 0 1px 2px rgba(16, 24, 40, 0.06), 0 1px 3px rgba(16, 24, 40, 0.08);
    --shadow-lg: 0 10px 30px rgba(16, 24, 40, 0.10);
    color-scheme: light;
}

@media (prefers-color-scheme: dark) {
    :root:not([data-theme="light"]) {
        --bg: #0f131a;
        --bg-elevated: #171c26;
        --bg-soft: #1f2632;
        --fg: #e7eaf0;
        --fg-muted: #9aa3b2;
        --border: #2b323f;
        --accent: #5b9bd8;
        --accent-2: #4f9cf5;
        --accent-fg: #0b1220;
        --gold: #f4b942;
        --danger: #f47171;
        --danger-bg: #3a1c1c;
        --success: #57c98a;
        --success-bg: #163524;
        --info: #7cb8e8;
        --info-bg: #1a2e42;
        --warn: #f4b942;
        --warn-bg: #3a2f14;
        --shadow-lg: 0 10px 30px rgba(0, 0, 0, 0.35);
        color-scheme: dark;
    }
}

:root[data-theme="dark"] {
    --bg: #0f131a;
    --bg-elevated: #171c26;
    --bg-soft: #1f2632;
    --fg: #e7eaf0;
    --fg-muted: #9aa3b2;
    --border: #2b323f;
    --accent: #5b9bd8;
    --accent-2: #4f9cf5;
    --accent-fg: #0b1220;
    --gold: #f4b942;
    --danger: #f47171;
    --danger-bg: #3a1c1c;
    --success: #57c98a;
    --success-bg: #163524;
    --info: #7cb8e8;
    --info-bg: #1a2e42;
    --warn: #f4b942;
    --warn-bg: #3a2f14;
    --shadow-lg: 0 10px 30px rgba(0, 0, 0, 0.35);
    color-scheme: dark;
}

* { box-sizing: border-box; }

body {
    margin: 0;
    background: var(--bg);
    color: var(--fg);
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    line-height: 1.5;
}

a { color: var(--accent-2); }
h1, h2, h3 { line-height: 1.25; }
h1 { font-size: 28px; }
code { background: var(--bg-soft); padding: 2px 5px; border-radius: 4px; font-size: 0.92em; }

.container { max-width: 960px; margin: 0 auto; padding: 0 20px; }
.container-wide { max-width: 1140px; }

/* --- Top nav --- */
.nav { background: var(--bg-elevated); border-bottom: 1px solid var(--border); position: relative; }
.nav-inner {
    display: flex; align-items: center; justify-content: space-between;
    max-width: 1140px; margin: 0 auto; padding: 10px 20px;
}
.brand { display: flex; align-items: center; gap: 8px; font-weight: 700; font-size: 19px; color: var(--fg); text-decoration: none; letter-spacing: -0.2px; }
.brand img { height: 32px; width: auto; }
.brand-word span { color: var(--accent-2); }
.nav-links { display: flex; align-items: center; gap: 18px; list-style: none; margin: 0; padding: 0; }
.nav-links a { color: var(--fg-muted); text-decoration: none; font-size: 14px; }
.nav-links a:hover, .nav-links a.active { color: var(--fg); }
.nav-links a.btn { color: var(--accent-fg); }
.nav-toggle { display: none; background: none; border: 1px solid var(--border); border-radius: 6px; color: var(--fg); font-size: 18px; padding: 4px 10px; cursor: pointer; }
.theme-switch { display: flex; gap: 2px; border: 1px solid var(--border); border-radius: 999px; padding: 2px; }
.theme-switch button { background: none; border: none; color: var(--fg-muted); cursor: pointer; width: 26px; height: 26px; border-radius: 999px; font-size: 13px; }
.theme-switch button:hover { background: var(--bg-soft); color: var(--fg); }

@media (max-width: 760px) {
    .nav-toggle { display: inline-block; }
    .nav-links { display: none; position: absolute; top: 100%; left: 0; right: 0; flex-direction: column; align-items: flex-start; gap: 12px; background: var(--bg-elevated); border-bottom: 1px solid var(--border); padding: 14px 20px; z-index: 50; }
    .nav-links.open { display: flex; }
}

/* --- Buttons / forms --- */
.btn {
    display: inline-block; padding: 9px 16px; border-radius: 8px; border: 1px solid transparent;
    background: var(--accent); color: var(--accent-fg); font-size: 14px; font-weight: 600;
    cursor: pointer; text-decoration: none; line-height: 1.3;
}
.btn:hover { opacity: 0.92; }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }
.btn-secondary { background: transparent; border-color: var(--border); color: var(--fg); }
.btn-danger { background: var(--danger); color: #fff; }
.btn-success { background: var(--success); color: #fff; }
.btn-sm { padding: 6px 12px; font-size: 13px; }
.btn-lg { padding: 13px 24px; font-size: 16px; }
.btn-block { display: block; width: 100%; text-align: center; }

.field { margin-bottom: 16px; }
.field label { display: block; font-size: 13px; font-weight: 600; margin-bottom: 6px; color: var(--fg-muted); }
.field input[type="text"], .field input[type="email"], .field input[type="password"], .field input[type="number"], .field input[type="date"],
.field select, .field textarea {
    width: 100%; padding: 10px 12px; border: 1px solid var(--border); border-radius: 8px;
    background: var(--bg-elevated); color: var(--fg); font-size: 14px; font-family: inherit;
}
.field textarea { min-height: 110px; resize: vertical; }
.field .hint { font-size: 12px; color: var(--fg-muted); margin-top: 4px; }
.field-row { display: flex; gap: 12px; }
.field-row > .field { flex: 1; }
.input-addon { display: flex; align-items: stretch; }
.input-addon input { border-radius: 8px 0 0 8px !important; }
.input-addon span { display: flex; align-items: center; padding: 0 12px; border: 1px solid var(--border); border-left: none; border-radius: 0 8px 8px 0; background: var(--bg-soft); color: var(--fg-muted); font-size: 14px; white-space: nowrap; }

.pwd-wrap { position: relative; }
.pwd-wrap input[type="password"], .pwd-wrap input[type="text"] { padding-right: 40px; }
.pwd-toggle {
    position: absolute; top: 50%; right: 8px; transform: translateY(-50%);
    display: flex; align-items: center; justify-content: center; width: 28px; height: 28px;
    padding: 0; background: none; border: none; cursor: pointer; color: var(--fg-muted);
}
.pwd-toggle:hover { color: var(--fg); }
.pwd-toggle svg { width: 18px; height: 18px; }

.card { background: var(--bg-elevated); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); padding: 24px; }
.card + .card { margin-top: 16px; }
.card h3:first-child, .card h2:first-child { margin-top: 0; }
.card-accent { border-left: 4px solid var(--accent-2); }
.card-danger { border-left: 4px solid var(--danger); }
.card-success { border-left: 4px solid var(--success); }
.card-warn { border-left: 4px solid var(--gold); }

.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.grid-3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 16px; }
@media (max-width: 760px) { .grid-2, .grid-3 { grid-template-columns: 1fr; } .field-row { flex-direction: column; gap: 0; } }

/* --- Flash messages / notices --- */
.flash { padding: 12px 16px; border-radius: 8px; margin-bottom: 16px; font-size: 14px; }
.flash-success { background: var(--success-bg); color: var(--success); }
.flash-error { background: var(--danger-bg); color: var(--danger); }
.flash-info { background: var(--info-bg); color: var(--info); }
.flash-warn { background: var(--warn-bg); color: var(--warn); }
.notice { padding: 12px 16px; border-radius: 8px; font-size: 14px; border-left: 4px solid var(--gold); background: var(--warn-bg); color: var(--fg); margin: 12px 0; }
.notice-danger { border-left-color: var(--danger); background: var(--danger-bg); }
.notice-info { border-left-color: var(--accent-2); background: var(--info-bg); }
.notice-success { border-left-color: var(--success); background: var(--success-bg); }

/* --- Usage bar --- */
.usage-bar { background: var(--border); border-radius: 999px; height: 8px; overflow: hidden; }
.usage-bar-fill { background: var(--accent-2); height: 100%; transition: width .3s; }
.usage-bar-fill.usage-warn { background: var(--gold); }
.usage-bar-fill.usage-danger { background: var(--danger); }

/* --- Lists / rows --- */
.row-list .row { display: flex; justify-content: space-between; align-items: center; gap: 12px; padding: 14px 0; border-bottom: 1px solid var(--border); }
.row-list .row:last-child { border-bottom: none; }
.row-title { font-weight: 600; text-decoration: none; color: var(--fg); }
.meta { font-size: 12px; color: var(--fg-muted); }
.badge { display: inline-block; font-size: 11px; padding: 2px 8px; border-radius: 999px; background: var(--border); color: var(--fg-muted); white-space: nowrap; }
.badge-success { background: var(--success-bg); color: var(--success); }
.badge-danger { background: var(--danger-bg); color: var(--danger); }
.badge-info { background: var(--info-bg); color: var(--info); }
.badge-warn { background: var(--warn-bg); color: var(--warn); }
.badge-gold { background: var(--gold); color: #3a2f14; }

/* --- Status pills (dashboard) --- */
.status-hero { display: flex; gap: 20px; align-items: center; flex-wrap: wrap; }
.status-dot { width: 14px; height: 14px; border-radius: 999px; display: inline-block; margin-right: 8px; vertical-align: middle; }
.dot-green { background: var(--success); box-shadow: 0 0 0 4px var(--success-bg); }
.dot-amber { background: var(--gold); box-shadow: 0 0 0 4px var(--warn-bg); }
.dot-red { background: var(--danger); box-shadow: 0 0 0 4px var(--danger-bg); }
.dot-grey { background: var(--fg-muted); box-shadow: 0 0 0 4px var(--bg-soft); }
.strikes { display: flex; gap: 8px; }
.strike { width: 34px; height: 10px; border-radius: 999px; background: var(--border); }
.strike.hit { background: var(--danger); }

.copy-box { display: flex; gap: 8px; align-items: center; }
.copy-box input { flex: 1; font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 12px; }

/* --- Rich text editor (Quill) --- */
#quill-editor .ql-toolbar { border-color: var(--border); border-radius: 8px 8px 0 0; background: var(--bg-elevated); }
#quill-editor .ql-container { border-color: var(--border); border-radius: 0 0 8px 8px; font-size: 15px; }
#quill-editor .ql-editor { min-height: 320px; color: var(--fg); resize: vertical; overflow-y: auto; }
#quill-editor .ql-editor.ql-blank::before { color: var(--fg-muted); font-style: normal; }
#quill-editor .ql-stroke { stroke: var(--fg-muted); }
#quill-editor .ql-fill { fill: var(--fg-muted); }
#quill-editor .ql-picker-label { color: var(--fg-muted); }

.message-content { word-wrap: break-word; line-height: 1.6; }
.message-content img { max-width: 100%; }

/* --- Tables --- */
.table-wrap { overflow-x: auto; }
table.data-table { width: 100%; border-collapse: collapse; font-size: 14px; }
table.data-table th, table.data-table td { text-align: left; padding: 10px 12px; border-bottom: 1px solid var(--border); vertical-align: top; }
table.data-table th { color: var(--fg-muted); font-weight: 600; font-size: 12px; text-transform: uppercase; }
table.data-table tr:hover td { background: var(--bg-soft); }

/* --- Details / accordion (downgrade flow) --- */
details.asset-detail { border: 1px solid var(--border); border-radius: 8px; padding: 10px 14px; margin-bottom: 10px; background: var(--bg-elevated); }
details.asset-detail summary { cursor: pointer; font-weight: 600; display: flex; justify-content: space-between; align-items: center; gap: 10px; }
details.asset-detail .message-content { border-top: 1px solid var(--border); margin-top: 10px; padding-top: 10px; font-size: 14px; }

/* --- Spotlight tour --- */
.tour-overlay { position: fixed; inset: 0; background: rgba(0,0,0,0.6); z-index: 1000; }
.tour-tooltip { position: absolute; max-width: 320px; background: var(--bg-elevated); color: var(--fg); border-radius: 10px; box-shadow: var(--shadow-lg); padding: 16px; z-index: 1001; }
.tour-tooltip h4 { margin: 0 0 6px; }
.tour-tooltip p { margin: 0 0 12px; font-size: 13px; color: var(--fg-muted); }
.tour-highlight { position: relative; z-index: 1001; outline: 3px solid var(--gold); border-radius: 6px; background: var(--bg-elevated); }

/* --- Homepage --- */
.hero { display: grid; grid-template-columns: 1.15fr 1fr; gap: 40px; align-items: center; padding: 36px 0 20px; }
.hero h1 { font-size: 40px; margin: 0 0 14px; letter-spacing: -0.5px; }
.hero p.lead { font-size: 18px; color: var(--fg-muted); margin: 0 0 24px; }
.hero-art { width: 100%; height: auto; }
.section { padding: 40px 0 10px; }
.section h2 { font-size: 26px; margin: 0 0 6px; }
.section p.sub { color: var(--fg-muted); margin: 0 0 22px; font-size: 16px; }
.step { text-align: center; padding: 22px 18px; }
.step .step-num { display: inline-flex; width: 34px; height: 34px; border-radius: 999px; background: var(--accent-2); color: #fff; align-items: center; justify-content: center; font-weight: 700; margin-bottom: 10px; }
.step svg { width: 96px; height: 96px; margin: 6px auto 10px; display: block; }
.step h3 { margin: 6px 0; font-size: 17px; }
.step p { margin: 0; color: var(--fg-muted); font-size: 14px; }
.feature { display: flex; gap: 14px; align-items: flex-start; }
.feature svg { width: 34px; height: 34px; flex: none; color: var(--accent-2); }
.feature h4 { margin: 0 0 4px; }
.feature p { margin: 0; color: var(--fg-muted); font-size: 14px; }
.pricing { display: grid; grid-template-columns: repeat(3, 1fr); gap: 16px; }
.price-card { position: relative; }
.price-card.featured { border-color: var(--accent-2); box-shadow: var(--shadow-lg); }
.price-card .price { font-size: 32px; font-weight: 700; margin: 4px 0; }
.price-card .price small { font-size: 14px; color: var(--fg-muted); font-weight: 400; }
.price-card ul { padding-left: 18px; margin: 12px 0 18px; color: var(--fg-muted); font-size: 14px; line-height: 1.8; }
.faq details { border-bottom: 1px solid var(--border); padding: 12px 0; }
.faq summary { cursor: pointer; font-weight: 600; }
.faq p { color: var(--fg-muted); margin: 8px 0 0; font-size: 14px; }
@media (max-width: 760px) { .hero { grid-template-columns: 1fr; } .hero h1 { font-size: 30px; } .pricing { grid-template-columns: 1fr; } }

.qr { width: 200px; height: 200px; border: 1px solid var(--border); border-radius: 8px; padding: 6px; background: #fff; }
.mono { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; word-break: break-all; }
.text-center { text-align: center; }
.mt-0 { margin-top: 0; } .mt-1 { margin-top: 8px; } .mt-2 { margin-top: 16px; } .mt-3 { margin-top: 24px; }
.mb-0 { margin-bottom: 0; } .mb-2 { margin-bottom: 16px; }
.muted { color: var(--fg-muted); }
.small { font-size: 13px; }
.actions { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }

footer.site-footer { text-align: center; color: var(--fg-muted); font-size: 12px; padding: 32px 20px; }
footer.site-footer a { color: var(--fg-muted); }
