:root {
    --bg-main: #eef3fb;
    --bg-card: #ffffff;
    --surface-glass: rgba(255, 255, 255, 0.82);
    --surface-soft: #f8fafc;
    --sidebar-bg: #071329;
    --sidebar-hover: rgba(37, 99, 235, 0.18);
    --text-main: #0f172a;
    --text-muted: #64748b;
    --primary: #2563eb;
    --primary-deep: #1d4ed8;
    --accent: #0891b2;
    --danger: #dc2626;
    --success: #16a34a;
    --offline: #64748b;
    --border: #dbe3ef;
    --border-strong: #c7d2e4;
    --shadow-soft: 0 10px 28px rgba(15, 23, 42, 0.08);
    --shadow-premium: 0 22px 70px rgba(15, 23, 42, 0.16);
    --radius-lg: 22px;
    --radius-md: 16px;
}

* {
    box-sizing: border-box;
}

body {
    margin: 0;
    background:
        radial-gradient(circle at 18% 0%, rgba(37, 99, 235, 0.13), transparent 34%),
        radial-gradient(circle at 90% 10%, rgba(8, 145, 178, 0.12), transparent 32%),
        var(--bg-main);
    color: var(--text-main);
    font-family: "Pretendard", "Noto Sans KR", system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
    letter-spacing: -0.015em;
}

.admin-shell {
    min-height: 100vh;
    position: relative;
}

.sidebar {
    width: min(336px, calc(100vw - 32px));
    background:
        radial-gradient(circle at 25% 0%, rgba(59, 130, 246, 0.24), transparent 32%),
        linear-gradient(180deg, #071329 0%, #0c1830 100%);
    color: #fff;
    padding: 1.35rem;
    display: flex;
    flex-direction: column;
    position: fixed;
    top: 0;
    left: 0;
    height: 100vh;
    z-index: 1040;
    transform: translateX(-100%);
    transition: transform 0.26s ease;
    box-shadow: 24px 0 80px rgba(7, 19, 41, 0.34);
}

.admin-shell.sidebar-open .sidebar {
    transform: translateX(0);
}

.sidebar-overlay {
    position: fixed;
    inset: 0;
    z-index: 1030;
    border: 0;
    background: rgba(7, 19, 41, 0.46);
    backdrop-filter: blur(3px);
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.2s ease, visibility 0.2s ease;
}

.admin-shell.sidebar-open .sidebar-overlay {
    opacity: 1;
    visibility: visible;
}

.admin-brand {
    display: flex;
    align-items: center;
    gap: 0.9rem;
    margin-bottom: 1.5rem;
}

.admin-brand-mark {
    width: 52px;
    height: 52px;
    border-radius: 18px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, #3b82f6, #06b6d4);
    box-shadow: 0 16px 40px rgba(37, 99, 235, 0.34);
    color: #fff;
    font-size: 0.9rem;
    font-weight: 800;
    letter-spacing: 0.04em;
}

.sidebar-title {
    font-size: 1.12rem;
    font-weight: 800;
    line-height: 1.1;
    margin-bottom: 0.25rem;
}

.sidebar-sub {
    font-size: 0.8rem;
    color: #bfdbfe;
    margin-bottom: 0;
}

.sidebar-nav {
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
}

.menu-link {
    color: #dbeafe;
    text-decoration: none;
    display: flex;
    align-items: center;
    min-height: 46px;
    padding: 0.72rem 0.85rem;
    border: 1px solid transparent;
    border-radius: 0.95rem;
    margin-bottom: 0.25rem;
    font-weight: 700;
    transition: background 0.18s ease, border-color 0.18s ease, transform 0.18s ease, color 0.18s ease;
}

.menu-link:hover,
.menu-link.active {
    background: var(--sidebar-hover);
    border-color: rgba(147, 197, 253, 0.18);
    color: #fff;
    transform: translateX(2px);
}

.menu-link.active {
    box-shadow: inset 3px 0 0 #67e8f9;
}

.sidebar-footer {
    margin-top: auto;
    font-size: 0.85rem;
    color: #b4c2e2;
}

.sidebar-system-note {
    padding: 0.9rem;
    border: 1px solid rgba(147, 197, 253, 0.16);
    border-radius: 1rem;
    background: rgba(255, 255, 255, 0.06);
    color: #dbeafe;
    font-weight: 700;
}

.main-wrap {
    min-width: 0;
    width: 100%;
}

.topbar {
    position: sticky;
    top: 0;
    z-index: 1020;
    margin: 1rem 1.25rem 0;
    background: var(--surface-glass);
    border: 1px solid rgba(219, 227, 239, 0.82);
    border-radius: var(--radius-lg);
    padding: 0.95rem 1.1rem;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.75rem;
    box-shadow: var(--shadow-soft);
    backdrop-filter: blur(18px);
}

.sidebar-toggle {
    width: 42px;
    height: 42px;
    border: 1px solid var(--border);
    border-radius: 14px;
    background: #fff;
    display: inline-flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 5px;
    transition: border-color 0.18s ease, background 0.18s ease, transform 0.18s ease;
}

.sidebar-toggle:hover,
.sidebar-toggle:focus-visible {
    border-color: #bfdbfe;
    background: #eff6ff;
    outline: none;
    box-shadow: 0 0 0 4px rgba(37, 99, 235, 0.12);
}

.sidebar-toggle:active {
    transform: scale(0.97);
}

.sidebar-toggle span {
    width: 18px;
    height: 2px;
    border-radius: 999px;
    background: var(--sidebar-bg);
}

.topbar-title {
    font-size: 1.24rem;
    font-weight: 800;
    letter-spacing: -0.04em;
}

.topbar-kicker,
.section-kicker {
    color: var(--primary);
    font-size: 0.76rem;
    font-weight: 800;
    letter-spacing: 0.08em;
    text-transform: uppercase;
}

.profile-box {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.profile-avatar {
    width: 38px;
    height: 38px;
    border-radius: 999px;
    background: linear-gradient(135deg, #dbeafe, #cffafe);
    color: #1d4ed8;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.8rem;
    font-weight: 700;
}

.page-content {
    position: relative;
    padding: 1.35rem 1.5rem 2rem;
}

.page-content::before {
    content: "";
    position: fixed;
    inset: 0;
    z-index: -1;
    pointer-events: none;
    background:
        linear-gradient(135deg, rgba(7, 19, 41, 0.05), transparent 32%),
        radial-gradient(circle at 75% 20%, rgba(37, 99, 235, 0.1), transparent 28%);
}

.page-hero {
    display: flex;
    align-items: flex-end;
    justify-content: space-between;
    gap: 1rem;
    padding: clamp(1.25rem, 3vw, 2rem);
    border: 1px solid rgba(219, 227, 239, 0.86);
    border-radius: var(--radius-lg);
    background:
        linear-gradient(135deg, rgba(255, 255, 255, 0.92), rgba(248, 250, 252, 0.86)),
        radial-gradient(circle at 95% 0%, rgba(59, 130, 246, 0.12), transparent 28%);
    box-shadow: var(--shadow-soft);
}

.page-hero h1 {
    margin: 0;
    font-size: clamp(1.7rem, 3vw, 2.5rem);
    font-weight: 800;
    letter-spacing: -0.055em;
}

.page-hero p:not(.section-kicker) {
    margin: 0.55rem 0 0;
    color: var(--text-muted);
    line-height: 1.65;
    word-break: keep-all;
}

.card {
    border: 1px solid rgba(219, 227, 239, 0.9);
    border-radius: var(--radius-md);
    background: rgba(255, 255, 255, 0.92);
    box-shadow: var(--shadow-soft);
    overflow: visible;
}

.card-header {
    border-bottom: 1px solid var(--border);
    background: linear-gradient(180deg, #ffffff, #f8fafc);
    color: var(--text-main);
    font-weight: 800;
    letter-spacing: -0.02em;
}

.card-body {
    position: relative;
}

.table {
    --bs-table-bg: transparent;
    --bs-table-striped-bg: rgba(248, 250, 252, 0.8);
    color: var(--text-main);
}

.table thead th {
    border-bottom: 1px solid var(--border);
    background: #f8fafc;
    color: #475569;
    font-size: 0.82rem;
    font-weight: 800;
    letter-spacing: -0.01em;
    white-space: nowrap;
}

.table tbody td {
    border-color: #edf2f7;
    vertical-align: middle;
}

.form-control,
.form-select {
    min-height: 42px;
    border-color: var(--border);
    border-radius: 0.9rem;
    background-color: #f8fafc;
    font-weight: 600;
}

.form-control:focus,
.form-select:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 4px rgba(37, 99, 235, 0.13);
}

.form-label {
    color: #334155;
    font-weight: 800;
}

.btn {
    border-radius: 0.9rem;
    font-weight: 800;
    letter-spacing: -0.01em;
}

.btn-primary {
    border-color: transparent;
    background: linear-gradient(135deg, var(--primary), var(--accent));
    box-shadow: 0 12px 26px rgba(37, 99, 235, 0.22);
}

.btn-dark {
    border-color: transparent;
    background: linear-gradient(135deg, #0f172a, #1e293b);
    box-shadow: 0 12px 26px rgba(15, 23, 42, 0.18);
}

.btn-outline-primary,
.btn-outline-secondary,
.btn-outline-success,
.btn-outline-danger,
.btn-outline-dark {
    background: rgba(255, 255, 255, 0.72);
}

.badge {
    border-radius: 999px;
    padding: 0.42em 0.68em;
    font-weight: 800;
}

.stat-card {
    min-height: 118px;
}

.stat-value {
    font-size: 1.9rem;
    font-weight: 800;
    letter-spacing: -0.055em;
}

.control-toolbar {
    background: rgba(255, 255, 255, 0.9);
}

.control-display-card {
    height: 100%;
    transition: all 0.2s ease;
}

.control-display-card .card-body {
    padding: 0.8rem;
}

.control-display-card:hover {
    transform: translateY(-2px);
}

.control-display-card.online {
    box-shadow: inset 4px 0 0 var(--success), var(--shadow-soft);
}

.control-display-card.offline {
    box-shadow: inset 4px 0 0 var(--offline), var(--shadow-soft);
    background: rgba(252, 252, 253, 0.94);
}

.control-display-card.emergency-active {
    border: 2px solid var(--danger);
    box-shadow: 0 0 0 3px rgba(220, 38, 38, 0.12);
}

.display-preview-portrait {
    width: 100%;
    aspect-ratio: 9 / 16;
    max-height: 250px;
    background: #000;
    border-radius: 14px;
    overflow-y: auto;
    border: 1px solid var(--border);
}

.emergency-panel {
    border: 1px solid rgba(220, 38, 38, 0.18);
    border-radius: var(--radius-md);
    padding: 1rem;
    background: linear-gradient(135deg, rgba(254, 242, 242, 0.9), rgba(255, 255, 255, 0.92));
}

.display-preview-portrait img,
.display-preview-portrait video {
    width: 100%;
    height: 100%;
    object-fit: cover;
    object-position: center center;
}

.content-thumb-portrait {
    width: 78px;
    aspect-ratio: 9 / 16;
    border-radius: 10px;
    overflow: hidden;
    border: 1px solid var(--border);
    background: #000;
}

.content-thumb-portrait img,
.content-thumb-portrait video {
    width: 100%;
    height: 100%;
    object-fit: cover;
    object-position: center center;
}

.mobile-card-table {
    table-layout: auto;
}

.mobile-card-table th,
.mobile-card-table td {
    word-break: keep-all;
    overflow-wrap: anywhere;
}

.mini-label {
    font-size: 0.8rem;
    color: var(--text-muted);
    font-weight: 700;
}

.admin-create-modal .modal-dialog {
    max-width: min(1180px, calc(100vw - 2rem));
}

.admin-create-modal .modal-content {
    border: 1px solid rgba(219, 227, 239, 0.9);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-premium);
}

.admin-create-modal .modal-header {
    background: linear-gradient(135deg, #071329, #101d35);
    color: #fff;
}

.admin-create-modal-frame {
    display: block;
    width: 100%;
    height: min(78vh, 860px);
    border: 0;
    background: #f8fafc;
}

.admin-modal-body {
    min-height: 100vh;
    background:
        radial-gradient(circle at 16% 0%, rgba(37, 99, 235, 0.1), transparent 30%),
        #f8fafc;
}

.modal-page-content {
    padding: 1rem;
}

.modal-page-content .page-hero {
    margin-bottom: 1rem !important;
}

.login-shell {
    min-height: 100vh;
    width: 100%;
    max-width: 100vw;
    display: grid;
    grid-template-columns: minmax(0, 1.05fr) minmax(380px, 480px);
    gap: clamp(2rem, 6vw, 5rem);
    align-items: center;
    padding: clamp(1.25rem, 4vw, 4rem);
    background:
        radial-gradient(circle at 18% 20%, rgba(59, 130, 246, 0.22), transparent 34%),
        radial-gradient(circle at 84% 80%, rgba(20, 184, 166, 0.18), transparent 30%),
        linear-gradient(90deg, #071329 0%, #101d35 58%, #edf2fb 58.2%, #f8fafc 100%);
    font-family: "Pretendard", "Noto Sans KR", system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
    letter-spacing: 0;
    color: #f8fafc;
    overflow-x: hidden;
    overflow-y: auto;
}

.login-hero,
.login-panel {
    animation: loginPanelIn 0.55s ease both;
}

.login-hero {
    max-width: 620px;
    min-width: 0;
}

.login-brand {
    display: flex;
    gap: 1rem;
    align-items: center;
    margin-bottom: 2rem;
    min-width: 0;
}

.login-brand > div {
    min-width: 0;
}

.login-brand-mark {
    width: 64px;
    height: 64px;
    border-radius: 1.25rem;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, #3b82f6, #06b6d4);
    box-shadow: 0 18px 48px rgba(37, 99, 235, 0.35);
    font-weight: 800;
    letter-spacing: 0.04em;
}

.login-kicker,
.login-panel-eyebrow {
    margin: 0 0 0.35rem;
    color: #93c5fd;
    font-size: 0.82rem;
    font-weight: 700;
    letter-spacing: 0.08em;
    text-transform: uppercase;
}

.login-brand h1 {
    margin: 0;
    font-size: clamp(2rem, 4vw, 4rem);
    line-height: 1;
    letter-spacing: 0;
    overflow-wrap: anywhere;
}

.login-hero-copy {
    margin: 0 0 2rem;
    max-width: 540px;
    color: #dbeafe;
    font-size: clamp(1rem, 1.6vw, 1.25rem);
    line-height: 1.75;
    word-break: keep-all;
}

.login-status-grid {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 0.85rem;
}

.login-status-grid div {
    min-height: 112px;
    padding: 1rem;
    border: 1px solid rgba(255, 255, 255, 0.15);
    border-radius: 1.25rem;
    background: rgba(255, 255, 255, 0.08);
    backdrop-filter: blur(14px);
    color: #ffffff;
    font-weight: 700;
    line-height: 1.45;
    word-break: keep-all;
}

.login-status-grid span {
    display: block;
    margin-bottom: 0.75rem;
    color: #67e8f9;
    font-size: 0.78rem;
    letter-spacing: 0.08em;
}

.login-panel {
    width: min(100%, 480px);
    min-width: 0;
    max-width: 100%;
    padding: clamp(1.5rem, 4vw, 2.5rem);
    border: 1px solid rgba(148, 163, 184, 0.22);
    border-radius: 1.75rem;
    background: rgba(255, 255, 255, 0.92);
    box-shadow: 0 28px 80px rgba(15, 23, 42, 0.24);
    color: #0f172a;
    backdrop-filter: blur(18px);
}

.login-panel-header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 1rem;
    margin-bottom: 1.75rem;
}

.login-panel-header h2 {
    margin: 0;
    font-size: clamp(1.75rem, 3vw, 2.35rem);
    font-weight: 800;
    letter-spacing: 0;
    word-break: keep-all;
}

.login-panel-eyebrow {
    color: #2563eb;
}

.login-secure-badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 64px;
    height: 34px;
    padding: 0 0.75rem;
    border-radius: 999px;
    background: #eff6ff;
    color: #1d4ed8;
    font-size: 0.78rem;
    font-weight: 800;
    letter-spacing: 0.06em;
}

.login-form {
    display: grid;
    gap: 1rem;
}

.login-field {
    display: grid;
    gap: 0.45rem;
}

.login-field label {
    color: #334155;
    font-size: 0.92rem;
    font-weight: 800;
}

.login-field input {
    width: 100%;
    min-height: 52px;
    padding: 0 1rem;
    border: 1px solid #d7deea;
    border-radius: 0.95rem;
    background: #f8fafc;
    color: #0f172a;
    font-size: 1rem;
    font-weight: 600;
    transition: border-color 0.18s ease, box-shadow 0.18s ease, background 0.18s ease;
}

.login-field input:focus {
    border-color: #2563eb;
    background: #ffffff;
    box-shadow: 0 0 0 4px rgba(37, 99, 235, 0.14);
    outline: none;
}

.login-submit {
    width: 100%;
    min-height: 54px;
    margin-top: 0.35rem;
    border: 0;
    border-radius: 1rem;
    background: linear-gradient(135deg, #2563eb, #0891b2);
    color: #ffffff;
    font-size: 1.05rem;
    font-weight: 800;
    letter-spacing: 0;
    box-shadow: 0 16px 34px rgba(37, 99, 235, 0.28);
    cursor: pointer;
    transition: transform 0.18s ease, box-shadow 0.18s ease, filter 0.18s ease;
}

.login-submit:hover,
.login-submit:focus-visible {
    transform: translateY(-1px);
    box-shadow: 0 20px 42px rgba(37, 99, 235, 0.35);
    filter: brightness(1.03);
}

.login-help {
    margin: 1.25rem 0 0;
    color: #64748b;
    font-size: 0.92rem;
    line-height: 1.6;
    text-align: center;
}

@keyframes loginPanelIn {
    from {
        opacity: 0;
        transform: translateY(18px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        scroll-behavior: auto !important;
    }

    .menu-link,
    .control-display-card,
    .login-hero,
    .login-panel {
        animation: none;
        transition: none;
    }

    .login-submit,
    .login-field input {
        transition: none;
    }

    .login-submit:hover,
    .login-submit:focus-visible {
        transform: none;
    }
}

@media (max-width: 900px) {
    .login-shell {
        grid-template-columns: 1fr;
        justify-items: center;
        background:
            radial-gradient(circle at 50% 0%, rgba(59, 130, 246, 0.18), transparent 34%),
            linear-gradient(180deg, #071329 0%, #101d35 30%, #f8fafc 30.2%, #f8fafc 100%);
        overflow-x: hidden;
        overflow-y: auto;
    }

    .login-hero {
        width: min(100%, 520px);
        text-align: center;
    }

    .login-brand {
        justify-content: center;
        margin-bottom: 1.25rem;
    }

    .login-hero-copy {
        margin: 0 auto 1.25rem;
    }

    .login-status-grid {
        display: none;
    }

    .login-panel {
        width: min(100%, 520px);
    }
}

@media (max-width: 576px) {
    .login-shell {
        padding: 1rem;
        align-content: start;
        gap: 1rem;
    }

    .login-brand {
        align-items: flex-start;
        text-align: left;
        width: 100%;
        gap: 0.85rem;
    }

    .login-brand-mark {
        width: 52px;
        height: 52px;
        border-radius: 1rem;
        flex: 0 0 auto;
    }

    .login-hero {
        width: min(340px, calc(100vw - 2rem));
        max-width: min(340px, calc(100vw - 2rem));
        justify-self: start;
        text-align: left;
    }

    .login-brand h1 {
        font-size: clamp(1.55rem, 8vw, 2rem);
        line-height: 1.08;
        max-width: 11ch;
    }

    .login-kicker {
        font-size: 0.72rem;
    }

    .login-hero-copy {
        display: none;
    }

    .login-panel {
        width: min(340px, calc(100vw - 2rem));
        max-width: min(340px, calc(100vw - 2rem));
        justify-self: start;
        padding: 1.35rem;
        border-radius: 1.25rem;
    }

    .login-panel-header {
        align-items: center;
        gap: 0.75rem;
    }

    .login-secure-badge {
        display: none;
    }
}

@media (max-width: 1400px) {
    .display-preview-portrait {
        max-height: 240px;
    }
}

@media (max-width: 992px) {
    .display-preview-portrait {
        max-height: 280px;
    }
}

@media (max-width: 576px) {
    .topbar {
        margin: 0.75rem 0.75rem 0;
        padding: 0.85rem 1rem;
        border-radius: 18px;
    }

    .topbar-title {
        font-size: 1.05rem;
    }

    .profile-box .text-end {
        display: none;
    }

    .page-content {
        padding: 1rem 0.75rem 1.25rem;
    }

    .page-hero {
        align-items: stretch;
        flex-direction: column;
        padding: 1.1rem;
    }

    .page-hero .btn {
        width: 100%;
    }

    .page-hero h1 {
        font-size: 1.55rem;
    }

    .table-responsive {
        overflow-x: hidden;
    }

    .mobile-card-table {
        border-collapse: separate;
        border-spacing: 0 0.85rem;
    }

    .mobile-card-table thead {
        position: absolute;
        width: 1px;
        height: 1px;
        overflow: hidden;
        clip: rect(0, 0, 0, 0);
        clip-path: inset(50%);
        white-space: nowrap;
    }

    .mobile-card-table tbody,
    .mobile-card-table tr,
    .mobile-card-table td {
        display: block;
        width: 100%;
    }

    .mobile-card-table tr {
        background: #fff;
        border: 1px solid var(--border);
        border-radius: 14px;
        box-shadow: 0 8px 22px rgba(15, 23, 42, 0.06);
        overflow: hidden;
        padding: 0.35rem 0;
    }

    .mobile-card-table td {
        border: 0;
        padding: 0.65rem 0.9rem;
        min-height: 38px;
    }

    .mobile-card-table td:not([colspan]) {
        display: grid;
        grid-template-columns: minmax(82px, 34%) minmax(0, 1fr);
        align-items: start;
        gap: 0.8rem;
    }

    .mobile-card-table td::before {
        content: attr(data-label);
        color: var(--text-muted);
        font-size: 0.78rem;
        font-weight: 700;
        letter-spacing: -0.01em;
        white-space: normal;
    }

    .mobile-card-table td[colspan] {
        text-align: center;
    }

    .mobile-card-table td[colspan]::before {
        content: none;
    }

    .mobile-card-table .mobile-actions {
        display: flex;
        flex-wrap: wrap;
        gap: 0.4rem;
    }

    .content-thumb-portrait {
        width: 76px;
    }

    .admin-create-modal .modal-dialog {
        max-width: calc(100vw - 0.75rem);
        margin: 0.375rem auto;
    }

    .admin-create-modal-frame {
        height: 82vh;
    }
}
