:root {
    color-scheme: light;
    --bg: #f5f8fb;
    --surface: #ffffff;
    --surface-soft: #f8fbfd;
    --surface-blue: #edf6fc;
    --surface-green: #edf8f5;
    --ink: #18324a;
    --ink-strong: #10283d;
    --muted: #63798d;
    --line: #dce6ed;
    --line-strong: #cad9e3;
    --primary: #287fa8;
    --primary-strong: #1f6688;
    --primary-soft: #dceff8;
    --accent: #3c8b7d;
    --accent-strong: #2c6f64;
    --accent-soft: #dff2ed;
    --danger: #c65353;
    --danger-strong: #a93d3d;
    --danger-soft: #fdeaea;
    --warning: #a56d21;
    --warning-soft: #fff3da;
    --success: #2f7d63;
    --success-soft: #e2f5ed;
    --shadow-sm: 0 2px 12px rgba(29, 62, 84, .07);
    --shadow-md: 0 14px 40px rgba(29, 62, 84, .10);
    --shadow-lg: 0 24px 64px rgba(29, 62, 84, .14);
    --radius-sm: 10px;
    --radius-md: 16px;
    --radius-lg: 24px;
    --radius-xl: 32px;
    --content: 1240px;
    --ease: cubic-bezier(.2, .8, .2, 1);
}

*,
*::before,
*::after {
    box-sizing: border-box;
}

html {
    min-width: 0;
    scroll-behavior: smooth;
}

body {
    margin: 0;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    overflow-x: hidden;
    background:
        radial-gradient(circle at 8% 3%, rgba(99, 179, 210, .13), transparent 27rem),
        radial-gradient(circle at 93% 7%, rgba(83, 167, 145, .12), transparent 25rem),
        var(--bg);
    color: var(--ink);
    font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
    font-size: 15px;
    line-height: 1.6;
    -webkit-font-smoothing: antialiased;
}

body::before {
    content: "";
    position: fixed;
    inset: 0;
    pointer-events: none;
    opacity: .35;
    background-image: linear-gradient(rgba(24, 50, 74, .025) 1px, transparent 1px), linear-gradient(90deg, rgba(24, 50, 74, .025) 1px, transparent 1px);
    background-size: 32px 32px;
    mask-image: linear-gradient(to bottom, #000, transparent 72%);
    z-index: -1;
}

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

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

a {
    color: var(--primary-strong);
}

img,
svg {
    display: block;
}

.icon {
    width: 1.15rem;
    height: 1.15rem;
    flex: 0 0 auto;
    fill: none;
    stroke: currentColor;
    stroke-width: 1.8;
    stroke-linecap: round;
    stroke-linejoin: round;
}

.visually-hidden {
    position: absolute !important;
    width: 1px !important;
    height: 1px !important;
    padding: 0 !important;
    margin: -1px !important;
    overflow: hidden !important;
    clip: rect(0, 0, 0, 0) !important;
    white-space: nowrap !important;
    border: 0 !important;
}

.skip-link {
    position: fixed;
    top: 10px;
    left: 10px;
    z-index: 1000;
    transform: translateY(-160%);
    padding: 10px 14px;
    border-radius: var(--radius-sm);
    background: var(--ink-strong);
    color: #fff;
    text-decoration: none;
}

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

:focus-visible {
    outline: 3px solid rgba(40, 127, 168, .28);
    outline-offset: 3px;
}

.app-header {
    position: sticky;
    top: 0;
    z-index: 100;
    border-bottom: 1px solid rgba(202, 217, 227, .78);
    background: rgba(255, 255, 255, .94);
    box-shadow: 0 3px 18px rgba(29, 62, 84, .05);
}

@supports (backdrop-filter: blur(12px)) {
    .app-header {
        background: rgba(255, 255, 255, .82);
        backdrop-filter: blur(14px) saturate(130%);
    }
}

.app-header__inner {
    width: min(calc(100% - 32px), var(--content));
    min-height: 72px;
    margin: 0 auto;
    display: flex;
    align-items: center;
    gap: 24px;
}

.brand {
    display: inline-flex;
    align-items: center;
    gap: 11px;
    min-width: max-content;
    color: var(--ink-strong);
    text-decoration: none;
}

.brand__mark {
    width: 40px;
    height: 40px;
    display: grid;
    place-items: center;
    border-radius: 13px;
    background: linear-gradient(145deg, var(--primary), var(--accent));
    color: #fff;
    box-shadow: 0 8px 18px rgba(40, 127, 168, .2);
}

.brand__mark .icon {
    width: 23px;
    height: 23px;
}

.brand__copy {
    display: grid;
    line-height: 1.2;
}

.brand__copy strong {
    font-size: 14px;
    letter-spacing: -.01em;
}

.brand__copy small {
    margin-top: 3px;
    color: var(--muted);
    font-size: 11px;
    font-weight: 650;
    letter-spacing: .08em;
    text-transform: uppercase;
}

.app-nav {
    margin-left: auto;
    display: flex;
    align-items: center;
    gap: 4px;
}

.nav-link {
    display: inline-flex;
    align-items: center;
    gap: 7px;
    min-height: 42px;
    padding: 8px 12px;
    border-radius: 12px;
    color: var(--muted);
    font-size: 13px;
    font-weight: 700;
    text-decoration: none;
    transition: color .18s ease, background .18s ease, transform .18s var(--ease);
}

.nav-link:hover {
    color: var(--ink-strong);
    background: var(--surface-blue);
}

.nav-link.is-active {
    color: var(--primary-strong);
    background: var(--primary-soft);
}

.nav-actions {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-left: 6px;
    padding-left: 12px;
    border-left: 1px solid var(--line);
}

.nav-actions form {
    margin: 0;
}

.menu-toggle {
    display: none;
    margin-left: auto;
    width: 44px;
    height: 44px;
    place-items: center;
    border: 1px solid var(--line);
    border-radius: 13px;
    background: var(--surface);
    color: var(--ink);
    cursor: pointer;
}

.page-main {
    flex: 1;
    width: min(calc(100% - 32px), var(--content));
    margin: 0 auto;
    padding: 42px 0 64px;
}

.page-main--narrow {
    max-width: 820px;
}

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

.page-head__copy {
    min-width: 0;
}

.eyebrow {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 8px;
    color: var(--accent-strong);
    font-size: 12px;
    font-weight: 800;
    letter-spacing: .11em;
    text-transform: uppercase;
}

.eyebrow::before {
    content: "";
    width: 18px;
    height: 2px;
    border-radius: 99px;
    background: currentColor;
}

.page-title,
.hero-title {
    margin: 0;
    color: var(--ink-strong);
    font-weight: 780;
    letter-spacing: -.035em;
    line-height: 1.15;
}

.page-title {
    font-size: clamp(1.75rem, 3vw, 2.45rem);
}

.page-description {
    max-width: 670px;
    margin: 9px 0 0;
    color: var(--muted);
    font-size: 15px;
}

.page-actions,
.button-row,
.toolbar-actions {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 10px;
}

.btn {
    min-height: 42px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 9px 16px;
    border: 1px solid transparent;
    border-radius: 12px;
    background: transparent;
    color: var(--ink);
    font-size: 13px;
    font-weight: 750;
    line-height: 1.2;
    text-decoration: none;
    cursor: pointer;
    transition: transform .18s var(--ease), box-shadow .18s ease, background .18s ease, border-color .18s ease;
}

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

.btn:active {
    transform: translateY(0);
}

.btn--primary {
    background: var(--primary);
    color: #fff;
    box-shadow: 0 7px 18px rgba(40, 127, 168, .18);
}

.btn--primary:hover {
    background: var(--primary-strong);
    box-shadow: 0 10px 22px rgba(40, 127, 168, .24);
}

.btn--accent {
    background: var(--accent);
    color: #fff;
    box-shadow: 0 7px 18px rgba(60, 139, 125, .16);
}

.btn--accent:hover {
    background: var(--accent-strong);
}

.btn--soft {
    border-color: var(--line);
    background: var(--surface);
    color: var(--ink);
}

.btn--soft:hover {
    border-color: var(--line-strong);
    background: var(--surface-soft);
    box-shadow: var(--shadow-sm);
}

.btn--danger-soft {
    border-color: #f3caca;
    background: var(--danger-soft);
    color: var(--danger-strong);
}

.btn--danger-soft:hover {
    border-color: #eeb0b0;
    background: #fbdede;
}

.btn--sm {
    min-height: 36px;
    padding: 7px 11px;
    border-radius: 10px;
    font-size: 12px;
}

.btn--block {
    width: 100%;
}

.panel,
.camera-card,
.form-card,
.stream-card,
.stat-card {
    border: 1px solid var(--line);
    background: var(--surface);
    box-shadow: var(--shadow-sm);
}

.panel,
.form-card,
.stream-card {
    border-radius: var(--radius-lg);
}

.hero {
    position: relative;
    overflow: hidden;
    display: grid;
    grid-template-columns: minmax(0, 1.35fr) minmax(280px, .65fr);
    gap: 32px;
    padding: clamp(28px, 5vw, 52px);
    margin-bottom: 28px;
    border: 1px solid #cfe2ed;
    border-radius: var(--radius-xl);
    background:
        linear-gradient(125deg, rgba(255, 255, 255, .96), rgba(239, 248, 251, .91)),
        var(--surface);
    box-shadow: var(--shadow-md);
}

.hero::after {
    content: "";
    position: absolute;
    width: 310px;
    height: 310px;
    right: -110px;
    top: -150px;
    border-radius: 50%;
    background: linear-gradient(145deg, rgba(70, 155, 186, .18), rgba(73, 160, 139, .08));
}

.hero__content,
.hero__aside {
    position: relative;
    z-index: 1;
}

.hero-title {
    max-width: 650px;
    font-size: clamp(2rem, 5vw, 3.55rem);
}

.hero-copy {
    max-width: 640px;
    margin: 16px 0 24px;
    color: var(--muted);
    font-size: clamp(15px, 2vw, 17px);
}

.hero__aside {
    align-self: stretch;
    display: grid;
    align-content: center;
    gap: 12px;
    padding: 22px;
    border: 1px solid rgba(202, 217, 227, .75);
    border-radius: 20px;
    background: rgba(255, 255, 255, .65);
}

.hero__aside-label {
    color: var(--muted);
    font-size: 12px;
    font-weight: 750;
    letter-spacing: .08em;
    text-transform: uppercase;
}

.hero__aside strong {
    color: var(--ink-strong);
    font-size: 20px;
    line-height: 1.3;
}

.live-dot,
.status-dot {
    width: 9px;
    height: 9px;
    display: inline-block;
    border-radius: 50%;
    background: var(--accent);
    box-shadow: 0 0 0 5px var(--accent-soft);
}

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

.stat-card {
    display: flex;
    align-items: center;
    gap: 14px;
    padding: 18px;
    border-radius: var(--radius-md);
}

.stat-card__icon {
    width: 42px;
    height: 42px;
    display: grid;
    place-items: center;
    border-radius: 13px;
    background: var(--surface-blue);
    color: var(--primary);
}

.stat-card__value {
    display: block;
    color: var(--ink-strong);
    font-size: 21px;
    font-weight: 800;
    line-height: 1.15;
}

.stat-card__label {
    color: var(--muted);
    font-size: 12px;
    font-weight: 650;
}

.section-head,
.panel-head,
.toolbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 18px;
}

.section-head {
    margin: 34px 0 18px;
}

.section-title {
    margin: 0;
    color: var(--ink-strong);
    font-size: 20px;
    font-weight: 780;
    letter-spacing: -.02em;
}

.section-note {
    margin: 3px 0 0;
    color: var(--muted);
    font-size: 13px;
}

.toolbar {
    margin-bottom: 18px;
    padding: 14px;
    border: 1px solid var(--line);
    border-radius: var(--radius-md);
    background: rgba(255, 255, 255, .72);
}

.search-box {
    position: relative;
    width: min(100%, 360px);
}

.search-box .icon {
    position: absolute;
    top: 50%;
    left: 13px;
    transform: translateY(-50%);
    color: var(--muted);
    pointer-events: none;
}

.search-box input {
    width: 100%;
    min-height: 42px;
    padding: 9px 14px 9px 40px;
    border: 1px solid var(--line);
    border-radius: 12px;
    background: var(--surface);
    color: var(--ink);
    outline: none;
}

.search-box input:focus {
    border-color: #8abbd0;
    box-shadow: 0 0 0 4px rgba(40, 127, 168, .1);
}

.camera-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(270px, 1fr));
    gap: 18px;
}

.camera-card {
    position: relative;
    min-width: 0;
    padding: 20px;
    border-radius: 19px;
    transition: transform .2s var(--ease), box-shadow .2s ease, border-color .2s ease;
}

.camera-card:hover {
    transform: translateY(-3px);
    border-color: #b8d4e1;
    box-shadow: var(--shadow-md);
}

.camera-card__top {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 12px;
}

.channel-badge,
.status-badge,
.code-badge {
    display: inline-flex;
    align-items: center;
    gap: 7px;
    border-radius: 999px;
    font-size: 11px;
    font-weight: 800;
    letter-spacing: .04em;
}

.channel-badge {
    padding: 7px 10px;
    background: var(--primary-soft);
    color: var(--primary-strong);
}

.status-badge {
    padding: 6px 9px;
    background: var(--accent-soft);
    color: var(--accent-strong);
}

.camera-card__title {
    margin: 18px 0 5px;
    color: var(--ink-strong);
    font-size: 17px;
    line-height: 1.35;
}

.camera-card__meta {
    margin-bottom: 18px;
    color: var(--muted);
    font-size: 12px;
}

.code-badge {
    max-width: 100%;
    padding: 7px 10px;
    overflow: hidden;
    background: var(--surface-soft);
    color: var(--muted);
    font-family: ui-monospace, SFMono-Regular, Consolas, monospace;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.camera-card__actions {
    margin-top: 18px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
}

.empty-state {
    grid-column: 1 / -1;
    padding: 52px 24px;
    border: 1px dashed var(--line-strong);
    border-radius: var(--radius-lg);
    background: rgba(255, 255, 255, .55);
    text-align: center;
}

.empty-state__icon {
    width: 54px;
    height: 54px;
    margin: 0 auto 14px;
    display: grid;
    place-items: center;
    border-radius: 18px;
    background: var(--surface-blue);
    color: var(--primary);
}

.empty-state h2,
.empty-state h3 {
    margin: 0 0 7px;
    color: var(--ink-strong);
}

.empty-state p {
    margin: 0;
    color: var(--muted);
}

.stream-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(340px, 1fr));
    gap: 20px;
}

.stream-card {
    min-width: 0;
    overflow: hidden;
    transition: transform .2s var(--ease), box-shadow .2s ease;
}

.stream-card:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-md);
}

.stream-card__head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 15px 17px;
}

.stream-card__title {
    min-width: 0;
}

.stream-card__title h2,
.stream-card__title h3 {
    margin: 0;
    overflow: hidden;
    color: var(--ink-strong);
    font-size: 14px;
    font-weight: 760;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.stream-card__title small {
    display: block;
    margin-top: 2px;
    color: var(--muted);
    font-size: 11px;
}

.frame-wrap {
    position: relative;
    aspect-ratio: 16 / 9;
    overflow: hidden;
    background: #102437;
}

.frame-wrap iframe {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    border: 0;
    background: #102437;
}

.frame-placeholder {
    position: absolute;
    inset: 0;
    display: grid;
    place-items: center;
    padding: 22px;
    background:
        radial-gradient(circle at 50% 40%, rgba(82, 164, 183, .2), transparent 35%),
        #102437;
    color: #d7e7ef;
    text-align: center;
}

.frame-placeholder .icon {
    width: 30px;
    height: 30px;
    margin: 0 auto 9px;
    color: #82c6d5;
}

.frame-placeholder span {
    display: block;
    font-size: 12px;
}

.frame-wrap.is-loaded .frame-placeholder {
    display: none;
}

.stream-card--single {
    max-width: 1040px;
    margin: 0 auto;
}

.stream-card--single .stream-card__head {
    padding: 20px 22px;
}

.stream-card--single .stream-card__title h2 {
    font-size: 19px;
}

.stream-meta {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 14px 18px;
    color: var(--muted);
    font-size: 12px;
}

.panel {
    overflow: hidden;
}

.panel-head {
    padding: 20px 22px;
    border-bottom: 1px solid var(--line);
}

.panel-head h2 {
    margin: 0;
    color: var(--ink-strong);
    font-size: 17px;
}

.panel-head p {
    margin: 3px 0 0;
    color: var(--muted);
    font-size: 12px;
}

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

.data-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 13px;
}

.data-table th,
.data-table td {
    padding: 14px 17px;
    border-bottom: 1px solid var(--line);
    text-align: left;
    vertical-align: middle;
}

.data-table th {
    background: var(--surface-soft);
    color: var(--muted);
    font-size: 10px;
    font-weight: 800;
    letter-spacing: .09em;
    text-transform: uppercase;
}

.data-table tbody tr {
    transition: background .16s ease;
}

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

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

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

.table-index {
    color: var(--muted);
    font-weight: 750;
}

.notice {
    position: relative;
    display: flex;
    align-items: flex-start;
    gap: 11px;
    margin-bottom: 18px;
    padding: 13px 44px 13px 14px;
    border: 1px solid;
    border-radius: 13px;
    font-size: 13px;
    font-weight: 650;
    transition: opacity .25s ease, transform .25s var(--ease);
}

.notice--success {
    border-color: #bfe4d5;
    background: var(--success-soft);
    color: #26654f;
}

.notice--error {
    border-color: #efc5c5;
    background: var(--danger-soft);
    color: var(--danger-strong);
}

.notice.is-leaving {
    opacity: 0;
    transform: translateY(-6px);
}

.notice__close {
    position: absolute;
    top: 7px;
    right: 8px;
    width: 30px;
    height: 30px;
    border: 0;
    border-radius: 9px;
    background: transparent;
    color: currentColor;
    cursor: pointer;
}

.form-card {
    padding: clamp(22px, 4vw, 36px);
}

.backup-summary {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 1px;
    overflow: hidden;
    margin-bottom: 22px;
    border: 1px solid var(--line);
    border-radius: 16px;
    background: var(--line);
    box-shadow: var(--shadow-sm);
}

.backup-summary > div {
    min-width: 0;
    display: grid;
    gap: 5px;
    padding: 17px 18px;
    background: var(--surface);
}

.backup-summary span {
    color: var(--muted);
    font-size: 10px;
    font-weight: 800;
    letter-spacing: .07em;
    text-transform: uppercase;
}

.backup-summary strong {
    overflow-wrap: anywhere;
    color: var(--ink-strong);
    font-size: 18px;
}

.backup-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 22px;
    align-items: start;
}

.backup-card {
    display: grid;
    gap: 22px;
}

.backup-card--danger {
    border-color: #ead3d3;
}

.backup-card__intro {
    display: flex;
    align-items: flex-start;
    gap: 14px;
    padding-bottom: 20px;
    border-bottom: 1px solid var(--line);
}

.backup-card__intro h2 {
    margin: 0;
    color: var(--ink-strong);
    font-size: 21px;
}

.backup-card__intro p {
    margin: 6px 0 0;
    color: var(--muted);
    font-size: 13px;
}

.backup-card__icon {
    flex: 0 0 auto;
    width: 44px;
    height: 44px;
    display: grid;
    place-items: center;
    border-radius: 13px;
    background: var(--surface-blue);
    color: var(--primary);
}

.backup-card__icon--danger {
    background: var(--danger-soft);
    color: var(--danger-strong);
}

.security-note {
    display: flex;
    align-items: flex-start;
    gap: 10px;
    padding: 13px;
    border: 1px solid #d8e4eb;
    border-radius: 13px;
    background: var(--surface-soft);
    color: var(--muted);
}

.security-note .icon {
    flex: 0 0 auto;
    margin-top: 1px;
    color: var(--accent-strong);
}

.security-note p {
    margin: 0;
    font-size: 12px;
}

.backup-card form {
    display: grid;
    gap: 18px;
}

.file-picker {
    min-height: 64px;
    display: flex !important;
    justify-content: flex-start !important;
    gap: 10px !important;
    margin: 0 !important;
    padding: 13px 15px;
    border: 1px dashed var(--line-strong);
    border-radius: 13px;
    background: var(--surface-soft);
    color: var(--muted) !important;
    cursor: pointer;
    overflow-wrap: anywhere;
    transition: border-color .16s ease, background .16s ease;
}

.file-picker:hover,
.file-picker:focus-within {
    border-color: #79b2cb;
    background: var(--surface-blue);
}

.scope-fieldset {
    min-width: 0;
    display: grid;
    gap: 10px;
    margin: 0;
    padding: 0;
    border: 0;
}

.scope-fieldset legend {
    margin-bottom: 7px;
    color: var(--ink-strong);
    font-size: 13px;
    font-weight: 750;
}

.scope-option {
    display: grid;
    grid-template-columns: auto minmax(0, 1fr);
    align-items: start;
    gap: 11px;
    padding: 13px;
    border: 1px solid var(--line);
    border-radius: 13px;
    cursor: pointer;
}

.scope-option:has(input:checked) {
    border-color: #83bdcf;
    background: var(--surface-blue);
    box-shadow: 0 0 0 3px rgba(40, 127, 168, .08);
}

.scope-option--danger:has(input:checked) {
    border-color: #e4aaaa;
    background: var(--danger-soft);
    box-shadow: 0 0 0 3px rgba(198, 83, 83, .07);
}

.scope-option input {
    margin: 3px 0 0;
    accent-color: var(--primary);
}

.scope-option span,
.scope-option strong,
.scope-option small {
    display: block;
}

.scope-option strong {
    color: var(--ink-strong);
    font-size: 13px;
}

.scope-option small {
    margin-top: 4px;
    color: var(--muted);
    font-size: 11px;
}

.scope-option em {
    display: inline-block;
    margin-left: 5px;
    padding: 2px 6px;
    border-radius: 99px;
    background: #d9eee8;
    color: var(--accent-strong);
    font-size: 9px;
    font-style: normal;
    letter-spacing: .04em;
    text-transform: uppercase;
}

.form-card__head {
    margin-bottom: 26px;
    padding-bottom: 20px;
    border-bottom: 1px solid var(--line);
}

.form-card__head h1,
.form-card__head h2 {
    margin: 0;
    color: var(--ink-strong);
    font-size: 22px;
    letter-spacing: -.02em;
}

.form-card__head p {
    margin: 7px 0 0;
    color: var(--muted);
    font-size: 13px;
}

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

.field--full {
    grid-column: 1 / -1;
}

.field label {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    margin-bottom: 7px;
    color: var(--ink-strong);
    font-size: 13px;
    font-weight: 750;
}

.field-label-note {
    color: var(--muted);
    font-size: 10px;
    font-weight: 650;
}

.input-wrap {
    position: relative;
}

.field input,
.field select,
.field textarea {
    width: 100%;
    min-height: 46px;
    padding: 10px 13px;
    border: 1px solid var(--line-strong);
    border-radius: 12px;
    background: var(--surface);
    color: var(--ink);
    outline: none;
    transition: border-color .16s ease, box-shadow .16s ease, background .16s ease;
}

.field input::placeholder,
.field textarea::placeholder {
    color: #99a9b7;
}

.field input:focus,
.field select:focus,
.field textarea:focus {
    border-color: #79b2cb;
    background: #fcfeff;
    box-shadow: 0 0 0 4px rgba(40, 127, 168, .1);
}

.field input[aria-invalid="true"] {
    border-color: #dc8c8c;
    box-shadow: 0 0 0 4px rgba(198, 83, 83, .08);
}

.field-help,
.field-error,
.field-status {
    display: block;
    margin-top: 6px;
    font-size: 11px;
}

.field-help,
.field-status {
    color: var(--muted);
}

.field-error {
    color: var(--danger-strong);
    font-weight: 650;
}

.field-error:empty {
    display: none;
}

.password-toggle {
    position: absolute;
    top: 50%;
    right: 8px;
    transform: translateY(-50%);
    width: 34px;
    height: 34px;
    display: grid;
    place-items: center;
    border: 0;
    border-radius: 9px;
    background: transparent;
    color: var(--muted);
    cursor: pointer;
}

.input-wrap input[type="password"],
.input-wrap input[data-password-input] {
    padding-right: 47px;
}

.password-meter {
    height: 5px;
    margin-top: 9px;
    overflow: hidden;
    border-radius: 99px;
    background: var(--line);
}

.password-meter span {
    width: 0;
    height: 100%;
    display: block;
    border-radius: inherit;
    background: var(--danger);
    transition: width .2s ease, background .2s ease;
}

.password-meter[data-score="2"] span {
    background: var(--warning);
}

.password-meter[data-score="3"] span,
.password-meter[data-score="4"] span {
    background: var(--success);
}

.form-preview {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 22px;
    padding: 14px;
    border: 1px solid #cfe2ed;
    border-radius: 14px;
    background: var(--surface-blue);
}

.form-preview__icon {
    width: 40px;
    height: 40px;
    display: grid;
    place-items: center;
    border-radius: 12px;
    background: var(--surface);
    color: var(--primary);
}

.form-preview strong {
    display: block;
    color: var(--ink-strong);
    font-size: 13px;
}

.form-preview small {
    color: var(--muted);
    font-size: 11px;
}

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

.app-footer {
    margin-top: auto;
    border-top: 1px solid var(--line);
    background: rgba(255, 255, 255, .72);
}

.app-footer__inner {
    width: min(calc(100% - 32px), var(--content));
    min-height: 76px;
    margin: 0 auto;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 20px;
    color: var(--muted);
    font-size: 11px;
}

.app-footer strong {
    color: var(--ink);
}

.footer-credit {
    text-align: right;
}

.footer-heart {
    color: var(--danger);
}

.dialog {
    width: min(calc(100% - 32px), 430px);
    padding: 0;
    border: 0;
    border-radius: 22px;
    background: var(--surface);
    color: var(--ink);
    box-shadow: var(--shadow-lg);
}

.dialog::backdrop {
    background: rgba(16, 40, 61, .48);
    backdrop-filter: blur(3px);
}

.dialog__body {
    padding: 28px;
}

.dialog__icon {
    width: 48px;
    height: 48px;
    display: grid;
    place-items: center;
    margin-bottom: 16px;
    border-radius: 15px;
    background: var(--danger-soft);
    color: var(--danger);
}

.dialog h2 {
    margin: 0 0 7px;
    color: var(--ink-strong);
    font-size: 20px;
}

.dialog p {
    margin: 0;
    color: var(--muted);
    font-size: 13px;
}

.dialog__actions {
    display: flex;
    justify-content: flex-end;
    gap: 9px;
    margin-top: 24px;
}

.is-hidden,
[hidden] {
    display: none !important;
}

.auth-body {
    background:
        radial-gradient(circle at 15% 15%, rgba(66, 153, 188, .18), transparent 30rem),
        radial-gradient(circle at 86% 76%, rgba(62, 145, 124, .15), transparent 28rem),
        #eef5f8;
}

.auth-main {
    flex: 1;
    min-height: 100vh;
    display: grid;
    grid-template-columns: minmax(320px, 1fr) minmax(360px, 520px);
}

.auth-story {
    position: relative;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    padding: clamp(36px, 6vw, 80px);
    background: linear-gradient(145deg, #17364f 0%, #19475a 55%, #27665f 100%);
    color: #fff;
}

.auth-story::before,
.auth-story::after {
    content: "";
    position: absolute;
    border-radius: 50%;
    border: 1px solid rgba(255, 255, 255, .12);
}

.auth-story::before {
    width: 430px;
    height: 430px;
    right: -190px;
    top: -150px;
}

.auth-story::after {
    width: 260px;
    height: 260px;
    left: -120px;
    bottom: -110px;
}

.auth-story__brand,
.auth-story__content,
.auth-story__footer {
    position: relative;
    z-index: 1;
}

.auth-story__brand {
    display: flex;
    align-items: center;
    gap: 13px;
    font-weight: 780;
}

.auth-story__brand .brand__mark {
    background: rgba(255, 255, 255, .13);
    box-shadow: none;
}

.auth-story__content {
    max-width: 640px;
    margin: auto 0;
    padding: 60px 0;
}

.auth-story__kicker {
    color: #a9dfe0;
    font-size: 12px;
    font-weight: 800;
    letter-spacing: .13em;
    text-transform: uppercase;
}

.auth-story h1 {
    max-width: 650px;
    margin: 14px 0 18px;
    font-size: clamp(2.5rem, 6vw, 5.2rem);
    line-height: .98;
    letter-spacing: -.055em;
}

.auth-story p {
    max-width: 560px;
    margin: 0;
    color: #c5dce6;
    font-size: clamp(15px, 2vw, 18px);
}

.auth-story__footer {
    color: #a9c5d1;
    font-size: 11px;
}

.auth-panel {
    display: grid;
    place-items: center;
    padding: clamp(24px, 6vw, 72px);
    background: rgba(255, 255, 255, .6);
}

.login-card {
    width: 100%;
    max-width: 410px;
}

.login-card__intro {
    margin-bottom: 28px;
}

.login-card__intro h2 {
    margin: 0 0 8px;
    color: var(--ink-strong);
    font-size: 28px;
    letter-spacing: -.035em;
}

.login-card__intro p {
    margin: 0;
    color: var(--muted);
    font-size: 13px;
}

.login-card .field {
    margin-bottom: 17px;
}

.login-card__meta {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    margin-top: 20px;
    padding-top: 18px;
    border-top: 1px solid var(--line);
    color: var(--muted);
    font-size: 11px;
    text-align: center;
}

@media (max-width: 1050px) {
    .app-header__inner {
        gap: 12px;
    }

    .nav-link {
        padding-inline: 9px;
    }

    .nav-link span {
        display: none;
    }

    .hero {
        grid-template-columns: minmax(0, 1fr) 260px;
    }
}

@media (max-width: 820px) {
    .app-header__inner {
        min-height: 66px;
        flex-wrap: wrap;
        padding: 10px 0;
    }

    .menu-toggle {
        display: grid;
    }

    .app-nav {
        width: 100%;
        display: none;
        margin: 0;
        padding: 8px 0 4px;
        border-top: 1px solid var(--line);
        flex-direction: column;
        align-items: stretch;
    }

    .app-nav.is-open {
        display: flex;
    }

    .nav-link {
        width: 100%;
        justify-content: flex-start;
        padding: 10px 12px;
    }

    .nav-link span {
        display: inline;
    }

    .nav-actions {
        margin: 4px 0 0;
        padding: 10px 0 0;
        border-top: 1px solid var(--line);
        border-left: 0;
    }

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

    .page-main {
        padding-top: 28px;
    }

    .page-head {
        align-items: flex-start;
        flex-direction: column;
    }

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

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

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

    .hero__aside {
        min-height: auto;
    }

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

    .auth-main {
        min-height: auto;
        grid-template-columns: 1fr;
    }

    .auth-story {
        min-height: 340px;
        padding: 34px 28px;
    }

    .auth-story__content {
        padding: 42px 0;
    }

    .auth-story h1 {
        max-width: 520px;
        font-size: clamp(2.4rem, 10vw, 4.2rem);
    }

    .auth-panel {
        padding: 42px 24px 54px;
    }
}

@media (max-width: 680px) {
    .page-main,
    .app-header__inner,
    .app-footer__inner {
        width: min(calc(100% - 24px), var(--content));
    }

    .page-main {
        padding-bottom: 44px;
    }

    .brand__copy small {
        display: none;
    }

    .hero {
        padding: 26px 22px;
        border-radius: 22px;
    }

    .hero-title {
        font-size: 2.25rem;
    }

    .toolbar,
    .section-head,
    .panel-head {
        align-items: stretch;
        flex-direction: column;
    }

    .search-box {
        width: 100%;
    }

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

    .camera-grid,
    .stream-grid {
        grid-template-columns: 1fr;
    }

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

    .field--full {
        grid-column: auto;
    }

    .form-actions {
        flex-direction: column-reverse;
    }

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

    .data-table thead {
        display: none;
    }

    .data-table,
    .data-table tbody,
    .data-table tr,
    .data-table td {
        display: block;
        width: 100%;
    }

    .data-table tbody {
        display: grid;
        gap: 12px;
        padding: 12px;
    }

    .data-table tr {
        overflow: hidden;
        border: 1px solid var(--line);
        border-radius: 14px;
        background: var(--surface);
    }

    .data-table td {
        display: grid;
        grid-template-columns: minmax(92px, .42fr) minmax(0, 1fr);
        gap: 12px;
        padding: 10px 13px;
        text-align: right;
    }

    .data-table td::before {
        content: attr(data-label);
        color: var(--muted);
        font-size: 10px;
        font-weight: 800;
        letter-spacing: .06em;
        text-align: left;
        text-transform: uppercase;
    }

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

    .table-actions {
        justify-content: flex-end;
    }

    .app-footer__inner {
        padding: 18px 0;
        align-items: flex-start;
        flex-direction: column;
        gap: 6px;
    }

    .footer-credit {
        text-align: left;
    }

    .stream-meta {
        align-items: flex-start;
        flex-direction: column;
    }
}

@media (max-width: 420px) {
    .brand__mark {
        width: 36px;
        height: 36px;
    }

    .brand__copy strong {
        font-size: 12px;
    }

    .backup-summary {
        grid-template-columns: 1fr;
    }

    .backup-card__intro {
        align-items: center;
    }

    .camera-card {
        padding: 17px;
    }

    .camera-card__actions {
        align-items: stretch;
        flex-direction: column;
    }

    .camera-card__actions .btn {
        width: 100%;
    }

    .auth-story {
        min-height: 300px;
        padding: 28px 22px;
    }

    .auth-panel {
        padding-inline: 18px;
    }
}

@media (prefers-reduced-motion: reduce) {
    html {
        scroll-behavior: auto;
    }

    *,
    *::before,
    *::after {
        scroll-behavior: auto !important;
        transition-duration: .01ms !important;
        animation-duration: .01ms !important;
        animation-iteration-count: 1 !important;
    }
}

@media print {
    .app-header,
    .app-footer,
    .toolbar,
    .page-actions,
    .table-actions {
        display: none !important;
    }

    body {
        background: #fff;
    }

    .page-main {
        width: 100%;
        padding: 0;
    }

    .panel,
    .camera-card,
    .form-card {
        box-shadow: none;
    }
}
