/* =====================================================================
   Page layout: the app fills the window exactly. The main canvas never
   scrolls; panels inside it scroll on their own (.panel-body).
   ===================================================================== */

*, *::before, *::after { box-sizing: border-box; }

html, body {
    height: 100%;
    margin: 0;
}

body {
    font-family: var(--font);
    font-size: var(--font-size);
    color: var(--text-primary);
    background: var(--page-bg);
    background-attachment: fixed;
    overflow: hidden;              /* no scrolling on the main canvas */
    -webkit-font-smoothing: antialiased;
}

[hidden] { display: none !important; }

a { color: var(--link); text-decoration: none; }
h1, h2, h3, h4 { margin: 0; font-weight: 650; letter-spacing: -0.01em; }

/* ---------------------------------------------------------------- app frame */
.app {
    height: 100vh;
    display: grid;
    grid-template-rows: var(--topbar-height) minmax(0, 1fr) var(--footer-height);
    /* one column exactly as wide as the window: the menu's full width (every label) never widens the page; the menu
       scrolls (and compacts, see responsive.css) instead */
    grid-template-columns: minmax(0, 1fr);
}
.app > * { min-width: 0; }

/* ---------------------------------------------------------------- top bar */
.topbar {
    position: relative;
    display: flex;
    align-items: center;
    gap: 14px;
    padding: 0 14px;
    background: var(--grad-ocean);
    color: var(--text-inverse);
    box-shadow: 0 4px 18px rgba(6, 32, 56, 0.28);
    z-index: 20;
}
.topbar::before {                  /* glossy highlight on the upper half */
    content: "";
    position: absolute;
    inset: 0 0 50% 0;
    background: linear-gradient(180deg, rgba(255, 255, 255, 0.22), rgba(255, 255, 255, 0.04));
    pointer-events: none;
}
.topbar::after {                   /* thin ice line at the bottom */
    content: "";
    position: absolute;
    left: 0; right: 0; bottom: 0;
    height: 2px;
    background: linear-gradient(90deg, transparent, #7dd0f5 20%, #c9ecfb 50%, #7dd0f5 80%, transparent);
    opacity: 0.8;
}

.brand {
    display: flex;
    align-items: center;
    gap: 10px;
    color: var(--text-inverse);
    flex-shrink: 0;
    z-index: 1;
}
.brand-logo {
    width: 32px; height: 32px;
    filter: drop-shadow(0 3px 6px rgba(0, 0, 0, 0.3));
}
.brand-text { display: flex; flex-direction: column; line-height: 1.15; }
.brand-text strong { font-size: 14px; letter-spacing: 0.02em; font-weight: 750; }
.brand-text strong em { font-style: normal; color: #7de3d6; }
.brand-text small { font-size: var(--font-size-xs); color: var(--glacier-200); opacity: 0.9; }

.menu {
    display: flex;
    align-items: center;
    gap: 2px;
    flex: 1;
    min-width: 0;
    overflow-x: auto;
    scrollbar-width: none;
    z-index: 1;
}
.menu::-webkit-scrollbar { display: none; }
.menu a {
    display: flex;
    align-items: center;
    gap: 6px;
    height: 30px;
    padding: 0 10px;
    border-radius: 999px;
    color: #e3f5fd;
    font-size: 12.5px;
    font-weight: 550;
    white-space: nowrap;
    transition: background 0.15s, color 0.15s;
}
.menu a svg { width: 15px; height: 15px; opacity: 0.9; }
.menu a:hover { background: rgba(255, 255, 255, 0.12); color: #fff; }
.menu a.active {
    background: linear-gradient(180deg, rgba(255, 255, 255, 0.95), rgba(227, 245, 253, 0.92));
    color: var(--ocean-700);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.18), inset 0 -1px 0 rgba(10, 79, 128, 0.15);
}
.menu a.active svg { opacity: 1; }

.topbar-actions { display: flex; align-items: center; gap: 10px; z-index: 1; }

/* ---------------------------------------------------------------- user menu */
.user-menu { position: relative; }
.avatar-btn {
    display: flex; align-items: center; gap: 8px;
    background: rgba(255, 255, 255, 0.1);
    border: 1px solid rgba(255, 255, 255, 0.18);
    color: #fff;
    border-radius: 999px;
    padding: 3px 10px 3px 3px;
    cursor: pointer;
    font: inherit;
}
.avatar-btn:hover { background: rgba(255, 255, 255, 0.18); }
.avatar-btn svg { width: 14px; height: 14px; }
.avatar {
    width: 28px; height: 28px;
    border-radius: 50%;
    display: grid; place-items: center;
    background: var(--grad-aqua);
    font-weight: 700; font-size: 12px;
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.5);
}
.user-text { display: flex; flex-direction: column; text-align: left; line-height: 1.1; }
.user-text small { font-size: 10.5px; color: var(--glacier-200); }

.dropdown {
    position: absolute;
    right: 0; top: calc(100% + 8px);
    min-width: 200px;
    padding: 6px;
    border-radius: var(--radius);
    color: var(--text-primary);
    box-shadow: var(--shadow-lg);
}
.dropdown a, .dropdown button {
    display: flex; align-items: center; gap: 8px;
    width: 100%;
    padding: 8px 10px;
    border: 0; background: none;
    border-radius: var(--radius-sm);
    color: var(--text-primary);
    font: inherit; text-align: left; cursor: pointer;
}
.dropdown a:hover, .dropdown button:hover { background: var(--surface-hover); }
.dropdown svg { width: 16px; height: 16px; color: var(--ocean-600); }
.dropdown hr { border: 0; border-top: 1px solid var(--hairline); margin: 4px 0; }

/* ---------------------------------------------------------------- footer (live status bar) */
.footer {
    position: relative;
    display: flex;
    align-items: center;
    gap: 14px;
    padding: 0 12px;
    background: var(--grad-ocean);
    color: #cfe3f3;
    font-size: var(--font-size-xs);
    white-space: nowrap;
    overflow: hidden;
    z-index: 15;
}
.footer::before {                  /* thin ice line on top, mirrors the top bar */
    content: "";
    position: absolute;
    left: 0; right: 0; top: 0;
    height: 1px;
    background: linear-gradient(90deg, transparent, rgba(125, 208, 245, 0.7) 25%, rgba(201, 236, 251, 0.9) 50%, rgba(125, 208, 245, 0.7) 75%, transparent);
}
.footer svg { width: 12px; height: 12px; flex-shrink: 0; }
.foot-brand { display: flex; align-items: center; gap: 6px; color: #fff; font-weight: 650; letter-spacing: 0.02em; }
.foot-brand img { width: 15px; height: 15px; }
.foot-brand em { font-style: normal; color: #7de3d6; }
.foot-brand .ver {
    padding: 0 5px; border-radius: 999px;
    border: 1px solid rgba(201, 154, 59, 0.6);
    color: #f0d49a; font-size: 9.5px; font-weight: 600;
}
.foot-sep { width: 1px; height: 14px; background: rgba(255, 255, 255, 0.16); flex-shrink: 0; }
.foot-pulse { display: flex; align-items: center; gap: 4px; flex: 1; min-width: 0; overflow: hidden; }
.foot-item {
    display: inline-flex; align-items: center; gap: 5px;
    height: 20px; padding: 0 8px;
    border-radius: 999px;
    color: #cfe3f3;
    background: transparent; border: 0; font: inherit; cursor: pointer;
    transition: background 0.15s;
}
.foot-item:hover { background: rgba(255, 255, 255, 0.1); color: #fff; }
.foot-item b { color: #fff; font-weight: 650; font-variant-numeric: tabular-nums; }
.foot-item .warn { color: #ffcf7a; }
.foot-item .good { color: #7de3b0; }
.foot-meter { width: 38px; height: 4px; border-radius: 3px; background: rgba(255, 255, 255, 0.15); overflow: hidden; }
.foot-meter i { display: block; height: 100%; border-radius: 3px; background: linear-gradient(90deg, #2fd0bf, #7dd0f5); }
.foot-meter i.over { background: linear-gradient(90deg, #f3a35c, #ef6a6a); }
.foot-status { display: flex; align-items: center; gap: 10px; color: #9fbdd6; }
.foot-dot { width: 7px; height: 7px; border-radius: 50%; background: #34d399; box-shadow: 0 0 0 3px rgba(52, 211, 153, 0.18); }
.foot-dot.busy { background: #fbbf24; box-shadow: 0 0 0 3px rgba(251, 191, 36, 0.2); }
.foot-dot.down { background: #f87171; box-shadow: 0 0 0 3px rgba(248, 113, 113, 0.2); }
.foot-keys .kbd { background: rgba(255, 255, 255, 0.1); border-color: rgba(255, 255, 255, 0.2); color: #fff; }

/* ---------------------------------------------------------------- main view */
.view {
    min-height: 0;
    padding: var(--gap);
    overflow: hidden;              /* children scroll, never the canvas */
}
.page {
    height: 100%;
    min-height: 0;
    display: grid;
    gap: var(--gap);
}

/* Generic layout helpers used by views */
.row { display: flex; align-items: center; gap: var(--gap-sm); }
.row.wrap { flex-wrap: wrap; }
.spacer { flex: 1; }
.stack { display: flex; flex-direction: column; gap: var(--gap-sm); }
.min-0 { min-height: 0; min-width: 0; }

/* ---------------------------------------------------------------- small screens
   On phones the fixed-canvas layout cannot fit, so the view itself scrolls. */
/* laptops: the full menu needs ~1540px; make room step by step so every item stays in view */
@media (max-width: 1600px) {
    .brand-text, .user-text { display: none; }
    .topbar { gap: 10px; }
    .menu a { padding: 0 8px; gap: 5px; font-size: 12px; }
}
@media (max-width: 1440px) {
    .menu a:not(.active) span { display: none; }   /* icons (named in their tooltips); the open page keeps its name */
}
@media (max-width: 1280px) {
    .brand-text, .user-text { display: none; }
    .foot-keys, .foot-hide-md { display: none !important; }
    .menu a span { display: none; }
    .menu a { padding: 0 10px; }
}
@media (max-width: 900px) {
    .view { overflow-y: auto; }
    .page { height: auto; grid-template-columns: 1fr !important; grid-template-rows: none !important; }
    .page > * { min-height: 320px; }
}
