:root,
[data-theme="light"] {
    --atlas-bg: #FAFAFA;
    --atlas-surface: #FFFFFF;
    --atlas-text: #111827;
    --atlas-text-muted: #6B7280;
    --atlas-border: #E5E7EB;
    --atlas-accent: #007AFF;
    --atlas-accent-hover: #0066D6;
    --atlas-sidebar-bg: #FFFFFF;
    --atlas-header-bg: rgba(255, 255, 255, 0.85);
    --atlas-shadow: none;
}

[data-theme="dark"] {
    --atlas-bg: #09090B;
    --atlas-surface: #18181B;
    --atlas-text: #F4F4F5;
    --atlas-text-muted: #A1A1AA;
    --atlas-border: #27272A;
    --atlas-accent: #0A84FF;
    --atlas-accent-hover: #409CFF;
    --atlas-sidebar-bg: #18181B;
    --atlas-header-bg: rgba(24, 24, 27, 0.9);
}

* {
    box-sizing: border-box;
}

body.atlas-body {
    margin: 0;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    background: var(--atlas-bg);
    color: var(--atlas-text);
    -webkit-font-smoothing: antialiased;
}

.atlas-shell {
    display: flex;
    min-height: 100vh;
}

.atlas-sidebar {
    width: 220px;
    flex-shrink: 0;
    background: var(--atlas-sidebar-bg);
    border-right: 1px solid var(--atlas-border);
    padding: 1.25rem 0.75rem;
    position: sticky;
    top: 0;
    height: 100vh;
}

.atlas-brand {
    display: flex;
    align-items: center;
    gap: 0.625rem;
    padding: 0 0.75rem 1.5rem;
}

.atlas-brand-mark {
    width: 2rem;
    height: 2rem;
    border-radius: 0.5rem;
    background: var(--atlas-text);
    color: var(--atlas-bg);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 0.875rem;
}

.atlas-brand-text {
    font-weight: 600;
    letter-spacing: -0.02em;
}

.atlas-nav {
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
}

.atlas-nav-link {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.625rem 0.75rem;
    border-radius: 0.5rem;
    color: var(--atlas-text-muted);
    text-decoration: none;
    font-size: 0.9375rem;
    transition: background 0.15s, color 0.15s;
}

.atlas-nav-link:hover {
    background: var(--atlas-bg);
    color: var(--atlas-text);
}

.atlas-nav-link.is-active {
    background: var(--atlas-bg);
    color: var(--atlas-text);
    font-weight: 500;
}

.atlas-icon {
    width: 1.125rem;
    height: 1.125rem;
    flex-shrink: 0;
}

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

.atlas-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    padding: 1rem 1.5rem;
    border-bottom: 1px solid var(--atlas-border);
    background: var(--atlas-header-bg);
    backdrop-filter: blur(12px);
    position: sticky;
    top: 0;
    z-index: 10;
}

.atlas-header-left {
    display: flex;
    align-items: center;
    gap: 1rem;
    min-width: 0;
}

.atlas-page-title {
    margin: 0;
    font-size: 1.125rem;
    font-weight: 600;
    letter-spacing: -0.02em;
}

.atlas-status {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 0.8125rem;
    color: var(--atlas-text-muted);
}

.atlas-status-dot {
    width: 0.5rem;
    height: 0.5rem;
    border-radius: 50%;
    background: #EF4444;
}

.atlas-status-dot.is-online {
    background: #22C55E;
}

.atlas-header-right {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.atlas-theme-toggle {
    border: 1px solid var(--atlas-border);
    background: var(--atlas-surface);
    color: var(--atlas-text);
    width: 2.25rem;
    height: 2.25rem;
    border-radius: 0.5rem;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
}

.atlas-user {
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    line-height: 1.2;
}

.atlas-user-name {
    font-size: 0.875rem;
    font-weight: 500;
}

.atlas-user-role {
    font-size: 0.75rem;
    color: var(--atlas-text-muted);
    text-transform: capitalize;
}

.atlas-btn {
    border: 1px solid var(--atlas-border);
    background: var(--atlas-surface);
    color: var(--atlas-text);
    padding: 0.375rem 0.75rem;
    border-radius: 0.5rem;
    font-size: 0.8125rem;
    cursor: pointer;
}

.atlas-btn-ghost:hover {
    background: var(--atlas-bg);
}

.atlas-btn-primary {
    background: var(--atlas-accent);
    border-color: var(--atlas-accent);
    color: #fff;
}

.atlas-btn-primary:hover {
    background: var(--atlas-accent-hover);
    border-color: var(--atlas-accent-hover);
}

.atlas-content {
    flex: 1;
    padding: 1.5rem;
}

.atlas-footer {
    padding: 0.875rem 1.5rem;
    border-top: 1px solid var(--atlas-border);
    color: var(--atlas-text-muted);
    font-size: 0.8125rem;
    display: flex;
    gap: 0.5rem;
}

.atlas-panel {
    background: var(--atlas-surface);
    border: 1px solid var(--atlas-border);
    border-radius: 0.75rem;
    overflow: hidden;
}

.atlas-panel + .atlas-panel {
    margin-top: 1.25rem;
}

.atlas-panel-header {
    padding: 1rem 1.25rem;
    border-bottom: 1px solid var(--atlas-border);
    font-weight: 600;
    font-size: 0.9375rem;
}

.atlas-panel-body {
    padding: 1.25rem;
}

.atlas-stat-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 1rem;
    margin-bottom: 1.25rem;
}

.atlas-stat-card {
    background: var(--atlas-surface);
    border: 1px solid var(--atlas-border);
    border-radius: 0.75rem;
    padding: 1.25rem;
}

.atlas-stat-label {
    font-size: 0.8125rem;
    color: var(--atlas-text-muted);
    margin-bottom: 0.375rem;
}

.atlas-stat-value {
    font-size: 1.75rem;
    font-weight: 600;
    letter-spacing: -0.03em;
    line-height: 1;
}

.atlas-stat-hint {
    font-size: 0.75rem;
    color: var(--atlas-text-muted);
    margin-top: 0.5rem;
}

.atlas-badge {
    display: inline-flex;
    align-items: center;
    padding: 0.2rem 0.5rem;
    border-radius: 999px;
    font-size: 0.75rem;
    font-weight: 500;
    border: 1px solid var(--atlas-border);
}

.atlas-badge-success {
    background: rgba(34, 197, 94, 0.12);
    color: #16A34A;
    border-color: rgba(34, 197, 94, 0.25);
}

.atlas-badge-danger {
    background: rgba(239, 68, 68, 0.12);
    color: #DC2626;
    border-color: rgba(239, 68, 68, 0.25);
}

.atlas-badge-muted {
    background: var(--atlas-bg);
    color: var(--atlas-text-muted);
}

.atlas-badge-warning {
    background: rgba(255, 149, 0, 0.12);
    color: #C93400;
    border-color: rgba(255, 149, 0, 0.25);
}

.atlas-error-hint {
    font-size: 0.75rem;
    color: #DC2626;
    margin-top: 0.25rem;
}

.atlas-alert {
    border: 1px solid var(--atlas-border);
    border-radius: 0.625rem;
    padding: 0.875rem 1rem;
    margin-bottom: 1.25rem;
    font-size: 0.875rem;
}

.atlas-alert-warning {
    background: rgba(245, 158, 11, 0.08);
    border-color: rgba(245, 158, 11, 0.25);
    color: var(--atlas-text);
}

.atlas-alert-success {
    background: rgba(34, 197, 94, 0.08);
    border-color: rgba(34, 197, 94, 0.25);
    color: var(--atlas-text);
}

.atlas-alert-danger {
    background: rgba(239, 68, 68, 0.08);
    border-color: rgba(239, 68, 68, 0.25);
    color: var(--atlas-text);
}

.atlas-table {
    width: 100%;
    border-collapse: collapse;
}

.atlas-table th,
.atlas-table td {
    padding: 0.75rem 1rem;
    border-bottom: 1px solid var(--atlas-border);
    text-align: left;
    vertical-align: middle;
}

.atlas-table th {
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: var(--atlas-text-muted);
    font-weight: 500;
}

.atlas-table tr:last-child td {
    border-bottom: none;
}

.atlas-table-compact th,
.atlas-table-compact td {
    padding: 0.4rem 0.65rem;
    font-size: 0.8125rem;
}

.atlas-table-compact th {
    padding-top: 0.5rem;
    padding-bottom: 0.5rem;
}

.atlas-th-sub {
    font-weight: 400;
    text-transform: none;
    letter-spacing: 0;
    color: var(--atlas-text-muted);
    font-size: 0.6875rem;
}

.atlas-planning-panel .atlas-panel-body {
    padding: 0.75rem 1.25rem 0.5rem;
}

.atlas-planning-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    flex-wrap: nowrap;
}

.atlas-planning-title {
    flex-shrink: 0;
}

.atlas-planning-toolbar {
    display: flex;
    flex-direction: row;
    flex-wrap: nowrap;
    align-items: center;
    gap: 0.5rem;
    flex-shrink: 0;
    margin-left: auto;
}

.atlas-select-inline {
    width: auto;
    min-width: 9.5rem;
    max-width: 11rem;
    flex: 0 0 auto;
}

.atlas-planning-table-wrap {
    padding: 0 0 0.25rem;
}

.atlas-planning-table th:first-child,
.atlas-planning-table td:first-child {
    padding-left: 1.25rem;
}

.atlas-planning-table th:last-child,
.atlas-planning-table td:last-child {
    padding-right: 1.25rem;
}

.atlas-event-cell {
    max-width: 0;
    width: 38%;
}

.atlas-event-line {
    display: flex;
    align-items: center;
    gap: 0.35rem;
    min-width: 0;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    font-size: 0.8125rem;
    line-height: 1.3;
}

.atlas-event-title {
    font-weight: 600;
    flex-shrink: 0;
    max-width: 42%;
    overflow: hidden;
    text-overflow: ellipsis;
}

.atlas-event-venue {
    color: var(--atlas-text-muted);
    overflow: hidden;
    text-overflow: ellipsis;
    min-width: 0;
}

.atlas-event-date {
    color: var(--atlas-text-muted);
    flex-shrink: 0;
    font-variant-numeric: tabular-nums;
}

.atlas-event-sep {
    color: var(--atlas-border);
    flex-shrink: 0;
    user-select: none;
}

.atlas-cell-muted {
    color: var(--atlas-text-muted);
    white-space: nowrap;
}

.atlas-badge-sm {
    padding: 0.1rem 0.4rem;
    font-size: 0.6875rem;
}

.atlas-btn-sm {
    padding: 0.25rem 0.5rem;
    font-size: 0.75rem;
}

.atlas-planning-table .atlas-input-compact {
    min-width: 0;
    width: 100%;
    max-width: 175px;
    padding: 0.3rem 0.45rem;
    font-size: 0.75rem;
}

.atlas-planning-panel-body {
    padding: 0.75rem 1.25rem 1rem;
}

.atlas-form-grid-compact {
    gap: 0.65rem 0.75rem;
}

.atlas-form-grid-compact .atlas-form-label {
    margin-bottom: 0.25rem;
    font-size: 0.75rem;
}

.atlas-queue-filter .atlas-select-inline {
    min-width: 7.5rem;
    max-width: 9rem;
}

.atlas-cell-num {
    white-space: nowrap;
    font-variant-numeric: tabular-nums;
    font-size: 0.75rem;
}

.atlas-queue-result {
    font-size: 0.75rem;
    max-width: 140px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.atlas-queue-error {
    color: #DC2626;
}

.atlas-planning-table col.atlas-col-id {
    width: 2.5rem;
}

.atlas-platform-select {
    min-width: 0;
    width: 100%;
    max-width: 118px;
    padding: 0.25rem 0.35rem;
    font-size: 0.6875rem;
}

.atlas-form-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
    gap: 1rem;
    align-items: end;
}

.atlas-form-label {
    display: block;
    font-size: 0.8125rem;
    color: var(--atlas-text-muted);
    margin-bottom: 0.375rem;
}

.atlas-input,
.atlas-select {
    width: 100%;
    padding: 0.5rem 0.75rem;
    border: 1px solid var(--atlas-border);
    border-radius: 0.5rem;
    background: var(--atlas-bg);
    color: var(--atlas-text);
    font-size: 0.875rem;
}

.atlas-input:focus,
.atlas-select:focus {
    outline: none;
    border-color: var(--atlas-accent);
    box-shadow: 0 0 0 3px rgba(0, 122, 255, 0.15);
}

.atlas-input-compact {
    min-width: 195px;
    padding: 0.45rem 0.55rem;
    font-size: 0.8125rem;
}

.atlas-welcome {
    margin-bottom: 1.25rem;
}

.atlas-welcome h2 {
    font-size: 1.25rem;
    font-weight: 600;
    margin: 0 0 0.25rem;
    letter-spacing: -0.02em;
}

.atlas-welcome p {
    margin: 0;
    color: var(--atlas-text-muted);
    font-size: 0.9375rem;
}

.atlas-toast-container {
    position: fixed;
    top: 1rem;
    right: 1rem;
    z-index: 9999;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.atlas-toast {
    background: var(--atlas-surface);
    border: 1px solid var(--atlas-border);
    border-radius: 0.625rem;
    padding: 0.75rem 1rem;
    font-size: 0.875rem;
    min-width: 220px;
    animation: atlas-toast-in 0.2s ease;
}

@keyframes atlas-toast-in {
    from { opacity: 0; transform: translateY(-8px); }
    to { opacity: 1; transform: translateY(0); }
}

.atlas-code {
    font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
    font-size: 0.8125rem;
    line-height: 1.5;
    resize: vertical;
}

.atlas-var-chip {
    font-size: 0.75rem;
    padding: 0.15rem 0.45rem;
    border-radius: 0.375rem;
    background: var(--atlas-bg);
    border: 1px solid var(--atlas-border);
}

.atlas-preview-frame-wrap {
    background: #111;
    border-radius: 0.5rem;
    padding: 0.75rem;
    overflow: hidden;
    display: flex;
    justify-content: center;
    align-items: flex-start;
}

.atlas-preview-scaler {
    position: relative;
    overflow: hidden;
    flex-shrink: 0;
}

.atlas-preview-frame {
    width: 1080px;
    height: 1080px;
    border: none;
    border-radius: 0.375rem;
    background: #000;
    transform-origin: top left;
    display: block;
}

.atlas-preview-panel {
    position: sticky;
    top: 1rem;
    align-self: flex-start;
}

.atlas-preview-panel .atlas-panel-body {
    max-height: calc(100vh - 8rem);
    overflow-y: auto;
}

.atlas-preview-vars {
    max-height: 88px;
    overflow-y: auto;
}

.atlas-bar-settings-columns {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 0.75rem;
    align-items: start;
}

@media (min-width: 1200px) {
    .atlas-bar-settings-columns {
        grid-template-columns: repeat(3, minmax(0, 1fr));
    }
}

.atlas-bar-settings-block {
    border: 1px solid var(--atlas-border);
    border-radius: 0.5rem;
    padding: 0.75rem;
    background: var(--atlas-bg);
    min-width: 0;
}

.atlas-bar-settings-block-title {
    font-size: 0.8125rem;
    font-weight: 600;
    margin-bottom: 0.625rem;
    color: var(--atlas-text);
}

.atlas-bar-settings-fields {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 0.5rem 0.625rem;
}

.atlas-bar-settings-fields .atlas-form-label {
    font-size: 0.75rem;
    margin-bottom: 0.125rem;
}

.atlas-bar-settings-fields .atlas-input {
    padding: 0.375rem 0.5rem;
    font-size: 0.875rem;
}

@media (max-width: 576px) {
    .atlas-bar-settings-columns {
        grid-template-columns: 1fr;
    }
}

@media (max-width: 768px) {
    .atlas-shell {
        flex-direction: column;
    }

    .atlas-sidebar {
        width: 100%;
        height: auto;
        position: static;
        border-right: none;
        border-bottom: 1px solid var(--atlas-border);
    }

    .atlas-nav {
        flex-direction: row;
        overflow-x: auto;
    }

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

    .atlas-header-right {
        width: 100%;
        justify-content: space-between;
    }
}
