@import url('https://fonts.googleapis.com/css2?family=Space+Grotesk:wght@400;500;600;700&family=IBM+Plex+Mono:wght@400;500&display=swap');

:root {
    --bg-1: #f2f7fa;
    --bg-2: #dcecf2;
    --ink: #18313b;
    --muted: #60747d;
    --line: #d8e5eb;
    --brand: #287b8f;
    --brand-2: #a87812;
    --ok: #23856f;
    --warn: #9a6a00;
    --err: #a64036;
    --panel: rgba(255, 255, 255, 0.94);
    --shadow: 0 18px 44px rgba(24, 49, 59, 0.08);
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
    min-height: 100vh;
    font-family: 'Space Grotesk', sans-serif;
    color: var(--ink);
    background:
        linear-gradient(180deg, rgba(255, 255, 255, 0.68), rgba(255, 255, 255, 0.16)),
        linear-gradient(135deg, var(--bg-1), var(--bg-2));
}
.page-bg {
    position: fixed;
    inset: 0;
    pointer-events: none;
    background:
        linear-gradient(90deg, rgba(40, 123, 143, 0.075) 1px, transparent 1px),
        linear-gradient(180deg, rgba(40, 123, 143, 0.06) 1px, transparent 1px);
    background-size: 48px 48px;
    opacity: 0.82;
    z-index: 0;
}
.topbar, .shell, .footer { position: relative; z-index: 1; }
.topbar { padding: 20px 24px 56px; z-index: 20; }
.topbar-row { display: flex; align-items: flex-start; justify-content: space-between; gap: 18px; }
.brand { display: flex; align-items: center; gap: 12px; margin-bottom: 14px; }
.brand-mark {
    width: 44px;
    height: 44px;
    border-radius: 10px;
    overflow: hidden;
    background: #287b8f;
    border: 1px solid rgba(216, 229, 235, 0.95);
    box-shadow: var(--shadow);
}
.brand-logo { width: 100%; height: 100%; display: block; object-fit: contain; padding: 5px; }
.brand h1 { margin: 0; font-size: 1.1rem; }
.brand p { margin: 2px 0 0; color: var(--muted); font-size: 0.86rem; }
.main-nav { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.nav-link {
    display: inline-flex;
    align-items: center;
    gap: 7px;
    text-decoration: none;
    color: var(--ink);
    border: 1px solid var(--line);
    padding: 8px 12px;
    border-radius: 999px;
    font-size: 0.88rem;
    background: rgba(255, 255, 255, 0.82);
    transition: 150ms ease;
}
.nav-link:hover { border-color: var(--brand); color: var(--brand); }
.nav-link.active { background: var(--brand); border-color: var(--brand); color: #fff; }
.nav-link__icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 1.1rem;
    min-width: 1.1rem;
    font-size: 0.92rem;
}
.nav-group { position: relative; display: inline-flex; align-items: center; }
.nav-link--group { cursor: default; }
.nav-group.active .nav-link--group,
.nav-group:hover .nav-link--group,
.nav-group:focus-within .nav-link--group {
    background: var(--brand);
    border-color: var(--brand);
    color: #fff;
}
.nav-submenu {
    position: absolute;
    top: 100%;
    left: 0;
    min-width: 190px;
    display: none;
    flex-direction: column;
    gap: 6px;
    padding: 8px;
    border-radius: 12px;
    border: 1px solid var(--line);
    background: rgba(255, 255, 255, 0.99);
    box-shadow: var(--shadow);
    z-index: 30;
}
.nav-group:hover .nav-submenu,
.nav-group:focus-within .nav-submenu { display: flex; }
.nav-submenu .nav-link { width: 100%; }
.nav-toggle {
    display: none;
    align-items: center;
    justify-content: center;
    width: 34px;
    height: 34px;
    padding: 0;
    background: rgba(255, 255, 255, 0.9);
    border: 1px solid var(--line);
    border-radius: 8px;
    color: var(--ink);
    cursor: pointer;
}
.user-badge { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; justify-content: flex-end; }
.user-badge__name, .user-badge__role {
    border: 1px solid var(--line);
    border-radius: 999px;
    background: rgba(255, 255, 255, 0.9);
    padding: 8px 11px;
    font-weight: 700;
    font-size: 0.82rem;
}
.user-badge__role { color: var(--brand); }
.shell { padding: 8px 24px 36px; margin: 0 auto; }
.page-title {
    margin: 8px 0 14px;
    font-size: clamp(1.25rem, 2.4vw, 2rem);
    letter-spacing: 0.02em;
}
.panel {
    background: var(--panel);
    border: 1px solid rgba(216, 229, 235, 0.95);
    border-radius: 18px;
    padding: 16px;
    box-shadow: var(--shadow);
    margin-bottom: 16px;
    overflow: hidden;
}
.panel h3 { margin: 0 0 10px; }
.panel-meta { color: var(--muted); font-size: 0.88rem; line-height: 1.45; }
.dashboard-grid {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 12px;
}
.metric-card {
    background: rgba(255, 255, 255, 0.96);
    border: 1px solid var(--line);
    border-radius: 12px;
    padding: 14px;
}
.metric-card__label {
    color: var(--muted);
    font-size: 0.76rem;
    text-transform: uppercase;
    letter-spacing: 0.03em;
}
.metric-card__value { margin-top: 8px; font-size: 1.9rem; font-weight: 700; }
.metric-card__note { margin-top: 4px; color: var(--muted); font-size: 0.82rem; }
.grid-form {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 10px;
    align-items: end;
}
.field { display: flex; flex-direction: column; gap: 6px; }
.field label {
    color: var(--muted);
    font-size: 0.78rem;
    letter-spacing: 0.02em;
    text-transform: uppercase;
}
input, select, textarea, button { font: inherit; }
input, select, textarea {
    border: 1px solid var(--line);
    border-radius: 10px;
    padding: 9px 10px;
    background: #fff;
    color: var(--ink);
}
textarea { min-height: 74px; resize: vertical; }
button, .button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    text-decoration: none;
    border: 0;
    border-radius: 10px;
    padding: 10px 14px;
    cursor: pointer;
    background: var(--brand);
    color: #fff;
    font-weight: 600;
}
button.alt, .button.alt { background: var(--brand-2); }
button.ghost, a.ghost {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    text-decoration: none;
    background: #fff;
    color: var(--ink);
    border: 1px solid var(--line);
    border-radius: 10px;
    padding: 8px 12px;
    font-weight: 600;
}
a.ghost:hover, button.ghost:hover { border-color: var(--brand); color: var(--brand); }
.message {
    margin-top: 10px;
    border-radius: 10px;
    padding: 10px 12px;
    border: 1px solid transparent;
    font-size: 0.92rem;
}
.message.info { color: #12334d; background: #e6f2ff; border-color: #c4e0ff; }
.message.success { color: #0f4d42; background: #e2f5f0; border-color: #b9e6dc; }
.message.warn { color: #624400; background: #fff6d8; border-color: #ecd68c; }
.message.error { color: #74251f; background: #f7e5e2; border-color: #e5bbb5; }
.table-wrap {
    overflow-x: auto;
    margin-top: 12px;
    border: 1px solid var(--line);
    border-radius: 12px;
}
.table-wrap table {
    width: 100%;
    border-collapse: collapse;
    min-width: 860px;
    background: #fff;
}
.table-wrap th,
.table-wrap td {
    padding: 9px 10px;
    border-bottom: 1px solid #e8f0f3;
    vertical-align: top;
    text-align: left;
    font-size: 0.9rem;
}
.table-wrap th {
    font-size: 0.76rem;
    letter-spacing: 0.03em;
    text-transform: uppercase;
    color: var(--muted);
    background: #f5fafc;
}
.table-wrap td code {
    font-family: 'IBM Plex Mono', monospace;
    font-size: 0.84rem;
    color: #1b6578;
}
.table-link {
    color: var(--brand);
    font-weight: 700;
    text-decoration: none;
}
.table-link:hover,
.table-link:focus-visible {
    text-decoration: underline;
}
.table-wrap tr[data-row-href] { cursor: pointer; }
.table-wrap tbody tr[data-row-href]:hover { background: #f4fafb; }
.badge {
    display: inline-flex;
    align-items: center;
    padding: 3px 9px;
    border-radius: 999px;
    border: 1px solid transparent;
    font-size: 0.72rem;
    font-weight: 700;
    line-height: 1.1;
    text-transform: uppercase;
}
.badge.ok { background: #e0f3ec; border-color: #a7dccc; color: #145844; }
.badge.warn { background: #fff4cf; border-color: #e6c971; color: #7a5300; }
.badge.err { background: #f6e4df; border-color: #dfa99f; color: #87342b; }
.badge.neutral { background: #eaf1f5; border-color: #cbdbe3; color: #35505b; }
.empty-state {
    border: 1px dashed var(--line);
    border-radius: 12px;
    padding: 18px;
    color: var(--muted);
    background: rgba(255, 255, 255, 0.72);
}
.actions-row { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.modal {
    width: min(960px, calc(100vw - 28px));
    max-height: calc(100vh - 36px);
    margin: auto;
    padding: 0;
    border: 0;
    background: transparent;
    color: var(--ink);
}
.modal::backdrop {
    background: rgba(24, 49, 59, 0.42);
    backdrop-filter: blur(3px);
}
.modal__panel {
    max-height: calc(100vh - 36px);
    overflow: auto;
    padding: 16px;
    border: 1px solid rgba(216, 229, 235, 0.95);
    border-radius: 18px;
    background: rgba(255, 255, 255, 0.98);
    box-shadow: 0 26px 74px rgba(24, 49, 59, 0.24);
}
.modal__header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 14px;
    margin-bottom: 14px;
}
.modal__header h3 { margin: 0 0 4px; }
.modal__close { white-space: nowrap; }
.login-page { min-height: 100vh; display: grid; place-items: center; padding: 24px; }
.login-card {
    width: 100%;
    max-width: 400px;
    background: var(--panel);
    border: 1px solid rgba(216, 229, 235, 0.95);
    border-radius: 18px;
    padding: 32px;
    box-shadow: var(--shadow);
}
.login-card__brand { display: flex; align-items: center; gap: 12px; margin-bottom: 28px; }
.login-card__brand .brand-mark { width: 54px; height: 54px; border-radius: 12px; }
.login-card h2 { margin: 0 0 20px; font-size: 1.1rem; color: var(--muted); font-weight: 500; }
.login-error {
    background: #f7e5e2;
    border: 1px solid #e5bbb5;
    color: var(--err);
    border-radius: 10px;
    padding: 10px 12px;
    font-size: 0.88rem;
    margin-bottom: 14px;
}
.footer {
    display: flex;
    justify-content: space-between;
    gap: 12px;
    flex-wrap: wrap;
    padding: 18px 24px 26px;
    color: var(--muted);
    font-size: 0.78rem;
}
.footer-db {
    font-family: 'IBM Plex Mono', monospace;
    background: rgba(255, 255, 255, 0.88);
    border: 1px solid var(--line);
    border-radius: 999px;
    padding: 4px 8px;
}
.timeline-panel {
    padding: 18px;
    background:
        linear-gradient(180deg, rgba(255, 255, 255, 0.98), rgba(250, 253, 252, 0.94));
}
.timeline-heading {
    justify-content: space-between;
    align-items: flex-start;
}
.timeline-window {
    min-width: 148px;
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    gap: 2px;
    color: var(--muted);
    font-size: 0.8rem;
}
.timeline-window strong {
    color: var(--ink);
    font-size: 1rem;
}
.timeline-tools {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 7px;
}
.timeline-zoom {
    width: 34px;
    height: 34px;
    padding: 0;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: #fff;
    color: var(--ink);
    font-size: 1.05rem;
    line-height: 1;
}
.timeline-zoom:hover {
    border-color: var(--brand);
    color: var(--brand);
}
.timeline-scroll {
    position: relative;
    margin-top: 18px;
    border: 1px solid #cadce3;
    border-radius: 12px;
    overflow-x: auto;
    overflow-y: hidden;
    cursor: grab;
    scrollbar-color: #8bb5bf #e8f2f5;
    scrollbar-width: thin;
    -webkit-overflow-scrolling: touch;
    touch-action: none;
}
.timeline-scroll::before,
.timeline-scroll::after {
    content: "";
    position: absolute;
    top: 0;
    bottom: 10px;
    z-index: 8;
    display: block;
    width: 26px;
    height: auto;
    pointer-events: none;
}
.timeline-scroll::before {
    left: 0;
    background: linear-gradient(90deg, rgba(255, 255, 255, 0.96), rgba(255, 255, 255, 0));
}
.timeline-scroll::after {
    right: 0;
    background: linear-gradient(270deg, rgba(255, 255, 255, 0.96), rgba(255, 255, 255, 0));
}
.timeline-scroll.is-dragging {
    cursor: grabbing;
    user-select: none;
}
.timeline-scroll.is-dragging .timeline-marker {
    pointer-events: none;
}
.timeline-scroll::-webkit-scrollbar { height: 10px; }
.timeline-scroll::-webkit-scrollbar-track {
    background: #e8f2f5;
    border-radius: 999px;
}
.timeline-scroll::-webkit-scrollbar-thumb {
    background: #8bb5bf;
    border: 2px solid #e8f2f5;
    border-radius: 999px;
}
.timeline-chart {
    position: relative;
    height: 546px;
    width: max(calc(var(--timeline-base-width, 1480px) * var(--timeline-zoom, 1)), 100%);
    background:
        linear-gradient(90deg, rgba(40, 123, 143, 0.08) 1px, transparent 1px),
        linear-gradient(180deg, #ffffff, #f7fbfa);
    background-size: 10% 100%, 100% 100%;
    overflow: hidden;
}
.timeline-chart--hours {
    width: max(calc(var(--timeline-base-width, 1320px) * var(--timeline-zoom, 1)), 100%);
}
.timeline-axis {
    position: absolute;
    left: 22px;
    right: 22px;
    bottom: 46px;
    height: 3px;
    border-radius: 999px;
    background: linear-gradient(90deg, #a64036, #d09a28 18%, #287b8f 45%, #23856f);
}
.timeline-tick {
    position: absolute;
    bottom: 18px;
    top: 0;
    width: 1px;
    background: rgba(96, 116, 125, 0.16);
}
.timeline-tick span {
    position: absolute;
    bottom: -1px;
    left: 0;
    transform: translateX(-50%);
    color: var(--muted);
    font-family: 'IBM Plex Mono', monospace;
    font-size: 0.72rem;
    white-space: nowrap;
}
.timeline-now {
    position: absolute;
    top: 0;
    bottom: 18px;
    width: 3px;
    z-index: 3;
    background: #18313b;
    box-shadow: 0 0 0 3px rgba(24, 49, 59, 0.08);
}
.timeline-now span {
    position: absolute;
    top: 8px;
    left: 9px;
    border: 1px solid rgba(24, 49, 59, 0.3);
    border-radius: 999px;
    padding: 4px 9px;
    background: #18313b;
    color: var(--ink);
    font-size: 0.7rem;
    font-weight: 700;
    white-space: nowrap;
    color: #fff;
    box-shadow: 0 9px 18px rgba(24, 49, 59, 0.16);
}
.timeline-marker {
    position: absolute;
    bottom: calc(66px + (var(--lane) * 34px));
    width: 0;
    height: 1px;
    color: var(--ink);
    z-index: 5;
    text-decoration: none;
    cursor: pointer;
}
.timeline-marker:hover,
.timeline-marker:focus-visible {
    z-index: 12;
}
.timeline-marker:focus-visible .timeline-dot {
    outline: 3px solid rgba(40, 123, 143, 0.22);
    outline-offset: 3px;
}
.timeline-dot {
    position: absolute;
    left: -7px;
    bottom: 4px;
    width: 14px;
    height: 14px;
    border-radius: 999px;
    background: #60747d;
    border: 2px solid #fff;
    box-shadow: 0 7px 14px rgba(24, 49, 59, 0.18);
}
.timeline-marker::after {
    content: "";
    position: absolute;
    left: 0;
    top: 18px;
    bottom: -53px;
    width: 1px;
    background: rgba(96, 116, 125, 0.28);
}
.timeline-label {
    position: absolute;
    left: 10px;
    bottom: 0;
    z-index: 2;
    width: 176px;
    min-height: 30px;
    max-height: 38px;
    display: flex;
    flex-direction: column;
    gap: 6px;
    padding: 5px 7px;
    border: 1px solid rgba(216, 229, 235, 0.92);
    border-radius: 8px;
    background: rgba(255, 255, 255, 0.94);
    box-shadow: 0 10px 24px rgba(24, 49, 59, 0.08);
    cursor: pointer;
    overflow: hidden;
    transition:
        width 0.16s ease,
        max-height 0.16s ease,
        padding 0.16s ease,
        border-color 0.16s ease,
        box-shadow 0.16s ease;
}
.timeline-marker--dense .timeline-label {
    width: 150px;
    padding: 4px 6px;
}
.timeline-label strong {
    font-size: 0.7rem;
    line-height: 1.1;
}
.timeline-label-details {
    display: grid;
    gap: 4px;
    opacity: 0;
    transform: translateY(-3px);
    transition: opacity 0.12s ease, transform 0.12s ease;
}
.timeline-label-details .badge {
    width: fit-content;
}
.timeline-label-details span:not(.badge),
.timeline-label-details em {
    color: var(--muted);
    font-size: 0.72rem;
    line-height: 1.22;
    font-style: normal;
}
.timeline-marker:hover .timeline-label,
.timeline-marker:focus-visible .timeline-label {
    width: 280px;
    max-height: 132px;
    padding: 9px 10px;
    border-color: #bfd4dc;
    box-shadow: 0 16px 34px rgba(24, 49, 59, 0.18);
}
.timeline-marker--dense:hover .timeline-label,
.timeline-marker--dense:focus-visible .timeline-label {
    width: 260px;
}
.timeline-marker:hover .timeline-label-details,
.timeline-marker:focus-visible .timeline-label-details {
    opacity: 1;
    transform: translateY(0);
}
.timeline-marker--left .timeline-label {
    left: auto;
    right: 10px;
}
.timeline-marker--overdue .timeline-dot { background: #a64036; }
.timeline-marker--due_soon .timeline-dot { background: #c88716; }
.timeline-marker--current .timeline-dot { background: #23856f; }
.timeline-marker--unknown .timeline-dot { background: #60747d; }
.timeline-marker--overdue .timeline-label { border-left: 4px solid #a64036; }
.timeline-marker--due_soon .timeline-label { border-left: 4px solid #c88716; }
.timeline-marker--current .timeline-label { border-left: 4px solid #23856f; }
.timeline-marker--unknown .timeline-label { border-left: 4px solid #60747d; }
.timeline-list {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 8px;
    margin-top: 12px;
}
.timeline-list-item {
    display: grid;
    grid-template-columns: 1fr;
    gap: 3px;
    min-height: 62px;
    border: 1px solid var(--line);
    border-radius: 10px;
    padding: 10px;
    background: #fff;
}
.timeline-list-item strong {
    font-size: 0.86rem;
    line-height: 1.15;
}
.timeline-list-item span:last-child {
    color: var(--muted);
    font-family: 'IBM Plex Mono', monospace;
    font-size: 0.72rem;
}
.timeline-list-status {
    width: fit-content;
    border-radius: 999px;
    padding: 2px 7px;
    color: #fff;
    font-size: 0.65rem;
    font-weight: 700;
    text-transform: uppercase;
}
.timeline-list-item--overdue .timeline-list-status { background: #a64036; }
.timeline-list-item--due_soon .timeline-list-status { background: #c88716; }
.timeline-list-item--current .timeline-list-status { background: #23856f; }
.timeline-list-item--unknown .timeline-list-status { background: #60747d; }
tr:target,
tr.is-timeline-target {
    scroll-margin-top: 90px;
    outline: 2px solid rgba(40, 123, 143, 0.36);
    outline-offset: -2px;
    background: #f0f8f8;
}
@media (max-width: 1000px) {
    .grid-form, .dashboard-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .timeline-list { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .timeline-label { width: 170px; }
}
@media (max-width: 720px) {
    .topbar { padding: 14px 14px 28px; }
    .topbar-row { align-items: center; }
    .main-nav { display: none; flex-direction: column; align-items: stretch; }
    .main-nav.is-open { display: flex; }
    .nav-toggle { display: inline-flex; }
    .nav-group { display: flex; flex-direction: column; align-items: stretch; }
    .nav-submenu { position: static; display: flex; box-shadow: none; margin-top: 6px; }
    .shell { padding: 8px 14px 28px; }
    .grid-form, .dashboard-grid { grid-template-columns: 1fr; }
    .user-badge__role { display: none; }
    .timeline-chart { height: 330px; width: 1120px; }
    .timeline-chart--hours { width: 1040px; }
    .timeline-label { display: none; }
    .timeline-list { grid-template-columns: 1fr; }
    .timeline-tools { width: 100%; justify-content: flex-start; flex-wrap: wrap; }
    .timeline-window { align-items: flex-start; }
}
