:root {
    --bg: #0b0f14;
    --panel: #121821;
    --panel-2: #171f2a;
    --line: #283241;
    --text: #edf2f7;
    --muted: #8f9bab;
    --accent: #5d8dff;
    --accent-hover: #77a1ff;
    --danger-bg: #351c23;
    --danger-line: #71313e;
    --danger-text: #ffb6c3;
    --ok: #48c78e;
    --wait: #d7a94a;
}

* {
    box-sizing: border-box;
}

html,
body {
    margin: 0;
    min-height: 100%;
    background: var(--bg);
    color: var(--text);
    font-family:
        Inter,
        ui-sans-serif,
        system-ui,
        -apple-system,
        BlinkMacSystemFont,
        "Segoe UI",
        sans-serif;
}

body {
    min-height: 100vh;
}

.topbar {
    height: 72px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 28px;
    border-bottom: 1px solid var(--line);
    background: rgba(11, 15, 20, 0.96);
}

.brand {
    display: flex;
    align-items: center;
    gap: 12px;
}

.brand-mark {
    width: 38px;
    height: 38px;
    display: grid;
    place-items: center;
    border-radius: 10px;
    font-size: 18px;
    font-weight: 800;
    background: var(--accent);
    color: #fff;
}

.brand strong,
.brand small {
    display: block;
}

.brand small {
    margin-top: 2px;
    color: var(--muted);
    font-size: 12px;
}

.topbar-actions {
    display: flex;
    align-items: center;
    gap: 14px;
}

.username {
    color: var(--muted);
    font-size: 14px;
}

.page {
    width: min(1180px, calc(100% - 40px));
    margin: 0 auto;
    padding: 36px 0 60px;
}

.login-wrap {
    min-height: calc(100vh - 180px);
    display: grid;
    place-items: center;
}

.login-card {
    width: min(430px, 100%);
    padding: 32px;
    border: 1px solid var(--line);
    border-radius: 18px;
    background: var(--panel);
}

h1,
h2,
p {
    margin-top: 0;
}

h1 {
    margin-bottom: 10px;
    font-size: 28px;
}

h2 {
    margin-bottom: 0;
    font-size: 18px;
}

.eyebrow {
    margin-bottom: 10px;
    color: var(--accent);
    font-size: 11px;
    font-weight: 800;
    letter-spacing: 0.14em;
}

.muted {
    color: var(--muted);
}

.login-form {
    display: grid;
    gap: 18px;
    margin-top: 26px;
}

.login-form label {
    display: grid;
    gap: 8px;
}

.login-form label span {
    color: #c8d0da;
    font-size: 13px;
    font-weight: 600;
}

input {
    width: 100%;
    padding: 12px 13px;
    border: 1px solid var(--line);
    border-radius: 10px;
    outline: none;
    background: #0e141c;
    color: var(--text);
    font: inherit;
}

input:focus {
    border-color: var(--accent);
}

.button {
    border: 0;
    border-radius: 10px;
    padding: 11px 16px;
    font: inherit;
    font-weight: 700;
    cursor: pointer;
}

.button-primary {
    background: var(--accent);
    color: #fff;
}

.button-primary:hover {
    background: var(--accent-hover);
}

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

.inline-form {
    margin: 0;
}

.alert {
    margin-top: 20px;
    padding: 12px 14px;
    border: 1px solid var(--danger-line);
    border-radius: 10px;
    background: var(--danger-bg);
    color: var(--danger-text);
    font-size: 14px;
}

.page-head {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 20px;
    margin-bottom: 28px;
}

.status-pill {
    padding: 8px 11px;
    border: 1px solid var(--line);
    border-radius: 999px;
    color: var(--muted);
    font-size: 11px;
    font-weight: 800;
    letter-spacing: 0.08em;
}

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

.stat-card {
    min-height: 125px;
    padding: 20px;
    border: 1px solid var(--line);
    border-radius: 14px;
    background: var(--panel);
}

.stat-card span {
    display: block;
    color: var(--muted);
    font-size: 13px;
}

.stat-card strong {
    display: block;
    margin-top: 18px;
    font-size: 30px;
}

.panel {
    margin-top: 20px;
    padding: 22px;
    border: 1px solid var(--line);
    border-radius: 14px;
    background: var(--panel);
}

.panel-head {
    margin-bottom: 20px;
}

.status-grid {
    display: grid;
    grid-template-columns:
        repeat(2, minmax(0, 1fr));
    gap: 14px;
    color: #ccd4de;
    font-size: 14px;
}

.dot {
    width: 8px;
    height: 8px;
    display: inline-block;
    margin-right: 8px;
    border-radius: 50%;
}

.dot-ok {
    background: var(--ok);
}

.dot-wait {
    background: var(--wait);
}

@media (max-width: 760px) {
    .topbar {
        padding: 0 16px;
    }

    .page {
        width: min(100% - 24px, 1180px);
        padding-top: 24px;
    }

    .cards {
        grid-template-columns: 1fr 1fr;
    }

    .page-head {
        flex-direction: column;
    }
}

@media (max-width: 480px) {
    .brand small,
    .username {
        display: none;
    }

    .cards,
    .status-grid {
        grid-template-columns: 1fr;
    }

    .login-card {
        padding: 24px;
    }
}


/* ==========================================================
   Phase 4A — Platform Management
   ========================================================== */

.topbar-left {
    display: flex;
    align-items: center;
    gap: 34px;
}

.brand-link {
    color: inherit;
    text-decoration: none;
}

.main-nav {
    display: flex;
    align-items: center;
    gap: 6px;
}

.main-nav a {
    padding: 9px 12px;
    border-radius: 9px;
    color: var(--muted);
    text-decoration: none;
    font-size: 13px;
    font-weight: 650;
}

.main-nav a:hover {
    background: var(--panel-2);
    color: var(--text);
}

.button-link {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    text-decoration: none;
}

.button-danger {
    border: 1px solid #69313a;
    background: #3b1d23;
    color: #ffbdc7;
}

.button-danger:hover {
    background: #4b222a;
}

.page-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
}

.platform-summary {
    grid-template-columns:
        repeat(4, minmax(0, 1fr));
    margin-bottom: 20px;
}

.panel-head-row {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 20px;
}

.compact {
    margin: 6px 0 0;
    font-size: 13px;
}

.table-wrap {
    overflow-x: auto;
}

.data-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 14px;
}

.data-table th,
.data-table td {
    padding: 15px 12px;
    border-bottom: 1px solid var(--line);
    text-align: left;
    vertical-align: top;
}

.data-table th {
    color: var(--muted);
    font-size: 11px;
    font-weight: 750;
    letter-spacing: .05em;
    text-transform: uppercase;
}

.data-table tbody tr:last-child td {
    border-bottom: 0;
}

.data-table tbody tr:hover {
    background: rgba(255, 255, 255, .015);
}

.table-title {
    color: var(--text);
    font-weight: 750;
    text-decoration: none;
}

.table-title:hover {
    color: var(--accent-hover);
}

.table-sub {
    margin-top: 5px;
    color: var(--muted);
    font-size: 12px;
}

.badge {
    display: inline-flex;
    align-items: center;
    min-height: 25px;
    padding: 4px 9px;
    border: 1px solid var(--line);
    border-radius: 999px;
    font-size: 10px;
    font-weight: 800;
    letter-spacing: .04em;
    white-space: nowrap;
}

.badge-ok {
    border-color: #235d49;
    background: #132c24;
    color: #7ae5b7;
}

.badge-warn {
    border-color: #6b5423;
    background: #2f2715;
    color: #f2cb72;
}

.badge-danger {
    border-color: #71313e;
    background: #351c23;
    color: #ffb6c3;
}

.badge-neutral {
    color: #b8c1cc;
}

.empty-state {
    padding: 45px 25px;
    text-align: center;
    color: var(--muted);
}

.empty-state strong {
    display: block;
    margin-bottom: 8px;
    color: var(--text);
    font-size: 17px;
}

.empty-state p {
    margin-bottom: 20px;
}

.small-empty {
    padding: 25px;
}

.platform-form {
    display: grid;
    gap: 18px;
}

.form-section {
    margin-top: 0;
}

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

.field {
    display: grid;
    align-content: start;
    gap: 8px;
}

.field > span {
    color: #c8d0da;
    font-size: 13px;
    font-weight: 650;
}

.field-full {
    grid-column: 1 / -1;
}

textarea,
select {
    width: 100%;
    padding: 12px 13px;
    border: 1px solid var(--line);
    border-radius: 10px;
    outline: none;
    background: #0e141c;
    color: var(--text);
    font: inherit;
}

textarea {
    resize: vertical;
    min-height: 84px;
}

textarea:focus,
select:focus {
    border-color: var(--accent);
}

.readonly-box {
    min-height: 44px;
    display: flex;
    align-items: center;
    padding: 12px 13px;
    border: 1px dashed var(--line);
    border-radius: 10px;
    color: var(--muted);
    background: #0e141c;
    font-size: 13px;
}

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

.check-card {
    display: flex;
    align-items: flex-start;
    gap: 11px;
    padding: 14px;
    border: 1px solid var(--line);
    border-radius: 11px;
    cursor: pointer;
    background: #0e141c;
}

.check-card input {
    width: auto;
    margin-top: 3px;
}

.check-card span {
    display: grid;
    gap: 3px;
}

.check-card strong {
    font-size: 13px;
}

.check-card small {
    color: var(--muted);
    line-height: 1.4;
}

.form-actions {
    display: flex;
    gap: 10px;
    margin-bottom: 30px;
}

.notice-success {
    margin-bottom: 18px;
    padding: 13px 15px;
    border: 1px solid #235d49;
    border-radius: 10px;
    background: #132c24;
    color: #8be7bf;
}

.policy-card {
    display: flex;
    justify-content: space-between;
    gap: 25px;
    margin-bottom: 20px;
    padding: 22px;
    border: 1px solid var(--line);
    border-radius: 14px;
}

.policy-card h2 {
    margin-bottom: 8px;
}

.policy-card p {
    margin-bottom: 0;
    color: var(--muted);
}

.policy-ok {
    border-color: #235d49;
    background: linear-gradient(
        135deg,
        #12271f,
        var(--panel)
    );
}

.policy-blocked {
    border-color: #6b5423;
    background: linear-gradient(
        135deg,
        #292313,
        var(--panel)
    );
}

.policy-meta {
    min-width: 170px;
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    gap: 8px;
    color: var(--muted);
}

.blocker-list {
    margin: 14px 0 0;
    padding-left: 20px;
    color: #e9c774;
    line-height: 1.7;
}

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

.detail-grid .panel {
    margin-top: 0;
}

.detail-list {
    display: grid;
    gap: 0;
    margin: 0;
}

.detail-list > div {
    display: grid;
    grid-template-columns: 190px 1fr;
    gap: 18px;
    padding: 12px 0;
    border-bottom: 1px solid var(--line);
}

.detail-list > div:last-child {
    border-bottom: 0;
}

.detail-list dt {
    color: var(--muted);
    font-size: 13px;
}

.detail-list dd {
    min-width: 0;
    margin: 0;
    overflow-wrap: anywhere;
}

.detail-list a,
.rule-item a {
    color: var(--accent-hover);
}

.detail-full {
    grid-template-columns: 190px 1fr !important;
}

.pre-line {
    white-space: pre-line;
}

.rule-history {
    display: grid;
    gap: 12px;
}

.rule-item {
    padding: 16px;
    border: 1px solid var(--line);
    border-radius: 11px;
    background: #0e141c;
}

.rule-item-head {
    display: flex;
    justify-content: space-between;
    gap: 15px;
    margin-bottom: 10px;
}

.rule-item p {
    margin: 12px 0 0;
    color: #ccd4de;
    line-height: 1.55;
}

.danger-zone {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 25px;
    margin-top: 20px;
    padding: 20px 22px;
    border: 1px solid var(--line);
    border-radius: 14px;
    background: var(--panel);
}

.danger-zone p {
    margin: 5px 0 0;
    color: var(--muted);
    font-size: 13px;
}

@media (max-width: 900px) {
    .platform-summary {
        grid-template-columns:
            repeat(2, minmax(0, 1fr));
    }

    .topbar-left {
        gap: 15px;
    }
}

@media (max-width: 760px) {
    .main-nav {
        display: none;
    }

    .form-grid,
    .check-grid,
    .detail-grid {
        grid-template-columns: 1fr;
    }

    .field-full {
        grid-column: auto;
    }

    .policy-card {
        flex-direction: column;
    }

    .policy-meta {
        align-items: flex-start;
    }

    .detail-list > div,
    .detail-full {
        grid-template-columns: 1fr !important;
        gap: 5px;
    }

    .danger-zone {
        align-items: flex-start;
        flex-direction: column;
    }
}

@media (max-width: 480px) {
    .platform-summary {
        grid-template-columns: 1fr;
    }

    .page-actions,
    .form-actions {
        width: 100%;
        flex-direction: column;
    }

    .page-actions .button,
    .form-actions .button {
        width: 100%;
    }
}


/* ==========================================================
   Phase 5A — Campaign Management
   ========================================================== */

.campaign-summary,
.campaign-post-stats {
    grid-template-columns:
        repeat(4, minmax(0, 1fr));
    margin-bottom: 20px;
}

.data-table td > a {
    color: var(--accent-hover);
}

@media (max-width: 900px) {
    .campaign-summary,
    .campaign-post-stats {
        grid-template-columns:
            repeat(2, minmax(0, 1fr));
    }
}

@media (max-width: 480px) {
    .campaign-summary,
    .campaign-post-stats {
        grid-template-columns: 1fr;
    }
}


/* ==========================================================
   Phase 5B — Templates + Posts
   ========================================================== */

.content-summary {
    grid-template-columns:
        repeat(4, minmax(0, 1fr));
    margin-bottom: 20px;
}

.row-actions {
    display: flex;
    flex-wrap: wrap;
    justify-content: flex-end;
    gap: 7px;
}

.row-actions .button {
    padding: 8px 10px;
    font-size: 12px;
}

.policy-note {
    display: flex;
    flex-wrap: wrap;
    gap: 6px 10px;
    margin-top: 18px;
    padding: 13px 15px;
    border: 1px solid var(--line);
    border-radius: 10px;
    background: #0e141c;
    color: var(--muted);
    font-size: 13px;
}

.policy-note strong {
    color: var(--text);
}

.preview-layout {
    display: grid;
    grid-template-columns:
        minmax(0, 1.6fr)
        minmax(300px, .7fr);
    gap: 20px;
}

.preview-layout > .panel {
    margin-top: 0;
}

.preview-card {
    min-height: 350px;
}

.preview-title {
    margin:
        16px
        0
        14px;
    font-size: 24px;
    line-height: 1.3;
}

.preview-body {
    white-space: pre-wrap;
    overflow-wrap: anywhere;
    color: #e8edf3;
    font-size: 16px;
    line-height: 1.65;
}

.preview-link {
    margin-top: 25px;
    padding-top: 15px;
    border-top: 1px solid var(--line);
    color: var(--accent-hover);
    overflow-wrap: anywhere;
}

.mono-small {
    font-family:
        ui-monospace,
        SFMono-Regular,
        Consolas,
        monospace;
    font-size: 11px;
    overflow-wrap: anywhere;
}

.workflow-row {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 8px;
}

.workflow-step {
    padding: 7px 10px;
    border: 1px solid var(--line);
    border-radius: 8px;
    color: var(--muted);
    font-size: 11px;
    font-weight: 800;
}

.workflow-step.active {
    border-color: #235d49;
    background: #132c24;
    color: #7ae5b7;
}

.workflow-note {
    margin:
        15px
        0
        0;
    font-size: 13px;
}

button:disabled {
    opacity: .45;
    cursor: not-allowed;
}

@media (max-width: 900px) {
    .content-summary {
        grid-template-columns:
            repeat(2, minmax(0, 1fr));
    }

    .preview-layout {
        grid-template-columns: 1fr;
    }
}

@media (max-width: 480px) {
    .content-summary {
        grid-template-columns: 1fr;
    }

    .row-actions {
        justify-content: flex-start;
    }
}


/* =========================================================
   AI Integration Settings
   ========================================================= */

.ai-settings-panel {
    max-width: 860px;
}

.ai-settings-form {
    display: grid;
    gap: 20px;
    margin-top: 20px;
}

.ai-settings-form .form-group {
    display: grid;
    gap: 8px;
}

.ai-settings-form label {
    font-size: 13px;
    font-weight: 700;
}

.ai-settings-form input[type="text"],
.ai-settings-form input[type="password"] {
    width: 100%;
    box-sizing: border-box;
    padding: 12px 14px;
    border: 1px solid var(--line);
    border-radius: 9px;
    background: #0b1118;
    color: var(--text);
    font: inherit;
}

.ai-settings-form input:focus {
    outline: none;
    border-color: #5681ff;
}

.field-help {
    color: var(--muted);
    font-size: 12px;
    line-height: 1.45;
}

.ai-settings-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
}

.ai-result {
    margin-top: 18px;
    padding: 12px 14px;
    border-radius: 9px;
    font-size: 13px;
    line-height: 1.5;
}

.ai-result-ok {
    border: 1px solid #275c3e;
    background: #10271b;
    color: #8ee6ad;
}

.ai-result-error {
    border: 1px solid #713838;
    background: #2a1515;
    color: #ff9a9a;
}

.ai-settings-note {
    margin-top: 22px;
    padding: 12px 14px;
    border: 1px solid #514827;
    border-radius: 9px;
    background: #221f13;
    color: #d7c77a;
    font-size: 12px;
    line-height: 1.5;
}


/* Opportunity Discovery */

.discovery-stats {
    margin-bottom: 22px;
}

.discovery-panel {
    margin-top: 20px;
}

.discovery-list {
    display: grid;
    gap: 12px;
}

.discovery-item {
    display: flex;
    justify-content: space-between;
    gap: 24px;
    padding: 18px;
    border: 1px solid var(--line);
    border-radius: 12px;
    background: rgba(255,255,255,0.015);
}

.discovery-main {
    min-width: 0;
    flex: 1;
}

.discovery-title-row {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-wrap: wrap;
}

.discovery-title-row h3 {
    margin: 0;
}

.discovery-url {
    display: block;
    margin-top: 8px;
    overflow-wrap: anywhere;
    font-size: 13px;
}

.discovery-meta {
    display: flex;
    flex-wrap: wrap;
    gap: 14px;
    margin-top: 12px;
    color: var(--muted);
    font-size: 12px;
}

.discovery-actions {
    display: flex;
    align-items: center;
    align-content: flex-start;
    justify-content: flex-end;
    gap: 8px;
    flex-wrap: wrap;
}

.notice-success,
.notice-error {
    margin: 0 0 18px;
    padding: 12px 14px;
    border-radius: 9px;
    font-size: 13px;
}

.notice-success {
    border: 1px solid #275c3e;
    background: #10271b;
    color: #8ee6ad;
}

.notice-error {
    border: 1px solid #713838;
    background: #2a1515;
    color: #ff9a9a;
}

.empty-state {
    padding: 28px 4px;
}

@media (max-width: 850px) {
    .discovery-item {
        flex-direction: column;
    }

    .discovery-actions {
        justify-content: flex-start;
    }
}
