:root {
    --bg: #eef2f4;
    --bg-elev: #ffffff;
    --bg-soft: #f4f7f8;
    --line: #d5dde3;
    --text: #1c2430;
    --muted: #5f6b78;
    --accent: #1f6f78;
    --accent-soft: #e6f3f4;
    --accent-hover: #185961;
    --danger: #b42318;
    --ok: #1f7a4d;
    --ok-soft: #e8f6ee;
    --warn: #9a6700;
    --warn-soft: #fff4d6;
    --radius: 10px;
    --font: "DM Sans", "Segoe UI", sans-serif;
    --mono: "IBM Plex Mono", ui-monospace, monospace;
}

* { box-sizing: border-box; }

html, body {
    margin: 0;
    min-height: 100%;
    font-family: var(--font);
    color: var(--text);
    background:
        linear-gradient(180deg, #f7f9fb 0%, var(--bg) 40%, #e8eef1 100%);
}

h1, h2 {
    margin: 0;
    font-weight: 650;
    letter-spacing: -0.02em;
    color: var(--text);
}

p { margin: 0; }

.eyebrow {
    margin: 0 0 0.35rem;
    font-size: 0.72rem;
    text-transform: uppercase;
    letter-spacing: 0.12em;
    color: var(--accent);
    font-weight: 600;
}

.muted { color: var(--muted); font-size: 0.9rem; }
.mono { font-family: var(--mono); font-size: 0.86rem; }

/* Login */
.page-login {
    min-height: 100vh;
    display: grid;
    place-items: center;
    padding: 2rem;
    background:
        radial-gradient(900px 420px at 0% 0%, rgba(31, 111, 120, 0.08), transparent 60%),
        radial-gradient(700px 360px at 100% 100%, rgba(28, 36, 48, 0.04), transparent 55%),
        var(--bg);
}

.login-shell {
    width: min(880px, 100%);
    display: grid;
    grid-template-columns: 1.05fr 0.95fr;
    gap: 1.5rem;
    align-items: stretch;
}

.login-brand {
    padding: 2rem 1rem;
    display: flex;
    flex-direction: column;
    justify-content: center;
}

.login-brand h1 {
    font-size: clamp(2rem, 4vw, 2.8rem);
    line-height: 1.08;
    margin-bottom: 0.75rem;
}

.lede {
    color: var(--muted);
    max-width: 30ch;
    line-height: 1.55;
    font-size: 1.02rem;
}

.login-card {
    background: var(--bg-elev);
    border: 1px solid var(--line);
    border-radius: 12px;
    padding: 1.75rem;
    display: flex;
    flex-direction: column;
    gap: 0.95rem;
}

.login-card h2 { font-size: 1.2rem; margin-bottom: 0.1rem; }

.login-card label {
    display: flex;
    flex-direction: column;
    gap: 0.35rem;
    font-size: 0.88rem;
    color: var(--muted);
    font-weight: 500;
}

.login-card input {
    border: 1px solid var(--line);
    background: var(--bg-soft);
    color: var(--text);
    border-radius: 8px;
    padding: 0.8rem 0.9rem;
    font: inherit;
}

.login-card input:focus {
    outline: 2px solid rgba(31, 111, 120, 0.25);
    border-color: var(--accent);
    background: #fff;
}

.login-card button,
.btn-ghost,
.btn-accent {
    font: inherit;
    cursor: pointer;
    border-radius: 8px;
}

.login-card button {
    margin-top: 0.35rem;
    border: 0;
    background: var(--accent);
    color: #fff;
    font-weight: 600;
    padding: 0.85rem 1.1rem;
}

.login-card button:hover { background: var(--accent-hover); }

.alert {
    padding: 0.7rem 0.85rem;
    border-radius: 8px;
    font-size: 0.9rem;
}

.alert-error {
    background: #fef3f2;
    color: var(--danger);
    border: 1px solid #f5c2c0;
}

/* App */
.page-app { min-height: 100vh; }

.topbar {
    display: flex;
    justify-content: space-between;
    align-items: flex-end;
    gap: 1rem;
    padding: 1.5rem clamp(1.25rem, 4vw, 2.5rem) 1.1rem;
    background: var(--bg-elev);
    border-bottom: 1px solid var(--line);
}

.topbar h1 { font-size: clamp(1.45rem, 2.6vw, 1.9rem); }

.topbar-actions {
    display: flex;
    align-items: center;
    gap: 0.65rem;
}

.user-pill {
    font-size: 0.84rem;
    color: var(--muted);
    background: var(--bg-soft);
    border: 1px solid var(--line);
    padding: 0.4rem 0.75rem;
    border-radius: 8px;
}

.btn-ghost {
    text-decoration: none;
    color: var(--text);
    border: 1px solid var(--line);
    background: #fff;
    padding: 0.45rem 0.85rem;
    font-size: 0.88rem;
}

.btn-ghost:hover {
    border-color: var(--accent);
    color: var(--accent);
    background: var(--accent-soft);
}

.btn-accent {
    display: inline-block;
    text-decoration: none;
    font-size: 0.88rem;
    font-weight: 600;
    color: #fff;
    background: var(--accent);
    padding: 0.55rem 1rem;
    white-space: nowrap;
    border: 0;
}

.btn-accent:hover { background: var(--accent-hover); }

.tools-help {
    margin: 0 0 1rem;
    line-height: 1.5;
    max-width: 70ch;
}

.delta-up { color: var(--ok); }
.delta-down { color: var(--warn); }

.chart-wrap {
    width: 100%;
    overflow-x: auto;
    margin-bottom: 1.1rem;
    background: var(--bg-soft);
    border: 1px solid var(--line);
    border-radius: 8px;
    padding: 0.75rem 0.5rem 0.35rem;
}

.size-chart {
    width: 100%;
    min-width: 520px;
    height: auto;
    display: block;
}

.chart-grid {
    stroke: #dfe6eb;
    stroke-width: 1;
}

.chart-axis-line {
    stroke: #b7c2cb;
    stroke-width: 1.2;
}

.chart-axis,
.chart-xlabel {
    fill: var(--muted);
    font-family: var(--mono);
    font-size: 11px;
}

.chart-xlabel-sub {
    font-size: 10px;
    fill: #8a96a2;
}

.chart-area {
    fill: rgba(31, 111, 120, 0.12);
}

.chart-line {
    stroke: var(--accent);
    stroke-width: 2.75;
    stroke-linejoin: round;
    stroke-linecap: round;
}

.chart-point {
    fill: #fff;
    stroke: var(--accent);
    stroke-width: 2.25;
}

.chart-point.is-latest {
    fill: var(--accent);
    stroke: var(--accent);
}

.htimeline {
    position: relative;
    min-height: 8rem;
    margin: 0.35rem 0.25rem 0.15rem;
    padding: 0.85rem 0.5rem 0.25rem;
    background: var(--bg-soft);
    border: 1px solid var(--line);
    border-radius: 8px;
}

.htimeline-track {
    position: absolute;
    left: 1rem;
    right: 1rem;
    top: 18px;
    height: 2px;
    background: #c8d2da;
}

.htimeline-node {
    position: absolute;
    top: 8px;
    transform: translateX(-50%);
    width: min(190px, 44vw);
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.55rem;
}

.htimeline-dot {
    width: 12px;
    height: 12px;
    border-radius: 50%;
    background: #fff;
    border: 2px solid var(--accent);
    z-index: 1;
}

.htimeline-node.is-latest .htimeline-dot {
    background: var(--accent);
    border-color: var(--accent);
}

.htimeline-card {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.22rem;
    text-align: center;
    font-size: 0.78rem;
    color: var(--muted);
    line-height: 1.3;
    background: #fff;
    border: 1px solid var(--line);
    border-radius: 8px;
    padding: 0.55rem 0.6rem;
    width: 100%;
}

.htimeline-card strong {
    color: var(--text);
    font-size: 0.9rem;
}

.htimeline-file {
    max-width: 100%;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    font-size: 0.68rem;
}

@media (max-width: 700px) {
    .htimeline { min-height: 9rem; }
    .htimeline-node { width: min(150px, 50vw); }
}

.wrap {
    width: min(1100px, calc(100% - 2rem));
    margin: 0 auto;
    padding: 1.35rem 0 2.75rem;
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.metrics {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 0.85rem;
}

.metric {
    background: var(--bg-elev);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    padding: 1rem 1.05rem;
}

.metric-label {
    color: var(--muted);
    font-size: 0.72rem;
    text-transform: uppercase;
    letter-spacing: 0.07em;
    margin-bottom: 0.45rem;
    font-weight: 600;
}

.metric-value {
    font-size: 1.45rem;
    font-weight: 650;
    letter-spacing: -0.03em;
    color: var(--text);
}

.metric-value-sm {
    font-size: 0.92rem;
    font-weight: 500;
    line-height: 1.35;
    word-break: break-all;
}

.panel {
    background: var(--bg-elev);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    padding: 1.1rem 1.15rem 1.2rem;
}

.panel-head {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 1rem;
    margin-bottom: 0.9rem;
    padding-bottom: 0.75rem;
    border-bottom: 1px solid var(--line);
}

.panel-head h2 { font-size: 1.05rem; }

.status-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 0.95rem;
}

.status-grid .muted {
    display: block;
    margin-bottom: 0.2rem;
    font-size: 0.72rem;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    font-weight: 600;
}

.status-grid strong {
    font-weight: 600;
    color: var(--text);
}

.table-wrap { overflow-x: auto; }

table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.9rem;
}

th, td {
    text-align: left;
    padding: 0.7rem 0.45rem;
    border-bottom: 1px solid var(--line);
    vertical-align: middle;
}

th {
    color: var(--muted);
    font-weight: 600;
    font-size: 0.72rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

tbody tr:hover {
    background: var(--bg-soft);
}

.tag {
    display: inline-block;
    font-family: var(--mono);
    font-size: 0.68rem;
    padding: 0.18rem 0.4rem;
    border-radius: 5px;
    background: var(--accent-soft);
    color: var(--accent);
    border: 1px solid #c7e1e4;
}

.badge {
    display: inline-block;
    font-size: 0.7rem;
    font-weight: 700;
    letter-spacing: 0.03em;
    padding: 0.22rem 0.5rem;
    border-radius: 6px;
}

.badge-ok {
    background: var(--ok-soft);
    color: var(--ok);
    border: 1px solid #b7e0c7;
}

.badge-warn {
    background: var(--warn-soft);
    color: var(--warn);
    border: 1px solid #efd48a;
}

.actions a {
    color: var(--accent);
    text-decoration: none;
    font-size: 0.88rem;
    font-weight: 600;
}

.actions a:hover { text-decoration: underline; }

.empty {
    color: var(--muted);
    padding: 0.85rem 0;
}

.footer {
    border-top: 1px solid var(--line);
    background: var(--bg-elev);
    padding: 0.95rem clamp(1.25rem, 4vw, 2.5rem) 1.35rem;
    color: var(--muted);
    font-size: 0.8rem;
}

@media (max-width: 900px) {
    .login-shell { grid-template-columns: 1fr; }
    .metrics { grid-template-columns: 1fr 1fr; }
    .status-grid { grid-template-columns: 1fr; }
    .topbar { flex-direction: column; align-items: flex-start; }
}

@media (max-width: 560px) {
    .metrics { grid-template-columns: 1fr; }
}
