:root {
    --bg: #eef0f5;
    --fg: #1c1917;
    --muted: #6b7280;
    --card: #ffffff;
    --line: #e4e6eb;
    --accent: #845c3d;
    --accent-dark: #5c3d2a;
    --accent-soft: #fff8f0;
    --accent-line: #edd5bc;
    --ok: #1b9e4b;
    --warn: #c4892a;
    --crit: #c2410c;
    --radius: 12px;
    --shadow: 0 1px 2px rgba(28, 25, 23, .05), 0 10px 28px rgba(28, 25, 23, .05);
}
* { box-sizing: border-box; }
html, body { height: 100%; }
body {
    margin: 0;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    font: 15px/1.5 -apple-system, BlinkMacSystemFont, "Segoe UI", Helvetica, Arial, sans-serif;
    color: var(--fg);
    background: var(--bg);
    -webkit-font-smoothing: antialiased;
}
a { color: var(--accent); }
a:hover { color: var(--accent-dark); }
.wrap { width: 100%; max-width: 1080px; margin: 0 auto; padding: 0 20px; }
.top {
    background: var(--card);
    border-bottom: 1px solid var(--line);
    border-top: 3px solid var(--accent);
    position: sticky;
    top: 0;
    z-index: 20;
}
.top-inner {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: 12px 20px;
    min-height: 64px;
}
.brand {
    display: flex;
    align-items: center;
    gap: 10px;
    color: inherit;
    text-decoration: none;
    min-width: 0;
}
.brand-mark-img { height: 36px; width: auto; display: block; }
.brand-words { display: flex; flex-direction: column; line-height: 1.12; }
.brand-words strong { font-size: 13px; font-weight: 650; }
.brand-words span { font-size: 12px; font-weight: 500; color: var(--muted); }
.brand img.platform-logo { height: 40px; width: auto; display: block; }
.tenant {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    max-width: 240px;
    padding: 5px 10px;
    border-radius: 999px;
    background: var(--accent-soft);
    border: 1px solid var(--accent-line);
    color: var(--accent-dark);
    font-size: 12px;
    font-weight: 600;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.tenant img { height: 18px; width: auto; }
.nav { display: flex; flex-wrap: wrap; gap: 4px; }
.nav a {
    text-decoration: none;
    color: var(--muted);
    padding: 7px 11px;
    border-radius: 8px;
    font-weight: 500;
    font-size: 14px;
}
.nav a:hover { color: var(--fg); background: #f3f4f6; }
.nav a.is-active {
    color: var(--accent-dark);
    background: var(--accent-soft);
}
main { flex: 1; padding: 28px 0 72px; }
h1 { margin: 0 0 8px; font-size: 24px; font-weight: 650; letter-spacing: -.02em; }
h2 { margin: 24px 0 10px; font-size: 16px; font-weight: 650; }
.card {
    background: var(--card);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    padding: 28px;
}
.card > h1:first-child { margin-top: 0; }
.form-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 18px 24px;
    align-items: end;
}
.form-grid label { margin: 0; }
.form-grid .span-2 { grid-column: 1 / -1; }
.form-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    justify-content: flex-end;
    align-items: center;
}
.form-checks { display: flex; flex-direction: column; gap: 12px; margin-bottom: 18px; }
.panel-row {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 12px;
    margin-top: 16px;
}
.panel-action {
    display: flex;
    flex-direction: column;
    gap: 8px;
    padding: 18px 20px;
    border: 1px solid var(--line);
    border-radius: 12px;
    background: var(--card);
    box-shadow: var(--shadow);
}
.panel-action p { margin: 0; font-size: 13px; color: var(--muted); }
.panel-action .btn { width: 100%; min-width: 0; }
.muted { color: var(--muted); }
.flash {
    background: var(--accent-soft);
    border: 1px solid var(--accent-line);
    color: var(--accent-dark);
    padding: 12px 14px;
    margin-bottom: 16px;
    border-radius: 10px;
    font-size: 14px;
}
.lede { margin: 0 0 22px; color: var(--muted); font-size: 14px; }
label { display: block; margin: 0 0 14px; font-weight: 600; font-size: 13px; }
label input, label select, label textarea {
    display: block; width: 100%; margin-top: 6px; padding: 10px 12px;
    border: 1px solid var(--line); font: inherit; background: #fff;
    border-radius: 8px; color: var(--fg);
}
label input[type=radio],
label input[type=checkbox] {
    width: auto;
    margin-top: 3px;
    padding: 0;
    display: inline-block;
    box-shadow: none;
}
label input:focus, label select:focus, label textarea:focus {
    outline: none;
    border-color: var(--accent);
    box-shadow: 0 0 0 3px rgba(132, 92, 61, .16);
}
label input:disabled { background: #f3f4f6; color: var(--muted); }
.check { font-weight: 500; display: flex; gap: 8px; align-items: flex-start; }
.check input { width: auto; margin-top: 4px; }
.btn {
    display: inline-flex; align-items: center; justify-content: center;
    background: var(--accent-dark); color: #fff; border: 0;
    padding: 11px 18px; font: inherit; font-size: 14px; font-weight: 600;
    cursor: pointer; text-decoration: none; border-radius: 8px;
    width: 100%;
}
.btn:hover { background: #4a3122; color: #fff; }
.card .btn, .stack .btn, form .btn { width: auto; min-width: 140px; }
.btn-ghost {
    background: #fff; color: var(--fg); border: 1px solid var(--line);
}
.btn-ghost:hover { background: #f8f8f9; color: var(--fg); }
.btn-danger {
    background: #fff; color: var(--crit); border: 1px solid #f1d0c8;
}
.btn-danger:hover { background: #fff5f2; color: var(--crit); }
.stack { display: flex; flex-direction: column; gap: 4px; }
.stack + .stack, .card .stack + p, .card form + form { margin-top: 22px; padding-top: 22px; border-top: 1px solid var(--line); }
.toolbar { display: flex; justify-content: space-between; align-items: center; gap: 12px; flex-wrap: wrap; margin-bottom: 16px; }
.toolbar h1 { margin: 0; }
.kpi { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; margin-bottom: 22px; }
.kpi-item {
    background: var(--card); border: 1px solid var(--line); padding: 16px 18px;
    border-radius: var(--radius); box-shadow: var(--shadow);
    font-size: 14px; color: var(--muted);
}
.kpi-item strong { display: block; font-size: 22px; color: var(--fg); margin-bottom: 2px; }
.kpi-item.ok { border-top: 3px solid var(--ok); }
.kpi-item.warn { border-top: 3px solid var(--warn); }
.kpi-item.crit { border-top: 3px solid var(--crit); }
.cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 12px; }
.device-card {
    background: var(--card); border: 1px solid var(--line); padding: 16px 18px;
    text-decoration: none; color: inherit; display: block;
    border-radius: var(--radius); box-shadow: var(--shadow);
    transition: transform .15s ease, box-shadow .15s ease;
}
.device-card:hover { transform: translateY(-2px); box-shadow: 0 12px 28px rgba(28,25,23,.08); color: inherit; }
.device-card h2 { margin: 8px 0 4px; font-size: 17px; }
.device-card p { margin: 4px 0; }
.light-ok { border-top: 3px solid var(--ok); }
.light-warning { border-top: 3px solid var(--warn); }
.light-critical { border-top: 3px solid var(--crit); }
.lamp {
    font-size: 11px; letter-spacing: .04em; text-transform: uppercase;
    color: var(--muted); font-weight: 650;
}
.lamp-ok { color: var(--ok); }
.lamp-warning { color: var(--warn); }
.lamp-critical { color: var(--crit); }
.choice {
    display: flex; gap: 12px; align-items: center;
    border: 1px solid var(--line); padding: 12px 14px; background: var(--card);
    font-weight: 500; border-radius: 10px; cursor: pointer;
}
.choice:hover { border-color: var(--accent-line); background: var(--accent-soft); }
.choice input { flex: 0 0 auto; width: auto !important; }
.picker { max-width: none; }
.picker .lede { margin-bottom: 0; max-width: 42em; }
.picker-form { display: flex; flex-direction: column; gap: 20px; }
.picker-list {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 12px;
}
.picker-card {
    display: flex;
    align-items: center;
    gap: 16px;
    margin: 0;
    padding: 20px 22px;
    min-height: 108px;
    width: 100%;
    border: 1px solid var(--line);
    border-radius: 12px;
    background: #fff;
    box-shadow: var(--shadow);
    cursor: pointer;
    font: inherit;
    font-weight: 500;
    color: inherit;
    text-align: left;
    appearance: none;
    -webkit-appearance: none;
    transition: border-color .15s ease, background .15s ease, box-shadow .15s ease, transform .15s ease;
}
.picker-card:hover {
    border-color: var(--accent);
    background: var(--accent-soft);
    transform: translateY(-1px);
    box-shadow: 0 12px 28px rgba(28,25,23,.08);
}
.picker-card:focus {
    outline: none;
    border-color: var(--accent);
    box-shadow: 0 0 0 3px rgba(132, 92, 61, .16);
}
.picker-avatar {
    flex: 0 0 56px;
    width: 56px;
    height: 56px;
    border-radius: 12px;
    background: #f3f1ee;
    color: var(--accent-dark);
    font-size: 15px;
    font-weight: 700;
    letter-spacing: .02em;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
    position: relative;
}
.picker-avatar img { width: 100%; height: 100%; object-fit: contain; background: #fff; }
.picker-fallback { display: none; }
.picker-avatar.is-fallback img { display: none !important; }
.picker-avatar.is-fallback .picker-fallback {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 100%;
    height: 100%;
}
.picker-avatar-all { color: var(--muted); background: #f3f4f6; }
.picker-body { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 3px; }
.picker-title { font-size: 16px; font-weight: 650; color: var(--fg); line-height: 1.3; }
.picker-sub { font-size: 13px; color: var(--muted); }
.picker-badge {
    align-self: flex-start;
    margin-top: 6px;
    font-size: 11px;
    font-weight: 650;
    letter-spacing: .02em;
    color: var(--accent-dark);
    background: #fff;
    border: 1px solid var(--accent-line);
    border-radius: 999px;
    padding: 2px 8px;
}
.picker-card-all { border-style: dashed; grid-column: 1 / -1; min-height: 88px; }
@media (max-width: 720px) {
    .picker-list { grid-template-columns: 1fr; }
    .picker-card-all { grid-column: auto; }
}
.mini-logo { height: 28px; }
.list { list-style: none; padding: 0; margin: 0; background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); overflow: hidden; }
.list li { padding: 14px 18px; border-bottom: 1px solid var(--line); display: flex; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
.list li:last-child { border-bottom: 0; }
.plain { width: 100%; border-collapse: collapse; background: var(--card); border-radius: var(--radius); overflow: hidden; }
.plain th, .plain td { text-align: left; border-bottom: 1px solid var(--line); padding: 10px 12px; }
.plain th { font-size: 12px; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); font-weight: 650; }
.steps { list-style: none; padding: 0; margin: 0 0 16px; background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); }
.steps li { padding: 14px 18px; border-bottom: 1px solid var(--line); }
.steps li:last-child { border-bottom: 0; }
.foot { border-top: 1px solid var(--line); padding: 18px 0 28px; font-size: 13px; color: var(--muted); }
.foot .wrap { display: flex; gap: 16px; flex-wrap: wrap; align-items: center; }
.foot a { color: var(--muted); text-decoration: none; }
.foot a:hover { color: var(--accent); }
.cookie-bar { position: sticky; top: 0; z-index: 30; background: #1c1917; color: #fff; }
.cookie-bar a { color: #e8d5c4; }
.cookie-inner { display: flex; flex-wrap: wrap; gap: 12px; align-items: center; padding: 12px 16px; }
.cookie-inner p { flex: 1; margin: 0; font-size: 13px; }
.cookie-bar .btn { width: auto; min-width: 0; background: var(--accent); }
.popup-backdrop {
    position: fixed; inset: 0; z-index: 40;
    background: rgba(28, 25, 23, .45);
    display: flex; align-items: center; justify-content: center;
    padding: 16px;
}
.popup {
    background: var(--card); color: var(--fg);
    max-width: 420px; width: 100%;
    padding: 24px; border: 1px solid var(--line);
    border-radius: var(--radius);
    box-shadow: 0 16px 48px rgba(28, 25, 23, .2);
}
.popup p { margin: 0 0 16px; }
.popup .btn { width: auto; }

body.is-auth {
    background: #f4f1ec;
}
body.is-auth .auth-shell {
    flex: 1;
    display: grid;
    grid-template-columns: minmax(280px, 42%) minmax(0, 1fr);
    min-height: 0;
}
.auth-aside {
    position: relative;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    gap: 48px;
    padding: 40px 44px 48px;
    color: #fff8f0;
    background:
        radial-gradient(1200px 600px at -10% 110%, rgba(255, 248, 240, .12), transparent 55%),
        linear-gradient(165deg, #2c1c12 0%, #5c3d2a 48%, #845c3d 100%);
}
.auth-aside:before,
.auth-aside:after {
    content: "";
    position: absolute;
    border-radius: 50%;
    pointer-events: none;
}
.auth-aside:before {
    width: 360px;
    height: 360px;
    right: -120px;
    top: -80px;
    background: rgba(255, 248, 240, .08);
}
.auth-aside:after {
    width: 220px;
    height: 220px;
    left: -70px;
    bottom: 80px;
    border: 1px solid rgba(255, 248, 240, .14);
}
.auth-aside .brand {
    align-self: flex-start;
    background: #fff;
    color: var(--fg);
    padding: 8px 14px 8px 10px;
    border-radius: 12px;
    box-shadow: 0 10px 30px rgba(28, 25, 23, .16);
}
.auth-aside .brand:hover { color: var(--fg); }
.brand-on-dark .brand-words span { color: var(--muted); }
.auth-aside-copy { position: relative; z-index: 1; max-width: 420px; }
.auth-kicker {
    margin: 0 0 10px;
    font-size: 12px;
    font-weight: 650;
    letter-spacing: .14em;
    text-transform: uppercase;
    color: rgba(255, 248, 240, .7);
}
.auth-aside-copy h2 {
    margin: 0 0 28px;
    font-size: 32px;
    line-height: 1.2;
    font-weight: 650;
    letter-spacing: -.03em;
    color: #fff8f0;
}
.auth-points {
    list-style: none;
    margin: 0;
    padding: 0;
    display: flex;
    flex-direction: column;
    gap: 12px;
}
.auth-points li {
    position: relative;
    padding-left: 22px;
    font-size: 14px;
    line-height: 1.45;
    color: rgba(255, 248, 240, .82);
}
.auth-points li:before {
    content: "";
    position: absolute;
    left: 0;
    top: .55em;
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: #e8d5c4;
}
.auth-stage {
    display: flex;
    flex-direction: column;
    min-width: 0;
    background: #f4f1ec;
}
.auth-main {
    flex: 1;
    display: flex;
    flex-direction: column;
    justify-content: center;
    padding: 48px 32px 24px;
    width: 100%;
    max-width: 460px;
    margin: 0 auto;
}
.auth-main .flash { margin-bottom: 18px; }
.auth-card { width: 100%; }
.auth-card h1 {
    font-size: 28px;
    letter-spacing: -.03em;
    margin-bottom: 8px;
}
.auth-card .lede { margin-bottom: 28px; font-size: 15px; }
.auth-card .lede strong { color: var(--fg); font-weight: 650; }
.auth-form { display: flex; flex-direction: column; gap: 16px; }
.auth-form label { margin: 0; }
.auth-form label input {
    margin-top: 8px;
    padding: 13px 14px;
    border-radius: 10px;
    background: #fff;
    font-size: 16px;
}
.auth-form .btn {
    width: 100%;
    min-width: 0;
    margin-top: 4px;
    padding: 13px 18px;
    border-radius: 10px;
}
.auth-code {
    letter-spacing: .42em;
    font-size: 26px;
    font-weight: 650;
    text-align: center;
    font-variant-numeric: tabular-nums;
}
.auth-alt {
    display: inline-block;
    text-align: center;
    font-size: 14px;
    font-weight: 500;
    color: var(--muted);
    text-decoration: none;
}
.auth-alt:hover { color: var(--accent-dark); }
.auth-foot {
    display: flex;
    flex-wrap: wrap;
    gap: 12px 16px;
    align-items: center;
    justify-content: center;
    padding: 8px 24px 28px;
    font-size: 13px;
    color: var(--muted);
}
.auth-foot a { color: var(--muted); text-decoration: none; }
.auth-foot a:hover { color: var(--accent); }
@media (max-width: 860px) {
    body.is-auth .auth-shell {
        grid-template-columns: 1fr;
        grid-template-rows: auto 1fr;
    }
    .auth-aside {
        padding: 14px 20px;
        min-height: 0;
        flex-direction: row;
        align-items: center;
        justify-content: flex-start;
        gap: 16px;
    }
    .auth-aside:before,
    .auth-aside:after { display: none; }
    .auth-aside-copy { display: none; }
    .auth-main { padding: 32px 20px 16px; max-width: 420px; }
}
@media (max-width: 720px) {
    .form-grid, .panel-row { grid-template-columns: 1fr; }
    .form-grid .span-2 { grid-column: auto; }
}
@media (max-width: 640px) {
    .kpi { grid-template-columns: 1fr; }
    .card { padding: 20px; }
    .nav { width: 100%; }
}
