:root {
    --bg: #f2f5f3;
    --surface: #ffffff;
    --surface-soft: #f7faf8;
    --surface-green: #eef8f3;
    --sidebar: #0a211a;
    --sidebar-soft: #12382b;
    --text: #13251e;
    --muted: #667a71;
    --muted-light: #91a097;
    --border: #dce6e1;
    --border-strong: #c8d6cf;
    --primary: #0f8f61;
    --primary-dark: #08734d;
    --primary-soft: #e4f5ed;
    --blue: #3679d8;
    --blue-soft: #eaf2ff;
    --violet: #7b61c9;
    --violet-soft: #f0edff;
    --orange: #c87427;
    --orange-soft: #fff2e5;
    --danger: #c44848;
    --danger-soft: #fff0f0;
    --warning: #a66a16;
    --warning-soft: #fff5dd;
    --shadow-xs: 0 1px 2px rgba(10, 35, 26, .04);
    --shadow-sm: 0 1px 2px rgba(10, 35, 26, .04), 0 8px 24px rgba(10, 35, 26, .045);
    --shadow-lg: 0 24px 80px rgba(7, 35, 25, .22);
    --radius-sm: 9px;
    --radius: 13px;
    --radius-lg: 17px;
    --sidebar-width: 252px;
    --transition: 160ms ease;
}

* {
    box-sizing: border-box;
}

html {
    min-height: 100%;
    color-scheme: light;
    background: var(--bg);
}

body {
    min-height: 100vh;
    margin: 0;
    color: var(--text);
    background: var(--bg);
    font: 14px/1.55 Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
    -webkit-font-smoothing: antialiased;
}

button,
input,
select,
textarea {
    font: inherit;
}

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

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

button {
    color: inherit;
}

h1,
h2,
h3,
p,
dl,
dd {
    margin: 0;
}

h1,
h2,
h3,
strong {
    color: var(--text);
}

h1 {
    font-size: 26px;
    line-height: 1.2;
    letter-spacing: -.035em;
}

h2 {
    font-size: 20px;
    line-height: 1.3;
    letter-spacing: -.025em;
}

h3 {
    font-size: 15px;
    line-height: 1.35;
    letter-spacing: -.01em;
}

small {
    color: var(--muted);
}

code {
    display: inline-block;
    max-width: 100%;
    padding: 3px 7px;
    overflow-wrap: anywhere;
    color: #116844;
    border: 1px solid #d5e9df;
    border-radius: 7px;
    background: #f1faf5;
    font: 12px/1.45 ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
}

.icon {
    display: block;
    width: 18px;
    height: 18px;
    flex: 0 0 auto;
}

.stack {
    display: grid;
    gap: 16px;
}

.muted-text {
    color: var(--muted);
}

.error-text {
    color: var(--danger);
}

/* Buttons */

.btn {
    display: inline-flex;
    min-height: 40px;
    padding: 9px 14px;
    align-items: center;
    justify-content: center;
    gap: 8px;
    color: var(--text);
    border: 1px solid transparent;
    border-radius: var(--radius-sm);
    outline: none;
    cursor: pointer;
    background: transparent;
    font-weight: 700;
    line-height: 1.2;
    white-space: nowrap;
    transition: background var(--transition), border-color var(--transition), box-shadow var(--transition), transform var(--transition);
}

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

.btn:disabled,
.btn[aria-busy="true"] {
    cursor: wait;
    opacity: .62;
    transform: none;
}

.btn:focus-visible,
.icon-btn:focus-visible {
    box-shadow: 0 0 0 3px rgba(19, 154, 103, .18);
}

.btn-primary {
    color: #fff;
    border-color: var(--primary);
    background: var(--primary);
    box-shadow: 0 5px 14px rgba(19, 154, 103, .18);
}

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

.btn-danger {
    color: #a43e3e;
    border-color: #efcaca;
    background: #fff6f6;
}

.btn-danger:hover {
    color: #fff;
    border-color: var(--danger);
    background: var(--danger);
}

.btn-secondary {
    color: #24533f;
    border-color: #cfe1d8;
    background: #f7fbf9;
}

.btn-secondary:hover {
    border-color: #b9d5c8;
    background: var(--primary-soft);
}

.btn-ghost {
    color: var(--muted);
    border-color: transparent;
    background: transparent;
}

.btn-ghost:hover {
    color: var(--text);
    background: rgba(103, 126, 116, .09);
}

.btn-sm {
    min-height: 36px;
    padding: 7px 11px;
    font-size: 13px;
}

.btn-icon-only {
    width: 36px;
    min-width: 36px;
    height: 36px;
    min-height: 36px;
    padding: 0;
    flex: 0 0 36px;
}

.btn-icon-only .icon {
    width: 16px;
    height: 16px;
}

.btn-block {
    width: 100%;
}

.icon-btn {
    display: inline-grid;
    width: 38px;
    height: 38px;
    padding: 0;
    flex: 0 0 auto;
    place-items: center;
    color: var(--muted);
    border: 1px solid var(--border);
    border-radius: 10px;
    outline: none;
    cursor: pointer;
    background: var(--surface);
    transition: color var(--transition), background var(--transition), border-color var(--transition);
}

.icon-btn:hover {
    color: var(--primary-dark);
    border-color: #bcd8ca;
    background: var(--primary-soft);
}

/* Form controls */

.field {
    display: grid;
    min-width: 0;
    gap: 7px;
}

.field > span {
    color: #31453c;
    font-size: 13px;
    font-weight: 700;
}

.field > small {
    margin-top: -2px;
    font-size: 12px;
    font-weight: 500;
}

input,
select,
textarea {
    width: 100%;
    min-width: 0;
    min-height: 44px;
    padding: 10px 12px;
    color: var(--text);
    border: 1px solid var(--border-strong);
    border-radius: 10px;
    outline: none;
    background: var(--surface);
    transition: border-color var(--transition), box-shadow var(--transition), background var(--transition);
}

textarea {
    min-height: 116px;
    line-height: 1.55;
    resize: vertical;
}

input::placeholder,
textarea::placeholder {
    color: #a2afa9;
}

input:focus,
select:focus,
textarea:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(19, 154, 103, .11);
}

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

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

.form-divider {
    display: flex;
    align-items: center;
    gap: 12px;
    color: var(--muted);
    font-size: 11px;
    font-weight: 800;
    letter-spacing: .08em;
    text-transform: uppercase;
}

.form-divider::after {
    height: 1px;
    flex: 1;
    content: "";
    background: var(--border);
}

.form-fieldset {
    margin: 0;
    padding: 16px;
    border: 1px solid var(--border);
    border-radius: 12px;
    background: var(--surface-soft);
}

.form-fieldset legend {
    padding: 0 7px;
    color: var(--muted);
    font-size: 11px;
    font-weight: 800;
    letter-spacing: .08em;
    text-transform: uppercase;
}

.check-row input {
    width: 17px;
    height: 17px;
    min-height: 0;
    margin: 0;
    accent-color: var(--primary);
}

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

.team-weight-option {
    display: grid;
    min-height: 112px;
    padding: 11px;
    gap: 11px;
    border: 1px solid var(--border);
    border-radius: 10px;
    background: var(--surface);
}

.team-weight-option:has(input[type="checkbox"]:checked) {
    color: var(--primary-dark);
    border-color: #aed6c3;
    background: var(--primary-soft);
}

.team-weight-choice {
    display: flex;
    min-width: 0;
    align-items: center;
    gap: 9px;
    cursor: pointer;
}

.team-weight-choice strong {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.team-weight-choice input[type="checkbox"] {
    width: 17px;
    height: 17px;
    min-height: 0;
    margin: 0;
    flex: 0 0 auto;
    accent-color: var(--primary);
}

.team-membership-controls {
    display: grid;
    grid-template-columns: 72px repeat(2, minmax(0, 1fr));
    gap: 8px;
}

.team-membership-field {
    display: grid;
    gap: 5px;
}

.team-membership-field small {
    color: var(--muted);
    font-size: 10px;
    font-weight: 800;
    letter-spacing: .04em;
    text-transform: uppercase;
}

.team-membership-field input {
    width: 100%;
    min-height: 36px;
    padding: 7px 8px;
}

.team-membership-field input[type="number"] {
    text-align: center;
}

.fieldset-help {
    display: block;
    margin-top: 10px;
    color: var(--muted);
    line-height: 1.5;
}

.check-row {
    display: flex;
    padding: 11px 12px;
    align-items: center;
    gap: 10px;
    border: 1px solid var(--border);
    border-radius: 10px;
    background: var(--surface-soft);
    cursor: pointer;
}

.check-row input {
    margin-top: 2px;
}

.check-row span,
.check-row strong,
.check-row small {
    display: block;
}

.check-row small {
    margin-top: 2px;
}

.danger-check {
    border-color: #f0cccc;
    background: #fff7f7;
}

.danger-check strong {
    color: var(--danger);
}

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

.switch-card {
    display: flex;
    min-height: 56px;
    padding: 13px 14px;
    align-items: center;
    justify-content: space-between;
    gap: 15px;
    border: 1px solid var(--border);
    border-radius: 11px;
    background: var(--surface-soft);
    cursor: pointer;
}

.switch-card span,
.switch-card strong,
.switch-card small {
    display: block;
}

.switch-card small {
    margin-top: 3px;
    font-weight: 500;
}

.switch-card input[type="checkbox"] {
    position: relative;
    width: 44px;
    height: 24px;
    min-height: 24px;
    padding: 0;
    flex: 0 0 auto;
    appearance: none;
    border: 0;
    border-radius: 999px;
    cursor: pointer;
    background: #bac6c0;
    box-shadow: none;
    transition: background var(--transition);
}

.switch-card input[type="checkbox"]::before {
    position: absolute;
    top: 3px;
    left: 3px;
    width: 18px;
    height: 18px;
    content: "";
    border-radius: 50%;
    background: #fff;
    box-shadow: 0 1px 4px rgba(0, 0, 0, .2);
    transition: transform var(--transition);
}

.switch-card input[type="checkbox"]:checked {
    background: var(--primary);
}

.switch-card input[type="checkbox"]:checked::before {
    transform: translateX(20px);
}

.input-suffix {
    display: flex;
    align-items: stretch;
}

.input-suffix input {
    border-radius: 10px 0 0 10px;
}

.input-suffix > span {
    display: flex;
    min-width: 58px;
    padding: 0 12px;
    align-items: center;
    justify-content: center;
    color: var(--muted);
    border: 1px solid var(--border-strong);
    border-left: 0;
    border-radius: 0 10px 10px 0;
    background: var(--surface-soft);
    font-size: 12px;
    font-weight: 700;
}

/* Login */

.login-page {
    display: grid;
    min-height: 100vh;
    padding: 24px;
    place-items: center;
    color: #fff;
    background:
        radial-gradient(circle at 12% 15%, rgba(46, 201, 145, .21), transparent 30%),
        radial-gradient(circle at 92% 85%, rgba(29, 150, 106, .12), transparent 35%),
        linear-gradient(145deg, #082c20, #071c16);
}

.login-shell {
    display: grid;
    width: min(100%, 1040px);
    grid-template-columns: 1.08fr .92fr;
    overflow: hidden;
    border: 1px solid rgba(255, 255, 255, .13);
    border-radius: 26px;
    background: rgba(255, 255, 255, .06);
    box-shadow: 0 35px 100px rgba(0, 0, 0, .26);
    backdrop-filter: blur(14px);
}

.login-copy {
    display: flex;
    min-height: 590px;
    padding: clamp(42px, 7vw, 76px);
    flex-direction: column;
    justify-content: center;
}

.login-eyebrow,
.section-eyebrow {
    display: block;
    color: var(--primary-dark);
    font-size: 10px;
    font-weight: 850;
    letter-spacing: .11em;
    text-transform: uppercase;
}

.login-eyebrow {
    margin-bottom: 18px;
    color: #6ee0b4;
}

.login-copy h1 {
    max-width: 540px;
    margin-bottom: 18px;
    color: #fff;
    font-size: clamp(42px, 5vw, 66px);
    line-height: 1.02;
    letter-spacing: -.055em;
}

.login-copy p {
    max-width: 520px;
    color: rgba(255, 255, 255, .7);
    font-size: 17px;
}

.login-points {
    display: flex;
    margin-top: 32px;
    flex-wrap: wrap;
    gap: 10px;
}

.login-points span {
    display: inline-flex;
    padding: 8px 11px;
    align-items: center;
    gap: 7px;
    color: rgba(255, 255, 255, .82);
    border: 1px solid rgba(255, 255, 255, .12);
    border-radius: 999px;
    background: rgba(255, 255, 255, .06);
    font-size: 11px;
    font-weight: 700;
}

.login-points .icon {
    width: 14px;
    height: 14px;
    color: #5fd9aa;
}

.login-card {
    display: flex;
    margin: 18px;
    padding: clamp(30px, 5vw, 52px);
    flex-direction: column;
    justify-content: center;
    color: var(--text);
    border-radius: 20px;
    background: #fff;
}

.brand {
    display: flex;
    align-items: center;
    gap: 11px;
}

.brand > span:first-child {
    display: grid;
    width: 40px;
    height: 40px;
    flex: 0 0 auto;
    place-items: center;
    color: #fff;
    border-radius: 12px;
    background: linear-gradient(145deg, #24c88c, #0c8d5d);
    box-shadow: 0 10px 22px rgba(19, 154, 103, .22);
    font-weight: 900;
}

.login-card .brand {
    margin-bottom: 48px;
}

.login-card h2 {
    margin-bottom: 8px;
    font-size: 28px;
}

.login-helper {
    margin-bottom: 24px;
    color: var(--muted);
}

.login-card .alert {
    margin: -4px 0 18px;
}

.login-card > small {
    margin-top: 16px;
}

/* App shell and sidebar */

.app {
    min-height: 100vh;
}

.sidebar {
    position: fixed;
    z-index: 50;
    top: 0;
    bottom: 0;
    left: 0;
    display: flex;
    width: var(--sidebar-width);
    padding: 22px 13px 16px;
    flex-direction: column;
    color: #dbe9e3;
    background: var(--sidebar);
    box-shadow: inset -1px 0 rgba(255, 255, 255, .04);
    transition: transform 190ms ease;
}

.side-brand {
    padding: 2px 9px 20px;
    color: #fff;
}

.side-brand > span:last-child,
.side-brand strong,
.side-brand small {
    display: block;
}

.side-brand strong {
    color: #fff;
    font-size: 15px;
}

.side-brand small {
    color: #8fafa2;
    font-size: 11px;
    font-weight: 600;
}

.side-nav {
    min-height: 0;
    padding-right: 2px;
    overflow-y: auto;
    scrollbar-width: thin;
}

.nav-group + .nav-group {
    margin-top: 13px;
}

.nav-label {
    display: block;
    padding: 0 11px 5px;
    color: #708f83;
    font-size: 9px;
    font-weight: 850;
    letter-spacing: .13em;
    text-transform: uppercase;
}

.nav-item {
    display: flex;
    min-height: 41px;
    padding: 9px 11px;
    align-items: center;
    gap: 11px;
    color: #aec4bb;
    border-radius: 9px;
    font-size: 13px;
    font-weight: 670;
    transition: color var(--transition), background var(--transition);
}

.nav-item + .nav-item {
    margin-top: 2px;
}

.nav-item:hover {
    color: #fff;
    background: rgba(255, 255, 255, .06);
}

.nav-item.active {
    color: #fff;
    background: rgba(31, 195, 132, .17);
    box-shadow: inset 3px 0 #2bd194;
}

.nav-item .icon {
    width: 17px;
    height: 17px;
}

.side-foot {
    display: grid;
    margin-top: auto;
    padding-top: 14px;
    gap: 8px;
    border-top: 1px solid rgba(255, 255, 255, .08);
}

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

.user-avatar {
    display: grid;
    width: 34px;
    height: 34px;
    flex: 0 0 auto;
    place-items: center;
    color: #dff8ed;
    border-radius: 10px;
    background: var(--sidebar-soft);
    font-weight: 850;
}

.user-card > span:last-child,
.user-card strong,
.user-card small {
    display: block;
}

.user-card strong {
    overflow: hidden;
    color: #eaf5f0;
    font-size: 12px;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.user-card small {
    color: #77998b;
    font-size: 10px;
}

.side-foot .btn-ghost {
    color: #91aea2;
}

.side-foot .btn-ghost:hover {
    color: #fff;
    background: rgba(255, 255, 255, .07);
}

.main {
    min-height: 100vh;
    margin-left: var(--sidebar-width);
    transition: margin-left 190ms ease;
}

.topbar {
    position: sticky;
    z-index: 30;
    top: 0;
    display: flex;
    min-height: 84px;
    padding: 13px 28px;
    align-items: center;
    justify-content: space-between;
    gap: 22px;
    border-bottom: 1px solid rgba(211, 224, 218, .9);
    background: rgba(242, 245, 243, .91);
    backdrop-filter: blur(14px);
}

.topbar-title {
    display: flex;
    min-width: 0;
    align-items: center;
    gap: 13px;
}

.page-heading {
    display: grid;
    min-width: 0;
    gap: 2px;
}

.page-heading h1 {
    font-size: 22px;
}

.page-heading p {
    overflow: hidden;
    color: var(--muted);
    font-size: 12px;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.menu {
    display: inline-grid;
}

body.sidebar-hidden .sidebar {
    transform: translateX(-105%);
}

body.sidebar-hidden .main {
    margin-left: 0;
}

.topbar-link {
    flex: 0 0 auto;
}

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

.content {
    width: 100%;
    max-width: 1540px;
    margin: 0 auto;
    padding: 24px 28px 52px;
}

.backdrop {
    display: none;
}

/* Alerts */

.alert {
    display: flex;
    min-height: 52px;
    margin-bottom: 20px;
    padding: 10px 10px 10px 13px;
    align-items: center;
    gap: 11px;
    color: #176446;
    border: 1px solid #bfe1d1;
    border-radius: 12px;
    background: #eaf8f1;
    box-shadow: var(--shadow-sm);
}

.alert-danger {
    color: #8d3f3f;
    border-color: #efc9c9;
    background: var(--danger-soft);
}

.alert-icon {
    display: grid;
    width: 30px;
    height: 30px;
    flex: 0 0 auto;
    place-items: center;
    border-radius: 9px;
    background: rgba(255, 255, 255, .68);
}

.alert-icon .icon {
    width: 16px;
    height: 16px;
}

.alert-close {
    margin-left: auto;
    color: currentColor;
    border-color: transparent;
    background: transparent;
}

/* Setup overview */

.setup-banner,
.settings-overview {
    display: grid;
    margin-bottom: 20px;
    padding: 20px;
    grid-template-columns: minmax(220px, .72fr) minmax(0, 1.55fr);
    align-items: center;
    gap: 22px;
    border: 1px solid #cfe1d8;
    border-radius: var(--radius-lg);
    background: linear-gradient(135deg, #f9fcfa, #edf7f2);
    box-shadow: var(--shadow-xs);
}

.setup-banner.is-complete {
    border-color: #bcdcca;
    background: linear-gradient(135deg, #f8fcfa, #e7f5ee);
}

.setup-banner-copy,
.settings-overview-copy {
    display: grid;
    gap: 5px;
}

.setup-banner-copy h2,
.settings-overview-copy h2 {
    font-size: 18px;
}

.setup-banner-copy p,
.settings-overview-copy p {
    color: var(--muted);
    font-size: 12px;
}

.setup-steps {
    display: grid;
    grid-template-columns: repeat(5, minmax(0, 1fr));
    gap: 8px;
}

.setup-step {
    display: flex;
    min-width: 0;
    min-height: 62px;
    padding: 10px;
    align-items: center;
    gap: 9px;
    color: var(--muted);
    border: 1px solid var(--border);
    border-radius: 11px;
    background: rgba(255, 255, 255, .82);
    transition: color var(--transition), border-color var(--transition), transform var(--transition);
}

.setup-step:hover {
    color: var(--text);
    border-color: #b9d4c7;
    transform: translateY(-1px);
}

.setup-step.is-ready {
    color: var(--primary-dark);
    border-color: #c5e1d3;
    background: rgba(247, 253, 250, .92);
}

.setup-step-icon {
    display: grid;
    width: 30px;
    height: 30px;
    flex: 0 0 30px;
    place-items: center;
    color: var(--warning);
    border-radius: 9px;
    background: var(--warning-soft);
}

.setup-step.is-ready .setup-step-icon {
    color: var(--primary-dark);
    background: var(--primary-soft);
}

.setup-step-icon .icon {
    width: 15px;
    height: 15px;
}

.setup-step > span:last-child,
.setup-step strong,
.setup-step small {
    display: block;
    min-width: 0;
}

.setup-step strong {
    overflow: hidden;
    font-size: 11px;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.setup-step small {
    margin-top: 2px;
    overflow: hidden;
    font-size: 9px;
    text-overflow: ellipsis;
    white-space: nowrap;
}

/* Dashboard stats */

.stats-grid {
    display: grid;
    margin-bottom: 20px;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 14px;
}

.stat-card {
    display: flex;
    min-width: 0;
    padding: 18px;
    align-items: center;
    gap: 14px;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: var(--surface);
    box-shadow: var(--shadow-sm);
}

.stat-card > div,
.stat-card > div > span,
.stat-card strong,
.stat-card small {
    display: block;
}

.stat-card > div {
    min-width: 0;
}

.stat-card > div > span {
    color: var(--muted);
    font-size: 12px;
    font-weight: 700;
}

.stat-card strong {
    margin: 2px 0;
    font-size: 27px;
    line-height: 1.1;
    letter-spacing: -.04em;
}

.stat-card small {
    overflow: hidden;
    font-size: 11px;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.stat-icon,
.resource-icon {
    display: grid;
    flex: 0 0 auto;
    place-items: center;
    border-radius: 12px;
}

.stat-icon {
    width: 44px;
    height: 44px;
}

.stat-green .stat-icon {
    color: var(--primary);
    background: var(--primary-soft);
}

.stat-blue .stat-icon {
    color: var(--blue);
    background: var(--blue-soft);
}

.stat-violet .stat-icon {
    color: var(--violet);
    background: var(--violet-soft);
}

.stat-orange .stat-icon {
    color: var(--orange);
    background: var(--orange-soft);
}

/* Panels and cards */

.panel {
    margin-bottom: 20px;
    padding: 21px;
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    background: var(--surface);
    box-shadow: var(--shadow-sm);
}

.panel-header {
    display: flex;
    min-height: 40px;
    margin-bottom: 16px;
    align-items: center;
    justify-content: space-between;
    gap: 18px;
}

.toolbar-actions {
    display: flex;
    min-width: 0;
    flex: 0 1 auto;
    align-items: center;
    gap: 9px;
}

.panel-header-toolbar {
    display: grid;
    grid-template-columns: minmax(180px, 1fr) minmax(0, 480px);
    align-items: center;
}

.panel-header-toolbar .toolbar-actions {
    width: 100%;
}

.panel-header-toolbar .search-field {
    width: auto;
    min-width: 0;
    flex: 1 1 auto;
}

.panel-header-toolbar .btn {
    flex: 0 0 auto;
}

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

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

.resource-card {
    display: flex;
    min-width: 0;
    min-height: 100%;
    padding: 16px;
    flex-direction: column;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: var(--surface-soft);
    transition: border-color var(--transition), box-shadow var(--transition), transform var(--transition);
}

.resource-card:hover {
    border-color: #cbd9d2;
    box-shadow: 0 9px 26px rgba(13, 43, 32, .07);
    transform: translateY(-1px);
}

.compact-card {
    min-height: 138px;
}

.resource-header {
    display: flex;
    margin-bottom: 14px;
    align-items: flex-start;
    justify-content: space-between;
    gap: 12px;
}

.resource-identity {
    display: flex;
    min-width: 0;
    align-items: flex-start;
    gap: 10px;
}

.resource-identity > div {
    min-width: 0;
}

.resource-identity h2,
.resource-identity h3 {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.resource-identity p {
    margin-top: 3px;
    overflow: hidden;
    color: var(--muted);
    font-size: 12px;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.resource-identity p code {
    padding: 1px 5px;
}

.resource-icon {
    width: 36px;
    height: 36px;
    color: var(--primary);
    background: var(--primary-soft);
}

.resource-icon .icon {
    width: 17px;
    height: 17px;
}

.status-stack {
    display: grid;
    justify-items: end;
    gap: 5px;
}

.status-badge {
    display: inline-flex;
    min-height: 26px;
    padding: 4px 9px;
    align-items: center;
    gap: 6px;
    border-radius: 999px;
    font-size: 10px;
    font-weight: 800;
    line-height: 1;
    white-space: nowrap;
}

.status-badge i {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: currentColor;
}

.status-success {
    color: #08734b;
    background: var(--primary-soft);
}

.status-info {
    color: #2c69bd;
    background: var(--blue-soft);
}

.status-warning {
    color: var(--warning);
    background: var(--warning-soft);
}

.status-danger {
    color: var(--danger);
    background: var(--danger-soft);
}

.status-muted {
    color: #687871;
    background: #e9efec;
}

.mini-stats {
    display: grid;
    margin-bottom: 14px;
    padding: 11px 0;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    border-top: 1px solid var(--border);
    border-bottom: 1px solid var(--border);
}

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

.mini-stats > div {
    min-width: 0;
    padding: 0 10px;
}

.mini-stats > div:first-child {
    padding-left: 0;
}

.mini-stats > div + div {
    border-left: 1px solid var(--border);
}

.mini-stats span,
.mini-stats strong {
    display: block;
}

.mini-stats span {
    color: var(--muted);
    font-size: 10px;
    font-weight: 700;
}

.mini-stats strong {
    margin-top: 2px;
    overflow: hidden;
    font-size: 18px;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.mini-stats .small-value {
    font-size: 12px;
    line-height: 1.9;
}

.detail-list {
    display: grid;
    margin-bottom: 14px;
    gap: 0;
}

.detail-list > div {
    display: flex;
    min-height: 34px;
    padding: 7px 0;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    border-bottom: 1px dashed #dde6e1;
}

.detail-list dt {
    color: var(--muted);
    font-size: 11px;
}

.detail-list dd {
    overflow: hidden;
    text-align: right;
    text-overflow: ellipsis;
    white-space: nowrap;
    font-size: 12px;
    font-weight: 700;
}

.route-field {
    display: flex;
    min-width: 0;
    margin-top: auto;
    padding: 6px 6px 6px 9px;
    align-items: center;
    gap: 6px;
    border: 1px solid #d8e6df;
    border-radius: 10px;
    background: #f2f8f5;
}

.route-field code {
    display: block;
    min-width: 0;
    padding: 0;
    flex: 1;
    overflow: hidden;
    border: 0;
    background: transparent;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.copy-btn {
    width: 31px;
    height: 31px;
    border-color: transparent;
    background: #fff;
}

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

.card-actions {
    display: flex;
    min-height: 51px;
    margin: 14px -16px -16px;
    padding: 10px 16px;
    align-items: center;
    flex-wrap: wrap;
    gap: 8px;
    border-top: 1px solid var(--border);
    border-radius: 0 0 var(--radius) var(--radius);
    background: #fff;
}

.card-actions form {
    margin: 0;
}

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

.agent-row-actions {
    min-width: 390px;
    flex-wrap: wrap;
}

.agent-test-form {
    display: inline-flex;
    margin: 0;
    align-items: center;
    gap: 6px;
}

.team-test-select {
    width: auto;
    min-width: 180px;
    max-width: 250px;
    min-height: 36px;
    padding: 7px 30px 7px 9px;
    border-radius: 9px;
    background: var(--surface-soft);
    font-size: 12px;
    font-weight: 650;
}

.context-site-list {
    overflow: hidden;
    border: 1px solid var(--border);
    border-radius: 13px;
    background: var(--surface);
}

.context-site-item + .context-site-item {
    border-top: 1px solid var(--border);
}

.context-site-trigger {
    display: grid;
    width: 100%;
    min-height: 76px;
    padding: 13px 15px;
    grid-template-columns: 42px minmax(0, 1fr) auto auto 24px;
    align-items: center;
    gap: 12px;
    color: var(--text);
    text-align: left;
    border: 0;
    cursor: pointer;
    background: var(--surface);
    transition: background var(--transition), color var(--transition);
}

.context-site-trigger:hover,
.context-site-item.open > .context-site-trigger {
    color: var(--primary-dark);
    background: var(--surface-green);
}

.context-site-name {
    display: grid;
    min-width: 0;
    gap: 3px;
}

.context-site-name strong {
    overflow: hidden;
    font-size: 14px;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.context-site-name code {
    width: max-content;
    max-width: 100%;
    overflow: hidden;
    color: var(--muted);
    font-size: 10px;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.context-site-count {
    color: var(--muted);
    font-size: 11px;
    font-weight: 750;
    white-space: nowrap;
}

.context-site-chevron {
    display: grid;
    width: 24px;
    height: 24px;
    place-items: center;
    color: var(--muted);
    transition: transform var(--transition);
}

.context-site-chevron .icon {
    width: 17px;
    height: 17px;
}

.context-site-item.open .context-site-chevron {
    transform: rotate(90deg);
}

.context-site-panel {
    padding: 0 15px 15px;
    background: var(--surface-green);
}

.context-site-panel[hidden] {
    display: none;
}

.context-subheader {
    display: flex;
    min-height: 54px;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    border-top: 1px solid var(--border);
}

.context-subheader > strong {
    font-size: 12px;
}

.context-sublist {
    overflow: hidden;
    border: 1px solid var(--border);
    border-radius: 12px;
    background: var(--surface);
}

.context-row {
    display: grid;
    padding: 13px;
    grid-template-columns: minmax(220px, 1fr) minmax(190px, .8fr) auto;
    align-items: center;
    gap: 11px 15px;
}

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

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

.resource-icon-small {
    width: 34px;
    height: 34px;
    flex: 0 0 34px;
    border-radius: 9px;
}

.resource-icon-small .icon {
    width: 17px;
    height: 17px;
}

.context-row-main > span:last-child {
    display: grid;
    min-width: 0;
    gap: 3px;
}

.context-row-main strong {
    overflow: hidden;
    font-size: 12px;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.context-row-main code,
.context-row-meta span {
    color: var(--muted);
    font-size: 10px;
}

.context-row-meta {
    display: grid;
    min-width: 0;
    gap: 4px;
}

.context-row-route {
    display: flex;
    min-width: 0;
    grid-column: 1 / 3;
    align-items: center;
    gap: 6px;
}

.context-row-route > code {
    display: block;
    min-width: 0;
    padding: 8px 10px;
    flex: 1;
    overflow: hidden;
    color: var(--muted);
    border: 1px solid var(--border);
    border-radius: 8px;
    background: var(--surface-soft);
    font-size: 9px;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.context-row-actions {
    display: flex;
    grid-column: 3;
    align-items: center;
    justify-content: flex-end;
    gap: 7px;
}

.compact-empty {
    min-height: 130px;
}

.inline-message {
    display: grid;
    margin-bottom: 13px;
    padding: 10px 11px;
    gap: 2px;
    border-radius: 9px;
    font-size: 11px;
}

.inline-danger {
    color: #8f3e3e;
    border: 1px solid #efcece;
    background: var(--danger-soft);
}

.inline-warning {
    color: #765117;
    border: 1px solid #ead8aa;
    background: var(--warning-soft);
}

.inline-success {
    color: var(--primary-dark);
    border: 1px solid #bfe2d2;
    background: var(--primary-soft);
}

/* Search and tables */

.search-field {
    position: relative;
    display: flex;
    width: min(290px, 100%);
    flex: 0 0 auto;
    align-items: center;
    color: var(--muted);
}

.search-field .icon {
    position: absolute;
    z-index: 1;
    left: 12px;
    width: 16px;
    height: 16px;
    pointer-events: none;
}

.search-field input {
    min-height: 40px;
    padding-left: 37px;
    background: var(--surface-soft);
}

.table-wrap {
    width: 100%;
    overflow-x: auto;
    border: 1px solid var(--border);
    border-radius: 12px;
}

.data-table {
    width: 100%;
    min-width: 780px;
    border-collapse: collapse;
    background: var(--surface);
}

.data-table th,
.data-table td {
    padding: 12px 13px;
    text-align: left;
    vertical-align: middle;
    border-bottom: 1px solid #e8eeeb;
}

.data-table th {
    position: sticky;
    z-index: 1;
    top: 0;
    color: #6d7a74;
    background: #f7f9f8;
    font-size: 10px;
    font-weight: 850;
    letter-spacing: .07em;
    text-transform: uppercase;
    white-space: nowrap;
}

.data-table tbody tr:last-child td {
    border-bottom: 0;
}

.data-table tbody tr:hover {
    background: #f8fcfa;
}

.cell-primary,
.cell-secondary {
    display: block;
}

.cell-primary {
    color: var(--text);
    font-size: 12px;
    font-weight: 750;
}

.cell-secondary {
    max-width: 230px;
    margin-top: 2px;
    overflow: hidden;
    color: var(--muted);
    font-size: 11px;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.cell-action {
    text-align: right !important;
}

.number-pill {
    display: inline-grid;
    min-width: 28px;
    height: 28px;
    padding: 0 7px;
    place-items: center;
    color: #275b45;
    border-radius: 8px;
    background: var(--primary-soft);
    font-size: 12px;
    font-weight: 800;
}

.inline-form {
    margin: 0;
}

.status-select {
    width: auto;
    min-width: 98px;
    min-height: 34px;
    padding: 5px 28px 5px 9px;
    border-radius: 999px;
    font-size: 11px;
    font-weight: 750;
}

.status-open {
    color: #2a68b9;
    border-color: #cdddf4;
    background: var(--blue-soft);
}

.status-done {
    color: #08734b;
    border-color: #c9e6d8;
    background: var(--primary-soft);
}

.status-cancelled {
    color: var(--danger);
    border-color: #efcfcf;
    background: var(--danger-soft);
}

/* Empty states */

.empty-state {
    display: flex;
    min-height: 210px;
    padding: 28px;
    grid-column: 1 / -1;
    align-items: center;
    justify-content: center;
    flex-direction: column;
    text-align: center;
    border: 1px dashed #cad8d1;
    border-radius: var(--radius);
    background: var(--surface-soft);
}

.empty-state > .icon {
    width: 30px;
    height: 30px;
    margin-bottom: 11px;
    color: #86a397;
}

.empty-state p {
    max-width: 440px;
    margin: 5px 0 15px;
    color: var(--muted);
}

.table-empty {
    min-height: 180px;
    border: 0;
    background: transparent;
}

/* Settings */

.settings-overview {
    grid-template-columns: minmax(240px, .72fr) minmax(0, 1.7fr);
}

.settings-steps {
    grid-template-columns: repeat(5, minmax(0, 1fr));
}

.settings-menu-panel {
    max-width: 1180px;
}

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

.settings-card {
    display: grid;
    width: 100%;
    min-height: 138px;
    padding: 17px;
    grid-template-columns: 42px minmax(0, 1fr) 24px;
    align-items: start;
    gap: 12px;
    color: var(--text);
    text-align: left;
    border: 1px solid var(--border);
    border-radius: 13px;
    cursor: pointer;
    background: var(--surface-soft);
    box-shadow: var(--shadow-xs);
    transition: background var(--transition), border-color var(--transition), box-shadow var(--transition), transform var(--transition);
}

.settings-card:hover {
    color: var(--primary-dark);
    border-color: #bdd8cb;
    background: var(--surface-green);
    box-shadow: var(--shadow-sm);
    transform: translateY(-1px);
}

.settings-card:target {
    border-color: #89bfa6;
    box-shadow: 0 0 0 3px rgba(15, 143, 97, .1);
}

.settings-card-icon {
    display: grid;
    width: 42px;
    height: 42px;
    place-items: center;
    color: var(--primary);
    border-radius: 11px;
    background: var(--primary-soft);
}

.settings-card-copy,
.settings-card-copy > span,
.settings-card-copy strong,
.settings-card-copy small {
    display: block;
    min-width: 0;
}

.settings-card-title {
    display: flex !important;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
}

.settings-card-title strong {
    font-size: 14px;
}

.settings-card-copy > span:nth-child(2) {
    margin-top: 7px;
    color: var(--muted);
    font-size: 12px;
    line-height: 1.45;
}

.settings-card-copy small {
    margin-top: 9px;
    color: var(--muted-light);
    font-size: 10px;
    font-weight: 700;
}

.settings-card-arrow {
    align-self: center;
    color: var(--muted-light);
}

.system-info {
    display: grid;
}

.system-info > div {
    display: grid;
    padding: 10px 0;
    gap: 4px;
    border-bottom: 1px solid var(--border);
}

.system-info > div:last-child {
    border-bottom: 0;
}

.system-info dt {
    color: var(--muted);
    font-size: 10px;
    font-weight: 750;
    letter-spacing: .05em;
    text-transform: uppercase;
}

.system-info dd {
    overflow-wrap: anywhere;
    font-size: 12px;
    font-weight: 700;
}

/* Modals */

.modal {
    position: fixed;
    z-index: 100;
    inset: 0;
    display: none;
    padding: 16px;
    align-items: center;
    justify-content: center;
}

.modal.open {
    display: flex;
}

.modal-backdrop {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    padding: 0;
    border: 0;
    background: rgba(5, 29, 20, .66);
    backdrop-filter: blur(5px);
}

.modal-card {
    position: relative;
    z-index: 1;
    display: flex;
    width: min(100%, 690px);
    max-height: calc(100vh - 32px);
    max-height: calc(100dvh - 32px);
    overflow: hidden;
    flex-direction: column;
    border: 1px solid rgba(255, 255, 255, .35);
    border-radius: 18px;
    background: var(--surface);
    box-shadow: var(--shadow-lg);
}

.modal-small {
    width: min(100%, 500px);
}

.modal-wide {
    width: min(100%, 850px);
}

.modal-header {
    display: flex;
    min-height: 68px;
    padding: 14px 21px;
    flex: 0 0 auto;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    border-bottom: 1px solid var(--border);
}

.modal-heading {
    display: grid;
    min-width: 0;
    gap: 3px;
}

.modal-heading p {
    color: var(--muted);
    font-size: 11px;
}

.modal-close {
    border-color: transparent;
    background: var(--surface-soft);
}

.modal-card form {
    display: flex;
    min-height: 0;
    flex: 1 1 auto;
    flex-direction: column;
    overflow: hidden;
}

.modal-body {
    min-height: 0;
    padding: 20px 21px;
    flex: 1 1 auto;
    overflow-y: auto;
    overscroll-behavior: contain;
    scrollbar-gutter: stable;
    touch-action: pan-y;
    -webkit-overflow-scrolling: touch;
}

.modal-actions {
    display: flex;
    min-height: 66px;
    padding: 12px 21px;
    align-items: center;
    flex: 0 0 auto;
    justify-content: flex-end;
    gap: 9px;
    border-top: 1px solid var(--border);
    background: var(--surface-soft);
}

.modal-actions-split {
    justify-content: space-between;
}

.modal-action-group {
    display: flex;
    align-items: center;
    gap: 9px;
}

.delete-confirm {
    display: grid;
    padding: 14px 4px;
    justify-items: center;
    text-align: center;
    gap: 10px;
}

.delete-confirm-icon {
    display: grid;
    width: 52px;
    height: 52px;
    place-items: center;
    color: var(--danger);
    border-radius: 15px;
    background: var(--danger-soft);
}

.delete-confirm-icon .icon {
    width: 23px;
    height: 23px;
}

.delete-confirm p {
    max-width: 390px;
    color: var(--muted);
    font-size: 13px;
}

body.modal-lock {
    overflow: hidden;
}


/* Monthly routing report and recent click detail */

.panel-subtitle {
    margin-top: 4px;
    color: var(--muted);
    font-size: 12px;
}

.monthly-report-header {
    align-items: flex-end;
}

.month-filter {
    display: flex;
    align-items: flex-end;
    gap: 8px;
}

.month-field {
    width: 168px;
}

.month-field > span {
    font-size: 10px;
    letter-spacing: .07em;
    text-transform: uppercase;
}

.month-field input {
    min-height: 38px;
    padding: 7px 10px;
}

.team-report-stack {
    display: grid;
    gap: 16px;
}

.team-report-card {
    min-width: 0;
    overflow: hidden;
    border: 1px solid var(--border);
    border-radius: 14px;
    background: var(--surface-soft);
}

.team-report-title {
    display: flex;
    padding: 14px 15px;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    border-bottom: 1px solid var(--border);
    background: var(--surface);
}

.team-report-title h3,
.team-report-title span {
    display: block;
}

.team-report-title > div > span {
    margin-top: 2px;
    color: var(--muted);
    font-size: 11px;
}

.monthly-table-wrap {
    border: 0;
    border-radius: 0;
}

.monthly-table {
    min-width: 1640px;
    table-layout: fixed;
}

.monthly-table th,
.monthly-table td {
    padding: 9px 7px;
    text-align: center;
}

.monthly-table .monthly-admin-column {
    position: sticky;
    z-index: 2;
    left: 0;
    width: 170px;
    min-width: 170px;
    text-align: left;
    background: var(--surface);
    box-shadow: 1px 0 0 var(--border);
}

.monthly-table thead .monthly-admin-column,
.monthly-table tfoot .monthly-admin-column {
    z-index: 4;
    background: #f7f9f8;
}

.monthly-table .monthly-day-column {
    width: 43px;
    min-width: 43px;
}

.monthly-table .monthly-total-column {
    position: sticky;
    z-index: 2;
    right: 0;
    width: 68px;
    min-width: 68px;
    background: #f4faf7;
    box-shadow: -1px 0 0 var(--border);
}

.monthly-table thead .monthly-total-column,
.monthly-table tfoot .monthly-total-column {
    z-index: 4;
}

.monthly-number {
    color: var(--muted-light);
    font-size: 11px;
    font-variant-numeric: tabular-nums;
}

.monthly-number.has-value {
    color: var(--primary-dark);
    background: var(--primary-soft);
    font-weight: 850;
}

.monthly-table tfoot th,
.monthly-table tfoot td {
    border-top: 1px solid var(--border-strong);
    border-bottom: 0;
    background: #f7f9f8;
    font-weight: 800;
}

.recent-clicks-table {
    min-width: 1450px;
}

.event-detail {
    min-width: 70px;
}

.event-detail summary {
    color: var(--primary-dark);
    cursor: pointer;
    font-size: 12px;
    font-weight: 800;
}

.event-detail > div {
    display: grid;
    width: min(520px, 70vw);
    margin-top: 10px;
    gap: 7px;
    color: var(--muted);
    white-space: normal;
}

.event-detail pre {
    max-height: 210px;
    margin: 0;
    padding: 10px;
    overflow: auto;
    color: var(--text);
    border: 1px solid var(--border);
    border-radius: 9px;
    background: var(--surface-soft);
    font: 12px/1.5 ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
    white-space: pre-wrap;
    word-break: break-word;
}

.event-detail a {
    color: var(--primary-dark);
    overflow-wrap: anywhere;
}

/* Responsive */

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

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

    .setup-steps,
    .settings-steps {
        grid-template-columns: repeat(3, minmax(0, 1fr));
    }
}

@media (max-width: 1020px) {
    .sidebar {
        transform: translateX(-105%);
        transition: transform 190ms ease;
    }

    .sidebar.open {
        transform: translateX(0);
    }

    .main {
        margin-left: 0;
    }

    .menu {
        display: inline-grid;
    }

    .backdrop {
        position: fixed;
        z-index: 45;
        inset: 0;
        width: 100%;
        padding: 0;
        border: 0;
        background: rgba(5, 29, 20, .52);
    }

    .backdrop.open {
        display: block;
    }

}

@media (max-width: 880px) {
    .setup-banner,
    .settings-overview {
        grid-template-columns: 1fr;
    }

    .panel-header-toolbar {
        grid-template-columns: 1fr;
    }

    .context-row {
        grid-template-columns: minmax(0, 1fr) auto;
    }

    .context-row-meta,
    .context-row-route {
        grid-column: 1;
    }

    .context-row > .status-badge,
    .context-row-actions {
        grid-column: 2;
    }
}

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

    .login-copy {
        min-height: auto;
        padding: 40px 28px 24px;
    }

    .login-copy h1 {
        font-size: 42px;
    }

    .login-card {
        margin-top: 0;
    }

    .topbar {
        min-height: 82px;
        padding: 14px 17px;
    }

    .page-heading p {
        max-width: 62vw;
    }

    .topbar-link {
        display: none;
    }

    .content {
        padding: 18px 15px 36px;
    }

    .resource-grid,
    .resource-grid-compact,
    .settings-grid,
    .form-grid,
    .form-grid-three,
    .switch-grid,
    .team-weight-grid {
        grid-template-columns: 1fr;
    }

    .team-membership-controls {
        grid-template-columns: 72px repeat(2, minmax(0, 1fr));
    }

    .setup-steps,
    .settings-steps {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }

    .panel {
        padding: 16px;
        border-radius: 16px;
    }

    .panel-header {
        align-items: stretch;
        flex-direction: column;
    }

    .panel-header > .btn,
    .panel-header > .search-field {
        width: 100%;
    }

    .month-filter {
        width: 100%;
        align-items: flex-end;
    }

    .month-field {
        width: auto;
        flex: 1 1 auto;
    }

    .context-site-trigger {
        grid-template-columns: 42px minmax(0, 1fr) auto 24px;
    }

    .context-site-trigger > .status-badge {
        display: none;
    }

    .toolbar-actions {
        width: 100%;
        align-items: stretch;
        flex-direction: column;
    }

    .toolbar-actions .search-field,
    .toolbar-actions .btn {
        width: 100%;
    }

    .modal {
        padding: 9px;
    }

    .modal-card {
        max-height: calc(100vh - 18px);
        max-height: calc(100dvh - 18px);
        border-radius: 15px;
    }

    .modal-header,
    .modal-body,
    .modal-actions {
        padding-right: 16px;
        padding-left: 16px;
    }

    .modal-actions-split {
        align-items: stretch;
        flex-direction: column;
    }

    .modal-action-group,
    .modal-actions-split > .btn {
        width: 100%;
    }

    .modal-action-group .btn {
        flex: 1;
    }
}

@media (max-width: 520px) {
    .team-membership-controls {
        grid-template-columns: 1fr;
    }

    .login-page {
        padding: 8px;
    }

    .login-copy {
        padding: 32px 22px 18px;
    }

    .login-card {
        margin: 8px;
        padding: 27px 21px;
    }

    .login-card .brand {
        margin-bottom: 31px;
    }

    .login-points {
        align-items: flex-start;
        flex-direction: column;
    }

    .page-heading p {
        display: none;
    }

    .setup-banner,
    .settings-overview {
        padding: 16px;
    }

    .setup-steps,
    .settings-steps {
        grid-template-columns: 1fr;
    }

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

    .stat-card {
        padding: 15px;
    }

    .resource-header {
        align-items: flex-start;
    }

    .status-stack {
        max-width: 116px;
    }

    .card-actions .btn {
        flex: 1;
    }

    .card-actions form {
        display: flex;
        flex: 1;
    }

    .card-actions form .btn {
        width: 100%;
    }

    .modal-actions .btn {
        flex: 1;
    }

    .row-actions {
        justify-content: flex-start;
    }

    .agent-row-actions {
        min-width: 330px;
    }

    .agent-test-form {
        flex-wrap: wrap;
    }

    .context-site-trigger {
        padding: 12px;
        grid-template-columns: 38px minmax(0, 1fr) 22px;
        gap: 9px;
    }

    .context-site-trigger > .context-site-count {
        display: none;
    }

    .context-subheader {
        align-items: stretch;
        flex-direction: column;
        padding: 12px 0;
    }

    .context-subheader .btn {
        width: 100%;
    }

    .context-row {
        grid-template-columns: 1fr;
    }

    .context-row > .status-badge,
    .context-row-meta,
    .context-row-route,
    .context-row-actions {
        grid-column: 1;
    }

    .context-row-actions {
        justify-content: stretch;
    }

    .context-row-actions .btn {
        flex: 1;
    }
}

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

/* Source cards with long API content */
.source-card,
.source-card .resource-header,
.source-card .resource-identity,
.source-card .resource-identity > div,
.source-card .detail-list,
.source-card .detail-list > div,
.source-card dd {
    min-width: 0;
}

.source-card .resource-header {
    flex-wrap: wrap;
}

.source-card .resource-identity {
    flex: 1 1 180px;
    max-width: 100%;
}

.source-card .resource-identity h3,
.source-card .resource-identity p,
.source-card .detail-list dd,
.source-card .inline-message span {
    overflow-wrap: anywhere;
    word-break: break-word;
    white-space: normal;
}

.source-card .status-badge {
    flex: 0 0 auto;
    max-width: 100%;
}

.source-card .card-actions {
    align-items: stretch;
}

.source-card .card-actions form {
    min-width: 0;
}

@media (max-width: 520px) {
    .source-card .resource-header {
        display: grid;
        grid-template-columns: minmax(0, 1fr);
    }

    .source-card .status-badge {
        justify-self: start;
    }
}
