:root {
    --bg: #0f172a;
    --panel: #111827;
    --panel-2: #ffffff;
    --line: #e5e7eb;
    --text: #0f172a;
    --muted: #64748b;
    --sidebar: #0b1220;
    --gold: #6ea8fe;
    --gold-dark: #6d5ef4;
    --gold-soft: #e9e7ff;
    --gold-border: rgba(110,168,254,.35);
    --danger: #b91c1c;
    --success: #15803d;
    --warn: #b45309;
    --shadow: 0 12px 40px rgba(15,23,42,.08);
}

* { box-sizing: border-box; }

body {
    margin: 0;
    font-family: Inter, Arial, Helvetica, sans-serif;
    background: #f8fafc;
    color: var(--text);
}

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

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

.sidebar {
    background: linear-gradient(180deg, #0b1220 0%, #111827 100%);
    color: #fff;
    padding: 28px 20px;
}

.brand {
    display: flex;
    align-items: center;
    gap: 14px;
    margin-bottom: 28px;
}

.brand-mark {
    width: 50px;
    height: 50px;
    border-radius: 16px;
    background: linear-gradient(135deg, #6ea8fe 0%, #8b5cf6 100%);
    color: #ffffff;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 800;
    box-shadow: 0 10px 24px rgba(110,168,254,.22);
}

.brand-title {
    font-size: 20px;
    font-weight: 800;
}

.brand-subtitle {
    color: rgba(255,255,255,.7);
    font-size: 13px;
}

.sidebar-meta {
    background: rgba(255,255,255,.05);
    border: 1px solid rgba(255,255,255,.08);
    padding: 16px;
    border-radius: 18px;
}

.meta-label {
    color: rgba(255,255,255,.6);
    font-size: 12px;
    text-transform: uppercase;
    letter-spacing: .08em;
}

.meta-value {
  margin-top: 6px;
  font-weight: 600;
  word-break: normal;
  overflow-wrap: normal;
}

.meta-pill {
    display: inline-block;
    margin-top: 10px;
    padding: 5px 10px;
    border-radius: 999px;
    background: rgba(110,168,254,.14);
    color: var(--gold);
    font-size: 12px;
    font-weight: 700;
}

.credit-box {
    margin-top: 14px;
    padding: 12px;
    border-radius: 14px;
    background: rgba(255,255,255,.05);
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.credit-box strong {
    font-size: 22px;
}

.nav {
    margin-top: 24px;
    display: grid;
    gap: 8px;
}

.nav-link {
    padding: 12px 14px;
    border-radius: 12px;
    color: rgba(255,255,255,.88);
    font-weight: 600;
    transition: .2s ease;
}

.nav-link:hover,
.nav-link.active {
    background: rgba(110,168,254,.14);
    color: #fff;
    box-shadow: inset 0 0 0 1px rgba(110,168,254,.18);
}

.sidebar-cta {
    margin-top: 24px;
}

.main {
    padding: 28px;
}

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

.topbar h1 {
    margin: 0 0 6px;
    font-size: 30px;
}

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

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

.btn {
    border: none;
    padding: 12px 16px;
    border-radius: 12px;
    font-weight: 700;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    transition: all .22s ease;
    text-decoration: none;
}

.btn:hover {
    transform: translateY(-1px);
}

.btn-primary {
    background: linear-gradient(135deg, #6ea8fe 0%, #8b5cf6 100%);
    color: #ffffff;
    box-shadow: 0 8px 18px rgba(110,168,254,.24);
}

.btn-primary:hover {
    background: linear-gradient(135deg, #5f95ff 0%, #8458f4 100%);
    box-shadow: 0 12px 22px rgba(110,168,254,.28);
}

.btn-secondary {
    background: #fff;
    color: var(--text);
    border: 1px solid var(--line);
}

.btn-secondary:hover {
    background: #f8fafc;
    border-color: #cbd5e1;
}

.btn-danger {
    background: #fff;
    color: var(--danger);
    border: 1px solid #fecaca;
}

.btn-danger:hover {
    background: #fff5f5;
    border-color: #fca5a5;
}

.btn-dark {
    background: #111827;
    color: #fff;
    border: 1px solid #1f2937;
}

.btn-dark:hover {
    background: #1f2937;
}

.btn-success {
    background: #15803d;
    color: #fff;
}

.btn-success:hover {
    background: #166534;
}

.btn-block {
    width: 100%;
}

.btn-sm {
    padding: 10px 14px;
    border-radius: 12px;
}

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

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

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

.card {
    background: #fff;
    border: 1px solid var(--line);
    border-radius: 20px;
    padding: 20px;
    box-shadow: var(--shadow);
}

.card h3,
.card h2 {
    margin-top: 0;
}

.stat-value {
    font-size: 34px;
    font-weight: 800;
    margin-top: 8px;
}

.stat-label {
    color: var(--muted);
    font-size: 14px;
}

.banner {
    background: linear-gradient(120deg, #111827 0%, #1f2937 100%);
    color: #fff;
    border-radius: 22px;
    padding: 24px;
    margin-bottom: 20px;
    display: flex;
    justify-content: space-between;
    gap: 20px;
    align-items: center;
}

.banner h2 {
    margin: 0 0 6px;
}

.banner-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    align-items: center;
}

.pricing-mini-pill {
    display: inline-flex;
    align-items: center;
    padding: 10px 14px;
    border-radius: 999px;
    background: rgba(255,255,255,.08);
    border: 1px solid rgba(255,255,255,.12);
    font-size: 13px;
    font-weight: 700;
}

.table-wrap {
    overflow: auto;
}

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

th,
td {
    padding: 14px 12px;
    border-bottom: 1px solid var(--line);
    text-align: left;
    vertical-align: top;
}

th {
    color: var(--muted);
    font-size: 13px;
    text-transform: uppercase;
    letter-spacing: .06em;
}

.badge {
    display: inline-block;
    padding: 6px 10px;
    border-radius: 999px;
    font-size: 12px;
    font-weight: 700;
}

.badge-queued { background: #fef3c7; color: #92400e; }
.badge-running { background: #dbeafe; color: #1d4ed8; }
.badge-completed { background: #dcfce7; color: #166534; }
.badge-failed { background: #fee2e2; color: #991b1b; }
.badge-paused { background: #e0e7ff; color: #4338ca; }
.badge-cancelled { background: #e5e7eb; color: #374151; }

.progress {
    height: 12px;
    background: #e5e7eb;
    border-radius: 999px;
    overflow: hidden;
}

.progress > span {
    display: block;
    height: 100%;
    background: linear-gradient(90deg, #6ea8fe 0%, #8b5cf6 100%);
    transition: width .6s ease;
}

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

.field {
    display: grid;
    gap: 8px;
    margin-bottom: 14px;
}

label {
    font-weight: 700;
}

input,
select,
textarea {
    width: 100%;
    padding: 12px 14px;
    border-radius: 12px;
    border: 1px solid #d1d5db;
    background: #fff;
    font: inherit;
    transition: border-color .2s ease, box-shadow .2s ease;
}



/* Global dark select/dropdown readability fix */
select {
  color: #eef4ff;
  -webkit-text-fill-color: #eef4ff;
  appearance: none;
  -webkit-appearance: none;
  -moz-appearance: none;
  background-image:
    linear-gradient(45deg, transparent 50%, #9eb8e8 50%),
    linear-gradient(135deg, #9eb8e8 50%, transparent 50%);
  background-position:
    calc(100% - 20px) calc(50% - 3px),
    calc(100% - 14px) calc(50% - 3px);
  background-size: 6px 6px, 6px 6px;
  background-repeat: no-repeat;
  padding-right: 42px;
}

select option,
select optgroup {
  background: #0b1730;
  color: #eef4ff;
}

select option:disabled {
  color: #8fa4c8;
}

select::-ms-expand {
  display: none;
}
input:focus,
select:focus,
textarea:focus {
    outline: none;
    border-color: rgba(110,168,254,.55);
    box-shadow: 0 0 0 4px rgba(110,168,254,.12);
}

textarea {
    min-height: 110px;
    resize: vertical;
}

.alert {
    padding: 14px 16px;
    border-radius: 14px;
    margin-bottom: 16px;
    font-weight: 600;
}

.alert-success { background: #dcfce7; color: #166534; }
.alert-error { background: #fee2e2; color: #991b1b; }
.alert-warn { background: #fef3c7; color: #92400e; }

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

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

.auth-wrap {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background: radial-gradient(circle at top left, #1f2937 0%, #0f172a 40%, #020617 100%);
    padding: 28px;
}

.auth-card {
    width: 100%;
    max-width: 460px;
    background: #fff;
    border-radius: 24px;
    padding: 30px;
    box-shadow: var(--shadow);
}

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

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

.auth-card-wide {
    max-width: 520px;
}

.auth-brand {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 18px;
}

.auth-brand-mark {
    width: 48px;
    height: 48px;
    border-radius: 14px;
    background: linear-gradient(135deg, #6ea8fe 0%, #8b5cf6 100%);
    color: #ffffff;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 900;
    box-shadow: 0 10px 24px rgba(110,168,254,.22);
}

.auth-brand-copy strong {
    display: block;
    font-size: 18px;
}

.auth-brand-copy span {
    color: var(--muted);
    font-size: 13px;
}

.footer-note {
    color: var(--muted);
    font-size: 14px;
    margin-top: 14px;
}

.inline-actions {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
}

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

.social-auth-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0,1fr));
    gap: 12px;
    margin: 18px 0 10px;
}

.social-btn {
    text-align: center;
}

.auth-divider {
    position: relative;
    text-align: center;
    margin: 16px 0;
}

.auth-divider span {
    background: #fff;
    padding: 0 10px;
    position: relative;
    z-index: 1;
}

.auth-divider::before {
    content: '';
    position: absolute;
    left: 0;
    right: 0;
    top: 50%;
    border-top: 1px solid rgba(15,23,42,.12);
}

.toggle-card {
    position: relative;
    display: grid;
    grid-template-columns: 68px 1fr;
    gap: 16px;
    align-items: center;
    margin: 18px 0 16px;
    padding: 18px 20px;
    border: 1px solid var(--line);
    border-radius: 22px;
    background: linear-gradient(180deg, #ffffff 0%, #f8fafc 100%);
    box-shadow: 0 6px 18px rgba(15,23,42,.04);
    cursor: pointer;
    transition: transform .2s ease, box-shadow .25s ease, border-color .25s ease, background-color .25s ease;
}

.toggle-card:hover {
    transform: translateY(-1px);
    box-shadow: 0 10px 24px rgba(15,23,42,.08);
}

.toggle-card-compact {
    margin-top: 12px;
    margin-bottom: 16px;
}

.toggle-input {
    position: absolute;
    opacity: 0;
    pointer-events: none;
}

.toggle-switch {
    position: relative;
    width: 56px;
    height: 34px;
    border-radius: 999px;
    background: #e5e7eb;
    box-shadow: inset 0 1px 2px rgba(15,23,42,.10);
    transition: background-color .25s ease, box-shadow .25s ease, transform .2s ease;
}

.toggle-switch::before {
    content: '';
    position: absolute;
    top: 4px;
    left: 4px;
    width: 26px;
    height: 26px;
    border-radius: 50%;
    background: #fff;
    box-shadow: 0 2px 8px rgba(15,23,42,.18);
    transition: transform .28s cubic-bezier(.22,1,.36,1), box-shadow .25s ease;
}

.toggle-copy {
    display: grid;
    gap: 4px;
}

.toggle-copy strong {
    font-size: 16px;
    line-height: 1.2;
}

.toggle-copy span {
    color: var(--muted);
    font-size: 14px;
    line-height: 1.35;
}

.toggle-input:focus-visible + .toggle-switch {
    outline: 3px solid rgba(110,168,254,.28);
    outline-offset: 3px;
}

.toggle-input:checked + .toggle-switch {
    background: rgba(110,168,254,.88);
    box-shadow: inset 0 1px 2px rgba(0,0,0,.08), 0 0 0 6px rgba(110,168,254,.10);
}

.toggle-input:checked + .toggle-switch::before {
    transform: translateX(22px);
    box-shadow: 0 4px 12px rgba(15,23,42,.22);
}

.toggle-input:checked + .toggle-switch + .toggle-copy strong {
    color: #111827;
}

.toggle-input:checked + .toggle-switch + .toggle-copy span {
    color: #475569;
}

.toggle-card:has(.toggle-input:checked) {
    border-color: rgba(110,168,254,.55);
    background: linear-gradient(180deg, #f3f7ff 0%, #f6f0ff 100%);
    box-shadow: 0 12px 28px rgba(110,168,254,.14);
}

.pricing-card {
    position: relative;
    overflow: hidden;
}

.pricing-card::before {
    content: "";
    position: absolute;
    inset: 0 0 auto 0;
    height: 4px;
    background: linear-gradient(90deg, #6ea8fe 0%, #8b5cf6 100%);
}

.plan-badge {
    display: inline-flex;
    padding: 6px 10px;
    border-radius: 999px;
    background: rgba(110,168,254,.12);
    color: var(--gold-dark);
    font-size: 12px;
    font-weight: 800;
    margin-bottom: 12px;
}

.pricing-copy {
    min-height: 40px;
}

.pricing-credits {
    font-weight: 700;
    color: var(--text);
}

/* Users admin page */
.users-toolbar {
    margin-bottom: 16px;
}

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

.mini-stat {
    background: linear-gradient(180deg, rgba(18, 31, 61, 0.96), rgba(11, 23, 48, 0.96));
    border: 1px solid rgba(148, 163, 184, 0.14);
    border-radius: 18px;
    padding: 16px 18px;
    box-shadow: inset 0 1px 0 rgba(255,255,255,0.04), 0 18px 40px rgba(2, 6, 23, 0.22);
    color: #e5eefc;
}

.mini-stat-label {
    display: block;
    color: rgba(191, 219, 254, 0.78);
    font-size: 13px;
    margin-bottom: 6px;
}

.mini-stat-value {
    font-size: 28px;
    font-weight: 800;
    color: #ffffff;
}

.section-head {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 12px;
    margin-bottom: 16px;
}

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

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

.users-admin-table {
    width: 100%;
    min-width: 0 !important;
    table-layout: fixed !important;
}

.users-admin-table th,
.users-admin-table td {
    vertical-align: middle;
    overflow: hidden;
    word-break: break-word;
}

.users-admin-table th:nth-child(1),
.users-admin-table td:nth-child(1) { width: 28% !important; }

.users-admin-table th:nth-child(2),
.users-admin-table td:nth-child(2) { width: 8% !important; }

.users-admin-table th:nth-child(3),
.users-admin-table td:nth-child(3) { width: 12% !important; }

.users-admin-table th:nth-child(4),
.users-admin-table td:nth-child(4) { width: 8% !important; }

.users-admin-table th:nth-child(5),
.users-admin-table td:nth-child(5) { width: 18% !important; }

.users-admin-table th:nth-child(6),
.users-admin-table td:nth-child(6) { width: 10% !important; }

.users-admin-table th:nth-child(7),
.users-admin-table td:nth-child(7) { width: 10% !important; }

.user-cell {
    min-width: 0;
}

.user-card-inline {
    display: flex;
    align-items: center;
    gap: 10px;
}

.user-avatar {
    width: 34px !important;
    height: 34px !important;
    border-radius: 50%;
    background: rgba(110,168,254,.16);
    color: var(--gold-dark);
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 800;
    flex-shrink: 0;
    font-size: 18px;
}

.credits-pill {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 0 !important;
    width: 72px;
    padding: 8px 10px !important;
    border-radius: 999px;
    background: #f8fafc;
    border: 1px solid var(--line);
    font-weight: 700;
}

.role-select-wide,
.users-admin-table select[name="role"] {
    width: 100% !important;
    min-width: 0 !important;
    max-width: 100% !important;
}

.compact-input {
    width: 100%;
    min-width: 0;
}

.users-admin-table input[name="amount"],
.users-admin-table td:nth-child(4) .compact-input {
    width: 100% !important;
    min-width: 0 !important;
    max-width: 100% !important;
}

.users-admin-table td:nth-child(5) .compact-input {
    width: 100% !important;
    min-width: 0 !important;
    max-width: 100% !important;
}

.users-admin-table .btn-sm,
.users-admin-table .btn-danger,
.users-admin-table .btn-primary {
    width: 100% !important;
    min-width: 0 !important;
    white-space: nowrap;
    padding-left: 10px !important;
    padding-right: 10px !important;
}

.users-search {
    display: flex;
    gap: 10px;
    align-items: center;
    flex-wrap: wrap;
    justify-content: flex-end;
}

.users-search input {
    min-width: 220px !important;
    width: 220px !important;
    max-width: 100%;
}

.users-vertical-stack {
    display: flex;
    flex-direction: column;
    gap: 28px;
}

.pagination-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    margin-top: 16px;
}

.sortable-link {
    color: inherit;
    text-decoration: none;
}

.sortable-link:hover {
    text-decoration: underline;
}

.status-badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 4px 8px !important;
    border-radius: 999px;
    font-size: 11px !important;
    font-weight: 700;
}

.status-active {
    background: #dcfce7;
    color: #166534;
}

.status-muted {
    background: #e5e7eb;
    color: #475569;
}

.status-current {
    background: #dbeafe;
    color: #1d4ed8;
}

.role-admin {
    border-color: #c7d2fe !important;
    background: #eef2ff !important;
}

.role-user {
    border-color: #e5e7eb !important;
    background: #fff !important;
}

.job-logs-list {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.job-log-item {
    border: 1px solid var(--line);
    border-radius: 16px;
    padding: 16px;
    background: #fff;
}

.job-log-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    margin-bottom: 10px;
}

.job-log-level {
    font-size: 12px;
    font-weight: 800;
    letter-spacing: .06em;
}

.job-log-message {
    line-height: 1.5;
}

.log-error {
    border-color: #fecaca;
    background: #fff7f7;
}

.log-error .job-log-level {
    color: #991b1b;
}

.log-warn {
    border-color: #fde68a;
    background: #fffbeb;
}

.log-warn .job-log-level {
    color: #92400e;
}

.log-info {
    border-color: #dbeafe;
    background: #f8fbff;
}

.log-info .job-log-level {
    color: #1d4ed8;
}

.action-stack {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    min-width: 0;
}

.live-dot {
    width: 10px;
    height: 10px;
    border-radius: 999px;
    display: inline-block;
    background: #22c55e;
    box-shadow: 0 0 0 0 rgba(34,197,94,.45);
    animation: pulseLive 1.8s infinite;
}

.live-dot.idle {
    background: #94a3b8;
    box-shadow: none;
    animation: none;
}

.live-inline {
    display: inline-flex;
    align-items: center;
    gap: 8px;
}

.live-note {
    color: var(--muted);
    font-size: 12px;
}

@keyframes pulseLive {
    0% { box-shadow: 0 0 0 0 rgba(34,197,94,.45); }
    70% { box-shadow: 0 0 0 10px rgba(34,197,94,0); }
    100% { box-shadow: 0 0 0 0 rgba(34,197,94,0); }
}

.btn-icon-only {
    min-width: 38px;
    width: 38px;
    height: 38px;
    padding: 0;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: 10px;
}

.btn-icon-only span {
    font-size: 16px;
    line-height: 1;
}

.btn-refresh {
    display: inline-flex;
    align-items: center;
    gap: 8px;
}

.create-job-card {
    width: 100%;
}

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

.job-route-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 18px;
    margin-top: 6px;
}

.route-column {
    border: 1px solid var(--line);
    border-radius: 18px;
    padding: 18px;
    background: #fafafa;
}

.route-title {
    font-weight: 800;
    margin-bottom: 12px;
    font-size: 15px;
}

.expand-job-btn {
    width: 34px;
    height: 34px;
    border-radius: 10px;
    border: 1px solid var(--line);
    background: #fff;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    transition: transform .2s ease, background .2s ease;
}

.expand-job-btn.is-open span {
    transform: rotate(180deg);
    display: inline-block;
}

.expand-job-btn:hover {
    background: #f8fafc;
}

.job-detail-row.is-hidden {
    display: none;
}

.job-detail-panel {
    background: #f8fafc;
    border: 1px solid var(--line);
    border-radius: 18px;
    padding: 16px;
}

.folder-summary {
    margin-bottom: 12px;
    color: var(--muted);
    font-size: 13px;
}

.folder-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 12px;
}

.folder-card {
    border-radius: 14px;
    padding: 12px 14px;
    border: 1px solid var(--line);
    background: #fff;
}

.folder-card.done {
    border-color: #bbf7d0;
    background: #f0fdf4;
}

.folder-card.active {
    border-color: #c4b5fd;
    background: #f5f3ff;
}

.folder-card-top {
    display: flex;
    justify-content: space-between;
    gap: 10px;
    align-items: center;
    margin-bottom: 8px;
}

.folder-state {
    font-size: 12px;
    color: var(--muted);
    font-weight: 700;
}

.folder-metrics {
    display: flex;
    flex-wrap: wrap;
    gap: 8px 12px;
    font-size: 12px;
    color: var(--muted);
}

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

.single-project-row {
    grid-template-columns: 1fr !important;
}

.field-full-width {
    grid-column: 1 / -1;
}

.btn-refresh[disabled] {
    opacity: .65;
    pointer-events: none;
}

@media (prefers-reduced-motion: reduce) {
    .toggle-card,
    .toggle-switch,
    .toggle-switch::before,
    .btn,
    .progress > span {
        transition: none;
    }
}

@media (max-width: 1400px) {
    .users-admin-table {
        font-size: 14px;
    }

    .users-admin-table th,
    .users-admin-table td {
        padding: 10px 8px !important;
    }
}

@media (max-width: 1280px) {
    .users-kpis,
    .form-grid-4 {
        grid-template-columns: 1fr;
    }
}

@media (max-width: 1100px) {
    .grid-4 {
        grid-template-columns: repeat(2, minmax(0,1fr));
    }

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

    .form-grid,
    .grid-2,
    .form-grid.form-grid-4 {
        grid-template-columns: 1fr !important;
    }

    .users-table-wrap {
        overflow-x: auto !important;
    }

    .users-admin-table {
        min-width: 980px !important;
    }
}

@media (max-width: 900px) {
    .form-grid-wide,
    .job-route-grid {
        grid-template-columns: 1fr;
    }
}

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

    .sidebar {
        padding-bottom: 10px;
    }

    .topbar {
        flex-direction: column;
    }
}

@media (max-width: 768px) {
    .btn-refresh span {
        display: none;
    }
}

@media (max-width: 640px) {
    .toggle-card {
        grid-template-columns: 60px 1fr;
        gap: 14px;
        padding: 16px;
        border-radius: 18px;
    }

    .toggle-copy strong {
        font-size: 15px;
    }

    .toggle-copy span {
        font-size: 13px;
    }
}


/* === Dashboard + login/register match website style === */
:root {
  --bg: #071326;
  --panel: rgba(7, 22, 48, 0.94);
  --panel-2: rgba(8, 20, 44, 0.98);
  --line: rgba(255,255,255,.08);
  --text: #eef4ff;
  --muted: #9db0d2;
  --sidebar: #08111f;
  --shadow: 0 18px 40px rgba(0,0,0,.24);
}

body {
  background:
    radial-gradient(circle at top left, rgba(110,168,254,.12), transparent 22%),
    radial-gradient(circle at top right, rgba(139,92,246,.10), transparent 26%),
    linear-gradient(180deg, #071326 0%, #08111f 100%);
  color: var(--text);
}

.app-shell {
  background:
    linear-gradient(rgba(255,255,255,.03) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255,255,255,.03) 1px, transparent 1px),
    radial-gradient(circle at top left, rgba(110,168,254,.10), transparent 20%),
    radial-gradient(circle at top right, rgba(139,92,246,.10), transparent 24%),
    linear-gradient(180deg, #071326 0%, #08111f 100%);
  background-size: 56px 56px, 56px 56px, auto, auto, auto;
}

.sidebar {
  background:
    linear-gradient(180deg, rgba(7,22,48,.98) 0%, rgba(3,14,35,.98) 100%);
  border-right: 1px solid rgba(255,255,255,.06);
  box-shadow: inset -1px 0 0 rgba(255,255,255,.03);
}

.brand-mark,
.auth-brand-mark {
  background: linear-gradient(135deg, #6ea8fe 0%, #8b5cf6 100%);
  color: #fff;
  box-shadow: 0 12px 24px rgba(110,168,254,.24);
}

.meta-pill {
  background: rgba(110,168,254,.14);
  color: #dbe7ff;
  border: 1px solid rgba(110,168,254,.16);
}

.credit-box,
.sidebar-meta {
  background: rgba(255,255,255,.04);
  border: 1px solid rgba(255,255,255,.08);
  box-shadow: inset 0 1px 0 rgba(255,255,255,.03);
}

.nav-link {
  color: rgba(255,255,255,.82);
}

.nav-link:hover,
.nav-link.active {
  background: linear-gradient(135deg, rgba(110,168,254,.16), rgba(139,92,246,.14));
  box-shadow:
    inset 0 0 0 1px rgba(110,168,254,.18),
    0 8px 18px rgba(0,0,0,.12);
  color: #fff;
}

.main {
  padding: 28px;
  background: transparent;
}

.topbar h1,
.card h2,
.card h3,
label,
th,
td strong {
  color: #eef4ff;
}

.muted,
.small,
.stat-label,
.auth-brand-copy span,
.footer-note,
.toggle-copy span,
th,
td,
p {
  color: var(--muted);
}

.card,
.banner,
.auth-card,
.toggle-card {
  background:
    radial-gradient(circle at top right, rgba(110,168,254,.08), transparent 28%),
    radial-gradient(circle at bottom left, rgba(139,92,246,.06), transparent 28%),
    linear-gradient(180deg, rgba(8,20,44,.98) 0%, rgba(5,14,33,.98) 100%);
  border: 1px solid rgba(255,255,255,.08);
  box-shadow:
    inset 0 1px 0 rgba(255,255,255,.04),
    0 18px 40px rgba(0,0,0,.24);
}

.banner {
  background:
    radial-gradient(circle at top right, rgba(110,168,254,.10), transparent 28%),
    linear-gradient(120deg, rgba(7,22,48,.98) 0%, rgba(16,30,57,.98) 100%);
}

.auth-wrap {
  background:
    linear-gradient(rgba(255,255,255,.03) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255,255,255,.03) 1px, transparent 1px),
    radial-gradient(circle at top left, rgba(110,168,254,.12), transparent 22%),
    radial-gradient(circle at top right, rgba(139,92,246,.10), transparent 24%),
    linear-gradient(180deg, #071326 0%, #08111f 100%);
  background-size: 56px 56px, 56px 56px, auto, auto, auto;
}

.auth-card {
  max-width: 520px;
  padding: 34px;
}

.auth-divider span {
  background: rgba(8,20,44,.98);
  color: var(--muted);
}

.auth-divider::before {
  border-top: 1px solid rgba(255,255,255,.09);
}

input,
select,
textarea {
  border: 1px solid rgba(255,255,255,.10);
  background: rgba(255,255,255,.03);
  color: #eef4ff;
  box-shadow: inset 0 1px 0 rgba(255,255,255,.02);
}

input::placeholder,
textarea::placeholder {
  color: #7f93b7;
}

input:focus,
select:focus,
textarea:focus {
  border-color: rgba(110,168,254,.5);
  box-shadow: 0 0 0 4px rgba(110,168,254,.14);
}

.btn-primary {
  background: linear-gradient(135deg, #6ea8fe 0%, #8b5cf6 100%);
  color: #ffffff;
  box-shadow: 0 10px 24px rgba(110,168,254,.24);
}

.btn-primary:hover {
  background: linear-gradient(135deg, #5f95ff 0%, #8458f4 100%);
  box-shadow: 0 14px 28px rgba(110,168,254,.28);
}

.btn-secondary {
  background: rgba(255,255,255,.04);
  color: #eef4ff;
  border: 1px solid rgba(255,255,255,.08);
}

.btn-secondary:hover {
  background: rgba(255,255,255,.06);
  border-color: rgba(255,255,255,.12);
}

.btn-danger {
  background: rgba(185,28,28,.10);
  color: #fecaca;
  border: 1px solid rgba(248,113,113,.20);
}

.btn-dark {
  background: rgba(255,255,255,.06);
  border: 1px solid rgba(255,255,255,.08);
}

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

th,
td {
  border-bottom: 1px solid rgba(255,255,255,.07);
}

.progress {
  background: rgba(255,255,255,.08);
}

.progress > span {
  background: linear-gradient(90deg, #6ea8fe 0%, #8b5cf6 100%);
}

.badge-queued { background: rgba(245, 158, 11, .18); color: #fcd34d; }
.badge-running { background: rgba(59, 130, 246, .18); color: #93c5fd; }
.badge-completed { background: rgba(34, 197, 94, .18); color: #86efac; }
.badge-failed { background: rgba(239, 68, 68, .18); color: #fca5a5; }
.badge-paused { background: rgba(139,92,246,.18); color: #c4b5fd; }
.badge-cancelled { background: rgba(148, 163, 184, .18); color: #cbd5e1; }

.toggle-card {
  border: 1px solid rgba(255,255,255,.08);
}

.toggle-copy strong {
  color: #eef4ff;
}

.toggle-switch {
  background: rgba(255,255,255,.12);
  box-shadow: inset 0 1px 2px rgba(0,0,0,.18);
}

.toggle-switch::before {
  background: #ffffff;
}

.toggle-input:checked + .toggle-switch {
  background: rgba(110,168,254,.88);
  box-shadow: inset 0 1px 2px rgba(0,0,0,.08), 0 0 0 6px rgba(110,168,254,.10);
}

.toggle-input:checked + .toggle-switch + .toggle-copy strong {
  color: #eef4ff;
}

.toggle-input:checked + .toggle-switch + .toggle-copy span {
  color: #c6d4ef;
}

.toggle-card:has(.toggle-input:checked) {
  border-color: rgba(110,168,254,.40);
  background:
    radial-gradient(circle at top right, rgba(110,168,254,.08), transparent 28%),
    linear-gradient(180deg, rgba(9,24,52,.98), rgba(6,18,40,.98));
  box-shadow: 0 14px 30px rgba(110,168,254,.10);
}

.alert-success { background: rgba(34,197,94,.14); color: #86efac; }
.alert-error { background: rgba(239,68,68,.14); color: #fca5a5; }
.alert-warn { background: rgba(245,158,11,.14); color: #fcd34d; }

/* form icons / password toggles and utility buttons */
.field button,
.field .btn,
.password-toggle,
.eye-btn,
.icon-btn {
  background: rgba(255,255,255,.06) !important;
  color: #dbe7ff !important;
  border: 1px solid rgba(255,255,255,.08) !important;
}

.field button:hover,
.password-toggle:hover,
.eye-btn:hover,
.icon-btn:hover {
  background: rgba(255,255,255,.09) !important;
}

/* high-contrast tables/cards within dashboard pages */
.table-wrap {
  border-radius: 16px;
}

@media (max-width: 900px) {
  .auth-card {
    padding: 26px;
  }
}


/* === Fix create job route panels in dark dashboard theme === */
.create-job-card .route-column {
  background:
    radial-gradient(circle at top right, rgba(110,168,254,.07), transparent 30%),
    linear-gradient(180deg, rgba(10,24,50,.96) 0%, rgba(6,17,38,.98) 100%);
  border: 1px solid rgba(255,255,255,.08);
  box-shadow: inset 0 1px 0 rgba(255,255,255,.03);
}

.create-job-card .route-title,
.create-job-card .field label,
.create-job-card .small,
.create-job-card #provider_summary,
.create-job-card #migration_help {
  color: #dbe7ff;
}

.create-job-card input,
.create-job-card select,
.create-job-card textarea {
  background: rgba(255,255,255,.04);
  color: #eef4ff;
  border: 1px solid rgba(255,255,255,.10);
}

.create-job-card input:disabled,
.create-job-card select:disabled,
.create-job-card textarea:disabled {
  background: rgba(255,255,255,.05);
  color: #eef4ff;
  opacity: 1;
  -webkit-text-fill-color: #eef4ff;
}

.create-job-card select option,
.create-job-card select optgroup {
  background: #0b1730;
  color: #eef4ff;
}

.create-job-card select option:disabled {
  color: #8fa4c8;
}


/* ===== Role toggle switch ===== */
.role-toggle {
    display: inline-grid !important;
    grid-template-columns: 1fr 1fr !important;
    gap: 4px !important;
    width: 100% !important;
    min-width: 180px !important;
    padding: 4px !important;
    border-radius: 18px !important;
    border: 1px solid rgba(148, 163, 184, 0.18) !important;
    background: linear-gradient(180deg, rgba(15, 23, 42, 0.96), rgba(9, 17, 38, 0.96)) !important;
    box-shadow: inset 0 1px 0 rgba(255,255,255,0.04), 0 8px 20px rgba(2, 6, 23, 0.24) !important;
}

.role-toggle-hidden,
.role-toggle-radio {
    position: absolute !important;
    opacity: 0 !important;
    pointer-events: none !important;
    width: 1px !important;
    height: 1px !important;
    overflow: hidden !important;
}

.role-toggle-option,
button.role-toggle-option,
input[type="button"].role-toggle-option,
input[type="submit"].role-toggle-option {
    -webkit-appearance: none !important;
    appearance: none !important;
    border: 1px solid rgba(255,255,255,0.08) !important;
    position: relative !important;
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    min-height: 42px !important;
    width: 100% !important;
    margin: 0 !important;
    padding: 0 14px !important;
    border-radius: 14px !important;
    background: rgba(15, 23, 42, 0.72) !important;
    color: rgba(226, 232, 240, 0.84) !important;
    font-size: 14px !important;
    line-height: 1.1 !important;
    font-weight: 800 !important;
    letter-spacing: .01em !important;
    cursor: pointer !important;
    user-select: none !important;
    text-align: center !important;
    white-space: nowrap !important;
    text-shadow: none !important;
    box-shadow: none !important;
    outline: none !important;
    opacity: 1 !important;
}

.role-toggle-option:hover,
button.role-toggle-option:hover {
    color: #fff !important;
    background: rgba(30, 41, 59, 0.95) !important;
}

/* The checked radio is now the single source of truth for the visual state.
   This means the toggle updates even if inline JavaScript is blocked by CSP. */
.role-toggle-radio[value="user"]:checked + .role-toggle-option {
    color: #fff !important;
    border-color: rgba(96, 165, 250, 0.3) !important;
    background: linear-gradient(135deg, rgba(59, 130, 246, 0.55), rgba(37, 99, 235, 0.72)) !important;
    box-shadow: 0 10px 24px rgba(15, 23, 42, 0.28), inset 0 1px 0 rgba(255,255,255,0.12) !important;
}

.role-toggle-radio[value="admin"]:checked + .role-toggle-option {
    color: #0f172a !important;
    border-color: rgba(250, 204, 21, 0.45) !important;
    background: linear-gradient(135deg, rgba(250, 204, 21, 0.98), rgba(234, 179, 8, 0.9)) !important;
    box-shadow: 0 10px 24px rgba(202, 138, 4, 0.28), inset 0 1px 0 rgba(255,255,255,0.18) !important;
}

.role-toggle-option:focus,
button.role-toggle-option:focus-visible {
    outline: 2px solid rgba(96, 165, 250, 0.75) !important;
    outline-offset: 2px !important;
}

.users-admin-table td .role-toggle {
    min-width: 180px !important;
}

.status-current-role {
    background: rgba(250, 204, 21, 0.16) !important;
    color: #fde68a !important;
    border-color: rgba(250, 204, 21, 0.28) !important;
}

@media (max-width: 720px) {
    .users-admin-table td .role-toggle,
    .role-toggle {
        min-width: 148px;
    }

    .role-toggle-option {
        min-height: 38px;
        padding: 0 10px;
        font-size: 13px;
    }
}


/* Final sidebar email fit tweak */
.sidebar-meta .meta-value {
  white-space: nowrap !important;
  overflow: visible !important;
  text-overflow: clip !important;
  word-break: normal !important;
  overflow-wrap: normal !important;
  display: block !important;
  width: 100%;
  max-width: 100%;
  font-size: 13px !important;
  font-weight: 700 !important;
  letter-spacing: -0.04em !important;
  line-height: 1.15 !important;
  margin-top: 4px !important;
}

.sidebar-meta {
  width: 100%;
}

.sidebar-card,
.sidebar-panel,
.account-panel,
.dashboard-sidebar .panel {
  overflow: visible !important;
}

/* Give the logged in card a touch more usable inner width */
.sidebar-card .sidebar-meta,
.account-panel .sidebar-meta {
  padding-right: 4px;
}


/* ===== Users stats cards dark theme fix ===== */
.stats-grid,
.summary-grid,
.metric-grid {
  align-items: stretch;
}

.stats-card,
.summary-card,
.metric-card,
.users-summary-card,
.dashboard-stat,
.stat-card,
.overview-card {
  background: linear-gradient(180deg, rgba(18, 31, 61, 0.96), rgba(11, 23, 48, 0.96)) !important;
  border: 1px solid rgba(148, 163, 184, 0.14) !important;
  box-shadow: inset 0 1px 0 rgba(255,255,255,0.04), 0 18px 40px rgba(2, 6, 23, 0.22) !important;
  color: #e5eefc !important;
}

.stats-card *,
.summary-card *,
.metric-card *,
.users-summary-card *,
.dashboard-stat *,
.stat-card *,
.overview-card * {
  color: inherit !important;
}

.stats-card .label,
.summary-card .label,
.metric-card .label,
.users-summary-card .label,
.dashboard-stat .label,
.stat-card .label,
.overview-card .label,
.stats-card .eyebrow,
.summary-card .eyebrow,
.metric-card .eyebrow,
.users-summary-card .eyebrow,
.dashboard-stat .eyebrow,
.stat-card .eyebrow,
.overview-card .eyebrow,
.stats-card .meta-label,
.summary-card .meta-label,
.metric-card .meta-label,
.users-summary-card .meta-label,
.dashboard-stat .meta-label,
.stat-card .meta-label,
.overview-card .meta-label {
  color: rgba(191, 219, 254, 0.78) !important;
}

.stats-card .value,
.summary-card .value,
.metric-card .value,
.users-summary-card .value,
.dashboard-stat .value,
.stat-card .value,
.overview-card .value,
.stats-card .metric-value,
.summary-card .metric-value,
.metric-card .metric-value,
.users-summary-card .metric-value,
.dashboard-stat .metric-value,
.stat-card .metric-value,
.overview-card .metric-value,
.stats-card strong,
.summary-card strong,
.metric-card strong,
.users-summary-card strong,
.dashboard-stat strong,
.stat-card strong,
.overview-card strong {
  color: #ffffff !important;
}

.stats-card,
.summary-card,
.metric-card,
.users-summary-card,
.dashboard-stat,
.stat-card,
.overview-card {
  overflow: hidden;
}

/* Extra targeting for generic first-row boxes on admin pages */
.users-page .panel-lite,
.users-page .mini-card,
.users-page .kpi-card,
.users-page .summary-box,
.users-page .stats-box {
  background: linear-gradient(180deg, rgba(18, 31, 61, 0.96), rgba(11, 23, 48, 0.96)) !important;
  border: 1px solid rgba(148, 163, 184, 0.14) !important;
  color: #e5eefc !important;
}


/* Clean Microsoft connected badge */
.status-connected-clean {
  background: rgba(34, 197, 94, 0.14) !important;
  color: #bbf7d0 !important;
  border-color: rgba(34, 197, 94, 0.28) !important;
  box-shadow: inset 0 1px 0 rgba(255,255,255,0.05);
}


/* Job logs readability */
.job-log-item {
  color: #0f172a;
}

.job-log-item .job-log-head,
.job-log-item .job-log-message,
.job-log-item .job-log-message p,
.job-log-item .job-log-message br,
.job-log-item .small {
  color: #334155;
}

.job-log-item .job-log-level {
  color: #1d4ed8;
}

.job-log-item .code-block {
  background: #0f172a;
  color: #e2e8f0;
  border: 1px solid rgba(15, 23, 42, .2);
  border-radius: 12px;
  padding: 12px 14px;
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace;
  font-size: 12px;
  line-height: 1.55;
  white-space: pre-wrap;
  word-break: break-word;
}

.job-log-item.log-info {
  background: #f8fbff;
}

.job-log-item.log-warn {
  background: #fffbeb;
}

.job-log-item.log-error {
  background: #fff7f7;
}

/* Policies & Processes pages */
.policy-list {
    margin: 0;
    padding-left: 1.35rem;
}
.policy-list li {
    margin: 0.65rem 0;
    line-height: 1.55;
}
.grid-3 {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 16px;
}
@media (max-width: 1000px) {
    .grid-3 {
        grid-template-columns: 1fr;
    }
}


/* Sidebar support modal */
.support-open-btn {
    margin-top: 12px;
}


.support-modal-backdrop[hidden] {
    display: none !important;
}

.support-modal-backdrop {
    position: fixed;
    inset: 0;
    z-index: 9999;
    display: none;
    align-items: center;
    justify-content: center;
    padding: 24px;
    background: rgba(15, 23, 42, 0.72);
    backdrop-filter: blur(8px);
}

.support-modal-backdrop.is-open {
    display: flex;
}

body.support-modal-active {
    overflow: hidden;
}

.support-modal {
    position: relative;
    width: min(560px, 100%);
    max-height: calc(100vh - 48px);
    overflow: auto;
    background: #0f1a2e;
    border-radius: 24px;
    padding: 26px;
    box-shadow: 0 28px 80px rgba(0, 0, 0, 0.45);
    border: 1px solid rgba(148, 163, 184, 0.28);
}

.support-modal-header {
    padding-right: 42px;
    margin-bottom: 18px;
}

.support-modal-header h2 {
    margin: 0 0 6px;
    font-size: 24px;
    color: #f8fafc;
}

.support-modal-close {
    position: absolute;
    top: 16px;
    right: 16px;
    width: 38px;
    height: 38px;
    border: 1px solid #e2e8f0;
    border-radius: 999px;
    background: rgba(15, 23, 42, 0.92);
    color: #f8fafc;
    font-size: 26px;
    line-height: 1;
    cursor: pointer;
}

.support-modal-close:hover {
    background: #eef2ff;
}

.support-form textarea {
    min-height: 140px;
}

.support-modal-actions {
    display: flex;
    justify-content: flex-end;
    gap: 10px;
    margin-top: 18px;
}

@media (max-width: 640px) {
    
.support-modal-backdrop[hidden] {
    display: none !important;
}

.support-modal-backdrop {
        padding: 14px;
    }

    .support-modal {
        padding: 20px;
        border-radius: 18px;
    }

    .support-modal-actions {
        flex-direction: column-reverse;
    }

    .support-modal-actions .btn {
        width: 100%;
    }
}
