:root {
    --bg: #f5f7fb;
    --surface: #ffffff;
    --surface-soft: #eef3f8;
    --text: #17202f;
    --muted: #637083;
    --border: #dbe3ed;
    --green: #168a4a;
    --green-soft: #e5f7ed;
    --yellow: #b77908;
    --yellow-soft: #fff5d7;
    --red: #c52525;
    --red-soft: #fde7e7;
    --blue: #2563eb;
    --shadow: 0 16px 40px rgba(18, 31, 53, 0.08);
}

* {
    box-sizing: border-box;
}

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

button,
input,
textarea {
    font: inherit;
}

.topbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 24px;
    padding: 28px clamp(18px, 4vw, 54px);
    background: #111827;
    color: #fff;
}

.topbar h1,
.section-heading h2 {
    margin: 0;
    line-height: 1.1;
    letter-spacing: 0;
}

.topbar h1 {
    font-size: clamp(1.45rem, 2.4vw, 2.45rem);
}

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

.server-clock {
    min-width: 168px;
    padding: 12px 16px;
    border: 1px solid rgba(255, 255, 255, 0.16);
    border-radius: 8px;
    text-align: right;
}

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

.admin-chip {
    display: grid;
    gap: 4px;
    min-width: 132px;
    padding: 12px 14px;
    border: 1px solid rgba(255, 255, 255, 0.16);
    border-radius: 8px;
    color: #dbeafe;
    font-size: 0.86rem;
    font-weight: 800;
}

.admin-chip a {
    color: #fff;
    text-decoration: none;
    font-size: 0.78rem;
}

.server-clock span,
.created,
.phase-window,
.changed-at,
.save-indicator {
    display: block;
    color: var(--muted);
    font-size: 0.82rem;
}

.server-clock span {
    color: #b7c5d8;
}

.server-clock strong {
    display: block;
    margin-top: 4px;
    font-size: 1.1rem;
}

.layout {
    width: min(1440px, 100%);
    margin: 0 auto;
    padding: 24px clamp(16px, 4vw, 54px) 48px;
}

.alert-strip {
    display: grid;
    gap: 10px;
    margin-bottom: 18px;
}

.alert-item {
    padding: 13px 16px;
    border-radius: 8px;
    border: 1px solid transparent;
    font-weight: 800;
}

.alert-item.urgent {
    background: var(--red-soft);
    border-color: rgba(197, 37, 37, 0.35);
    color: var(--red);
    animation: blinkAlert 1s ease-in-out infinite;
}

.alert-item.done {
    background: var(--green-soft);
    border-color: rgba(22, 138, 74, 0.25);
    color: var(--green);
}

.alert-item.wait {
    background: var(--yellow-soft);
    border-color: rgba(183, 121, 8, 0.25);
    color: var(--yellow);
}

@keyframes blinkAlert {
    0%,
    100% {
        filter: brightness(1);
    }
    50% {
        filter: brightness(0.92);
    }
}

.toolbar,
.dashboard,
.settings-panel {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 8px;
    box-shadow: var(--shadow);
}

.toolbar {
    display: flex;
    align-items: end;
    justify-content: space-between;
    gap: 16px;
    padding: 18px;
    margin-bottom: 20px;
}

.settings-panel {
    margin-bottom: 20px;
    overflow: hidden;
}

.section-heading.compact {
    padding-block: 16px;
}

.settings-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(220px, 1fr));
    gap: 12px;
    padding: 18px 20px;
}

.switch-row {
    display: flex;
    align-items: center;
    gap: 10px;
    min-height: 42px;
    color: #334155;
    font-weight: 760;
}

.switch-row input {
    width: 18px;
    height: 18px;
    accent-color: var(--blue);
}

.settings-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    grid-column: 1 / -1;
}

.settings-status {
    display: grid;
    gap: 6px;
    padding: 0 20px 18px;
    color: var(--muted);
    font-size: 0.84rem;
}

.campaign-form {
    display: grid;
    grid-template-columns: minmax(220px, 300px) minmax(220px, 1fr) minmax(220px, 300px) auto;
    align-items: end;
    gap: 14px;
    width: 100%;
}

.field-group label {
    display: block;
    margin-bottom: 7px;
    color: var(--muted);
    font-size: 0.84rem;
    font-weight: 800;
}

.field-group input,
.notes-field {
    width: 100%;
    border: 1px solid var(--border);
    border-radius: 8px;
    background: #fff;
    color: var(--text);
    outline: none;
    transition: border-color 0.18s ease, box-shadow 0.18s ease;
}

.field-group input[type="file"] {
    min-height: 42px;
    padding: 9px 10px;
}

.field-help {
    display: block;
    margin-top: 5px;
    color: var(--muted);
    font-size: 0.78rem;
    font-weight: 700;
}

.field-group input {
    min-height: 42px;
    padding: 0 12px;
}

.notes-field {
    min-width: 220px;
    resize: vertical;
    padding: 10px;
}

.field-group input:focus,
.notes-field:focus {
    border-color: rgba(37, 99, 235, 0.65);
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.12);
}

.btn {
    min-height: 42px;
    border: 0;
    border-radius: 8px;
    padding: 0 16px;
    color: #fff;
    font-weight: 850;
    cursor: pointer;
    white-space: nowrap;
    transition: transform 0.15s ease, filter 0.15s ease;
}

.btn:hover:not(:disabled) {
    transform: translateY(-1px);
    filter: brightness(0.96);
}

.btn:disabled {
    cursor: not-allowed;
    opacity: 0.72;
}

.btn-primary {
    background: var(--blue);
}

.btn-danger {
    background: var(--red);
}

.btn-success {
    background: var(--green);
}

.btn-secondary {
    background: #4b5563;
}

.btn-muted {
    background: #94a3b8;
}

.dashboard {
    overflow: hidden;
}

.section-heading {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    padding: 20px;
    border-bottom: 1px solid var(--border);
}

.section-heading .eyebrow {
    color: var(--blue);
}

.legend {
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
    color: var(--muted);
    font-size: 0.88rem;
    font-weight: 750;
}

.legend span {
    display: inline-flex;
    align-items: center;
    gap: 6px;
}

.dot {
    width: 9px;
    height: 9px;
    border-radius: 50%;
}

.dot.done {
    background: var(--green);
}

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

.dot.late {
    background: var(--red);
}

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

.campaign-table {
    width: 100%;
    border-collapse: collapse;
    min-width: 1320px;
}

.campaign-table th,
.campaign-table td {
    padding: 16px 18px;
    border-bottom: 1px solid var(--border);
    text-align: left;
    vertical-align: top;
}

.campaign-table th {
    background: var(--surface-soft);
    color: #42516a;
    font-size: 0.78rem;
    letter-spacing: 0.06em;
    text-transform: uppercase;
}

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

.campaign-row.row-done {
    background: rgba(22, 138, 74, 0.04);
}

.campaign-row.row-wait {
    background: rgba(183, 121, 8, 0.06);
}

.campaign-row.row-late {
    background: rgba(197, 37, 37, 0.06);
}

.email,
.phase-title {
    display: block;
    overflow-wrap: anywhere;
}

.created {
    margin-top: 6px;
}

.phase-pill,
.status-badge {
    display: inline-flex;
    align-items: center;
    min-height: 28px;
    border-radius: 999px;
    padding: 0 10px;
    font-size: 0.78rem;
    font-weight: 900;
}

.phase-pill {
    margin-bottom: 8px;
    background: #eaf1ff;
    color: #2452bb;
}

.phase-2 {
    background: var(--yellow-soft);
    color: var(--yellow);
}

.phase-3 {
    background: #edfdf7;
    color: #047857;
}

.phase-4 {
    background: #f2e8ff;
    color: #7c3aed;
}

.status-done {
    background: var(--green-soft);
    color: var(--green);
}

.status-wait {
    background: var(--yellow-soft);
    color: var(--yellow);
}

.status-pending {
    background: var(--red-soft);
    color: var(--red);
}

.changed-at {
    margin-top: 7px;
}

.save-indicator {
    min-height: 18px;
    margin-top: 6px;
    font-weight: 700;
}

.save-indicator.saved {
    color: var(--green);
}

.save-indicator.error {
    color: var(--red);
}

.btn-small {
    min-height: 34px;
    margin-top: 8px;
    padding-inline: 12px;
    font-size: 0.82rem;
}

.delete-campaign {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    min-height: 34px;
    border: 1px solid var(--border);
    border-radius: 8px;
    background: #fff;
    color: var(--muted);
    font: inherit;
    font-size: 0.82rem;
    font-weight: 850;
    cursor: pointer;
    transition: border-color 0.16s ease, color 0.16s ease, background 0.16s ease;
}

.delete-campaign:hover {
    border-color: rgba(197, 37, 37, 0.35);
    background: var(--red-soft);
    color: var(--red);
}

.document-panel {
    display: grid;
    gap: 10px;
    min-width: 230px;
}

.document-list {
    display: grid;
    gap: 7px;
}

.document-link {
    display: grid;
    gap: 2px;
    padding: 9px 10px;
    border: 1px solid var(--border);
    border-radius: 8px;
    background: #fff;
    color: var(--blue);
    text-decoration: none;
    font-weight: 850;
    overflow-wrap: anywhere;
}

.document-link small {
    color: var(--muted);
    font-weight: 700;
}

.document-empty,
.document-status {
    color: var(--muted);
    font-size: 0.84rem;
    font-weight: 750;
}

.document-upload-form {
    display: grid;
    gap: 8px;
}

.document-upload-form input[type="file"] {
    width: 100%;
    font-size: 0.82rem;
}

.login-page {
    display: grid;
    place-items: center;
    padding: 24px;
}

.login-shell {
    width: min(440px, 100%);
}

.install-shell {
    width: min(720px, 100%);
}

.login-card {
    display: grid;
    gap: 16px;
    padding: 28px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 8px;
    box-shadow: var(--shadow);
}

.install-card {
    gap: 18px;
}

.install-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(220px, 1fr));
    gap: 14px;
}

.login-card h1 {
    margin: 0;
}

.login-copy {
    margin: 0;
    color: var(--muted);
}

.field-group span {
    display: block;
    margin-bottom: 7px;
    color: var(--muted);
    font-size: 0.84rem;
    font-weight: 800;
}

.inline-error,
.inline-warning,
.inline-success {
    padding: 12px 14px;
    border-radius: 8px;
    font-size: 0.9rem;
    font-weight: 750;
}

.inline-error {
    background: var(--red-soft);
    color: var(--red);
}

.inline-warning {
    background: var(--yellow-soft);
    color: var(--yellow);
}

.inline-success {
    background: var(--green-soft);
    color: var(--green);
}

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

.empty-state {
    padding: 52px 20px;
    text-align: center;
}

.empty-state h3 {
    margin: 0 0 8px;
    font-size: 1.4rem;
}

.empty-state p {
    margin: 0;
    color: var(--muted);
}

@media (max-width: 920px) {
    .topbar,
    .toolbar,
    .section-heading {
        align-items: stretch;
        flex-direction: column;
    }

    .top-actions {
        align-items: stretch;
        flex-direction: column;
    }

    .server-clock {
        text-align: left;
    }

    .campaign-form {
        grid-template-columns: 1fr;
    }

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

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

    .btn,
    .delete-campaign {
        width: 100%;
        justify-content: center;
    }
}

@media (max-width: 720px) {
    .layout {
        padding-inline: 12px;
    }

    .table-wrap {
        overflow: visible;
    }

    .campaign-table,
    .campaign-table thead,
    .campaign-table tbody,
    .campaign-table th,
    .campaign-table td,
    .campaign-table tr {
        display: block;
        min-width: 0;
        width: 100%;
    }

    .campaign-table thead {
        display: none;
    }

    .campaign-table tr {
        padding: 12px;
        border-bottom: 1px solid var(--border);
    }

    .campaign-table td {
        display: grid;
        grid-template-columns: 112px minmax(0, 1fr);
        gap: 12px;
        padding: 11px 0;
        border-bottom: 0;
    }

    .campaign-table td::before {
        content: attr(data-label);
        color: var(--muted);
        font-size: 0.75rem;
        font-weight: 900;
        letter-spacing: 0.04em;
        text-transform: uppercase;
    }

    .notes-field {
        min-width: 0;
    }
}
