:root {
    --bg: #f6faf7;
    --surface: #ffffff;
    --surface-soft: #f1f7f3;
    --text: #173126;
    --muted: #647a70;
    --line: #d7e4dc;
    --accent: #1f7a4d;
    --accent-dark: #185f3c;
    --accent-soft: #e4f3ea;
    --danger-soft: #fff3f1;
    --shadow: 0 10px 24px rgba(23, 49, 38, 0.05);
}

* {
    box-sizing: border-box;
}

body {
    margin: 0;
    font-family: "Segoe UI", Arial, sans-serif;
    color: var(--text);
    background: var(--bg);
}

a {
    color: inherit;
    text-decoration: none;
}

button,
input,
select {
    font: inherit;
}

button,
.button-link {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 46px;
    padding: 0.8rem 1.1rem;
    border: 0;
    border-radius: 14px;
    background: var(--accent);
    color: white;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.16s ease, transform 0.16s ease;
}

button:hover,
.button-link:hover {
    background: var(--accent-dark);
}

button:focus-visible,
.button-link:focus-visible,
input:focus-visible,
select:focus-visible,
.nav-link:focus-visible,
.small-link:focus-visible {
    outline: 3px solid rgba(31, 122, 77, 0.18);
    outline-offset: 2px;
}

.ghost-button {
    background: white;
    color: var(--accent-dark);
    border: 1px solid var(--line);
}

.ghost-button:hover {
    background: var(--surface-soft);
}

.danger-button {
    color: #9b3d2d;
    border-color: #efc9c1;
    background: #fff8f6;
}

.danger-button:hover {
    background: #fff1ed;
}

.shell {
    width: min(1180px, calc(100% - 2rem));
    margin: 0 auto;
    padding: 1.5rem 0 3rem;
}

.shell-wide {
    width: min(96vw, 1800px);
}

.topbar {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 1rem;
    margin-bottom: 1rem;
}

.brand-block {
    display: flex;
    gap: 0.9rem;
    align-items: flex-start;
}

.brand-mark {
    display: grid;
    place-items: center;
    width: 52px;
    height: 52px;
    border-radius: 12px;
    background: var(--accent);
    color: white;
    font-weight: 700;
}

.hero-text {
    margin: 0.45rem 0 0;
    color: var(--muted);
    max-width: 720px;
}

.nav-shell {
    margin-bottom: 1rem;
    padding: 1rem 1.15rem;
    border: 1px solid var(--line);
    border-radius: 20px;
    background: linear-gradient(180deg, #ffffff 0%, #f7fbf8 100%);
    box-shadow: var(--shadow);
}

.nav-meta {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 1rem;
}

.nav-caption {
    margin: 0.2rem 0 0;
    color: var(--muted);
    font-size: 0.92rem;
}

.main-nav {
    display: flex;
    flex-wrap: wrap;
    gap: 0.45rem;
    justify-content: flex-end;
}

.nav-link {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 44px;
    padding: 0.72rem 1rem;
    border: 1px solid transparent;
    border-radius: 14px;
    background: white;
    color: var(--muted);
    font-weight: 600;
    white-space: nowrap;
}

.nav-link:hover {
    background: var(--surface-soft);
    color: var(--text);
    border-color: var(--line);
}

.nav-link.active {
    background: var(--accent-soft);
    color: var(--accent-dark);
    border-color: rgba(31, 122, 77, 0.1);
}

.nav-static {
    cursor: default;
}

.eyebrow {
    margin: 0 0 0.35rem;
    text-transform: uppercase;
    letter-spacing: 0.14em;
    font-size: 0.72rem;
    font-weight: 700;
    color: var(--accent);
}

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

h1 {
    margin-bottom: 0;
    font-size: clamp(1.8rem, 3vw, 2.5rem);
    letter-spacing: -0.03em;
}

h2 {
    margin-bottom: 0;
    font-size: 1.35rem;
    letter-spacing: -0.02em;
}

.dashboard {
    display: grid;
    gap: 1rem;
}

.panel {
    padding: 1.35rem;
    border-radius: 20px;
    background: var(--surface);
    border: 1px solid var(--line);
    box-shadow: var(--shadow);
}

.panel-hero {
    background: linear-gradient(180deg, #fcfffd 0%, #f6fbf8 100%);
}

.panel-header,
.actions,
.stats,
.hero-grid,
.hero-actions {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 1rem;
}

.run-days-form {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    flex-wrap: nowrap;
}

.run-days-form input {
    width: 74px;
    min-height: 40px;
    padding: 0.55rem 0.7rem;
}

.run-days-form select {
    width: 74px;
    min-height: 40px;
    padding: 0.55rem 0.7rem;
}

.run-days-form button {
    min-height: 40px;
    padding-inline: 0.95rem;
}

.hero-actions {
    flex-wrap: wrap;
    justify-content: flex-end;
}

.section-tag {
    display: inline-flex;
    align-items: center;
    min-height: 34px;
    padding: 0.45rem 0.75rem;
    border-radius: 999px;
    background: var(--accent-soft);
    color: var(--accent-dark);
    font-size: 0.84rem;
    font-weight: 600;
}

.auth-layout {
    display: grid;
    grid-template-columns: 1fr 420px;
    gap: 1rem;
    margin-top: 1.25rem;
}

.auth-intro,
.auth-card {
    min-height: 360px;
}

.auth-intro {
    display: flex;
    flex-direction: column;
    justify-content: space-between;
}

.auth-card {
    display: grid;
    align-content: center;
    gap: 1rem;
}

.feature-list {
    display: grid;
    gap: 0.7rem;
    margin-top: 1rem;
}

.feature-item {
    padding: 0.95rem 1rem;
    border-radius: 14px;
    background: var(--surface-soft);
    border: 1px solid var(--line);
    font-weight: 600;
}

.grid-form,
.stack {
    display: grid;
    gap: 1rem;
}

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

.settings-grid {
    display: grid;
    grid-template-columns: minmax(220px, 1fr) minmax(220px, 1fr) 260px;
    gap: 1rem;
    align-items: end;
}

.inline-space {
    margin-top: 1rem;
}

.panel-subsection {
    margin-top: 1rem;
    padding-top: 1rem;
    border-top: 1px solid #e9f0ec;
}

label {
    display: grid;
    gap: 0.4rem;
    color: var(--muted);
    font-size: 0.94rem;
    font-weight: 600;
}

input,
select {
    width: 100%;
    min-height: 48px;
    padding: 0.8rem 0.9rem;
    border-radius: 14px;
    border: 1px solid var(--line);
    background: white;
    color: var(--text);
}

input:focus-visible,
select:focus-visible {
    border-color: rgba(31, 122, 77, 0.35);
    box-shadow: 0 0 0 4px rgba(31, 122, 77, 0.08);
}

.toggle {
    display: flex;
    align-items: center;
    gap: 0.7rem;
    min-height: 48px;
    padding: 0.8rem 0.9rem;
    border-radius: 14px;
    background: var(--surface-soft);
    border: 1px solid var(--line);
    color: var(--text);
}

.toggle input {
    width: auto;
    accent-color: var(--accent);
}

.table-wrapper {
    overflow-x: auto;
    margin-top: 1rem;
    border: 1px solid var(--line);
    border-radius: 16px;
}

.data-table-wrapper {
    max-height: 70vh;
    overflow: auto;
}

.data-table {
    width: 100%;
    min-width: 0;
    table-layout: fixed;
}

.data-table thead th {
    position: sticky;
    top: 0;
    z-index: 1;
}

.data-page {
    width: min(100%, 1720px);
    margin: 0 auto;
}

.data-page .panel {
    margin-inline: auto;
}

.data-table th,
.data-table td {
    padding: 0.55rem 0.45rem;
    font-size: 0.75rem;
    line-height: 1.35;
    overflow-wrap: anywhere;
    word-break: break-word;
}

.data-table td {
    text-align: center;
}

.data-page .panel-header,
.data-page .hero-grid {
    align-items: center;
}

.site-list {
    display: grid;
    gap: 0.9rem;
    margin-top: 1rem;
}

.site-row {
    display: grid;
    grid-template-columns: minmax(260px, 1.4fr) minmax(240px, 1fr) minmax(320px, 1.2fr);
    gap: 1rem;
    align-items: center;
    padding: 1rem 1.1rem;
    border: 1px solid var(--line);
    border-radius: 18px;
    background: #fbfdfb;
}

.site-main,
.site-state,
.site-actions {
    min-width: 0;
}

.site-name {
    margin: 0 0 0.45rem;
    font-size: 1.05rem;
    font-weight: 700;
}

.site-meta {
    display: grid;
    gap: 0.35rem;
    color: var(--muted);
    font-size: 0.92rem;
}

.site-meta span,
.site-last-run {
    overflow-wrap: anywhere;
}

.site-chip-group {
    display: flex;
    flex-wrap: wrap;
    gap: 0.45rem;
    margin-bottom: 0.65rem;
}

.site-last-run {
    margin: 0;
    color: var(--muted);
    font-size: 0.92rem;
}

.site-actions {
    display: grid;
    gap: 0.75rem;
    justify-items: end;
}

.site-links,
.site-buttons {
    display: flex;
    flex-wrap: wrap;
    gap: 0.6rem;
    justify-content: flex-end;
}

.site-primary-links {
    justify-content: flex-end;
}

.site-links .small-link {
    display: inline-flex;
    align-items: center;
    min-height: 38px;
}

.site-link-button {
    padding: 0.62rem 0.9rem;
    border: 1px solid rgba(31, 122, 77, 0.28);
    border-radius: 12px;
    background: #ffffff;
    color: var(--text);
    font-weight: 700;
}

.site-link-button:hover {
    background: var(--surface-soft);
    border-color: rgba(31, 122, 77, 0.42);
    color: var(--text);
}

.secondary-action-form {
    display: inline-flex;
    align-items: center;
}

.secondary-action-form select {
    width: 138px;
    min-height: 40px;
    padding: 0.55rem 0.7rem;
}

.empty-state {
    padding: 1rem;
    border: 1px dashed var(--line);
    border-radius: 16px;
    color: var(--muted);
    text-align: center;
}

table {
    width: 100%;
    border-collapse: collapse;
    background: white;
}

th,
td {
    text-align: left;
    padding: 0.95rem 0.8rem;
    border-bottom: 1px solid #e9f0ec;
    vertical-align: middle;
}

th {
    background: #f7fbf8;
    color: var(--muted);
    text-transform: uppercase;
    font-size: 0.74rem;
    letter-spacing: 0.08em;
}

tbody tr:hover {
    background: #fbfdfb;
}

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

.status-chip {
    display: inline-flex;
    align-items: center;
    min-height: 30px;
    padding: 0.3rem 0.65rem;
    border-radius: 999px;
    background: var(--accent-soft);
    color: var(--accent-dark);
    font-size: 0.8rem;
    font-weight: 700;
    white-space: nowrap;
}

.status-chip.is-running {
    background: #fff7df;
    color: #8a6400;
}

.status-chip.is-success {
    background: #edf8f1;
    color: #1b6a40;
}

.status-chip.is-error {
    background: #fdeae6;
    color: #9b3d2d;
}

.status-chip.is-paused {
    background: #eef1f0;
    color: #5f6d66;
}

.muted {
    color: var(--muted);
    font-size: 0.9rem;
    word-break: break-word;
}

.small-link {
    color: var(--accent-dark);
    font-weight: 700;
}

.flash-stack {
    display: grid;
    gap: 0.75rem;
    margin: 1rem 0;
}

.flash {
    padding: 0.95rem 1rem;
    border-radius: 14px;
    border: 1px solid var(--line);
    background: white;
    overflow-wrap: anywhere;
}

.flash.success {
    background: #f5fbf7;
}

.flash.error {
    background: var(--danger-soft);
}

.stats {
    margin-top: 1rem;
}

.stat-card {
    flex: 1;
    padding: 1rem;
    border-radius: 16px;
    background: var(--surface-soft);
    border: 1px solid var(--line);
}

.stat-card span {
    display: block;
    margin-bottom: 0.35rem;
    color: var(--muted);
    font-size: 0.82rem;
    text-transform: uppercase;
    letter-spacing: 0.06em;
}

.stat-card strong {
    font-size: 1rem;
}

.danger-zone {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 1rem;
    margin-top: 1rem;
    padding: 1rem;
    border: 1px solid #f1d8d2;
    border-radius: 16px;
    background: #fffaf8;
}

.message-cell {
    max-width: 320px;
    white-space: normal;
}

.message-preview {
    color: var(--text);
    line-height: 1.45;
}

.message-details {
    margin-top: 0.55rem;
}

.message-details summary {
    cursor: pointer;
    color: var(--accent-dark);
    font-weight: 700;
    list-style: none;
}

.message-details summary::-webkit-details-marker {
    display: none;
}

.message-details summary::before {
    content: "+";
    margin-right: 0.35rem;
}

.message-details[open] summary::before {
    content: "-";
}

.message-full {
    margin-top: 0.65rem;
    padding: 0.85rem;
    border-radius: 12px;
    background: var(--surface-soft);
    border: 1px solid var(--line);
    overflow-wrap: anywhere;
    word-break: break-word;
    white-space: pre-wrap;
}

.copy-message-button {
    margin-top: 0.65rem;
    min-height: 38px;
    padding: 0.6rem 0.85rem;
}

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

@media (max-width: 920px) {
    .auth-layout,
    .grid-form,
    .settings-grid {
        grid-template-columns: 1fr;
    }

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

    .site-row {
        grid-template-columns: 1fr;
    }

    .site-actions {
        justify-items: stretch;
    }

    .site-links,
    .site-buttons {
        justify-content: flex-start;
    }
}

@media (max-width: 760px) {
    .topbar,
    .panel-header,
    .actions,
    .stats,
    .hero-grid,
    .hero-actions,
    .brand-block,
    .danger-zone {
        flex-direction: column;
        align-items: stretch;
    }

    .main-nav {
        width: 100%;
        display: grid;
        grid-template-columns: 1fr;
    }

    .nav-meta {
        flex-direction: column;
        align-items: stretch;
    }

    .nav-link,
    .actions form,
    .actions a,
    .hero-actions form,
    .hero-actions a,
    .run-days-form,
    .button-link,
    button {
        width: 100%;
    }

    .run-days-form input {
        width: 100%;
    }

    .shell {
        width: min(100% - 1rem, 1180px);
    }

    .shell-wide {
        width: min(100% - 1rem, 1800px);
    }
}
