@import url("https://fonts.googleapis.com/css2?family=Space+Grotesk:wght@400;500;600;700&family=JetBrains+Mono:wght@400;500&display=swap");

:root {
    --bg-main: #f1f5fb;
    --bg-panel: #ffffff;
    --bg-soft: #f8fbff;
    --text-main: #132035;
    --text-muted: #5d6a7f;
    --line: #dde6f3;
    --accent: #0f9f91;
    --accent-dark: #0a7a70;
    --danger: #c63b36;
    --success: #1f9d58;
    --shadow-lg: 0 18px 40px rgba(18, 31, 53, 0.08);
    --shadow-md: 0 10px 24px rgba(18, 31, 53, 0.06);
    --radius-lg: 18px;
    --radius-md: 12px;
    --radius-sm: 9px;
}

* {
    box-sizing: border-box;
}

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

.ambient-backdrop {
    position: fixed;
    inset: 0;
    z-index: -1;
    background:
        radial-gradient(circle at 15% 20%, #a4f6e430 0%, transparent 32%),
        radial-gradient(circle at 88% 12%, #88b6ff2f 0%, transparent 35%),
        radial-gradient(circle at 80% 90%, #ffe08a36 0%, transparent 36%);
}

.container {
    width: min(1100px, 100%);
    margin: 0 auto;
    padding: 1.25rem;
}

.layout-auth .container {
    width: min(1180px, 100%);
}

.app-shell {
    display: grid;
    grid-template-columns: 260px 1fr;
    min-height: 100vh;
}

.app-sidebar {
    padding: 1.4rem 1rem;
    border-right: 1px solid var(--line);
    background: linear-gradient(170deg, #0f192d 0%, #152844 55%, #1a3760 100%);
    color: #dce8ff;
    display: flex;
    flex-direction: column;
    gap: 1.6rem;
}

.app-sidebar .brand {
    color: #f5fbff;
    font-size: 1.08rem;
    font-weight: 700;
    letter-spacing: 0.02em;
    text-decoration: none;
}

.side-nav {
    display: grid;
    gap: 0.45rem;
}

.side-link {
    color: #d3dff2;
    text-decoration: none;
    border-radius: 10px;
    padding: 0.72rem 0.8rem;
    transition: background-color 0.18s ease, color 0.18s ease;
}

.side-link:hover {
    background: rgba(255, 255, 255, 0.09);
    color: #ffffff;
}

.side-link.is-active {
    background: linear-gradient(95deg, #0f9f91 0%, #17b8a8 100%);
    color: #ffffff;
    box-shadow: 0 8px 22px rgba(15, 159, 145, 0.35);
}

.sidebar-meta {
    margin-top: auto;
    padding-top: 1rem;
    border-top: 1px solid rgba(226, 235, 252, 0.2);
}

.meta-label {
    margin: 0;
    color: #b8c9e8;
    font-size: 0.8rem;
    letter-spacing: 0.04em;
    text-transform: uppercase;
}

.meta-value {
    margin: 0.35rem 0 0;
    font-size: 0.92rem;
    color: #f5fbff;
    word-break: break-all;
}

.app-main {
    display: flex;
    flex-direction: column;
    min-width: 0;
}

.app-topbar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 1rem;
    padding: 1.15rem 1.25rem;
    border-bottom: 1px solid var(--line);
    background: rgba(255, 255, 255, 0.9);
    backdrop-filter: blur(12px);
}

.eyebrow {
    margin: 0;
    color: var(--text-muted);
    font-size: 0.79rem;
    letter-spacing: 0.08em;
    text-transform: uppercase;
}

.top-title {
    margin: 0.15rem 0 0;
    font-size: 1.45rem;
    line-height: 1.15;
}

.content {
    width: 100%;
}

.layout-guest .content {
    padding-top: 0;
}

.card {
    background: var(--bg-panel);
    border: 1px solid var(--line);
    border-radius: var(--radius-lg);
    padding: 1.15rem;
    box-shadow: var(--shadow-md);
}

.auth-shell {
    min-height: 100vh;
    display: grid;
    align-items: center;
    grid-template-columns: 1fr minmax(300px, 460px);
    gap: 1.15rem;
}

.auth-intro {
    background: linear-gradient(150deg, #11243f 0%, #14335f 65%, #0f9f91 160%);
    color: #e9f5ff;
    border-radius: 24px;
    padding: clamp(1.3rem, 3.8vw, 2.2rem);
    box-shadow: var(--shadow-lg);
}

.auth-intro .brand {
    color: #f5fbff;
    text-decoration: none;
    font-weight: 700;
}

.auth-intro h1 {
    margin: 0.95rem 0 0.7rem;
    font-size: clamp(1.35rem, 3.2vw, 2.15rem);
    line-height: 1.15;
}

.auth-intro p {
    margin: 0;
    color: #d2e7ff;
    max-width: 36ch;
}

.auth-links {
    margin-top: 1.25rem;
    display: flex;
    gap: 0.6rem;
}

.auth-links a {
    text-decoration: none;
    border-radius: 999px;
    padding: 0.45rem 0.82rem;
    color: #ffffff;
    border: 1px solid rgba(255, 255, 255, 0.33);
}

.auth-card {
    max-width: 100%;
}

.auth-card h1 {
    margin-top: 0;
    margin-bottom: 0.55rem;
}

.auth-caption {
    margin: 0 0 1.1rem;
    color: var(--text-muted);
}

.section-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 0.8rem;
    margin-bottom: 0.8rem;
}

.section-header h1,
.section-header h2 {
    margin: 0;
}

.section-subtitle {
    margin: 0.32rem 0 0;
    color: var(--text-muted);
}

.form-grid {
    display: grid;
    gap: 0.84rem;
}

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

.form-grid.two-columns button {
    grid-column: 1 / -1;
    justify-self: start;
}

label {
    display: grid;
    gap: 0.3rem;
    color: var(--text-muted);
    font-size: 0.94rem;
}

input {
    width: 100%;
    background: var(--bg-soft);
    border: 1px solid var(--line);
    border-radius: var(--radius-sm);
    padding: 0.65rem 0.7rem;
    font: inherit;
    color: var(--text-main);
    transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

input:focus {
    outline: none;
    border-color: var(--accent);
    box-shadow: 0 0 0 4px rgba(15, 159, 145, 0.15);
}

button,
.button-link {
    border: 0;
    border-radius: 10px;
    background: linear-gradient(100deg, var(--accent) 0%, #17b8a8 100%);
    color: #ffffff;
    font: inherit;
    font-weight: 600;
    text-decoration: none;
    cursor: pointer;
    padding: 0.57rem 0.92rem;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    transition: transform 0.15s ease, filter 0.15s ease;
}

button:hover,
.button-link:hover {
    transform: translateY(-1px);
    filter: brightness(0.98);
}

.button-link.secondary {
    background: #ffffff;
    border: 1px solid var(--line);
    color: var(--text-main);
}

.button-link.secondary:hover {
    background: #f8fbff;
}

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

.inline-form {
    display: inline-flex;
}

.table-wrap {
    overflow: auto;
    border: 1px solid var(--line);
    border-radius: var(--radius-md);
}

table {
    width: 100%;
    border-collapse: collapse;
    min-width: 600px;
    background: #ffffff;
}

th {
    text-align: left;
    font-size: 0.77rem;
    text-transform: uppercase;
    letter-spacing: 0.07em;
    color: var(--text-muted);
    background: #f5f9ff;
    padding: 0.68rem 0.72rem;
    border-bottom: 1px solid var(--line);
}

td {
    padding: 0.72rem;
    border-bottom: 1px solid var(--line);
    vertical-align: middle;
}

tbody tr:hover {
    background: #f8fcff;
}

td.actions-cell {
    white-space: nowrap;
    width: 1%;
}

.action-group {
    display: inline-flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 0.38rem;
}

.action-chip {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 64px;
    padding: 0.38rem 0.65rem;
    border-radius: 999px;
    border: 1px solid transparent;
    font-size: 0.79rem;
    font-weight: 700;
    line-height: 1;
    text-decoration: none;
    cursor: pointer;
    transition: transform 0.14s ease, background-color 0.14s ease;
}

.action-chip:hover {
    transform: translateY(-1px);
    filter: none;
}

.action-chip-view {
    background: #e8f4ff;
    border-color: #c9ddf2;
    color: #1f5d99;
}

.action-chip-edit {
    background: #e8f8f2;
    border-color: #c6e8dc;
    color: #157965;
}

.action-chip-delete {
    background: #fff2f1;
    border-color: #f0c4c1;
    color: #b12722;
}

button.action-chip {
    box-shadow: none;
}

button.action-chip:hover {
    filter: none;
}

dl {
    margin: 0;
    display: grid;
    grid-template-columns: minmax(130px, 170px) 1fr;
    gap: 0.6rem 0.8rem;
}

dt {
    margin: 0;
    color: var(--text-muted);
}

dd {
    margin: 0;
    color: var(--text-main);
    font-family: "JetBrains Mono", monospace;
    font-size: 0.9rem;
    word-break: break-all;
}

.actions {
    margin-top: 1rem;
    display: flex;
    gap: 0.55rem;
}

.flash-list {
    list-style: none;
    margin: 0 0 1rem;
    padding: 0;
    display: grid;
    gap: 0.45rem;
}

.flash {
    border-radius: 10px;
    padding: 0.72rem 0.78rem;
    color: #ffffff;
    box-shadow: var(--shadow-md);
}

.flash-success {
    background: linear-gradient(95deg, #159957 0%, #32bf73 100%);
}

.flash-error {
    background: linear-gradient(95deg, #c63b36 0%, #df5648 100%);
}

.flash-info {
    background: linear-gradient(95deg, #2f6eb2 0%, #5e97df 100%);
}

.empty-state {
    margin: 0;
    color: var(--text-muted);
    padding: 0.9rem;
    border-radius: var(--radius-sm);
    background: var(--bg-soft);
    border: 1px dashed var(--line);
}

.dashboard-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 0.9rem;
}

.control-tile {
    border: 1px solid var(--line);
    border-radius: var(--radius-md);
    background: var(--bg-soft);
    padding: 0.95rem;
}

.control-tile h3 {
    margin: 0 0 0.4rem;
}

.control-tile p {
    margin: 0 0 0.8rem;
    color: var(--text-muted);
}

.control-tile code {
    font-family: "JetBrains Mono", monospace;
    font-size: 0.82rem;
}

.control-button {
    width: 100%;
}

.control-button:disabled {
    cursor: not-allowed;
    opacity: 0.52;
    transform: none;
    filter: grayscale(0.15);
}

.control-button-start {
    background: linear-gradient(96deg, #0ea773 0%, #37c987 100%);
}

.control-button-stop {
    background: linear-gradient(96deg, #d44a42 0%, #ea6658 100%);
}

.loop-state {
    margin: 0 0 1rem;
    color: var(--text-muted);
}

.state-pill {
    display: inline-flex;
    align-items: center;
    border-radius: 999px;
    padding: 0.23rem 0.6rem;
    font-size: 0.78rem;
    font-weight: 700;
}

.state-live {
    background: #ffece8;
    color: #9d2f2a;
    border: 1px solid #f4c7c2;
}

.state-idle {
    background: #e8f7ef;
    color: #14774f;
    border: 1px solid #c3e8d5;
}

.status-pill {
    display: inline-flex;
    align-items: center;
    border-radius: 999px;
    padding: 0.2rem 0.52rem;
    font-size: 0.76rem;
    font-weight: 700;
    border: 1px solid transparent;
}

.status-live {
    background: #fff1d7;
    color: #85510a;
    border-color: #f0d9a7;
}

.status-finished {
    background: #e9f7ef;
    color: #167348;
    border-color: #c6e8d4;
}

.status-failed {
    background: #ffeceb;
    color: #a63732;
    border-color: #f0c7c4;
}

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

    .app-sidebar .brand {
        font-size: 0;
        position: relative;
        min-height: 28px;
    }

    .app-sidebar .brand::after {
        content: "AA";
        font-size: 1rem;
        letter-spacing: 0.06em;
    }

    .side-link {
        text-align: center;
        font-size: 0.86rem;
        padding: 0.62rem 0.45rem;
    }

    .sidebar-meta {
        display: none;
    }
}

@media (max-width: 760px) {
    .app-shell {
        grid-template-columns: 1fr;
    }

    .app-sidebar {
        border-right: 0;
        border-bottom: 1px solid var(--line);
        padding: 1rem;
        gap: 0.9rem;
    }

    .app-sidebar .brand {
        font-size: 1rem;
    }

    .app-sidebar .brand::after {
        content: "";
        font-size: 0;
    }

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

    .auth-shell {
        grid-template-columns: 1fr;
        align-content: start;
        padding-top: 1.2rem;
    }

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

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

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