:root {
    color-scheme: light;
    --brand: #df4b37;
    --brand-dark: #b93626;
    --ink: #1b2733;
    --muted: #607080;
    --line: #dfe5eb;
    --surface: #fff;
    --canvas: #f4f6f8;
    --soft: #f8fafb;
    font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* { box-sizing: border-box; }
body { margin: 0; color: var(--ink); background: var(--canvas); line-height: 1.5; }
a { color: #b93626; }
a:hover { color: #8e271d; }
button, input, select { font: inherit; }
button, input, select { max-width: 100%; }
button { cursor: pointer; }
:focus-visible { outline: 3px solid #f2a299; outline-offset: 2px; }
h1, h2, h3, h4, p { margin-top: 0; }
h2 { font-size: 1.25rem; letter-spacing: -.02em; }
h3 { font-size: 1.02rem; }
.muted, small { color: var(--muted); }
.eyebrow { margin-bottom: .35rem; color: var(--brand-dark); font-size: .72rem; font-weight: 750; letter-spacing: .12em; text-transform: uppercase; }
.skip-link { position: absolute; left: 1rem; top: -4rem; z-index: 10; padding: .55rem .8rem; background: white; border-radius: .5rem; }
.skip-link:focus { top: .5rem; }

.portal-shell { display: flex; min-height: 100vh; }
.sidebar { position: sticky; top: 0; display: flex; flex: 0 0 246px; flex-direction: column; height: 100vh; background: var(--surface); border-right: 1px solid var(--line); }
.brand { display: flex; align-items: center; gap: .7rem; padding: 1.25rem 1.1rem; text-decoration: none; color: var(--ink); }
.brand:hover { color: var(--ink); }
.brand-mark { display: grid; flex: none; place-items: center; width: 36px; height: 36px; border-radius: 10px; color: white; background: linear-gradient(145deg, #f1745e, #bf3527); box-shadow: 0 4px 14px #df4b3733; font-weight: 850; font-size: 1.16rem; }
.brand strong, .brand small { display: block; line-height: 1.15; }
.brand strong { font-size: .97rem; letter-spacing: -.025em; }
.brand small { margin-top: .2rem; font-size: .72rem; letter-spacing: .08em; text-transform: uppercase; }
.side-nav { display: flex; flex-direction: column; gap: 3px; padding: .25rem .75rem; }
.nav-section { padding: 1rem .7rem .35rem; color: #7c8995; font-size: .69rem; font-weight: 750; letter-spacing: .1em; text-transform: uppercase; }
.nav-link { padding: .58rem .75rem; border-radius: 8px; color: #334454; text-decoration: none; font-size: .91rem; font-weight: 550; }
.nav-link:hover { background: #f4f5f7; color: var(--ink); }
.nav-link.active { background: #fceae6; color: #a52b20; font-weight: 700; }
.sidebar-foot { margin-top: auto; padding: 1rem 1.4rem; color: #8c97a2; font-size: .75rem; border-top: 1px solid var(--line); }
.portal-main { min-width: 0; flex: 1; }
.topbar { position: sticky; top: 0; z-index: 2; display: flex; align-items: center; justify-content: space-between; gap: 1rem; min-height: 67px; padding: .9rem 1.6rem; background: #fffffff0; border-bottom: 1px solid var(--line); backdrop-filter: blur(10px); }
.topbar h1 { margin: 0; font-size: 1.08rem; font-weight: 720; letter-spacing: -.025em; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.topbar-label { flex: none; color: #7d8995; font-size: .68rem; font-weight: 700; letter-spacing: .12em; }
.topbar-dot { display: inline-block; width: 6px; height: 6px; margin: 0 .25rem .1rem; border-radius: 50%; background: #20a779; }
.content { max-width: 1500px; padding: 1.7rem 1.8rem 4rem; }
.page-intro { margin-bottom: 1.35rem; }
.page-intro h2 { margin-bottom: .25rem; font-size: clamp(1.6rem, 2.5vw, 2rem); letter-spacing: -.045em; }
.page-intro p:last-child { margin-bottom: 0; color: var(--muted); }
.breadcrumbs { margin-bottom: 1.1rem; color: var(--muted); font-size: .85rem; }
.breadcrumbs a { text-decoration: none; }
.section-heading { margin: 1.6rem 0 .8rem; }
.section-heading h2 { margin-bottom: .15rem; }
.section-heading p { margin: 0; color: var(--muted); font-size: .88rem; }
.note { margin-top: 1rem; font-size: .82rem; }

.panel, .controls, .summary-card, .node-card { background: var(--surface); border: 1px solid var(--line); border-radius: 12px; box-shadow: 0 1px 2px #10203008; }
.panel, .controls { margin: 1rem 0; padding: 1.25rem 1.35rem; }
.panel > h2:first-child, .controls > h2:first-child { margin-bottom: .3rem; }
.panel .panel { margin: 1rem 0 0; background: var(--soft); box-shadow: none; }
.controls { border-left: 4px solid #26a780; }
.controls.manual { border-left-color: #e3a332; background: #fffdf8; }
.summary-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: .9rem; margin-bottom: 1.5rem; }
.summary-card { padding: 1rem 1.15rem; }
.summary-card span { display: block; color: var(--muted); font-size: .8rem; font-weight: 600; }
.summary-card strong { display: block; margin-top: .2rem; font-size: 1.8rem; line-height: 1.2; letter-spacing: -.045em; }
.node-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(270px, 1fr)); gap: 1rem; }
.node-card { display: block; min-width: 0; padding: 1.1rem 1.2rem; color: var(--ink); text-decoration: none; transition: border-color .15s, box-shadow .15s, transform .15s; }
.node-card:hover { color: var(--ink); border-color: #e9b0a7; box-shadow: 0 8px 22px #10203012; transform: translateY(-2px); }
.node-card-top { display: flex; align-items: center; gap: .5rem; min-width: 0; }
.node-card-top strong { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.node-card-top .status { margin-left: auto; }
.status-dot { flex: none; width: 8px; height: 8px; border-radius: 50%; background: #b0bbc5; }
.status-dot.is-online { background: #20a779; box-shadow: 0 0 0 3px #ddf4eb; }
.status { display: inline-flex; align-items: center; border-radius: 99px; padding: .18rem .53rem; font-size: .73rem; font-weight: 700; white-space: nowrap; }
.status-ok { color: #12664e; background: #e5f5ee; }
.status-warn { color: #9b5c12; background: #fff2dc; }
.status-muted { color: #5f6f7c; background: #edf1f4; }
.node-card > p { margin: .55rem 0 .75rem; font-size: .84rem; }
.node-card-facts { display: flex; flex-wrap: wrap; gap: .4rem .8rem; font-size: .78rem; color: #405367; }
.node-card .node-card-foot { display: flex; justify-content: space-between; gap: .5rem; margin: 1rem 0 0; padding-top: .7rem; border-top: 1px solid var(--line); color: var(--muted); font-size: .75rem; }
.node-card-foot span { color: var(--brand); font-size: 1rem; line-height: 1; }
.empty-state { padding: 2rem; text-align: center; color: var(--muted); }

.channel-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: .85rem; margin-bottom: 1.7rem; }
.channel-card { display: flex; flex-direction: column; gap: .6rem; min-height: 112px; padding: 1rem 1.15rem; border: 1px solid var(--line); border-radius: 12px; background: white; color: var(--ink); text-decoration: none; }
.channel-card:hover { border-color: #e9b0a7; box-shadow: 0 5px 16px #10203010; color: var(--ink); }
.channel-card strong { font-size: 1rem; }
.channel-card span { margin-top: auto; color: var(--muted); font-size: .78rem; }
.actions-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 330px), 1fr)); gap: 1rem; }
.actions-grid .panel { margin: 0; }
.actions-grid .panel h2 { margin-bottom: .2rem; }
.actions-grid .panel p { color: var(--muted); font-size: .85rem; }

form { display: flex; align-items: end; flex-wrap: wrap; gap: .7rem; margin: .8rem 0; }
form label { display: flex; flex-direction: column; gap: .3rem; min-width: min(100%, 160px); color: #405165; font-size: .8rem; font-weight: 650; }
form label:has(input[type=checkbox]) { flex-direction: row; align-items: center; min-width: auto; }
input:not([type=checkbox]):not([type=hidden]), select { width: 100%; min-height: 38px; padding: .45rem .65rem; color: var(--ink); background: white; border: 1px solid #cbd5de; border-radius: 7px; font-size: .9rem; }
input:focus, select:focus { border-color: var(--brand); }
button { min-height: 38px; padding: .45rem .9rem; border: 1px solid var(--brand); border-radius: 7px; color: white; background: var(--brand); font-size: .86rem; font-weight: 700; }
button:hover { background: var(--brand-dark); border-color: var(--brand-dark); }
form button { align-self: end; }
li form { display: inline-flex; margin: 0 0 0 .6rem; }
li form button { min-height: 29px; padding: .28rem .55rem; font-size: .76rem; }
.controls form { margin-bottom: 0; }
.toolbar { display: flex; gap: .8rem; flex-wrap: wrap; }
.toolbar a { display: inline-block; padding: .4rem .65rem; border: 1px solid var(--line); border-radius: 7px; background: white; text-decoration: none; font-size: .85rem; font-weight: 650; }
.toolbar a:hover { border-color: #e9b0a7; }
.signout-form { margin-top: 1.6rem; }
.signout-form button { color: #46586a; background: white; border-color: var(--line); }
.signout-form button:hover { color: var(--ink); background: #edf1f4; border-color: #cbd5de; }

dl { display: grid; grid-template-columns: minmax(8rem, 170px) minmax(0, 1fr); gap: .45rem 1rem; margin: 1rem 0; }
dt { color: var(--muted); font-size: .83rem; font-weight: 650; }
dd { min-width: 0; margin: 0; overflow-wrap: anywhere; font-size: .88rem; }
meter { width: min(220px, 100%); height: .7rem; margin-left: .4rem; accent-color: var(--brand); vertical-align: middle; }
.table-wrap { max-width: 100%; overflow-x: auto; }
table { width: 100%; border-collapse: collapse; background: white; }
th, td { padding: .8rem .9rem; border-bottom: 1px solid var(--line); text-align: left; vertical-align: top; overflow-wrap: anywhere; font-size: .84rem; }
th { color: var(--muted); background: var(--soft); font-size: .71rem; font-weight: 750; letter-spacing: .06em; text-transform: uppercase; white-space: nowrap; }
tr:last-child td { border-bottom: 0; }
td small { font-size: .75rem; }
ul { padding-left: 1.25rem; }
li { margin: .35rem 0; }

.signin-page { display: grid; place-items: center; min-height: 100vh; padding: 1rem; background: radial-gradient(circle at 50% -20%, #f8d8d0 0, transparent 53%), var(--canvas); }
.signin-card { width: min(100%, 430px); padding: 2rem; border: 1px solid var(--line); border-radius: 16px; background: white; box-shadow: 0 18px 50px #24384a15; }
.signin-card .brand-mark { margin-bottom: 1.6rem; }
.signin-card h1 { margin-bottom: .35rem; font-size: 1.8rem; letter-spacing: -.04em; }
.signin-providers { display: grid; gap: .65rem; margin-top: 1.5rem; }
.provider-link { display: flex; justify-content: space-between; align-items: center; padding: .75rem .9rem; border: 1px solid var(--line); border-radius: 9px; color: var(--ink); text-decoration: none; font-weight: 650; }
.provider-link:hover { border-color: var(--brand); color: var(--brand-dark); background: #fffaf9; }

@media (max-width: 850px) {
    .portal-shell { display: block; }
    .sidebar { position: static; width: 100%; height: auto; border-right: 0; border-bottom: 1px solid var(--line); }
    .brand { padding: .8rem 1rem .35rem; }
    .side-nav { flex-direction: row; align-items: center; flex-wrap: wrap; gap: .3rem; padding: .35rem .75rem .7rem; }
    .nav-section, .sidebar-foot { display: none; }
    .nav-link { padding: .45rem .7rem; }
    .topbar { position: static; min-height: 55px; padding: .75rem 1rem; }
    .content { padding: 1.25rem 1rem 3rem; }
}

@media (max-width: 560px) {
    .summary-grid { grid-template-columns: 1fr 1fr; }
    .summary-grid .summary-card:last-child { grid-column: 1 / -1; }
    .panel, .controls { padding: 1rem; }
    dl { grid-template-columns: 1fr; gap: .15rem; }
    dd { margin-bottom: .55rem; }
    .topbar-label { display: none; }
    form label { flex: 1 1 100%; }
    .signin-card { padding: 1.5rem; }
}

@media (prefers-reduced-motion: reduce) {
    .node-card { transition: none; }
    .node-card:hover { transform: none; }
}
