:root {
    --ink: #172033;
    --muted: #697386;
    --line: #e4e8ef;
    --surface: #ffffff;
    --background: #f5f7fa;
    --nav: #111827;
    --primary: #e84e3d;
    --primary-dark: #c93b2d;
    --success: #16875d;
    --warning: #ad6700;
    --danger: #c63838;
    --info: #2563a8;
    --radius: 14px;
}

* {
    box-sizing: border-box;
}

html {
    min-height: 100%;
    background: var(--background);
}

body {
    min-height: 100vh;
    margin: 0;
    color: var(--ink);
    background: var(--background);
    font: 15px/1.5 -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

a {
    color: var(--info);
    text-decoration: none;
}

a:hover {
    text-decoration: underline;
}

button,
input,
textarea {
    font: inherit;
}

.app-shell {
    min-height: 100vh;
}

.sidebar {
    position: fixed;
    inset: 0 auto 0 0;
    z-index: 20;
    display: flex;
    width: 245px;
    flex-direction: column;
    padding: 24px 16px;
    color: #d6dbea;
    background: var(--nav);
}

.brand {
    display: flex;
    align-items: center;
    gap: 12px;
    margin: 0 8px 34px;
    color: #fff;
}

.brand:hover {
    text-decoration: none;
}

.brand-mark,
.login-logo {
    display: grid;
    width: 42px;
    height: 42px;
    place-items: center;
    border-radius: 12px;
    color: #fff;
    background: var(--primary);
    font-size: 23px;
    font-weight: 800;
}

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

.brand strong {
    font-size: 19px;
    letter-spacing: .02em;
}

.brand small {
    color: #929bad;
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: .12em;
}

.sidebar nav {
    display: grid;
    gap: 7px;
}

.sidebar nav a {
    display: flex;
    align-items: center;
    gap: 13px;
    padding: 11px 13px;
    border-radius: 10px;
    color: #b8c0d0;
    font-weight: 600;
}

.sidebar nav a i {
    width: 19px;
    text-align: center;
}

.sidebar nav a:hover,
.sidebar nav a.active {
    color: #fff;
    background: #202b3e;
    text-decoration: none;
}

.sidebar nav a.active i {
    color: #ff7b6d;
}

.sidebar-bottom {
    display: grid;
    gap: 12px;
    margin-top: auto;
    padding: 18px 10px 2px;
    border-top: 1px solid #2b3546;
    font-size: 13px;
}

.link-button {
    padding: 0;
    border: 0;
    color: #9da6b6;
    background: transparent;
    cursor: pointer;
}

.link-button:hover {
    color: #fff;
}

.main {
    min-height: 100vh;
    margin-left: 245px;
}

.topbar {
    display: flex;
    height: 65px;
    align-items: center;
    justify-content: flex-end;
    padding: 0 34px;
    border-bottom: 1px solid var(--line);
    background: rgba(255, 255, 255, .92);
}

.environment {
    color: var(--muted);
    font-size: 13px;
}

.environment i {
    margin-right: 7px;
    color: var(--success);
}

.menu-button {
    display: none;
    margin-right: auto;
    border: 0;
    color: var(--ink);
    background: transparent;
    font-size: 20px;
}

.content {
    max-width: 1440px;
    margin: 0 auto;
    padding: 34px;
}

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

.page-heading h1 {
    margin: 0 0 5px;
    font-size: 27px;
    line-height: 1.2;
}

.page-heading p {
    margin: 0;
    color: var(--muted);
}

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

.page-actions form {
    margin: 0;
}

.button {
    display: inline-flex;
    min-height: 42px;
    align-items: center;
    justify-content: center;
    gap: 9px;
    padding: 9px 16px;
    border: 1px solid transparent;
    border-radius: 9px;
    font-weight: 700;
    cursor: pointer;
}

.button:hover {
    text-decoration: none;
}

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

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

.button-secondary {
    border-color: var(--line);
    color: var(--ink);
    background: #fff;
}

.button-secondary:hover {
    border-color: #bdc5d1;
    color: var(--ink);
}

.button-dark {
    color: #fff;
    background: #111;
}

.button-instagram {
    color: #fff;
    background: #a52b86;
}

.button-instagram:hover {
    color: #fff;
    background: #87206d;
}

.button-full {
    width: 100%;
}

.panel {
    padding: 22px;
    border: 1px solid var(--line);
    border-radius: var(--radius);
    background: var(--surface);
}

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

.panel-heading {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 18px;
    margin-bottom: 18px;
}

.panel-heading h2 {
    margin: 0;
}

.panel-heading > a,
.panel-heading > span {
    font-size: 13px;
}

.metrics {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 16px;
    margin-bottom: 22px;
}

.metric {
    display: flex;
    align-items: center;
    gap: 15px;
    padding: 18px;
    border: 1px solid var(--line);
    border-radius: 12px;
    background: #fff;
}

.metric > i {
    display: grid;
    width: 42px;
    height: 42px;
    place-items: center;
    border-radius: 10px;
    color: var(--info);
    background: #edf5ff;
    font-size: 18px;
}

.metric.danger > i {
    color: var(--danger);
    background: #fff0ef;
}

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

.metric strong {
    font-size: 24px;
    line-height: 1.1;
}

.metric small {
    margin-top: 3px;
    color: var(--muted);
}

.dashboard-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 22px;
}

.event-list,
.job-list,
.account-list {
    display: grid;
}

.event-row,
.job-row,
.account-row {
    display: flex;
    min-width: 0;
    align-items: center;
    gap: 13px;
    padding: 13px 0;
    border-top: 1px solid var(--line);
    color: var(--ink);
}

.event-row:first-child,
.job-row:first-child,
.account-row:first-child {
    padding-top: 0;
    border-top: 0;
}

.event-row:last-child,
.job-row:last-child,
.account-row:last-child {
    padding-bottom: 0;
}

.event-row:hover {
    text-decoration: none;
}

.event-row img {
    width: 50px;
    height: 58px;
    border-radius: 7px;
    object-fit: cover;
}

.event-row span,
.job-row span,
.account-row > span:nth-child(2) {
    min-width: 0;
    flex: 1;
}

.event-row strong,
.event-row small,
.job-row strong,
.job-row small,
.account-row strong,
.account-row small {
    display: block;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.event-row small,
.job-row small,
.account-row small {
    color: var(--muted);
    font-size: 12px;
}

.job-row > i {
    width: 22px;
    color: var(--muted);
    text-align: center;
    font-size: 18px;
}

.badge {
    display: inline-flex;
    align-items: center;
    padding: 4px 8px;
    border-radius: 999px;
    color: #4f5d70;
    background: #edf0f4;
    font-size: 11px;
    font-weight: 800;
    white-space: nowrap;
}

.badge-active,
.badge-published {
    color: #0d6b49;
    background: #e3f6ed;
}

.badge-processing {
    color: #175c93;
    background: #e6f3ff;
}

.badge-pending {
    color: #825600;
    background: #fff3d6;
}

.badge-failed {
    color: #a12a2a;
    background: #ffebeb;
}

.badge-uncertain {
    color: #7a4b00;
    background: #ffedc2;
}

.alert {
    display: flex;
    align-items: flex-start;
    gap: 11px;
    margin-bottom: 18px;
    padding: 13px 15px;
    border: 1px solid;
    border-radius: 10px;
}

.alert-success {
    border-color: #bde7d4;
    color: #0d6b49;
    background: #edfaf4;
}

.alert-error {
    border-color: #f1c1c1;
    color: #9e2d2d;
    background: #fff1f1;
}

.alert-warning {
    border-color: #efd7a1;
    color: #815500;
    background: #fff9e9;
}

.alert-info {
    border-color: #bdd8ed;
    color: #245f8f;
    background: #eff8ff;
}

.empty {
    display: grid;
    min-height: 150px;
    place-items: center;
    align-content: center;
    color: var(--muted);
    text-align: center;
}

.empty i {
    margin-bottom: 8px;
    font-size: 28px;
}

.empty p,
.empty h2,
.empty h3 {
    margin: 3px;
}

.empty.large {
    min-height: 260px;
}

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

.event-card {
    overflow: hidden;
    border: 1px solid var(--line);
    border-radius: var(--radius);
    background: #fff;
}

.event-card > img {
    display: block;
    width: 100%;
    aspect-ratio: 4 / 3;
    object-fit: cover;
}

.event-card > div {
    padding: 19px;
}

.eyebrow {
    color: var(--primary);
    font-size: 11px;
    font-weight: 800;
    text-transform: uppercase;
    letter-spacing: .1em;
}

.event-card h2 {
    margin: 6px 0;
    font-size: 19px;
}

.event-card p {
    min-height: 44px;
    margin: 0 0 14px;
    color: var(--muted);
}

.event-stats {
    display: flex;
    min-height: 32px;
    flex-wrap: wrap;
    gap: 12px;
    color: var(--muted);
    font-size: 12px;
}

.text-danger {
    color: var(--danger);
}

.event-form {
    display: grid;
    grid-template-columns: minmax(0, 1fr) 330px;
    gap: 22px;
}

.form-main {
    display: grid;
    gap: 22px;
}

.form-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 17px;
}

.form-grid .span-2 {
    grid-column: span 2;
}

label {
    color: #3b4657;
    font-size: 13px;
    font-weight: 700;
}

input[type="text"],
input[type="password"],
input[type="url"],
input[type="datetime-local"],
textarea {
    display: block;
    width: 100%;
    margin-top: 6px;
    padding: 10px 12px;
    border: 1px solid #cfd6e1;
    border-radius: 8px;
    outline: none;
    color: var(--ink);
    background: #fff;
}

input:focus,
textarea:focus {
    border-color: #638fbd;
    box-shadow: 0 0 0 3px rgba(37, 99, 168, .12);
}

textarea {
    resize: vertical;
}

.sticky {
    position: sticky;
    top: 85px;
}

.upload-zone {
    position: relative;
    display: grid;
    min-height: 350px;
    overflow: hidden;
    place-items: center;
    margin-bottom: 15px;
    padding: 20px;
    border: 2px dashed #cbd3df;
    border-radius: 11px;
    background: #f8fafc;
    cursor: pointer;
    text-align: center;
}

.upload-zone:hover {
    border-color: #8d9aad;
}

.upload-zone input {
    position: absolute;
    width: 1px;
    height: 1px;
    opacity: 0;
}

.upload-zone span strong,
.upload-zone span small {
    display: block;
}

.upload-zone span i {
    margin-bottom: 14px;
    color: var(--primary);
    font-size: 34px;
}

.upload-zone span small {
    margin-top: 6px;
    color: var(--muted);
    font-weight: 400;
}

.upload-zone img {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    object-fit: contain;
    background: #111827;
}

.notice {
    display: flex;
    gap: 10px;
    margin: 14px 0;
    padding: 12px;
    border-radius: 8px;
    color: var(--muted);
    background: #f4f6f9;
    font-size: 12px;
}

.notice p {
    margin: 0;
}

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

.target {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    padding: 13px 15px;
    border: 1px solid var(--line);
    border-radius: 10px;
}

.target-title {
    display: flex;
    min-width: 0;
    align-items: center;
    gap: 12px;
}

.target-title > i {
    width: 28px;
    font-size: 24px;
    text-align: center;
}

.target-title strong,
.target-title small {
    display: block;
}

.target-title small {
    color: var(--muted);
    font-size: 11px;
}

.target-options {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.check {
    position: relative;
}

.check input {
    position: absolute;
    opacity: 0;
}

.check span {
    display: inline-block;
    padding: 6px 10px;
    border: 1px solid var(--line);
    border-radius: 7px;
    color: var(--muted);
    background: #fff;
    cursor: pointer;
    font-size: 12px;
}

.check input:checked + span {
    border-color: #adc9e3;
    color: #185d94;
    background: #eef7ff;
}

.event-detail {
    display: grid;
    grid-template-columns: 340px minmax(0, 1fr);
    gap: 23px;
}

.poster-large {
    display: block;
    width: 100%;
    border-radius: var(--radius);
}

.detail-main {
    display: grid;
    align-content: start;
    gap: 22px;
}

.manual-cta {
    border-color: #efcf87;
    background: #fffbef;
}

.manual-cta h2 {
    margin-top: 9px;
}

.manual-cta ol {
    padding-left: 20px;
}

.step-number {
    color: var(--warning);
    font-size: 11px;
    font-weight: 800;
    text-transform: uppercase;
    letter-spacing: .1em;
}

.inline-error,
.table-error {
    display: block;
    color: var(--danger);
    font-size: 12px;
}

.inline-error {
    margin: -6px 0 10px 35px;
}

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

.connection-grid {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 20px;
    margin-bottom: 20px;
}

.connection-card {
    display: flex;
    align-items: flex-start;
    gap: 20px;
    padding: 24px;
    border: 1px solid var(--line);
    border-radius: var(--radius);
    background: #fff;
}

.connection-card > i {
    width: 50px;
    padding-top: 5px;
    font-size: 39px;
    text-align: center;
}

.connection-card h2 {
    margin: 0 0 5px;
}

.connection-card p {
    margin: 0 0 17px;
    color: var(--muted);
}

.snap-card {
    border-color: #e8dc98;
    background: #fffdf0;
}

.instagram-card {
    border-color: #dfbfda;
    background: #fff8fd;
}

.account-row .platform-icon {
    display: grid;
    width: 38px;
    height: 38px;
    flex: none;
    place-items: center;
    border-radius: 9px;
    color: #fff;
    background: #273449;
    font-size: 19px;
}

.account-row form {
    margin: 0;
}

.icon-button,
.icon-link {
    display: inline-grid;
    width: 34px;
    height: 34px;
    flex: none;
    place-items: center;
    border: 1px solid var(--line);
    border-radius: 7px;
    color: var(--muted);
    background: #fff;
    cursor: pointer;
}

.icon-button:hover,
.icon-link:hover {
    border-color: #b5bfcc;
    color: var(--ink);
    text-decoration: none;
}

.icon-button.danger:hover {
    border-color: #e4aaaa;
    color: var(--danger);
}

.compact {
    margin-top: 20px;
}

.copy-row {
    display: flex;
    justify-content: space-between;
    gap: 20px;
    padding: 10px 0;
    border-top: 1px solid var(--line);
}

.copy-row code {
    overflow: auto;
    color: #38465b;
}

.copy-row span {
    color: var(--muted);
}

.table-panel {
    padding: 0;
    overflow: hidden;
}

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

table {
    width: 100%;
    border-collapse: collapse;
    text-align: left;
}

th,
td {
    padding: 13px 15px;
    border-bottom: 1px solid var(--line);
    vertical-align: middle;
}

th {
    color: var(--muted);
    background: #f8fafc;
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: .05em;
}

td {
    font-size: 13px;
}

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

td.actions {
    display: flex;
    gap: 6px;
}

td.actions form {
    margin: 0;
}

.login-shell {
    display: grid;
    min-height: 100vh;
    place-items: center;
    padding: 24px;
    background: #111827;
}

.login-shell > .alert {
    position: fixed;
    top: 22px;
    left: 50%;
    width: min(560px, calc(100% - 32px));
    transform: translateX(-50%);
}

.login-card {
    width: min(430px, 100%);
    padding: 38px;
    border-radius: 18px;
    background: #fff;
}

.login-logo {
    width: 52px;
    height: 52px;
    margin-bottom: 20px;
}

.login-card h1 {
    margin: 4px 0 5px;
    font-size: 25px;
}

.login-card > p:not(.eyebrow) {
    margin: 0 0 24px;
    color: var(--muted);
}

.stack-form {
    display: grid;
    gap: 16px;
}

.legal-page {
    min-height: 100vh;
    padding: 42px 20px;
    background: var(--nav);
}

.legal-brand {
    width: min(760px, 100%);
    margin: 0 auto 20px;
}

.legal-card {
    width: min(760px, 100%);
    margin: 0 auto;
    padding: 34px;
}

.legal-card h1 {
    margin: 4px 0 24px;
}

.legal-card h2 {
    margin: 28px 0 7px;
}

.legal-card p,
.legal-card li {
    color: #4e596b;
}

@media (max-width: 1100px) {
    .metrics {
        grid-template-columns: 1fr 1fr;
    }

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

    .event-form {
        grid-template-columns: minmax(0, 1fr) 290px;
    }

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

@media (max-width: 820px) {
    .sidebar {
        transform: translateX(-100%);
        transition: transform .2s ease;
    }

    body.menu-open .sidebar {
        transform: translateX(0);
    }

    .main {
        margin-left: 0;
    }

    .menu-button {
        display: block;
    }

    .content {
        padding: 24px 18px;
    }

    .topbar {
        padding: 0 18px;
    }

    .dashboard-grid,
    .connection-grid,
    .event-form,
    .event-detail {
        grid-template-columns: 1fr;
    }

    .form-side {
        order: -1;
    }

    .sticky {
        position: static;
    }

    .upload-zone {
        min-height: 260px;
    }
}

@media (max-width: 580px) {
    .page-heading {
        display: grid;
    }

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

    .metrics,
    .event-grid,
    .form-grid {
        grid-template-columns: 1fr;
    }

    .form-grid .span-2 {
        grid-column: auto;
    }

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

    .event-detail > aside {
        max-width: 360px;
        margin: auto;
    }

    .login-card {
        padding: 28px 23px;
    }
}
