:root {
    --bg: #0d1224;
    --surface: #161b30;
    --border: #283054;
    --fg: #e7e9f0;
    --muted: #8a8fa3;
    --up: #22c55e;
    --down: #ef4444;
    --be: #94a3b8;
    --warn: #f59e0b;
}

* { box-sizing: border-box; }

html, body {
    margin: 0;
    padding: 0;
    background: var(--bg);
    color: var(--fg);
}

body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    font-size: 14px;
    line-height: 1.5;
}

main {
    max-width: 1100px;
    margin: 0 auto;
    padding: 1.5rem;
}

header {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    margin-bottom: 1.5rem;
    padding-bottom: 1rem;
    border-bottom: 1px solid var(--border);
}

h1 { margin: 0; font-size: 1.5rem; letter-spacing: 0.02em; }

h2 {
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: var(--muted);
    margin: 0 0 0.75rem;
    font-weight: 600;
}

section { margin-bottom: 2rem; }

.muted { color: var(--muted); font-size: 0.85rem; }
code {
    background: var(--surface);
    padding: 1px 6px;
    border-radius: 3px;
    font-size: 0.85em;
}

/* ---------- Stats grid ---------- */
.stats {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
    gap: 0.75rem;
    margin-bottom: 2rem;
}
.stat {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 0.85rem 1rem;
}
.stat .label {
    font-size: 0.7rem;
    color: var(--muted);
    text-transform: uppercase;
    letter-spacing: 0.06em;
}
.stat .value {
    font-size: 1.4rem;
    font-weight: 600;
    margin-top: 0.25rem;
    font-variant-numeric: tabular-nums;
}
.stat .sub {
    margin-top: 0.25rem;
    font-size: 0.75rem;
}
.value.up { color: var(--up); }
.value.down { color: var(--down); }

/* ---------- Open trade card ---------- */
.trade-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 1rem;
}
.trade-card + .trade-card {
    margin-top: 0.75rem;
}
.card-row {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    margin-bottom: 0.75rem;
    flex-wrap: wrap;
}
.trade-title {
    display: flex;
    align-items: center;
    gap: 0.65rem;
    min-width: 0;
}
.pair { font-weight: 700; font-size: 1.2rem; letter-spacing: 0.02em; }

.actions {
    display: inline-flex;
    gap: 0.35rem;
    margin-left: auto;
    align-items: center;
}

.action-button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 30px;
    min-width: 72px;
    padding: 0.36rem 0.7rem;
    border: 1px solid transparent;
    border-radius: 6px;
    font: inherit;
    font-size: 0.76rem;
    font-weight: 700;
    cursor: pointer;
    text-decoration: none;
    transition: background 140ms ease, border-color 140ms ease, color 140ms ease;
}

.action-button.edit {
    background: rgba(148, 163, 184, 0.11);
    border-color: rgba(148, 163, 184, 0.26);
    color: var(--fg);
}

.action-button.edit:hover {
    background: rgba(96, 165, 250, 0.18);
    border-color: rgba(96, 165, 250, 0.46);
    color: #dbeafe;
}

.action-button.delete {
    background: rgba(239, 68, 68, 0.1);
    border-color: rgba(239, 68, 68, 0.28);
    color: #fca5a5;
}

.action-button.delete:hover {
    background: rgba(239, 68, 68, 0.18);
    border-color: rgba(239, 68, 68, 0.48);
    color: #fecaca;
}

.small-action,
button.small-action {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 30px;
    padding: 0.35rem 0.65rem;
    border: 1px solid var(--border);
    border-radius: 6px;
    background: rgba(148, 163, 184, 0.08);
    color: var(--fg);
    text-decoration: none;
    font: inherit;
    font-size: 0.8rem;
    cursor: pointer;
}

.small-action:hover {
    background: rgba(148, 163, 184, 0.16);
}

.small-action.danger {
    color: #fca5a5;
    border-color: rgba(239, 68, 68, 0.4);
    background: rgba(239, 68, 68, 0.08);
}

.side, .outcome {
    display: inline-block;
    padding: 2px 8px;
    border-radius: 4px;
    font-size: 0.7rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.06em;
}
.side.long, .outcome.win { background: rgba(34, 197, 94, 0.15); color: var(--up); }
.side.short, .outcome.loss { background: rgba(239, 68, 68, 0.15); color: var(--down); }
.outcome.breakeven { background: rgba(148, 163, 184, 0.15); color: var(--be); }

.card-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
    gap: 0.4rem 1rem;
    font-variant-numeric: tabular-nums;
}
.card-grid .label {
    color: var(--muted);
    font-size: 0.7rem;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    margin-right: 0.4rem;
}
.note {
    margin-top: 0.75rem;
    padding-top: 0.75rem;
    border-top: 1px solid var(--border);
    font-style: italic;
    color: var(--muted);
}

/* ---------- Empty state ---------- */
.empty {
    background: var(--surface);
    border: 1px dashed var(--border);
    border-radius: 8px;
    padding: 1.25rem;
    text-align: center;
    color: var(--muted);
}

/* ---------- Closed trades table ---------- */
.table-wrap {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 8px;
    overflow-x: auto;
}
table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.85rem;
    font-variant-numeric: tabular-nums;
}
th, td {
    padding: 0.55rem 0.75rem;
    text-align: left;
    border-bottom: 1px solid var(--border);
    white-space: nowrap;
}
th {
    background: rgba(255, 255, 255, 0.02);
    font-size: 0.65rem;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--muted);
    font-weight: 600;
}
tbody tr:last-child td { border-bottom: none; }
tbody tr:hover { background: rgba(255, 255, 255, 0.02); }

td.r { font-weight: 600; }
td.r.up { color: var(--up); }
td.r.down { color: var(--down); }

.note-cell {
    color: var(--muted);
    max-width: 240px;
    overflow: hidden;
    text-overflow: ellipsis;
}

.admin-table td {
    vertical-align: top;
}

.admin-table strong {
    color: var(--fg);
}

.status-pill {
    display: inline-block;
    padding: 2px 8px;
    border-radius: 4px;
    font-size: 0.7rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.06em;
}

.status-pill.active {
    background: rgba(34, 197, 94, 0.15);
    color: var(--up);
}

.status-pill.inactive,
.status-pill.disabled,
.status-pill.disconnected,
.status-pill.idle {
    background: rgba(148, 163, 184, 0.15);
    color: var(--be);
}

.status-pill.ok {
    background: rgba(34, 197, 94, 0.15);
    color: var(--up);
}

.status-pill.warn {
    background: rgba(245, 158, 11, 0.15);
    color: var(--warn);
}

.status-pill.error {
    background: rgba(239, 68, 68, 0.15);
    color: var(--down);
}

.health-panel .status-pill {
    font-size: 0.8rem;
}

.error-text {
    color: var(--down);
}

/* ---------- Footer ---------- */
footer {
    margin-top: 2rem;
    padding-top: 1rem;
    border-top: 1px solid var(--border);
    text-align: center;
}

/* ---------- Login ---------- */
.login-main {
    min-height: 100vh;
    display: grid;
    place-items: center;
    padding: 1rem;
}
.login-panel {
    width: min(460px, 100%);
    margin: 0;
    padding: 1.25rem;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 8px;
    box-shadow: 0 24px 80px rgba(0, 0, 0, 0.24);
}
.login-brand {
    display: grid;
    grid-template-columns: 36px 1fr;
    gap: 0.85rem;
    align-items: center;
    margin-bottom: 1rem;
}
.login-brand img {
    display: block;
    border-radius: 8px;
}
.login-brand h1 {
    margin: 0;
}
.login-brand p {
    margin: 0.15rem 0 0;
    color: var(--muted);
    font-size: 0.9rem;
    line-height: 1.35;
}
.auth-error {
    margin-bottom: 1rem;
    color: var(--down);
}
.telegram-login-box {
    display: grid;
    place-items: center;
    min-height: 58px;
    padding: 0.75rem;
    background: rgba(148, 163, 184, 0.08);
    border: 1px solid var(--border);
    border-radius: 8px;
    text-align: center;
}
.telegram-login-box iframe {
    color-scheme: light;
}
.local-note {
    margin-top: 0.75rem;
    padding: 0.75rem;
    background: rgba(148, 163, 184, 0.12);
    border: 1px solid var(--border);
    border-radius: 8px;
    color: var(--muted);
    font-size: 0.85rem;
}
.setup-panel {
    text-align: left;
}
.setup-list {
    margin: 0 0 1.25rem;
    padding: 0;
    list-style: none;
    counter-reset: setup-step;
}
.setup-list li {
    counter-increment: setup-step;
    display: grid;
    grid-template-columns: 2rem 1fr;
    gap: 0.75rem;
    align-items: start;
    padding: 0.8rem 0;
    border-top: 1px solid var(--border);
}
.setup-list li:last-child {
    border-bottom: 1px solid var(--border);
}
.setup-list li::before {
    content: counter(setup-step);
    display: grid;
    place-items: center;
    width: 2rem;
    height: 2rem;
    border: 1px solid var(--border);
    border-radius: 999px;
    color: var(--fg);
    font-weight: 700;
    font-variant-numeric: tabular-nums;
}
.primary-action {
    display: block;
    width: 100%;
    padding: 0.75rem 1rem;
    border-radius: 8px;
    background: var(--up);
    color: #06140b;
    text-align: center;
    text-decoration: none;
    font-weight: 700;
}

.primary-action.compact,
.danger-button {
    display: inline-flex;
    min-width: 132px;
    height: 40px;
    align-items: center;
    justify-content: center;
    padding: 0 1rem;
    border: 1px solid transparent;
    border-radius: 7px;
    cursor: pointer;
    font: inherit;
    font-size: 0.8rem;
    font-weight: 700;
    line-height: 1;
    text-decoration: none;
    transition: background 140ms ease, border-color 140ms ease, color 140ms ease;
}

.primary-action.compact {
    width: auto;
    background: var(--up);
    border-color: rgba(34, 197, 94, 0.58);
    color: #06140b;
}

.primary-action.compact:hover {
    background: #4ade80;
    border-color: rgba(74, 222, 128, 0.72);
}

.danger-button {
    background: rgba(239, 68, 68, 0.14);
    border-color: rgba(239, 68, 68, 0.42);
    color: #fecaca;
}

.danger-button:hover {
    background: rgba(239, 68, 68, 0.24);
    border-color: rgba(239, 68, 68, 0.62);
    color: #fff;
}

.trade-form,
.confirm-panel {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 1rem;
}

.form-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(210px, 1fr));
    gap: 0.85rem;
}

.trade-form label,
.full-field {
    display: grid;
    gap: 0.35rem;
}

.trade-form label span {
    color: var(--muted);
    font-size: 0.7rem;
    font-weight: 600;
    letter-spacing: 0.06em;
    text-transform: uppercase;
}

input,
select,
textarea {
    width: 100%;
    min-height: 38px;
    border: 1px solid var(--border);
    border-radius: 6px;
    background: #10162a;
    color: var(--fg);
    font: inherit;
    padding: 0.55rem 0.65rem;
}

textarea {
    resize: vertical;
}

label small,
.form-error {
    color: #fca5a5;
}

.full-field {
    margin-top: 0.85rem;
}

.form-actions {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    margin-top: 1rem;
    flex-wrap: wrap;
}

.confirm-panel p {
    margin: 0.5rem 0 0;
}

/* ---------- Dashboard modals ---------- */
body.modal-open {
    overflow: hidden;
}

.modal-shell {
    position: fixed;
    inset: 0;
    z-index: 20;
    display: grid;
    place-items: center;
    min-height: 100dvh;
    padding: 1.25rem;
    padding-top: max(1.25rem, env(safe-area-inset-top));
    padding-bottom: max(1.25rem, env(safe-area-inset-bottom));
}

.modal-shell[hidden] {
    display: none;
}

.modal-backdrop {
    position: absolute;
    inset: 0;
    background: rgba(4, 8, 20, 0.74);
    backdrop-filter: blur(8px);
}

.modal-panel {
    position: relative;
    width: min(860px, 100%);
    max-height: min(760px, calc(100dvh - 2.5rem - env(safe-area-inset-top) - env(safe-area-inset-bottom)));
    overflow: auto;
    overscroll-behavior: contain;
    -webkit-overflow-scrolling: touch;
    background: #151b31;
    border: 1px solid rgba(148, 163, 184, 0.24);
    border-radius: 8px;
    box-shadow: 0 24px 80px rgba(0, 0, 0, 0.44);
    outline: none;
}

.modal-panel::before {
    content: "";
    position: absolute;
    inset: 0;
    pointer-events: none;
    border-radius: inherit;
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.04);
}

.modal-panel [hidden] {
    display: none !important;
}

.modal-head {
    position: sticky;
    top: 0;
    z-index: 1;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    padding: 1rem 1rem 0.85rem;
    background: rgba(21, 27, 49, 0.96);
    border-bottom: 1px solid var(--border);
}

.modal-head h1 {
    font-size: 1.15rem;
}

.modal-head p {
    margin: 0.2rem 0 0;
}

.icon-action {
    display: inline-grid;
    place-items: center;
    width: 36px;
    height: 36px;
    border: 1px solid var(--border);
    border-radius: 7px;
    background: rgba(148, 163, 184, 0.09);
    color: var(--fg);
    cursor: pointer;
    font: inherit;
    font-size: 1.25rem;
    line-height: 1;
}

.icon-action:hover {
    background: rgba(148, 163, 184, 0.18);
}

.modal-form,
.delete-confirm {
    border: 0;
    border-radius: 0;
    background: transparent;
    padding: 1rem;
}

.modal-actions {
    justify-content: flex-end;
    padding-top: 0.25rem;
}

.modal-actions .small-action {
    min-width: 132px;
    height: 40px;
    padding: 0 1rem;
    border-radius: 7px;
    font-size: 0.8rem;
    font-weight: 700;
    line-height: 1;
}

.delete-confirm {
    display: grid;
    gap: 1rem;
}

.delete-summary {
    padding: 1rem;
    border: 1px solid rgba(239, 68, 68, 0.3);
    border-radius: 8px;
    background: rgba(239, 68, 68, 0.08);
}

.delete-summary strong {
    display: block;
    margin-top: 0.25rem;
    font-size: 1.1rem;
}

.delete-summary p {
    margin: 0.5rem 0 0;
}

.delete-kicker {
    display: block;
    color: #fca5a5;
    font-size: 0.7rem;
    font-weight: 700;
    letter-spacing: 0.08em;
    text-transform: uppercase;
}

/* ---------- Landing page ---------- */
.landing-page {
    --landing-bg: #f5f7fb;
    --landing-ink: #111827;
    --landing-muted: #64748b;
    --landing-line: #d8dee9;
    --landing-panel: #ffffff;
    --landing-dark: #101525;
    background:
        linear-gradient(180deg, #ffffff 0, var(--landing-bg) 460px, #eef3f7 100%);
    color: var(--landing-ink);
}

.landing-page .landing-shell {
    max-width: 1180px;
    padding: 1.1rem 1.5rem 2rem;
}

.landing-nav {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    min-height: 58px;
    margin-bottom: 2.2rem;
}

.landing-brand,
.landing-nav a {
    color: var(--landing-ink);
    text-decoration: none;
}

.landing-brand {
    display: inline-flex;
    align-items: center;
    gap: 0.65rem;
    font-weight: 800;
}

.landing-brand img {
    border-radius: 8px;
    box-shadow: 0 8px 24px rgba(15, 23, 42, 0.14);
}

.landing-nav-actions {
    display: inline-flex;
    align-items: center;
    gap: 1rem;
    color: var(--landing-muted);
    font-size: 0.9rem;
}

.landing-nav-actions a:not(.nav-pill) {
    color: var(--landing-muted);
}

.landing-nav-actions a:hover {
    color: var(--landing-ink);
}

.nav-pill {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 36px;
    padding: 0 0.9rem;
    border: 1px solid var(--landing-line);
    border-radius: 8px;
    background: rgba(255, 255, 255, 0.72);
    box-shadow: 0 10px 28px rgba(15, 23, 42, 0.08);
}

.landing-hero {
    display: grid;
    grid-template-columns: minmax(0, 0.88fr) minmax(480px, 1.12fr);
    gap: 2.2rem;
    align-items: center;
    min-height: min(570px, calc(100vh - 9.5rem));
    padding-bottom: 1.5rem;
}

.hero-copy {
    min-width: 0;
}

.eyebrow {
    margin: 0 0 0.8rem;
    color: #0f766e;
    font-size: 0.75rem;
    font-weight: 800;
    letter-spacing: 0.08em;
    text-transform: uppercase;
}

.hero-copy h1 {
    max-width: 660px;
    margin: 0;
    color: var(--landing-ink);
    font-size: clamp(3rem, 7vw, 5.7rem);
    line-height: 0.94;
    letter-spacing: 0;
}

.hero-lede {
    max-width: 590px;
    margin: 1.2rem 0 0;
    color: #475569;
    font-size: 1.16rem;
    line-height: 1.65;
}

.hero-actions {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    margin-top: 1.6rem;
    flex-wrap: wrap;
}

.hero-primary,
.hero-secondary {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 46px;
    padding: 0 1.15rem;
    border-radius: 8px;
    font-weight: 800;
    text-decoration: none;
}

.hero-primary {
    background: #16a34a;
    color: #ffffff;
    box-shadow: 0 16px 34px rgba(22, 163, 74, 0.24);
}

.hero-primary:hover {
    background: #15803d;
}

.hero-secondary {
    border: 1px solid var(--landing-line);
    background: #ffffff;
    color: var(--landing-ink);
}

.hero-secondary:hover {
    border-color: #aeb8c7;
}

.hero-proof {
    display: flex;
    flex-wrap: wrap;
    gap: 0.55rem;
    margin-top: 1.25rem;
}

.hero-proof span {
    display: inline-flex;
    align-items: center;
    min-height: 28px;
    padding: 0 0.65rem;
    border: 1px solid rgba(20, 184, 166, 0.28);
    border-radius: 6px;
    background: rgba(20, 184, 166, 0.08);
    color: #115e59;
    font-size: 0.78rem;
    font-weight: 700;
}

.product-stage {
    position: relative;
    min-height: 520px;
    border-radius: 8px;
}

.product-stage::before {
    content: "";
    position: absolute;
    inset: 4rem 2rem 3rem;
    border-radius: 8px;
    background:
        radial-gradient(circle at 72% 24%, rgba(34, 197, 94, 0.2), transparent 36%),
        radial-gradient(circle at 28% 84%, rgba(14, 165, 233, 0.18), transparent 34%),
        #e8edf5;
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.7);
}

.telegram-window,
.dashboard-window {
    position: absolute;
    border: 1px solid rgba(148, 163, 184, 0.28);
    border-radius: 8px;
    background: var(--landing-dark);
    color: #e5edf8;
    box-shadow: 0 28px 80px rgba(15, 23, 42, 0.24);
}

.telegram-window {
    top: 0;
    left: 0;
    width: min(410px, 72%);
    padding: 0.85rem;
}

.dashboard-window {
    right: 0;
    bottom: 0;
    width: min(470px, 78%);
    padding: 1rem;
    background: #ffffff;
    color: var(--landing-ink);
}

.window-bar {
    display: flex;
    gap: 0.35rem;
    margin-bottom: 1rem;
}

.window-bar span {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    background: #ef4444;
}

.window-bar span:nth-child(2) {
    background: #f59e0b;
}

.window-bar span:nth-child(3) {
    background: #22c55e;
}

.chat-line {
    display: grid;
    gap: 0.18rem;
    max-width: 92%;
    margin-top: 0.75rem;
    padding: 0.75rem;
    border-radius: 8px;
    font-size: 0.86rem;
    line-height: 1.45;
}

.chat-line.user {
    margin-left: auto;
    background: #16a34a;
    color: #ffffff;
    font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
    font-size: 0.78rem;
}

.chat-line.bot {
    background: rgba(255, 255, 255, 0.08);
    border: 1px solid rgba(255, 255, 255, 0.08);
}

.chat-line.compact {
    background: rgba(14, 165, 233, 0.16);
    border-color: rgba(14, 165, 233, 0.24);
}

.dashboard-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    margin-bottom: 0.85rem;
}

.dashboard-head strong {
    display: block;
    margin-top: 0.15rem;
    font-size: 1.1rem;
}

.micro-label,
.mini-stats span {
    display: block;
    color: var(--landing-muted);
    font-size: 0.68rem;
    font-weight: 800;
    letter-spacing: 0.08em;
    text-transform: uppercase;
}

.status-dot {
    display: inline-flex;
    min-height: 26px;
    align-items: center;
    padding: 0 0.55rem;
    border-radius: 6px;
    background: rgba(34, 197, 94, 0.12);
    color: #15803d;
    font-size: 0.72rem;
    font-weight: 800;
}

.mini-stats {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 0.55rem;
    margin-bottom: 0.8rem;
}

.mini-stats div,
.trade-strip {
    border: 1px solid var(--landing-line);
    border-radius: 8px;
    background: #f8fafc;
}

.mini-stats div {
    padding: 0.72rem;
}

.mini-stats strong {
    display: block;
    margin-top: 0.25rem;
    color: #0f766e;
    font-size: 1.15rem;
}

.trade-strip {
    display: grid;
    grid-template-columns: 1fr auto auto;
    align-items: center;
    gap: 0.7rem;
    min-height: 46px;
    padding: 0 0.75rem;
    margin-top: 0.55rem;
    font-variant-numeric: tabular-nums;
}

.trade-strip span {
    font-weight: 800;
}

.trade-strip b {
    padding: 0.13rem 0.45rem;
    border-radius: 4px;
    font-size: 0.66rem;
    letter-spacing: 0.06em;
}

.trade-strip b.long {
    background: rgba(34, 197, 94, 0.14);
    color: #15803d;
}

.trade-strip b.short {
    background: rgba(239, 68, 68, 0.12);
    color: #dc2626;
}

.trade-strip.active {
    border-color: rgba(14, 165, 233, 0.32);
    background: rgba(14, 165, 233, 0.08);
}

.landing-section {
    margin-bottom: 5.5rem;
}

.section-heading {
    max-width: 650px;
    margin-bottom: 1.65rem;
}

.landing-section h2,
.landing-cta h2 {
    margin: 0;
    color: var(--landing-ink);
    font-size: clamp(2rem, 4vw, 3.2rem);
    line-height: 1.02;
    letter-spacing: 0;
    text-transform: none;
}

.workflow-grid,
.setup-grid,
.feature-layout {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 0.85rem;
}

.workflow-grid article,
.setup-card,
.feature-panel,
.security-section,
.landing-cta {
    border: 1px solid var(--landing-line);
    border-radius: 8px;
    background: rgba(255, 255, 255, 0.8);
    box-shadow: 0 18px 50px rgba(15, 23, 42, 0.07);
}

.workflow-grid article,
.setup-card,
.feature-panel {
    padding: 1rem;
}

.step-number {
    display: grid;
    place-items: center;
    width: 34px;
    height: 34px;
    margin-bottom: 1.1rem;
    border-radius: 8px;
    background: #111827;
    color: #ffffff;
    font-weight: 900;
    font-variant-numeric: tabular-nums;
}

.workflow-grid h3,
.setup-card h3,
.feature-panel h3 {
    margin: 0;
    color: var(--landing-ink);
    font-size: 1rem;
}

.workflow-grid p,
.setup-card p,
.feature-panel p,
.security-copy p,
.security-list span {
    margin: 0.45rem 0 0;
    color: var(--landing-muted);
    line-height: 1.62;
}

.setup-grid {
    grid-template-columns: repeat(4, minmax(0, 1fr));
}

.setup-card code {
    background: rgba(15, 23, 42, 0.06);
    color: var(--landing-ink);
}

.feature-layout {
    grid-template-columns: repeat(4, minmax(0, 1fr));
}

.feature-panel {
    min-height: 178px;
}

.security-section {
    display: grid;
    grid-template-columns: minmax(0, 0.9fr) minmax(360px, 1.1fr);
    gap: 1.2rem;
    padding: 1.2rem;
    align-items: center;
}

.security-copy {
    padding: 0.5rem;
}

.security-list {
    display: grid;
    gap: 0.65rem;
}

.security-list div {
    display: grid;
    gap: 0.18rem;
    padding: 0.85rem;
    border: 1px solid var(--landing-line);
    border-radius: 8px;
    background: #f8fafc;
}

.security-list strong {
    color: var(--landing-ink);
}

.landing-cta {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 2rem;
    margin-bottom: 1rem;
    padding: 2rem;
    background: #111827;
}

.landing-cta h2 {
    max-width: 700px;
    color: #ffffff;
}

.cta-copy {
    display: grid;
    gap: 0.75rem;
    max-width: 740px;
}

.cta-copy p {
    max-width: 590px;
    margin: 0;
    color: #cbd5e1;
    font-size: 1rem;
    line-height: 1.6;
}

.landing-cta .hero-actions {
    margin-top: 0;
    flex: 0 0 auto;
    justify-content: flex-end;
}

.landing-cta .hero-secondary {
    background: transparent;
    border-color: rgba(255, 255, 255, 0.22);
    color: #ffffff;
}

.site-footer {
    width: 100%;
    margin: 5rem 0 0;
    padding: 0;
    border-top: 1px solid var(--landing-line);
    background: #ffffff;
    color: var(--landing-ink);
    text-align: left;
}

.footer-inner,
.footer-bottom {
    width: min(1180px, calc(100% - 3rem));
    margin: 0 auto;
}

.footer-inner {
    display: grid;
    grid-template-columns: minmax(280px, 1fr) auto;
    gap: 2rem;
    padding: 2rem 0;
}

.footer-brand p {
    max-width: 460px;
    margin: 0.8rem 0 0;
    color: var(--landing-muted);
    line-height: 1.6;
}

.footer-links {
    display: grid;
    grid-template-columns: repeat(2, minmax(120px, 1fr));
    gap: 2rem;
}

.footer-links div {
    display: grid;
    gap: 0.55rem;
}

.footer-links strong {
    color: var(--landing-ink);
}

.footer-links a {
    color: var(--landing-muted);
    text-decoration: none;
}

.footer-links a:hover {
    color: var(--landing-ink);
}

.footer-bottom {
    display: flex;
    justify-content: space-between;
    gap: 1rem;
    padding: 1rem 0;
    border-top: 1px solid var(--landing-line);
    color: var(--landing-muted);
    font-size: 0.85rem;
}

/* ---------- Mobile ---------- */
@media (max-width: 720px) {
    main { padding: 1rem; }
    header { flex-direction: column; align-items: flex-start; gap: 0.25rem; }
    .stats { grid-template-columns: 1fr 1fr; }
    th, td { padding: 0.4rem 0.55rem; }
    .note-cell { max-width: 100px; }
    .pair { font-size: 1.05rem; }
    .actions { margin-left: auto; }
    .table-actions { width: auto; }
    .modal-shell {
        align-items: start;
        justify-items: center;
        padding: 1rem 0.75rem;
        padding-top: max(1rem, env(safe-area-inset-top));
        padding-bottom: max(1rem, env(safe-area-inset-bottom));
    }
    .modal-panel {
        max-height: calc(100dvh - 2rem - env(safe-area-inset-top) - env(safe-area-inset-bottom));
        width: 100%;
    }
    .modal-head {
        padding: 0.85rem 0.85rem 0.75rem;
    }
    .modal-form,
    .delete-confirm {
        padding: 0.85rem;
        padding-bottom: max(0.85rem, env(safe-area-inset-bottom));
    }
    .modal-form input,
    .modal-form select,
    .modal-form textarea {
        font-size: 16px;
    }
    .modal-actions {
        justify-content: stretch;
        position: sticky;
        bottom: -0.85rem;
        margin: 1rem -0.85rem -0.85rem;
        padding: 0.85rem;
        padding-bottom: max(0.85rem, env(safe-area-inset-bottom));
        border-top: 1px solid var(--border);
        background: rgba(21, 27, 49, 0.98);
    }
    .modal-actions > * {
        flex: 1 1 140px;
    }
}

@media (max-width: 980px) {
    .landing-hero {
        grid-template-columns: 1fr;
        min-height: 0;
        padding-bottom: 2.2rem;
    }
    .product-stage {
        min-height: 500px;
    }
    .workflow-grid,
    .setup-grid,
    .feature-layout,
    .security-section {
        grid-template-columns: 1fr 1fr;
    }
    .security-copy {
        grid-column: 1 / -1;
    }
    .landing-cta {
        align-items: flex-start;
        flex-direction: column;
    }
}

@media (max-width: 640px) {
    .landing-page .landing-shell {
        padding: 0.85rem 1rem 1.5rem;
    }
    .landing-nav {
        align-items: center;
        flex-direction: row;
        margin-bottom: 1.15rem;
    }
    .landing-nav-actions {
        width: auto;
        justify-content: flex-end;
        gap: 0.55rem;
        font-size: 0.82rem;
    }
    .landing-nav-actions a:not(.nav-pill) {
        display: none;
    }
    .nav-pill {
        min-height: 34px;
        padding: 0 0.7rem;
    }
    .hero-copy h1 {
        font-size: clamp(2.55rem, 13vw, 3.35rem);
    }
    .hero-lede {
        font-size: 1rem;
    }
    .hero-actions {
        margin-top: 1rem;
    }
    .hero-proof {
        margin-top: 0.8rem;
    }
    .hero-actions > * {
        flex: 1 1 160px;
    }
    .product-stage {
        min-height: 165px;
        margin-top: 0.8rem;
    }
    .product-stage::before {
        inset: 1.5rem 0 0.5rem;
    }
    .telegram-window,
    .dashboard-window {
        position: absolute;
        width: 100%;
    }
    .telegram-window {
        top: 0;
        left: 0;
        height: 102px;
        overflow: hidden;
        padding: 0.65rem;
    }
    .dashboard-window {
        top: 64px;
        right: 0;
        bottom: auto;
        width: 88%;
        margin-top: 0;
        padding: 0.6rem;
    }
    .chat-line.bot {
        display: none;
    }
    .chat-line.user {
        max-width: 100%;
        margin-top: 0.35rem;
    }
    .dashboard-head {
        margin-bottom: 0.5rem;
    }
    .dashboard-head strong {
        font-size: 0.88rem;
    }
    .mini-stats {
        grid-template-columns: repeat(3, 1fr);
        gap: 0.35rem;
    }
    .mini-stats div {
        padding: 0.45rem;
    }
    .mini-stats strong {
        font-size: 0.82rem;
    }
    .trade-strip {
        display: none;
    }
    .workflow-grid,
    .setup-grid,
    .feature-layout,
    .security-section {
        grid-template-columns: 1fr;
    }
    .landing-section {
        margin-bottom: 3.5rem;
    }
    .landing-cta {
        padding: 1.25rem;
    }
    .landing-cta .hero-actions {
        width: 100%;
        justify-content: stretch;
    }
    .site-footer {
        margin-top: 3.5rem;
    }
    .footer-inner,
    .footer-bottom {
        width: calc(100% - 2rem);
    }
    .footer-inner {
        grid-template-columns: 1fr;
        gap: 1.5rem;
        padding: 1.5rem 0;
    }
    .footer-links {
        grid-template-columns: 1fr 1fr;
        gap: 1.25rem;
    }
    .footer-bottom {
        flex-direction: column;
        gap: 0.35rem;
    }
}
