:root {
    --bg0: #0b1020;
    --bg1: #151d35;
    --glass: rgba(255, 255, 255, 0.12);
    --glass-strong: rgba(255, 255, 255, 0.18);
    --border: rgba(255, 255, 255, 0.22);
    --text: #eef4ff;
    --muted: rgba(238, 244, 255, 0.66);
    --accent: #7aa2ff;
    --accent2: #b985ff;
    --danger: #ff6b82;
    --warning: #ffd166;
    --ok: #7ef0b8;
    --shadow: 0 24px 80px rgba(0, 0, 0, 0.42);
    --radius: 24px;
    --font: ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* { box-sizing: border-box; }
html, body { min-height: 100%; }
body {
    margin: 0;
    color: var(--text);
    font-family: var(--font);
    background:
        radial-gradient(circle at 15% 15%, rgba(122, 162, 255, 0.28), transparent 32rem),
        radial-gradient(circle at 85% 12%, rgba(185, 133, 255, 0.24), transparent 28rem),
        linear-gradient(135deg, var(--bg0), var(--bg1));
    overflow-x: hidden;
}

.background-glow {
    position: fixed;
    inset: 0;
    pointer-events: none;
    background: linear-gradient(120deg, rgba(255,255,255,0.05), transparent 50%, rgba(255,255,255,0.04));
    opacity: 0.9;
}

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

a { color: inherit; text-decoration: none; }

.glass-card,
.glass-panel {
    background: linear-gradient(135deg, rgba(255,255,255,0.16), rgba(255,255,255,0.075));
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    backdrop-filter: blur(22px) saturate(145%);
    -webkit-backdrop-filter: blur(22px) saturate(145%);
}

.login-page {
    min-height: 100vh;
    display: grid;
    place-items: center;
    padding: 24px;
}

.login-card {
    width: min(420px, 100%);
    padding: 34px;
    position: relative;
    overflow: hidden;
}

.brand-orb {
    width: 86px;
    height: 86px;
    border-radius: 28px;
    background: linear-gradient(135deg, var(--accent), var(--accent2));
    box-shadow: 0 20px 60px rgba(122, 162, 255, 0.42);
    margin-bottom: 24px;
}

h1, h2, p { margin-top: 0; }
.login-card h1 { margin-bottom: 8px; font-size: 2.1rem; }
.muted { color: var(--muted); }
.eyebrow { color: var(--accent); text-transform: uppercase; letter-spacing: 0.12em; font-size: 0.72rem; margin-bottom: 6px; }

.login-form { display: grid; gap: 16px; margin-top: 28px; }
label { display: grid; gap: 8px; color: var(--muted); font-size: 0.9rem; }
input, select, textarea {
    width: 100%;
    color: var(--text);
    background: rgba(8, 12, 26, 0.45);
    border: 1px solid rgba(255, 255, 255, 0.18);
    border-radius: 14px;
    outline: none;
    padding: 12px 14px;
}
textarea { resize: vertical; }
input:focus, select:focus, textarea:focus { border-color: rgba(122, 162, 255, 0.85); box-shadow: 0 0 0 4px rgba(122,162,255,0.12); }

.button, .chip, .icon-button {
    border: 1px solid rgba(255,255,255,0.20);
    color: var(--text);
    background: rgba(255,255,255,0.10);
    border-radius: 14px;
    padding: 11px 15px;
    cursor: pointer;
    transition: transform .16s ease, background .16s ease, border-color .16s ease;
}
.button:hover, .chip:hover, .icon-button:hover { transform: translateY(-1px); background: rgba(255,255,255,0.16); border-color: rgba(255,255,255,0.34); }
.button-primary { background: linear-gradient(135deg, rgba(122,162,255,0.85), rgba(185,133,255,0.78)); border-color: rgba(255,255,255,0.24); }
.button-danger { background: rgba(255, 107, 130, 0.20); border-color: rgba(255, 107, 130, 0.50); }
.button-warning { background: rgba(255, 209, 102, 0.17); border-color: rgba(255, 209, 102, 0.42); }
.icon-button { width: 42px; height: 42px; padding: 0; font-size: 1.5rem; line-height: 1; }
.alert { border-radius: 14px; padding: 12px; margin: 16px 0; }
.alert-error { background: rgba(255, 107, 130, 0.16); border: 1px solid rgba(255, 107, 130, 0.35); }

.app-shell { min-height: 100vh; padding: 18px; display: grid; gap: 16px; position: relative; }
.topbar { display: flex; justify-content: space-between; gap: 18px; align-items: center; padding: 18px; }
.topbar-title { display: flex; align-items: center; gap: 14px; }
.app-icon { width: 48px; height: 48px; border-radius: 16px; display: grid; place-items: center; background: linear-gradient(135deg, var(--accent), var(--accent2)); font-weight: 800; }
.topbar h1 { margin: 0; font-size: 1.45rem; }
.topbar p { margin: 3px 0 0; color: var(--muted); font-size: .9rem; }
.topbar-actions { display: flex; gap: 10px; flex-wrap: wrap; }

.toolbar { display: flex; justify-content: space-between; gap: 16px; padding: 14px 18px; flex-wrap: wrap; }
.tool-group { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.tool-label { color: var(--muted); }
.chip { padding: 8px 12px; border-radius: 999px; }
.chip.active { background: rgba(122,162,255,0.28); border-color: rgba(122,162,255,0.55); }
.pill { border: 1px solid rgba(255,255,255,0.18); background: rgba(255,255,255,0.08); border-radius: 999px; padding: 8px 12px; color: var(--muted); }
#zoom-range { width: 180px; accent-color: var(--accent); }

.main-grid { display: grid; grid-template-columns: minmax(0, 1fr) 360px; gap: 16px; min-height: calc(100vh - 190px); }
.timeline-panel { padding: 18px; min-width: 0; }
.timeline-head { display: flex; align-items: end; justify-content: space-between; gap: 18px; margin-bottom: 16px; }
.timeline-head h2 { margin: 0; }
.hint { color: var(--muted); font-size: .9rem; max-width: 520px; margin: 0; }
.timeline-viewport {
    width: 100%;
    height: calc(100vh - 288px);
    min-height: 420px;
    overflow: auto;
    border-radius: 18px;
    border: 1px solid rgba(255,255,255,0.13);
    background: rgba(5, 8, 18, 0.32);
    position: relative;
}
.timeline-canvas { position: relative; min-height: 100%; }
.timeline-ruler { position: sticky; top: 0; height: 54px; z-index: 5; background: rgba(10, 14, 28, 0.82); backdrop-filter: blur(18px); border-bottom: 1px solid rgba(255,255,255,0.12); }
.tick { position: absolute; top: 0; bottom: 0; border-left: 1px solid rgba(255,255,255,0.16); color: rgba(238,244,255,0.78); font-size: .78rem; padding-left: 6px; display: flex; align-items: center; }
.tick.minor { color: rgba(238,244,255,0.42); border-left-color: rgba(255,255,255,0.08); }
.timeline-lanes { position: relative; padding-top: 10px; }
.lane { position: relative; height: 66px; border-bottom: 1px solid rgba(255,255,255,0.075); }
.lane:hover { background: rgba(255,255,255,0.035); }
.lane-label { position: sticky; left: 0; z-index: 3; width: 150px; height: 100%; display: flex; align-items: center; padding-left: 12px; color: var(--muted); background: linear-gradient(90deg, rgba(10,14,28,0.94), rgba(10,14,28,0.68), transparent); pointer-events: none; }
.entry-card { position: absolute; top: 12px; min-width: 150px; max-width: 320px; height: 42px; display: flex; flex-direction: column; justify-content: center; gap: 2px; padding: 7px 10px; border-radius: 14px; border: 1px solid rgba(122,162,255,0.42); background: linear-gradient(135deg, rgba(122,162,255,0.35), rgba(185,133,255,0.18)); box-shadow: 0 12px 30px rgba(0,0,0,0.25); cursor: pointer; overflow: hidden; }
.entry-card.periodic { border-color: rgba(126,240,184,0.42); background: linear-gradient(135deg, rgba(126,240,184,0.24), rgba(122,162,255,0.12)); }
.entry-card.raw { border-color: rgba(255,209,102,0.48); background: rgba(255,209,102,0.16); }
.entry-card.disabled { opacity: .48; filter: grayscale(.35); }
.entry-card strong { font-size: .82rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.entry-card span { color: rgba(238,244,255,0.72); font-size: .72rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.entry-range { max-width: none; }

.side-panel { padding: 18px; display: grid; align-content: start; gap: 20px; min-width: 0; }
.details-box { min-height: 150px; line-height: 1.5; }
.small-pre, .modal-preview pre { white-space: pre-wrap; word-break: break-word; background: rgba(5,8,18,0.42); border: 1px solid rgba(255,255,255,0.11); border-radius: 14px; padding: 12px; color: rgba(238,244,255,0.78); max-height: 280px; overflow: auto; }

.modal.hidden, .hidden { display: none !important; }
.modal { position: fixed; inset: 0; z-index: 50; display: grid; place-items: center; padding: 22px; }
.modal-backdrop { position: absolute; inset: 0; background: rgba(3, 5, 12, 0.54); backdrop-filter: blur(8px); }
.modal-card { position: relative; width: min(860px, 100%); max-height: min(880px, calc(100vh - 44px)); overflow: auto; padding: 20px; }
.modal-head { display: flex; justify-content: space-between; align-items: start; gap: 16px; margin-bottom: 16px; }
.modal-head h2 { margin: 0; }
.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px; }
.span-2 { grid-column: span 2; }
.modal-preview { margin-top: 16px; }
.modal-actions { display: flex; justify-content: space-between; gap: 12px; margin-top: 18px; }
.modal-actions-right { display: flex; gap: 10px; }
.toast-host { position: fixed; right: 18px; bottom: 18px; z-index: 90; display: grid; gap: 10px; width: min(360px, calc(100vw - 36px)); }
.toast { padding: 13px 15px; border-radius: 16px; background: rgba(18,24,44,0.92); border: 1px solid rgba(255,255,255,0.18); box-shadow: var(--shadow); }
.toast.ok { border-color: rgba(126,240,184,0.42); }
.toast.error { border-color: rgba(255,107,130,0.46); }

@media (max-width: 1100px) {
    .main-grid { grid-template-columns: 1fr; }
    .side-panel { order: -1; }
}

@media (max-width: 760px) {
    .app-shell { padding: 10px; }
    .topbar { align-items: flex-start; flex-direction: column; }
    .timeline-viewport { min-height: 520px; }
    .form-grid { grid-template-columns: 1fr; }
    .span-2 { grid-column: span 1; }
    .modal-actions { flex-direction: column; }
    .modal-actions-right { justify-content: stretch; }
    .modal-actions-right .button, .modal-actions .button { width: 100%; }
}

/* ServerSched WebGUI v2: kompakte Timeline */
.timeline-viewport {
    height: min(62vh, 640px);
    min-height: 360px;
    scroll-behavior: auto;
}

.timeline-lanes.compact-lanes {
    position: relative;
    padding-top: 12px;
    padding-bottom: 18px;
    min-height: 180px;
    background-image:
        linear-gradient(90deg, rgba(255,255,255,0.045) 1px, transparent 1px),
        linear-gradient(180deg, rgba(255,255,255,0.055) 1px, transparent 1px);
    background-size: 60px 100%, 100% 58px;
}

.compact-lane {
    height: 58px;
    border-bottom: 1px solid rgba(255,255,255,0.07);
}

.compact-lane::before {
    content: attr(data-lane);
    position: sticky;
    left: 10px;
    z-index: 2;
    width: 28px;
    height: 28px;
    top: 15px;
    display: inline-grid;
    place-items: center;
    border-radius: 999px;
    color: rgba(238,244,255,0.42);
    background: rgba(10,14,28,0.64);
    border: 1px solid rgba(255,255,255,0.08);
    font-size: .72rem;
    pointer-events: none;
}

.compact-lane:hover {
    background: rgba(255,255,255,0.03);
}

.compact-lane .entry-card {
    top: 8px;
    height: 42px;
    min-width: 96px;
    max-width: none;
    display: grid;
    gap: 1px;
    align-content: center;
}

.compact-lane .entry-card strong {
    font-size: .78rem;
    line-height: 1.1;
}

.compact-lane .entry-card em {
    color: rgba(238,244,255,0.68);
    font-size: .68rem;
    font-style: normal;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.entry-card.entry-repeat {
    background-image:
        repeating-linear-gradient(90deg, rgba(255,255,255,0.22) 0 2px, transparent 2px 18px),
        linear-gradient(135deg, rgba(126,240,184,0.20), rgba(122,162,255,0.12));
    background-blend-mode: overlay, normal;
}

.entry-card.entry-minutely {
    border-color: rgba(126,240,184,0.62);
    background-image:
        linear-gradient(90deg, rgba(126,240,184,0.34), rgba(122,162,255,0.20), rgba(126,240,184,0.28));
    box-shadow: inset 0 0 0 1px rgba(255,255,255,0.06), 0 12px 30px rgba(0,0,0,0.25);
}

.timeline-empty,
.hidden-summary {
    margin: 16px;
    padding: 14px 16px;
    border-radius: 16px;
    color: var(--muted);
    background: rgba(255,255,255,0.075);
    border: 1px solid rgba(255,255,255,0.12);
}

.hidden-summary {
    display: inline-block;
    margin-top: 12px;
    font-size: .86rem;
}

@media (max-width: 760px) {
    .timeline-viewport {
        height: 68vh;
        min-height: 460px;
    }
    .compact-lane {
        height: 64px;
    }
}
