:root {
    --blue-900: #153653;
    --blue-700: #2e638f;
    --blue-600: #3f78a8;
    --blue-100: #e7f0f7;
    --surface: #ffffff;
    --background: #f4f7fa;
    --text: #1c2b39;
    --muted: #667786;
    --border: #dfe7ee;
    --shadow: 0 12px 30px rgba(21, 54, 83, 0.11);
    --radius: 10px;
    color-scheme: light;
    font-family: Inter, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}

* { box-sizing: border-box; }

html { min-height: 100%; background: var(--background); }

body {
    min-height: 100vh;
    margin: 0;
    color: var(--text);
    background: var(--background);
    -webkit-font-smoothing: antialiased;
}

a { color: inherit; }

.skip-link {
    position: fixed;
    z-index: 100;
    top: 10px;
    left: 10px;
    padding: 10px 14px;
    color: #fff;
    background: var(--blue-900);
    border-radius: 8px;
    transform: translateY(-160%);
}

.skip-link:focus { transform: translateY(0); }

.topbar {
    position: sticky;
    z-index: 20;
    top: 0;
    display: flex;
    align-items: center;
    justify-content: space-between;
    min-height: 58px;
    padding: 0 clamp(18px, 3vw, 42px);
    color: #fff;
    background: rgba(46, 99, 143, 0.96);
    border-bottom: 1px solid rgba(255, 255, 255, 0.2);
    box-shadow: 0 5px 20px rgba(21, 54, 83, 0.16);
    backdrop-filter: blur(12px);
}

.brand {
    display: inline-flex;
    align-items: center;
    gap: 12px;
    color: #fff;
    text-decoration: none;
}

.brand-logo {
    display: block;
    width: 92px;
    height: 40px;
    object-fit: contain;
}

.brand-copy { display: flex; flex-direction: column; line-height: 1.15; }
.brand-copy strong { font-size: 13px; }
.brand-copy small { margin-top: 2px; color: rgba(255, 255, 255, 0.72); font-size: 10px; }

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

.app-switcher {
    display: grid;
    width: 34px;
    height: 34px;
    place-items: center;
    color: #fff;
    font-size: 16px;
    text-decoration: none;
    border: 1px solid transparent;
    border-radius: 9px;
    transition: background 160ms ease, border-color 160ms ease, transform 160ms ease;
}

.app-switcher:hover, .app-switcher:focus-visible, .app-switcher.is-active {
    background: rgba(255, 255, 255, 0.16);
    border-color: rgba(255, 255, 255, 0.28);
    transform: translateY(-1px);
}

.topbar-divider { width: 1px; height: 20px; background: rgba(255, 255, 255, 0.25); }
.organization-label { font-size: 12px; font-weight: 600; }

.page-shell {
    width: min(1360px, calc(100% - 36px));
    margin: 0 auto;
    padding: clamp(26px, 3.5vw, 44px) 0 56px;
}

.page-heading {
    display: flex;
    align-items: end;
    justify-content: space-between;
    gap: 18px;
    margin-bottom: 24px;
}

.eyebrow {
    display: block;
    margin-bottom: 5px;
    color: var(--blue-600);
    font-size: 10px;
    font-weight: 800;
    letter-spacing: 0.12em;
    text-transform: uppercase;
}

.page-heading h1, .module-hero h1 {
    margin: 0;
    color: var(--blue-900);
    font-size: clamp(25px, 3vw, 34px);
    line-height: 1.08;
    letter-spacing: -0.035em;
}

.page-heading h1 i { margin-right: 6px; font-size: 0.72em; }
.page-heading p, .module-hero p { max-width: 580px; margin: 7px 0 0; color: var(--muted); font-size: 13px; line-height: 1.5; }

.module-count {
    flex: none;
    padding: 6px 9px;
    color: var(--blue-700);
    font-size: 10px;
    font-weight: 700;
    background: var(--blue-100);
    border-radius: 999px;
}

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

.app-card {
    position: relative;
    isolation: isolate;
    display: flex;
    min-height: 184px;
    padding: 17px;
    overflow: hidden;
    flex-direction: column;
    color: #fff;
    text-decoration: none;
    background: var(--card-color);
    border: 1px solid rgba(255, 255, 255, 0.18);
    border-radius: var(--radius);
    box-shadow: 0 7px 18px color-mix(in srgb, var(--card-color) 18%, transparent);
    opacity: 0;
    transform: translateY(12px);
    animation: reveal 440ms ease forwards;
    animation-delay: var(--delay);
    transition: transform 180ms ease, box-shadow 180ms ease;
}

.theme-blue { --card-color: #315b8c; --module-color: #315b8c; }
.theme-teal { --card-color: #3d8b7d; --module-color: #3d8b7d; }
.theme-orange { --card-color: #dc7a2a; --module-color: #dc7a2a; }
.theme-purple { --card-color: #5b4f99; --module-color: #5b4f99; }
.theme-rose { --card-color: #b83268; --module-color: #b83268; }
.theme-slate { --card-color: #526a7a; --module-color: #526a7a; }
.sequence-1 { --delay: 0ms; }
.sequence-2 { --delay: 45ms; }
.sequence-3 { --delay: 90ms; }
.sequence-4 { --delay: 135ms; }
.sequence-5 { --delay: 180ms; }
.sequence-6 { --delay: 225ms; }

.app-card::after {
    content: "";
    position: absolute;
    z-index: -1;
    right: -42px;
    bottom: -55px;
    width: 125px;
    height: 125px;
    background: rgba(255, 255, 255, 0.07);
    border-radius: 50%;
}

.app-card:hover, .app-card:focus-visible {
    outline: none;
    transform: translateY(-4px);
    box-shadow: 0 12px 26px color-mix(in srgb, var(--card-color) 28%, transparent);
}

.app-card-status {
    position: absolute;
    top: 11px;
    right: 11px;
    padding: 4px 6px;
    font-size: 7px;
    font-weight: 800;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    background: rgba(0, 0, 0, 0.16);
    border-radius: 999px;
}

.app-card-icon { display: block; margin: 17px 0 14px; font-size: 28px; line-height: 1; }
.app-card strong { max-width: 170px; font-size: 16px; line-height: 1.15; }
.app-card-description { margin-top: 7px; color: rgba(255, 255, 255, 0.78); font-size: 11px; line-height: 1.4; }
.app-card-cta { display: flex; align-items: center; gap: 6px; margin-top: auto; padding-top: 14px; font-size: 10px; font-weight: 800; }
.app-card-cta i { transition: transform 160ms ease; }
.app-card:hover .app-card-cta i { transform: translateX(4px); }

.breadcrumb { display: flex; align-items: center; gap: 8px; margin-bottom: 20px; color: var(--muted); font-size: 11px; }
.breadcrumb a { color: var(--blue-700); font-weight: 700; text-decoration: none; }
.breadcrumb a:hover { text-decoration: underline; }

.module-hero {
    display: flex;
    align-items: center;
    gap: 20px;
    padding: clamp(20px, 3vw, 30px);
    background: #fff;
    border: 1px solid var(--border);
    border-top: 5px solid var(--module-color);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
}

.module-hero-icon {
    display: grid;
    flex: 0 0 auto;
    width: 66px;
    height: 66px;
    place-items: center;
    color: #fff;
    font-size: 28px;
    background: var(--module-color);
    border-radius: 16px;
}

.empty-state {
    max-width: 680px;
    margin: 48px auto 0;
    text-align: center;
}

.empty-state > i { color: var(--blue-600); font-size: 30px; }
.empty-state h1, .empty-state h2 { margin: 12px 0 6px; color: var(--blue-900); font-size: 21px; }
.empty-state p { margin: 0 auto 20px; color: var(--muted); font-size: 13px; line-height: 1.55; }

.button {
    display: inline-flex;
    align-items: center;
    gap: 9px;
    padding: 9px 13px;
    color: #fff;
    font-weight: 700;
    text-decoration: none;
    background: var(--blue-700);
    border-radius: 8px;
    font-size: 12px;
    box-shadow: 0 8px 18px rgba(46, 99, 143, 0.2);
}

.button:hover, .button:focus-visible { background: var(--blue-900); }
.error-code { display: block; color: var(--blue-600); font-size: 72px; font-weight: 900; letter-spacing: -0.06em; }

.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; border: 0; }
.settings-heading { margin-bottom: 20px; }
.settings-heading h1 { margin: 0; color: var(--blue-900); font-size: clamp(24px, 3vw, 32px); letter-spacing: -0.035em; }
.settings-heading h1 i { margin-right: 7px; font-size: 0.72em; }
.settings-heading p { margin: 6px 0 0; color: var(--muted); font-size: 13px; }
.alert { display: flex; align-items: center; gap: 9px; margin-bottom: 14px; padding: 10px 13px; font-size: 12px; border: 1px solid; border-radius: 8px; }
.alert-success { color: #1f684e; background: #e9f7f1; border-color: #bfe4d5; }
.alert-error { color: #8a3146; background: #fff0f3; border-color: #efc4ce; }
.integration-list { display: grid; max-width: 960px; gap: 20px; }
.integration-card { --provider-color: #814657; --provider-soft: #f5f2f3; position: relative; overflow: hidden; background: var(--surface); border: 1px solid #d7dee5; border-radius: 12px; box-shadow: 0 10px 28px rgba(21, 54, 83, 0.08); }
.provider-grok { --provider-color: #20252b; --provider-soft: #f0f2f4; }
.integration-accent { height: 4px; background: var(--provider-color); }
.integration-header { display: flex; align-items: center; justify-content: space-between; gap: 18px; padding: 20px 24px 14px; }
.integration-identity { display: flex; align-items: center; gap: 13px; }
.integration-logo { display: grid; width: 46px; height: 46px; place-items: center; color: var(--provider-color); font-size: 21px; background: var(--provider-soft); border-radius: 12px; }
.integration-identity > span:last-child { display: flex; flex-direction: column; }
.integration-identity strong { color: #151a20; font-size: 20px; line-height: 1.2; }
.integration-identity small { margin-top: 4px; color: var(--muted); font-size: 12px; }
.integration-actions { display: flex; align-items: center; gap: 14px; }
.button { border: 0; cursor: pointer; font-family: inherit; }
.button-outline { color: var(--provider-color); background: #fff; border: 1px solid var(--provider-color); box-shadow: none; }
.button-outline:hover, .button-outline:focus-visible { color: #fff; background: var(--provider-color); }
.switch { position: relative; display: inline-flex; cursor: pointer; }
.switch input { position: absolute; opacity: 0; pointer-events: none; }
.switch > span:first-of-type { position: relative; width: 46px; height: 26px; background: #aab5bd; border-radius: 999px; transition: background 160ms ease; }
.switch > span:first-of-type::after { content: ""; position: absolute; top: 3px; left: 3px; width: 20px; height: 20px; background: #fff; border-radius: 50%; box-shadow: 0 1px 4px rgba(0,0,0,.25); transition: transform 160ms ease; }
.switch input:checked + span { background: var(--provider-color); }
.switch input:checked + span::after { transform: translateX(20px); }
.switch input:focus-visible + span { outline: 3px solid rgba(63, 120, 168, .3); outline-offset: 2px; }
.settings-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px 20px; padding: 14px 24px 20px; }
.settings-grid label { display: flex; min-width: 0; flex-direction: column; gap: 7px; color: #1d2832; font-size: 12px; font-weight: 700; }
.settings-grid input, .settings-grid select { width: 100%; height: 42px; padding: 0 12px; color: var(--text); font: inherit; font-weight: 400; background: #fff; border: 1px solid #cad3db; border-radius: 8px; outline: none; }
.settings-grid input:focus, .settings-grid select:focus { border-color: var(--blue-600); box-shadow: 0 0 0 3px rgba(63, 120, 168, .12); }
.settings-grid label > small { color: var(--muted); font-size: 10px; font-weight: 400; }
.field-wide { grid-column: 1 / -1; }
.field-token { grid-column: 1 / -1; }
.configured-badge { display: inline-flex; align-self: flex-start; margin: -24px 0 1px 44px; padding: 3px 7px; color: #26634f; font-size: 9px; font-weight: 700; background: #e6f5ef; border-radius: 99px; }
.input-secret { position: relative; display: block; }
.input-secret input { padding-right: 42px; }
.input-secret button { position: absolute; top: 1px; right: 1px; display: grid; width: 40px; height: 40px; place-items: center; color: var(--muted); background: transparent; border: 0; cursor: pointer; }
.integration-footer { display: flex; align-items: center; justify-content: space-between; gap: 16px; padding: 14px 24px; background: #f8fafb; border-top: 1px solid var(--border); }
.integration-footer > a { color: var(--blue-700); font-size: 11px; font-weight: 700; text-decoration: none; }
.integration-footer > a:hover { text-decoration: underline; }

@keyframes reveal { to { opacity: 1; transform: translateY(0); } }

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

@media (max-width: 900px) {
    .apps-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
}

@media (max-width: 620px) {
    .topbar { min-height: 56px; padding: 0 14px; }
    .brand-logo { width: 82px; height: 36px; }
    .brand-copy small, .organization-label, .topbar-divider { display: none; }
    .page-shell { width: min(100% - 24px, 1360px); padding-top: 24px; }
    .page-heading { align-items: start; flex-direction: column; margin-bottom: 20px; }
    .apps-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
    .app-card { min-height: 176px; padding: 15px; }
    .app-card-icon { margin-top: 17px; }
    .module-hero { align-items: flex-start; flex-direction: column; }
    .module-hero-icon { width: 72px; height: 72px; font-size: 32px; border-radius: 18px; }
    .integration-header { align-items: flex-start; padding: 17px 16px 10px; flex-direction: column; }
    .integration-actions { width: 100%; justify-content: space-between; }
    .settings-grid { grid-template-columns: 1fr; padding: 12px 16px 18px; }
    .field-wide, .field-token { grid-column: auto; }
    .integration-footer { align-items: stretch; padding: 13px 16px; flex-direction: column; }
    .integration-footer .button { justify-content: center; }
}

@media (max-width: 390px) {
    .apps-grid { grid-template-columns: 1fr; }
}

@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after { scroll-behavior: auto !important; animation-duration: 0.01ms !important; animation-iteration-count: 1 !important; transition-duration: 0.01ms !important; }
}

