:root {
    --canvas: #f3f5f6;
    --surface: #ffffff;
    --surface-soft: #f8f9fa;
    --ink: #172126;
    --ink-soft: #546168;
    --line: #dce1e3;
    --line-strong: #c9d0d3;
    --nav: #172126;
    --nav-soft: #253137;
    --teal: #167384;
    --teal-dark: #0e5968;
    --green: #28794e;
    --green-soft: #e8f4ed;
    --amber: #9a6815;
    --amber-soft: #fbf1dc;
    --red: #a63e38;
    --red-soft: #fbe9e7;
    --blue-soft: #e6f1f4;
    --shadow: 0 8px 28px rgba(23, 33, 38, 0.07);
}

* {
    box-sizing: border-box;
}

html {
    min-height: 100%;
}

body {
    background: var(--canvas);
    color: var(--ink);
    font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
    line-height: 1.5;
    margin: 0;
    min-height: 100vh;
}

a {
    color: var(--teal);
    text-decoration: none;
}

button,
input {
    font: inherit;
}

button,
a {
    -webkit-tap-highlight-color: transparent;
}

.app-shell {
    display: grid;
    grid-template-columns: 248px minmax(0, 1fr);
    min-height: 100vh;
}

.sidebar {
    background: var(--nav);
    color: #edf2f3;
    display: flex;
    flex-direction: column;
    min-height: 100vh;
    padding: 26px 18px 20px;
    position: sticky;
    top: 0;
}

.brand {
    align-items: center;
    color: #ffffff;
    display: flex;
    gap: 12px;
    padding: 0 8px;
}

.brand-mark {
    align-items: center;
    background: #ffffff;
    border-radius: 6px;
    display: flex;
    height: 38px;
    justify-content: center;
    overflow: hidden;
    padding: 4px;
    width: 38px;
}

.toolbox-logo {
    color: var(--nav);
    display: block;
    height: 100%;
    overflow: visible;
    width: 100%;
}

.toolbox-logo .logo-part {
    cursor: pointer;
    fill: currentColor;
    transition: fill 140ms ease;
}

.toolbox-logo .logo-part:hover {
    fill: #ff1f2d;
}

.brand strong,
.brand small {
    display: block;
    letter-spacing: 0;
}

.brand strong {
    font-size: 0.95rem;
}

.brand small {
    color: #9eabad;
    font-size: 0.78rem;
    margin-top: 1px;
}

.side-nav {
    display: grid;
    gap: 5px;
    margin-top: 48px;
}

.nav-item {
    align-items: center;
    border-radius: 6px;
    color: #b9c4c7;
    display: flex;
    font-size: 0.9rem;
    font-weight: 650;
    gap: 12px;
    min-height: 44px;
    padding: 0 12px;
}

.nav-item:hover {
    background: var(--nav-soft);
    color: #ffffff;
}

.nav-item.active {
    background: #ffffff;
    color: var(--nav);
}

.nav-symbol {
    color: #718187;
    font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
    font-size: 0.68rem;
    font-weight: 800;
    width: 22px;
}

.nav-item.active .nav-symbol {
    color: var(--teal);
}

.sidebar-footer {
    border-top: 1px solid #324047;
    margin-top: auto;
    padding: 18px 8px 0;
}

.account {
    align-items: center;
    display: flex;
    gap: 10px;
    min-width: 0;
}

.account-avatar {
    align-items: center;
    background: #d8e9ed;
    border-radius: 50%;
    color: var(--teal-dark);
    display: inline-flex;
    flex: 0 0 auto;
    font-size: 0.78rem;
    font-weight: 850;
    height: 34px;
    justify-content: center;
    width: 34px;
}

.account-copy {
    min-width: 0;
}

.account-copy strong,
.account-copy small {
    display: block;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.account-copy strong {
    color: #ffffff;
    font-size: 0.83rem;
}

.account-copy small {
    color: #91a0a4;
    font-size: 0.7rem;
    margin-top: 2px;
}

.sidebar-action {
    background: transparent;
    border: 0;
    color: #9eabad;
    cursor: pointer;
    font-size: 0.78rem;
    margin-top: 14px;
    padding: 0;
}

.sidebar-action:hover {
    color: #ffffff;
}

.guest-actions {
    align-items: center;
    display: flex;
    gap: 12px;
    justify-content: space-between;
}

.workspace {
    min-width: 0;
}

.mobile-header {
    display: none;
}

.page {
    margin: 0 auto;
    max-width: 1320px;
    padding: 52px 52px 64px;
}

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

.eyebrow,
.panel-kicker {
    color: var(--teal);
    font-size: 0.7rem;
    font-weight: 850;
    letter-spacing: 0;
    margin: 0 0 8px;
    text-transform: uppercase;
}

h1,
h2 {
    letter-spacing: 0;
    line-height: 1.18;
    margin: 0;
}

h1 {
    font-size: 2.25rem;
    font-weight: 750;
}

h2 {
    font-size: 1.05rem;
    font-weight: 750;
}

p {
    margin: 0;
}

.lead {
    color: var(--ink-soft);
    font-size: 0.98rem;
    margin-top: 9px;
    max-width: 650px;
}

.muted,
.table-muted {
    color: var(--ink-soft);
}

.heading-meta {
    align-items: center;
    color: var(--ink-soft);
    display: flex;
    flex: 0 0 auto;
    font-size: 0.78rem;
    gap: 8px;
    padding-bottom: 4px;
}

.heading-actions {
    align-items: center;
    display: flex;
    gap: 18px;
}

.status-dot {
    background: var(--green);
    border-radius: 50%;
    box-shadow: 0 0 0 4px var(--green-soft);
    height: 7px;
    width: 7px;
}

.status-dot.attention {
    background: var(--amber);
    box-shadow: 0 0 0 4px var(--amber-soft);
}

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

.module-sections {
    display: grid;
    gap: 34px;
}

.module-section {
    min-width: 0;
}

.section-heading {
    align-items: center;
    border-bottom: 1px solid var(--line);
    display: flex;
    justify-content: space-between;
    margin-bottom: 16px;
    padding-bottom: 12px;
}

.section-title {
    font-size: 0.95rem;
    font-weight: 800;
}

.section-description {
    color: var(--ink-soft);
    font-size: 0.75rem;
    margin-top: 3px;
}

.section-toggle {
    background: transparent;
    border: 0;
    color: var(--teal);
    cursor: pointer;
    font-size: 0.72rem;
    font-weight: 750;
    padding: 6px;
}

.collapsed-summary {
    background: var(--surface-soft);
    border: 1px dashed var(--line-strong);
    border-radius: 6px;
    color: var(--ink-soft);
    font-size: 0.76rem;
    padding: 16px;
}

.module-card {
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: 8px;
    display: flex;
    flex-direction: column;
    min-height: 260px;
    overflow: hidden;
    padding: 22px;
    position: relative;
    transition: border-color 150ms ease, box-shadow 150ms ease, transform 150ms ease;
}

.module-card::before {
    background: var(--teal);
    content: "";
    height: 3px;
    left: 0;
    position: absolute;
    right: 0;
    top: 0;
}

.module-card.module-2::before {
    background: #bf7a28;
}

.module-card.module-3::before {
    background: #66727d;
}

.module-card:hover {
    border-color: var(--line-strong);
    box-shadow: var(--shadow);
    transform: translateY(-2px);
}

.module-card-top {
    align-items: center;
    display: flex;
    justify-content: space-between;
}

.module-number {
    color: #9aa5a9;
    font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
    font-size: 0.72rem;
    font-weight: 750;
}

.module-state,
.provider-label,
.count-badge {
    background: var(--surface-soft);
    border: 1px solid var(--line);
    border-radius: 999px;
    color: var(--ink-soft);
    display: inline-flex;
    font-size: 0.68rem;
    font-weight: 750;
    padding: 4px 8px;
}

.module-state.ready {
    background: var(--green-soft);
    border-color: #c8e4d3;
    color: var(--green);
}

.module-state.setup {
    background: var(--amber-soft);
    border-color: #ead7af;
    color: var(--amber);
}

.module-copy {
    margin-top: 42px;
}

.module-copy h2 {
    font-size: 1.28rem;
}

.module-copy p {
    color: var(--ink-soft);
    font-size: 0.86rem;
    margin-top: 10px;
}

.module-link {
    align-items: center;
    border-top: 1px solid var(--line);
    color: var(--ink);
    display: flex;
    font-size: 0.8rem;
    font-weight: 750;
    justify-content: space-between;
    margin-top: auto;
    padding-top: 16px;
}

.module-link:hover {
    color: var(--teal);
}

.module-link.disabled {
    color: #929da1;
}

.admin-grid {
    align-items: start;
    display: grid;
    gap: 18px;
    grid-template-columns: minmax(0, 1.55fr) minmax(320px, 0.65fr);
}

.panel,
.auth-card,
.status-page,
.empty-state {
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: 8px;
}

.panel {
    padding: 22px;
}

.panel-heading {
    align-items: center;
    display: flex;
    justify-content: space-between;
    margin-bottom: 20px;
}

.panel-kicker {
    color: var(--ink-soft);
    margin-bottom: 5px;
}

.count-badge {
    align-items: center;
    background: var(--blue-soft);
    border: 0;
    color: var(--teal-dark);
    height: 28px;
    justify-content: center;
    min-width: 28px;
}

.panel-empty {
    align-items: center;
    background: var(--surface-soft);
    border: 1px dashed var(--line-strong);
    border-radius: 6px;
    display: flex;
    flex-direction: column;
    min-height: 150px;
    justify-content: center;
    padding: 24px;
    text-align: center;
}

.panel-empty strong {
    font-size: 0.9rem;
}

.panel-empty span {
    color: var(--ink-soft);
    font-size: 0.8rem;
    margin-top: 4px;
}

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

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

th,
td {
    border-bottom: 1px solid var(--line);
    padding: 13px 9px;
    text-align: left;
    vertical-align: middle;
}

th {
    color: #7b878b;
    font-size: 0.66rem;
    font-weight: 800;
    text-transform: uppercase;
}

td {
    font-size: 0.8rem;
}

.row-actions {
    display: flex;
    gap: 7px;
    justify-content: flex-end;
}

.row-actions form {
    margin: 0;
}

.form {
    display: grid;
    gap: 17px;
}

.form label {
    color: var(--ink-soft);
    display: grid;
    font-size: 0.78rem;
    font-weight: 700;
    gap: 7px;
}

input {
    background: #ffffff;
    border: 1px solid var(--line-strong);
    border-radius: 6px;
    color: var(--ink);
    min-height: 42px;
    padding: 9px 11px;
    width: 100%;
}

select {
    appearance: none;
    background-color: #ffffff;
    background-image:
        linear-gradient(45deg, transparent 50%, #718087 50%),
        linear-gradient(135deg, #718087 50%, transparent 50%);
    background-position:
        calc(100% - 15px) 50%,
        calc(100% - 10px) 50%;
    background-repeat: no-repeat;
    background-size: 5px 5px, 5px 5px;
    border: 1px solid var(--line-strong);
    border-radius: 6px;
    color: var(--ink);
    min-height: 40px;
    padding: 8px 30px 8px 10px;
}

input:focus {
    border-color: var(--teal);
    box-shadow: 0 0 0 3px rgba(22, 115, 132, 0.12);
    outline: 0;
}

select:focus {
    border-color: var(--teal);
    box-shadow: 0 0 0 3px rgba(22, 115, 132, 0.12);
    outline: 0;
}

.inline-form {
    display: flex;
    gap: 8px;
    margin-bottom: 14px;
}

.button,
.oauth-button,
.small-button {
    align-items: center;
    border: 1px solid transparent;
    border-radius: 6px;
    cursor: pointer;
    display: inline-flex;
    font-weight: 750;
    justify-content: center;
    min-height: 42px;
    padding: 9px 15px;
}

.button.compact {
    font-size: 0.78rem;
    min-height: 36px;
    padding: 7px 11px;
}

.button.primary {
    background: var(--teal);
    color: #ffffff;
}

.button.primary:hover {
    background: var(--teal-dark);
}

.button.secondary,
.oauth-button {
    background: var(--surface);
    border-color: var(--line-strong);
    color: var(--ink);
}

.oauth-button:hover,
.button.secondary:hover {
    background: var(--surface-soft);
}

.small-button {
    font-size: 0.7rem;
    min-height: 32px;
    padding: 6px 9px;
}

.approve {
    background: var(--green-soft);
    border-color: #c8e4d3;
    color: var(--green);
}

.decline {
    background: var(--red-soft);
    border-color: #efd0cd;
    color: var(--red);
}

.link-button {
    background: transparent;
    border: 0;
    color: var(--teal);
    cursor: pointer;
    padding: 0;
}

.danger {
    color: var(--red);
}

.list {
    display: grid;
}

.list-row {
    align-items: center;
    border-top: 1px solid var(--line);
    display: flex;
    font-size: 0.78rem;
    gap: 12px;
    justify-content: space-between;
    min-width: 0;
    padding: 12px 0;
}

.list-row span {
    overflow: hidden;
    text-overflow: ellipsis;
}

.auth-card,
.status-page,
.empty-state {
    margin: 34px auto;
    max-width: 520px;
    padding: 30px;
}

.settings-list {
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: 8px;
}

.settings-row {
    align-items: center;
    display: grid;
    gap: 16px;
    grid-template-columns: 40px minmax(0, 1fr) auto;
    padding: 20px 22px;
}

.settings-row + .settings-row {
    border-top: 1px solid var(--line);
}

.settings-status {
    align-items: center;
    border-radius: 50%;
    display: flex;
    font-size: 0.72rem;
    font-weight: 900;
    height: 34px;
    justify-content: center;
    width: 34px;
}

.settings-status.valid {
    background: var(--green-soft);
    color: var(--green);
}

.settings-status.incomplete {
    background: var(--amber-soft);
    color: var(--amber);
}

.settings-copy p {
    color: var(--ink-soft);
    font-size: 0.78rem;
    margin-top: 4px;
}

.settings-state {
    align-items: center;
    display: flex;
    gap: 14px;
}

.settings-state > span {
    color: var(--ink-soft);
    font-size: 0.75rem;
}

.settings-form-panel {
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: 8px;
    max-width: 680px;
    padding: 26px;
}

.settings-form-panel .form label > span {
    align-items: center;
    display: flex;
    justify-content: space-between;
}

.settings-form-panel em {
    color: var(--amber);
    font-size: 0.65rem;
    font-style: normal;
    text-transform: uppercase;
}

.settings-form-panel small {
    color: var(--ink-soft);
    font-size: 0.7rem;
    font-weight: 400;
}

.form-actions {
    border-top: 1px solid var(--line);
    display: flex;
    gap: 8px;
    justify-content: flex-end;
    margin-top: 6px;
    padding-top: 18px;
}

.management-section {
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: 8px;
    margin-bottom: 18px;
    padding: 22px;
}

.module-management-list,
.user-access-list {
    display: grid;
}

.module-management-row {
    align-items: end;
    border-top: 1px solid var(--line);
    display: grid;
    gap: 10px;
    grid-template-columns: minmax(160px, 1.3fr) repeat(3, minmax(130px, 0.75fr)) auto;
    padding: 14px 0;
}

.module-management-row label,
.user-module-grid label {
    color: var(--ink-soft);
    display: grid;
    font-size: 0.66rem;
    font-weight: 750;
    gap: 5px;
}

.management-name strong,
.management-name small,
.user-access-heading strong,
.user-access-heading small {
    display: block;
}

.management-name strong,
.user-access-heading strong {
    font-size: 0.8rem;
}

.management-name small,
.user-access-heading small {
    color: var(--ink-soft);
    font-size: 0.68rem;
    margin-top: 2px;
}

.user-access-row {
    border-top: 1px solid var(--line);
    padding: 18px 0;
}

.user-access-heading {
    align-items: center;
    display: flex;
    gap: 10px;
    margin-bottom: 14px;
}

.user-module-grid {
    display: grid;
    gap: 10px;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    margin-bottom: 12px;
}

.auth-card h1,
.status-page h1 {
    font-size: 1.8rem;
}

.auth-card .lead,
.status-page .lead {
    font-size: 0.92rem;
}

.oauth-grid {
    display: grid;
    gap: 8px;
    margin: 22px 0;
}

.actions {
    display: flex;
    gap: 10px;
    margin-top: 26px;
}

.split {
    align-items: start;
    display: grid;
    gap: 28px;
    grid-template-columns: minmax(0, 1.25fr) minmax(280px, 0.75fr);
    padding-top: 30px;
}

.split > div {
    padding: 30px 0;
}

.split h1 {
    font-size: 2.8rem;
    max-width: 700px;
}

.flash {
    border: 1px solid;
    border-radius: 6px;
    font-size: 0.8rem;
    font-weight: 700;
    margin-bottom: 18px;
    padding: 11px 13px;
}

.flash-error {
    background: var(--red-soft);
    border-color: #efd0cd;
    color: var(--red);
}

.flash-success {
    background: var(--green-soft);
    border-color: #c8e4d3;
    color: var(--green);
}

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

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

@media (max-width: 760px) {
    .app-shell {
        display: block;
    }

    .sidebar {
        display: none;
    }

    .mobile-header {
        align-items: center;
        background: var(--surface);
        border-bottom: 1px solid var(--line);
        display: flex;
        justify-content: space-between;
        min-height: 58px;
        padding: 0 18px;
    }

    .mobile-brand {
        align-items: center;
        color: var(--ink);
        display: flex;
        font-size: 0.88rem;
        font-weight: 800;
        gap: 9px;
    }

    .mobile-logo {
        display: inline-flex;
        height: 32px;
        width: 32px;
    }

    .page {
        padding: 28px 16px 44px;
    }

    .page-heading {
        align-items: flex-start;
        flex-direction: column;
        gap: 14px;
        margin-bottom: 22px;
    }

    .heading-actions,
    .settings-state {
        align-items: flex-start;
        flex-direction: column;
    }

    h1 {
        font-size: 1.8rem;
    }

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

    .module-card {
        min-height: 220px;
    }

    .module-copy {
        margin-top: 30px;
    }

    .split {
        grid-template-columns: 1fr;
        padding-top: 0;
    }

    .split h1 {
        font-size: 2rem;
    }

    .row-actions,
    .inline-form {
        align-items: stretch;
        flex-direction: column;
    }

    .settings-row {
        align-items: start;
        grid-template-columns: 36px minmax(0, 1fr);
    }

    .settings-state {
        grid-column: 2;
        gap: 8px;
    }

    .module-management-row,
    .user-module-grid {
        grid-template-columns: 1fr;
    }

    .module-management-row {
        align-items: stretch;
    }

    .auth-card,
    .status-page,
    .empty-state {
        margin-top: 12px;
        padding: 22px;
    }
}
