:root {
    --bg: #f3f4f1;
    --surface: #ffffff;
    --surface-soft: #f8f8f5;
    --ink: #17201d;
    --muted: #69736f;
    --line: #e1e4de;
    --brand: #2f6f55;
    --brand-dark: #1d4d39;
    --brand-soft: #e5f1ea;
    --accent: #d9a441;
    --danger: #b9473e;
    --warning: #a26b16;
    --shadow: 0 10px 30px rgba(23, 32, 29, .06);
    --radius: 18px;
    --font: Inter, ui-sans-serif, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* { box-sizing: border-box; }
html { color-scheme: light; }
body { margin: 0; background: var(--bg); color: var(--ink); font-family: var(--font); font-size: 15px; line-height: 1.5; }
a { color: var(--brand-dark); text-decoration: none; }
a:hover { color: var(--brand); }
h1, h2, h3, p { margin-top: 0; }
h1 { margin-bottom: 0; font-size: clamp(24px, 3vw, 34px); letter-spacing: -.04em; }
h2 { margin-bottom: 12px; font-size: 20px; letter-spacing: -.025em; }
small { color: var(--muted); display: block; font-size: 12px; font-weight: 500; }
.muted { color: var(--muted); }
.eyebrow { color: var(--muted); font-size: 11px; font-weight: 800; letter-spacing: .13em; margin-bottom: 4px; text-transform: uppercase; }
.grow { flex: 1; }
.hidden { display: none !important; }

.app-shell { min-height: 100vh; }
.sidebar {
    background: #17251f;
    bottom: 0;
    color: #fff;
    display: flex;
    flex-direction: column;
    left: 0;
    padding: 28px 20px;
    position: fixed;
    top: 0;
    width: 255px;
    z-index: 30;
}
.brand { align-items: center; color: inherit; display: flex; gap: 12px; }
.brand:hover { color: inherit; }
.brand-mark {
    align-items: center;
    background: linear-gradient(145deg, #78ae8e, #39765b);
    border: 1px solid rgba(255, 255, 255, .25);
    border-radius: 13px;
    box-shadow: inset 0 1px rgba(255, 255, 255, .25);
    color: white;
    display: flex;
    font-family: Georgia, serif;
    font-size: 23px;
    font-style: italic;
    height: 44px;
    justify-content: center;
    width: 44px;
}
.brand b { display: block; font-size: 18px; letter-spacing: -.02em; }
.brand small { color: rgba(255, 255, 255, .55); }
.nav { display: grid; gap: 5px; margin-top: 44px; }
.nav a { border-radius: 10px; color: rgba(255, 255, 255, .74); font-weight: 650; padding: 11px 13px; }
.nav a:hover { background: rgba(255, 255, 255, .08); color: white; }
.logout { margin-top: auto; }
.link-button { background: none; border: 0; color: rgba(255, 255, 255, .62); cursor: pointer; font: inherit; padding: 10px 13px; }
.link-button:hover { color: #fff; }
.main { margin-left: 255px; min-height: 100vh; min-width: 0; padding: 32px 38px 60px; }
.topbar { align-items: center; display: flex; justify-content: space-between; margin: 0 auto 28px; max-width: 1500px; }
.system-dot { align-items: center; color: var(--muted); display: flex; font-size: 12px; gap: 8px; }
.system-dot i { background: #51a46e; border: 4px solid #dff1e5; border-radius: 50%; height: 13px; width: 13px; }
.menu-button { display: none; }
.page-content { display: grid; gap: 22px; margin: 0 auto; max-width: 1500px; min-width: 0; }

.card {
    background: var(--surface);
    border: 1px solid rgba(23, 32, 29, .07);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    min-width: 0;
    padding: 24px;
}
.card-head { align-items: center; display: flex; gap: 16px; justify-content: space-between; margin-bottom: 20px; }
.card-head h2, .card-head p { margin-bottom: 0; }
.metric-grid { display: grid; gap: 16px; grid-template-columns: repeat(4, 1fr); }
.metric { background: var(--surface); border: 1px solid rgba(23, 32, 29, .07); border-radius: var(--radius); box-shadow: var(--shadow); padding: 23px; }
.metric span { color: var(--muted); display: block; font-size: 13px; font-weight: 650; }
.metric strong { display: block; font-size: 31px; letter-spacing: -.04em; margin: 7px 0 3px; }
.metric.accent { background: linear-gradient(140deg, #244f3e, #38745a); color: #fff; }
.metric.accent span, .metric.accent small { color: rgba(255, 255, 255, .7); }
.split { align-items: start; display: grid; gap: 22px; grid-template-columns: minmax(0, 1.65fr) minmax(310px, .75fr); min-width: 0; }
.split > * { min-width: 0; }
.stack { display: grid; gap: 16px; }
.gap-lg { gap: 22px; }

.button {
    align-items: center;
    border: 1px solid transparent;
    border-radius: 10px;
    cursor: pointer;
    display: inline-flex;
    font: inherit;
    font-size: 13px;
    font-weight: 750;
    justify-content: center;
    min-height: 40px;
    padding: 9px 15px;
    transition: .15s ease;
}
.button:hover { transform: translateY(-1px); }
.button-primary { background: var(--brand); color: #fff; }
.button-primary:hover { background: var(--brand-dark); color: #fff; }
.button-secondary { background: var(--surface); border-color: var(--line); color: var(--ink); }
.button-secondary:hover { border-color: #b8c3bd; color: var(--ink); }
.button-wide { width: 100%; }
.button-group, .actions-row, .inline-meta, .inline-form { align-items: center; display: flex; flex-wrap: wrap; gap: 10px; }
.actions-row { justify-content: space-between; }
.actions-row form { margin: 0; }
.text-link { font-size: 13px; font-weight: 700; }

.alert { border: 1px solid; border-radius: 12px; margin: 0 auto 16px; max-width: 1500px; padding: 12px 15px; }
.alert-success { background: #e9f5ed; border-color: #c4e1cc; color: #285f3b; }
.alert-error { background: #faecea; border-color: #edc9c5; color: #87372f; }
.alert-warning { background: #fff5df; border-color: #ecd29b; color: #765018; }
.badge { border-radius: 999px; display: inline-flex; font-size: 11px; font-weight: 800; padding: 5px 9px; white-space: nowrap; }
.badge-active, .badge-connected, .badge-published, .badge-completed, .badge-ready, .badge-used { background: #e3f2e8; color: #2c6c43; }
.badge-paused, .badge-new, .badge-draft, .badge-pending, .badge-planned { background: #edf0ed; color: #66716c; }
.badge-authorizing, .badge-running, .badge-publishing { background: #e7eff8; color: #38628e; }
.badge-failed, .badge-error, .badge-expired, .badge-skipped { background: #fae9e7; color: #963e36; }
.badge-outcome_unknown { background: #fff0d1; color: #865913; }

.table-wrap { overflow-x: auto; }
table { border-collapse: collapse; min-width: 700px; width: 100%; }
th { color: var(--muted); font-size: 11px; letter-spacing: .08em; padding: 0 12px 10px; text-align: left; text-transform: uppercase; }
td { border-top: 1px solid var(--line); padding: 13px 12px; vertical-align: middle; }
td:first-child, th:first-child { padding-left: 0; }
td:last-child, th:last-child { padding-right: 0; }
td a { font-weight: 700; }
.empty { color: var(--muted); padding: 50px 15px; text-align: center; }
.empty.compact { padding: 25px 10px; }
.activity-list, .account-list { display: grid; }
.activity-list article, .account-list article { align-items: center; border-top: 1px solid var(--line); display: flex; gap: 12px; padding: 14px 0; }
.activity-list article:first-child, .account-list article:first-child { border-top: 0; padding-top: 0; }
.activity-list p { color: var(--muted); font-size: 12px; margin: 4px 0 0; }
.account-list > .account-card { align-items: stretch; display: grid; gap: 14px; }
.account-summary { align-items: center; display: flex; gap: 12px; }
.account-summary form, .channel-actions form { margin: 0; }
.account-channels { background: var(--surface-soft); border: 1px solid var(--line); border-radius: 13px; display: grid; gap: 12px; padding: 14px; }
.account-channels-head { display: grid; gap: 3px; }
.account-channels-head small, .channel-copy small { color: var(--muted); font-size: 12px; }
.channel-list { display: grid; }
.channel-row { align-items: center; border-top: 1px solid var(--line); display: grid; gap: 14px; grid-template-columns: minmax(0, 1fr) auto; padding: 12px 0; }
.channel-row:first-child { border-top: 0; padding-top: 0; }
.channel-copy { display: grid; gap: 5px; min-width: 0; }
.channel-copy > div { align-items: center; display: flex; flex-wrap: wrap; gap: 8px; }
.channel-copy a { font-size: 12px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.channel-add { border-top: 1px solid var(--line); padding-top: 11px; }
.channel-add summary { color: var(--brand-dark); cursor: pointer; font-size: 13px; font-weight: 800; }
.channel-add-form { align-items: end; display: grid; gap: 10px; grid-template-columns: minmax(150px, .7fr) minmax(260px, 1.3fr) auto; padding-top: 12px; }
.danger-dot { background: var(--danger); border-radius: 50%; flex: 0 0 8px; height: 8px; }
.account-icon, .project-avatar { align-items: center; background: var(--brand-soft); border-radius: 12px; color: var(--brand-dark); display: flex; font-size: 19px; font-weight: 800; height: 42px; justify-content: center; width: 42px; }

label { color: #46514c; display: grid; font-size: 13px; font-weight: 700; gap: 7px; }
input, select, textarea {
    background: #fff;
    border: 1px solid #cfd5d1;
    border-radius: 10px;
    color: var(--ink);
    font: inherit;
    font-weight: 500;
    outline: none;
    padding: 11px 12px;
    width: 100%;
}
textarea { line-height: 1.55; resize: vertical; }
input:focus, select:focus, textarea:focus { border-color: #69a287; box-shadow: 0 0 0 3px rgba(70, 135, 102, .12); }
label small { font-weight: 500; }
.form-grid { display: grid; gap: 18px; grid-template-columns: repeat(2, minmax(0, 1fr)); }
.span-2 { grid-column: span 2; }
.form-note { background: var(--surface-soft); border-radius: 10px; color: var(--muted); font-size: 12px; margin: 16px 0 0; padding: 11px 13px; }
.form-actions { display: flex; gap: 10px; }
.price-input { min-width: 110px; padding: 8px 10px; }
.add-model { border-top: 1px solid var(--line); margin-top: 18px; padding-top: 16px; }
.add-model summary { color: var(--brand-dark); cursor: pointer; font-weight: 750; margin-bottom: 16px; }
.security-note { background: var(--brand-soft); border-radius: 12px; margin-top: 20px; padding: 15px; }
.security-note b { color: var(--brand-dark); }
.security-note p { color: #526d60; font-size: 12px; margin: 5px 0 0; }
.switch { align-items: center; display: flex; gap: 9px; }
.switch input { display: none; }
.switch span { background: #cfd5d1; border-radius: 20px; display: block; height: 22px; position: relative; transition: .2s; width: 40px; }
.switch span::after { background: #fff; border-radius: 50%; box-shadow: 0 1px 3px rgba(0, 0, 0, .2); content: ""; height: 16px; left: 3px; position: absolute; top: 3px; transition: .2s; width: 16px; }
.switch input:checked + span { background: var(--brand); }
.switch input:checked + span::after { transform: translateX(18px); }
.day-picker { display: flex; flex-wrap: wrap; gap: 7px; margin: 4px 0 18px; }
.day-picker label { display: block; }
.day-picker input { display: none; }
.day-picker span { align-items: center; background: var(--surface-soft); border: 1px solid var(--line); border-radius: 9px; cursor: pointer; display: flex; height: 39px; justify-content: center; width: 43px; }
.day-picker input:checked + span { background: var(--brand); border-color: var(--brand); color: #fff; }
.cost-preview { background: linear-gradient(140deg, #eef5f0, #f8f4e8); border: 1px solid #dce5df; border-radius: 13px; margin-top: 7px; padding: 16px; }
.cost-preview span, .cost-preview small { color: var(--muted); display: block; }
.cost-preview strong { display: block; font-size: 28px; letter-spacing: -.04em; margin: 3px 0; }

.project-grid { display: grid; gap: 18px; grid-template-columns: repeat(3, minmax(0, 1fr)); }
.project-card-head, .card-actions { align-items: center; display: flex; justify-content: space-between; }
.project-card h2 { margin: 18px 0 2px; }
.project-stats { display: grid; grid-template-columns: repeat(2, 1fr); margin: 22px 0; }
.project-stats div { border-left: 1px solid var(--line); padding-left: 14px; }
.project-stats div:first-child { border-left: 0; padding-left: 0; }
.project-stats dt { color: var(--muted); font-size: 11px; }
.project-stats dd { font-size: 18px; font-weight: 800; margin: 3px 0 0; }
.compact-grid { margin-bottom: 0; }
.details { margin: 0 0 20px; }
.details div { border-top: 1px solid var(--line); display: flex; gap: 12px; justify-content: space-between; padding: 10px 0; }
.details div:first-child { border-top: 0; }
.details dt { color: var(--muted); }
.details dd { font-weight: 700; margin: 0; text-align: right; }
.model-list, .usage-list { display: grid; }
.model-list div, .usage-list div { align-items: center; border-top: 1px solid var(--line); display: flex; justify-content: space-between; padding: 10px 0; }
.model-list div:first-child, .usage-list div:first-child { border-top: 0; }
.plan-list { display: grid; }
.plan-list article { align-items: center; border-top: 1px solid var(--line); display: grid; gap: 12px; grid-template-columns: 55px minmax(0, 1fr) auto; padding: 12px 0; }
.plan-list article:first-child { border-top: 0; }
.plan-list time { color: var(--brand-dark); font-size: 17px; font-weight: 800; }
.plan-list time small { font-size: 11px; }
.hint { color: var(--muted); font-size: 12px; }

.article-layout { align-items: start; display: grid; gap: 22px; grid-template-columns: minmax(0, 1.7fr) minmax(300px, .65fr); }
.article-preview { padding: clamp(25px, 5vw, 55px); }
.article-preview h2 { font-size: clamp(28px, 4vw, 44px); line-height: 1.12; }
.lead { color: #55605c; font-size: 18px; }
.article-body { font-family: Georgia, "Times New Roman", serif; font-size: 18px; line-height: 1.75; }
.article-body h2 { font-family: var(--font); font-size: 25px; margin-top: 35px; }
.article-body h3 { font-family: var(--font); font-size: 20px; margin-top: 28px; }
.article-cover { border-radius: 14px; display: block; height: auto; margin-bottom: 12px; max-height: 560px; object-fit: cover; width: 100%; }
.local-image-note { background: var(--surface-soft); border-radius: 10px; color: var(--muted); font-size: 12px; margin-bottom: 28px; padding: 12px; }
.filter-card { padding: 14px 18px; }
.bar-chart { display: grid; gap: 11px; }
.bar-chart > div { align-items: center; display: grid; gap: 12px; grid-template-columns: 45px minmax(0, 1fr) 80px; }
.bar-chart time { color: var(--muted); font-size: 12px; }
.bar-chart span { background: var(--surface-soft); border-radius: 999px; display: block; height: 9px; overflow: hidden; }
.bar-chart i { background: linear-gradient(90deg, var(--brand), #8aaf8d); border-radius: inherit; display: block; height: 100%; }
.bar-chart b { font-size: 12px; text-align: right; }

.auth-browser { padding: 18px; }
.browser-toolbar { align-items: center; background: #e9ece9; border-radius: 11px 11px 0 0; display: flex; gap: 8px; padding: 9px; }
.browser-url { background: #fff; border-radius: 8px; color: var(--muted); flex: 1; font-size: 12px; overflow: hidden; padding: 9px 12px; text-overflow: ellipsis; white-space: nowrap; }
.browser-stage { align-items: center; background: #222; display: flex; justify-content: center; min-height: 450px; overflow: hidden; position: relative; }
.browser-stage img { cursor: crosshair; display: none; height: auto; max-height: 72vh; max-width: 100%; object-fit: contain; user-select: none; }
.browser-loading { color: rgba(255, 255, 255, .65); }
.browser-input { display: flex; gap: 8px; padding: 13px 0 0; }
.browser-footer { align-items: center; display: flex; gap: 18px; justify-content: space-between; padding-top: 13px; }
.browser-footer p { margin: 0; }

.login-page { align-items: center; background: radial-gradient(circle at top left, #dcebe1, transparent 40%), #eef0ec; display: flex; justify-content: center; min-height: 100vh; padding: 24px; }
.login-card { background: #fff; border: 1px solid rgba(23, 32, 29, .08); border-radius: 24px; box-shadow: 0 25px 70px rgba(23, 32, 29, .12); display: grid; gap: 25px; max-width: 450px; padding: clamp(28px, 6vw, 48px); width: 100%; }
.login-brand { color: var(--ink); }
.login-brand small { color: var(--muted); }

.install-page {
    background:
        radial-gradient(circle at 10% 0, rgba(69, 128, 94, .16), transparent 34%),
        var(--bg);
    min-height: 100vh;
    padding: 34px 18px 70px;
}
.install-shell { display: grid; gap: 20px; margin: 0 auto; max-width: 880px; }
.install-hero { padding: 18px 8px 8px; }
.install-hero .brand { margin-bottom: 32px; width: max-content; }
.install-hero h1 { font-size: clamp(34px, 6vw, 54px); margin-bottom: 12px; }
.install-hero > p:last-child { font-size: 17px; max-width: 720px; }
.install-checks { padding-bottom: 18px; }
.check-grid { display: grid; gap: 10px; grid-template-columns: repeat(2, minmax(0, 1fr)); }
.check-item {
    align-items: center;
    background: var(--surface-soft);
    border: 1px solid var(--line);
    border-radius: 12px;
    display: flex;
    gap: 11px;
    min-width: 0;
    padding: 12px;
}
.check-item > span {
    align-items: center;
    border-radius: 50%;
    display: flex;
    flex: 0 0 26px;
    font-size: 13px;
    font-weight: 900;
    height: 26px;
    justify-content: center;
}
.check-item.is-ok > span { background: #dff1e5; color: #2d7145; }
.check-item.is-warning > span { background: #fff0d1; color: #865913; }
.check-item b { display: block; font-size: 13px; }
.install-submit { font-size: 16px; min-height: 54px; }
.install-caption { font-size: 12px; margin: -8px 0 0; text-align: center; }

.setup-complete { align-items: center; background: linear-gradient(135deg, #eef7f1, #fff); display: flex; gap: 18px; }
.setup-complete h2, .setup-complete p { margin-bottom: 4px; }
.setup-check, .runtime-icon {
    align-items: center;
    background: #dff1e5;
    border-radius: 50%;
    color: #2d7145;
    display: flex;
    flex: 0 0 auto;
    font-weight: 900;
    justify-content: center;
}
.setup-check { font-size: 24px; height: 54px; width: 54px; }
.runtime-grid { display: grid; gap: 12px; grid-template-columns: repeat(2, minmax(0, 1fr)); }
.runtime-item {
    align-items: center;
    background: var(--surface-soft);
    border: 1px solid var(--line);
    border-radius: 13px;
    display: flex;
    gap: 13px;
    min-width: 0;
    padding: 15px;
}
.runtime-item h3, .runtime-item p { margin: 0; }
.runtime-item h3 { font-size: 15px; }
.runtime-item p { color: #46514c; font-size: 13px; }
.runtime-item small { margin-top: 3px; }
.runtime-icon { height: 34px; width: 34px; }
.runtime-item.is-warning { background: #fffaf0; border-color: #ecd9ad; }
.runtime-item.is-warning .runtime-icon { background: #fff0d1; color: #865913; }
.manual-setup { background: #fff8e9; border: 1px solid #ecd9ad; border-radius: 13px; display: grid; gap: 10px; margin-top: 16px; padding: 17px; }
.manual-setup h3, .manual-setup p { margin-bottom: 4px; }
.manual-setup code { background: #262d2a; border-radius: 8px; color: #eaf4ed; display: block; font-size: 12px; overflow-wrap: anywhere; padding: 11px 12px; user-select: all; }
.next-steps { align-items: center; display: flex; gap: 20px; justify-content: space-between; }
.next-steps h2, .next-steps p { margin-bottom: 5px; }
.runtime-intro { margin: -7px 0 18px; }

@media (max-width: 1120px) {
    .metric-grid { grid-template-columns: repeat(2, 1fr); }
    .project-grid { grid-template-columns: repeat(2, 1fr); }
    .split, .article-layout { grid-template-columns: 1fr; }
}

@media (max-width: 760px) {
    .sidebar { transform: translateX(-100%); transition: transform .2s ease; }
    body.menu-open .sidebar { transform: translateX(0); }
    .main { margin-left: 0; padding: 22px 15px 45px; }
    .menu-button { background: #fff; border: 1px solid var(--line); border-radius: 9px; display: block; font-size: 18px; padding: 7px 10px; }
    .topbar { justify-content: flex-start; gap: 14px; }
    .system-dot { margin-left: auto; }
    .metric-grid, .project-grid, .form-grid { grid-template-columns: 1fr; }
    .span-2 { grid-column: auto; }
    .card { border-radius: 14px; padding: 18px; }
    .card-head, .actions-row, .browser-footer { align-items: stretch; flex-direction: column; }
    .account-summary, .channel-row { align-items: stretch; grid-template-columns: 1fr; }
    .account-summary { display: grid; }
    .channel-add-form { grid-template-columns: 1fr; }
    .browser-stage { min-height: 300px; }
    .browser-input { flex-direction: column; }
    .check-grid { grid-template-columns: 1fr; }
    .runtime-grid { grid-template-columns: 1fr; }
    .setup-complete, .next-steps { align-items: flex-start; flex-direction: column; }
}
