/* ═══════════════════════════════════════════════
   DOM / COMMAND CENTER — katalog 0
═══════════════════════════════════════════════ */
:root {
    --topbar-h:           60px;
    --sidebar-w:          220px;
    --sidebar-icon-w:     60px;
    --bg:                 #05060a;
    --bg-elevated:        #0d1018;
    --bg-hover:           rgba(255, 255, 255, 0.04);
    --border:             rgba(255, 255, 255, 0.08);
    --accent:             #BFFF00;
    --accent-dim:         rgba(191, 255, 0, 0.12);
    --violet:             #8d42ff;
    --violet2:            #c982ff;
    --green:              #17f454;
    --amber:              #ffd21f;
    --red:                #ff2d46;
    --text:               #f5f5f7;
    --text-muted:         #9aa0ad;
    --transition:         0.25s cubic-bezier(0.4, 0, 0.2, 1);
}

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

html,
body {
    margin: 0;
    min-height: 100%;
    background: #05060a;
}

body {
    color: var(--text);
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', system-ui, sans-serif;
    font-size: 14px;
    overflow-x: hidden;
    -webkit-font-smoothing: antialiased;
    background:
        radial-gradient(circle at 78% -18%, rgba(141, 66, 255, 0.28), transparent 36%),
        radial-gradient(circle at 5% 115%, rgba(191, 255, 0, 0.12), transparent 34%),
        var(--bg);
}

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

button { color: inherit; }

.overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.55);
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.3s ease;
    z-index: 1400;
}
.overlay.show {
    opacity: 1;
    pointer-events: auto;
}

.top-bar {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: var(--topbar-h);
    background: rgba(8, 10, 16, 0.90);
    border-bottom: 1px solid rgba(255, 255, 255, 0.08);
    box-shadow: 0 14px 38px rgba(0, 0, 0, 0.42);
    backdrop-filter: blur(18px);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 8px 0 4px;
    z-index: 2000;
    gap: 8px;
}

.top-bar-left,
.top-bar-right {
    display: flex;
    align-items: center;
    gap: 10px;
    min-width: 0;
}

.top-title {
    min-width: 0;
    max-width: 36vw;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    font-weight: 800;
    letter-spacing: .02em;
}

.menu-btn,
.sidebar-toggle-btn,
.settings-btn {
    width: 42px;
    height: 42px;
    border: 1px solid rgba(255,255,255,.08);
    background: rgba(255,255,255,.035);
    border-radius: 13px;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    transition: background var(--transition), border-color var(--transition), transform var(--transition);
}

.menu-btn,
.sidebar-toggle-btn {
    flex-direction: column;
    gap: 4px;
}

.menu-btn span,
.sidebar-toggle-btn span {
    width: 18px;
    height: 2px;
    background: var(--text);
    border-radius: 999px;
}

.menu-btn:hover,
.sidebar-toggle-btn:hover,
.settings-btn:hover {
    background: rgba(191,255,0,.08);
    border-color: rgba(191,255,0,.26);
}

.menu-btn { display: none; }

.settings-btn {
    color: var(--text);
    display: none;
}

body.is-msplanner .settings-btn { display: inline-flex; }

.app-avatar {
    width: 42px;
    height: 42px;
    border-radius: 50%;
    padding: 0;
    overflow: hidden;
    cursor: pointer;
    background: #0b0e15;
    border: 1px solid rgba(191, 255, 0, 0.35);
    box-shadow: 0 0 22px rgba(191, 255, 0, 0.16);
}

.app-avatar img {
    width: 100%;
    height: 100%;
    display: block;
    object-fit: cover;
}

.sidebar-title {
    font-size: 10px;
    text-transform: uppercase;
    font-weight: 900;
    text-align: right;
    line-height: 1.05;
    color: rgba(245,245,247,.82);
}

.save-status {
    color: var(--text-muted);
    font-size: 12px;
}

#app {
    min-height: 100vh;
}

.sidebar {
    position: fixed;
    top: var(--topbar-h);
    left: 0;
    width: var(--sidebar-w);
    height: calc(100vh - var(--topbar-h));
    background: linear-gradient(180deg, rgba(13, 16, 24, 0.98), rgba(7, 8, 13, 0.94));
    border-right: 1px solid rgba(255, 255, 255, 0.08);
    z-index: 1500;
    overflow-y: auto;
    transition: width var(--transition), transform var(--transition);
    padding: 8px 0;
}

.sidebar-nav {
    display: grid;
    gap: 4px;
}

.nav-item {
    display: flex;
    align-items: center;
    width: calc(100% - 16px);
    margin: 3px 8px;
    min-height: 46px;
    padding: 10px 14px;
    gap: 12px;
    border: 0;
    border-radius: 12px;
    background: transparent;
    color: rgba(245,245,247,.82);
    cursor: pointer;
    text-align: left;
    transition: background var(--transition), color var(--transition), transform var(--transition);
}

.nav-item.active,
.nav-item:hover {
    background: linear-gradient(135deg, rgba(191, 255, 0, 0.14), rgba(141, 66, 255, 0.12));
    color: #fff;
}

.nav-icon {
    display: inline-grid;
    place-items: center;
    width: 22px;
    height: 22px;
    color: var(--accent);
    flex: 0 0 auto;
}

.nav-label {
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    font-weight: 720;
}

body.sidebar-collapsed .sidebar {
    width: var(--sidebar-icon-w);
}

body.sidebar-collapsed .nav-item {
    justify-content: center;
    padding: 10px;
}

body.sidebar-collapsed .nav-label {
    display: none;
}

.main-area {
    margin-left: var(--sidebar-w);
    padding-top: var(--topbar-h);
    min-height: 100vh;
    background:
        radial-gradient(circle at 85% 0%, rgba(141, 66, 255, 0.22), transparent 36%),
        linear-gradient(180deg, #07080d 0%, #05060a 100%);
    transition: margin-left var(--transition);
}

body.sidebar-collapsed .main-area {
    margin-left: var(--sidebar-icon-w);
}

.view {
    display: none;
    min-height: calc(100vh - var(--topbar-h));
    padding: 20px;
}
.view.active { display: block; }

.command-home {
    max-width: 1600px;
    margin: 0 auto;
    display: grid;
    gap: 18px;
}

.command-hero,
.command-panel,
.metric-card {
    border: 1px solid rgba(255, 255, 255, 0.08);
    background: linear-gradient(145deg, rgba(21, 24, 35, 0.96), rgba(8, 10, 16, 0.94));
    border-radius: 22px;
    box-shadow: 0 24px 70px rgba(0, 0, 0, 0.42);
}

.command-hero {
    min-height: 190px;
    padding: 24px;
    display: flex;
    justify-content: space-between;
    gap: 24px;
    align-items: center;
    overflow: hidden;
    position: relative;
}

.command-hero::after {
    content: "";
    position: absolute;
    inset: auto -12% -70% 34%;
    height: 170px;
    background: radial-gradient(circle, rgba(141, 66, 255, 0.42), transparent 68%);
    pointer-events: none;
}

.logo-lockup {
    display: flex;
    align-items: center;
    gap: 18px;
    min-width: 0;
    position: relative;
    z-index: 1;
}

.logo-orb {
    width: 122px;
    height: 86px;
    border-radius: 26px;
    display: grid;
    place-items: center;
    background: #0a0d15;
    border: 1px solid rgba(191, 255, 0, 0.22);
    box-shadow: 0 0 34px rgba(141, 66, 255, 0.26);
    overflow: hidden;
    flex: 0 0 auto;
}

.logo-orb img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.eyebrow,
.panel-kicker {
    display: inline-flex;
    color: #BFFF00;
    font-size: 11px;
    font-weight: 900;
    letter-spacing: .14em;
    text-transform: uppercase;
}

.hero-copy h1 {
    margin: 7px 0 8px;
    font-size: clamp(30px, 4vw, 58px);
    line-height: .95;
    letter-spacing: -0.055em;
}

.hero-copy p {
    margin: 0;
    max-width: 640px;
    color: rgba(245, 245, 251, 0.70);
    font-size: 15px;
}

.hero-side {
    position: relative;
    z-index: 1;
    display: grid;
    gap: 12px;
    justify-items: end;
}

.hero-clock {
    text-align: right;
    padding: 12px 16px;
    border-radius: 18px;
    background: rgba(255, 255, 255, 0.045);
    border: 1px solid rgba(255,255,255,.08);
}

.hero-clock b {
    display: block;
    font-size: 30px;
    letter-spacing: -0.04em;
}

.hero-clock span {
    color: rgba(245,245,251,.62);
    font-size: 12px;
}

.hero-badges {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
    justify-content: flex-end;
}

.status-dot {
    display: inline-flex;
    align-items: center;
    gap: 7px;
    padding: 7px 10px;
    border-radius: 999px;
    background: rgba(255, 255, 255, 0.045);
    border: 1px solid rgba(255,255,255,.08);
    color: rgba(245,245,251,.78);
    font-size: 12px;
    font-weight: 800;
}

.status-dot::before {
    content: "";
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: #17f454;
    box-shadow: 0 0 12px rgba(23,244,84,.55);
}

.status-dot.warn::before {
    background: #ffd21f;
    box-shadow: 0 0 12px rgba(255,210,31,.5);
}

.command-metrics {
    display: grid;
    grid-template-columns: repeat(4, minmax(150px, 1fr));
    gap: 14px;
}

.metric-card {
    position: relative;
    min-height: 132px;
    padding: 18px;
    overflow: hidden;
}

.metric-card span {
    color: rgba(245,245,251,.68);
    text-transform: uppercase;
    font-size: 12px;
    font-weight: 900;
    letter-spacing: .08em;
}

.metric-card b {
    display: block;
    margin-top: 12px;
    font-size: 30px;
    letter-spacing: -0.04em;
}

.metric-card small {
    display: block;
    margin-top: 5px;
    color: rgba(245,245,251,.52);
}

.metric-card.online b {
    color: #17f454;
    font-size: 24px;
}

.wave {
    position: absolute;
    left: 12px;
    right: 12px;
    bottom: 8px;
    height: 36px;
    opacity: .45;
    background: linear-gradient(135deg, transparent 45%, rgba(141,66,255,.62));
    clip-path: polygon(0 70%,8% 60%,14% 75%,22% 35%,29% 78%,36% 45%,43% 88%,53% 22%,61% 80%,70% 52%,80% 85%,90% 30%,100% 76%,100% 100%,0 100%);
}

.command-grid {
    display: grid;
    grid-template-columns: 1.15fr 1fr;
    gap: 16px;
}

.command-panel {
    min-height: 220px;
    padding: 18px;
}

.command-panel.wide {
    grid-row: span 2;
}

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

.panel-head h2 {
    margin: 4px 0 0;
    font-size: 17px;
    text-transform: uppercase;
    letter-spacing: .02em;
}

.panel-action,
.quick-action {
    border: 1px solid rgba(191,255,0,.22);
    background: rgba(255, 255, 255, .035);
    color: rgba(245,245,251,.86);
    border-radius: 12px;
    padding: 9px 12px;
    cursor: pointer;
    transition: transform .18s ease, background .18s ease, border-color .18s ease;
}

.primary-action {
    background: rgba(191,255,0,.12);
    border-color: rgba(191,255,0,.38);
}

.large-action {
    width: 100%;
    min-height: 54px;
    font-weight: 900;
}

.panel-action:hover,
.quick-action:hover {
    transform: translateY(-1px);
    background: rgba(191,255,0,.08);
    border-color: rgba(191,255,0,.42);
}

.home-list {
    list-style: none;
    padding: 0;
    margin: 0;
    display: grid;
    gap: 10px;
}

.home-item,
.home-empty {
    display: grid;
    grid-template-columns: 1fr auto;
    gap: 12px;
    align-items: center;
    min-height: 54px;
    padding: 12px 14px;
    border-radius: 15px;
    background: rgba(255,255,255,.035);
    border: 1px solid rgba(255,255,255,.065);
}

.home-empty {
    display: block;
    color: rgba(245,245,251,.55);
}

.home-item-title {
    font-weight: 760;
    line-height: 1.25;
}

.home-item-sub {
    margin-top: 3px;
    font-size: 12px;
    color: rgba(245,245,251,.54);
}

.home-item-tag {
    border-radius: 999px;
    padding: 5px 8px;
    background: rgba(141,66,255,.18);
    border: 1px solid rgba(141,66,255,.25);
    color: #d9bdff;
    font-size: 11px;
    font-weight: 900;
    white-space: nowrap;
    text-transform: uppercase;
}

.home-item-tag.warn {
    background: rgba(255,210,31,.14);
    border-color: rgba(255,210,31,.24);
    color: #ffe25b;
}

.home-item-tag.err {
    background: rgba(255,45,70,.14);
    border-color: rgba(255,45,70,.24);
    color: #ff8f9d;
}

.quick-actions {
    display: grid;
    gap: 10px;
}

.quick-action {
    width: 100%;
    text-align: left;
    font-weight: 750;
}

.module-wrap {
    max-width: 1400px;
    margin: 0 auto;
}

.module-main-panel {
    max-width: 980px;
    margin: 0 auto;
}

.note-compose {
    display: grid;
    gap: 10px;
    margin-bottom: 14px;
}

textarea,
input,
select {
    width: 100%;
    border-radius: 13px;
    border: 1px solid rgba(255,255,255,.09);
    background: rgba(0,0,0,.22);
    color: var(--text);
    padding: 11px 12px;
    outline: none;
}

textarea:focus,
input:focus,
select:focus {
    border-color: rgba(191,255,0,.38);
    box-shadow: 0 0 0 3px rgba(191,255,0,.08);
}

.search-input {
    margin: 8px 0 14px;
}

.notes-list {
    display: grid;
    gap: 10px;
}

.note-card {
    border: 1px solid rgba(255,255,255,.07);
    background: rgba(255,255,255,.035);
    border-radius: 16px;
    padding: 14px;
}

.note-card p {
    margin: 0 0 9px;
    white-space: pre-wrap;
}

.note-meta {
    display: flex;
    justify-content: space-between;
    gap: 12px;
    color: rgba(245,245,251,.55);
    font-size: 12px;
}

.note-delete,
.event-delete {
    border: 0;
    background: transparent;
    color: #ff8f9d;
    cursor: pointer;
    font-weight: 800;
}

.form-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px;
}

.form-grid label {
    display: grid;
    gap: 7px;
    color: rgba(245,245,251,.72);
    font-weight: 750;
}

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

.calendar-layout,
.camera-layout {
    display: grid;
    grid-template-columns: minmax(0, .9fr) minmax(0, 1.1fr);
    gap: 16px;
}

.iframe-panel {
    height: calc(100vh - var(--topbar-h) - 40px);
    border-radius: 22px;
    overflow: hidden;
    border: 1px solid rgba(255,255,255,.08);
    background: #0b0e15;
    box-shadow: 0 24px 70px rgba(0, 0, 0, 0.42);
}

.module-frame,
#msPlannerIframe {
    width: 100%;
    height: 100%;
    border: 0;
    background: #0b0e15;
}

.mspl-wrap {
    position: fixed;
    top: var(--topbar-h);
    left: var(--sidebar-w);
    right: 0;
    bottom: 0;
}

body.sidebar-collapsed .mspl-wrap {
    left: var(--sidebar-icon-w);
}

.muted-text {
    color: rgba(245,245,251,.62);
}

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

.camera-placeholder {
    min-height: 180px;
    border-radius: 16px;
    display: grid;
    place-items: center;
    color: rgba(245,245,251,.55);
    background:
        radial-gradient(circle at 50% 50%, rgba(141,66,255,.18), transparent 46%),
        rgba(255,255,255,.035);
    border: 1px dashed rgba(255,255,255,.16);
}

.settings-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,.45);
    z-index: 2100;
    display: none;
}
.settings-overlay.show { display: block; }

.settings-drawer {
    position: fixed;
    top: var(--topbar-h);
    right: 0;
    bottom: 0;
    width: min(340px, 86vw);
    background: #0b0f17;
    border-left: 1px solid rgba(255,255,255,.08);
    box-shadow: -20px 0 40px rgba(0,0,0,.45);
    transform: translateX(105%);
    transition: transform .18s ease;
    z-index: 2200;
}
.settings-drawer.open { transform: translateX(0); }

.settings-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 18px;
    border-bottom: 1px solid rgba(255,255,255,.08);
}
.settings-header h3 { margin: 0; }

.close-settings {
    border: 0;
    background: transparent;
    color: var(--text);
    font-size: 28px;
    cursor: pointer;
}

.settings-content {
    padding: 18px;
    color: var(--text-muted);
}

@media (max-width: 1050px) {
    .command-metrics { grid-template-columns: repeat(2, minmax(150px, 1fr)); }
    .command-grid { grid-template-columns: 1fr; }
    .command-panel.wide { grid-row: auto; }
    .calendar-layout,
    .camera-layout { grid-template-columns: 1fr; }
}

@media (max-width: 900px) {
    .menu-btn { display: inline-flex; }
    .sidebar-toggle-btn { display: none; }
    .sidebar {
        transform: translateX(-105%);
        width: min(76vw, 320px);
        top: 0;
        height: 100dvh;
        padding-top: 12px;
        background: rgba(13, 16, 24, .90);
        backdrop-filter: blur(16px);
    }
    .sidebar.open { transform: translateX(0); }
    .main-area,
    body.sidebar-collapsed .main-area {
        margin-left: 0;
    }
    .mspl-wrap,
    body.sidebar-collapsed .mspl-wrap {
        left: 0;
    }
}

@media (max-width: 760px) {
    .top-bar {
        height: auto;
        min-height: var(--topbar-h);
        flex-wrap: wrap;
        padding: 8px;
    }
    .top-bar-right {
        margin-left: auto;
    }
    .sidebar-title-wrap { display: none; }
    .view { padding: 14px; }
    .command-hero {
        align-items: stretch;
        flex-direction: column;
        min-height: 0;
        padding: 18px;
    }
    .logo-lockup { align-items: flex-start; }
    .logo-orb {
        width: 96px;
        height: 70px;
        border-radius: 20px;
    }
    .hero-side { justify-items: start; }
    .hero-clock { text-align: left; width: 100%; }
    .command-metrics { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .metric-card { min-height: 120px; padding: 15px; }
    .metric-card b { font-size: 24px; }
    .home-item { grid-template-columns: 1fr; }
    .form-grid { grid-template-columns: 1fr; }
    .iframe-panel { height: calc(100dvh - var(--topbar-h) - 28px); }
    .camera-placeholder-grid { grid-template-columns: 1fr; }
}

@media (max-width: 420px) {
    .command-metrics { grid-template-columns: 1fr; }
    .hero-copy h1 { font-size: 30px; }
}
