:root {
    --bg: #f4f6f8;
    --card: #ffffff;
    --ink: #1c2733;
    --muted: #6b7a89;
    --line: #dde3e9;
    --accent: #1f6feb;
    --accent-ink: #ffffff;
    --strong-bg: #eef3fb;
    --shadow: 0 1px 2px rgba(16, 32, 48, .06), 0 2px 8px rgba(16, 32, 48, .04);
    --radius: 10px;
}

* { box-sizing: border-box; }

body {
    margin: 0;
    font-family: "Segoe UI", system-ui, -apple-system, Roboto, Arial, sans-serif;
    color: var(--ink);
    background: var(--bg);
    font-size: 14px;
    line-height: 1.45;
}

.sr-only {
    position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
    overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}

/* ---- shell ---- */
.app-shell { max-width: 1200px; margin: 0 auto; padding: 16px; }

.app-header {
    display: flex; align-items: center; justify-content: space-between;
    padding: 12px 4px 20px;
}
.app-header__title { display: flex; align-items: center; gap: 12px; font-size: 18px; font-weight: 600; }
.app-header__badge {
    background: var(--accent); color: var(--accent-ink); font-weight: 700;
    letter-spacing: .5px; padding: 4px 10px; border-radius: 6px; font-size: 13px;
}
.app-header__version { color: var(--muted); font-variant-numeric: tabular-nums; }

/* ---- cards ---- */
.card {
    background: var(--card); border: 1px solid var(--line); border-radius: var(--radius);
    box-shadow: var(--shadow); padding: 18px; margin-bottom: 18px;
}
.card__head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 14px; }
.card__head h2 { margin: 0; font-size: 16px; }
.card__actions { display: flex; gap: 8px; }

/* ---- buttons ---- */
.btn {
    border: 1px solid var(--accent); background: var(--accent); color: var(--accent-ink);
    padding: 6px 12px; border-radius: 6px; cursor: pointer; font-size: 13px; font-weight: 600;
}
.btn:hover { filter: brightness(1.05); }
.btn--ghost { background: transparent; color: var(--accent); }
.btn--ghost:hover { background: var(--strong-bg); }
.btn--icon {
    border: none; background: transparent; color: var(--muted); font-size: 18px;
    line-height: 1; padding: 2px 6px; cursor: pointer;
}
.btn--icon:hover { color: #c0392b; }

/* ---- table ---- */
.table-scroll { overflow-x: auto; }
.grid { border-collapse: collapse; width: 100%; min-width: 980px; }
.grid th, .grid td { padding: 6px 8px; border-bottom: 1px solid var(--line); text-align: left; white-space: nowrap; }
.grid thead th {
    background: #fafbfc; font-size: 12px; color: var(--muted); font-weight: 600;
    text-align: left; border-bottom: 1px solid var(--line);
}
.grid thead th.group { text-align: center; background: var(--strong-bg); color: var(--ink); }
.grid tfoot td { border-top: 2px solid var(--line); border-bottom: none; }
.grid .num { text-align: right; font-variant-numeric: tabular-nums; }
.grid .muted { color: var(--muted); }
.grid .strong { font-weight: 700; }
.grid .desc { color: var(--muted); font-size: 13px; white-space: normal; min-width: 160px; }
.grid .pct { color: var(--muted); margin-left: 6px; font-size: 12px; }

.grid--ref { min-width: 0; }
.ref-code { font-weight: 600; width: 110px; }

/* ---- inputs ---- */
.in {
    border: 1px solid var(--line); border-radius: 6px; padding: 5px 7px; font: inherit;
    background: #fff; color: var(--ink); width: 100%;
}
.in:focus { outline: 2px solid var(--accent); outline-offset: -1px; border-color: var(--accent); }
.in--num { width: 92px; text-align: right; font-variant-numeric: tabular-nums; }
.in--name { width: 90px; }
.in--count { width: 70px; }

/* ---- splitter ---- */
.splitter { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; align-items: start; }
.splitter__controls { display: flex; flex-direction: column; gap: 14px; }
.field { display: flex; flex-direction: column; gap: 5px; }
.field > span { font-size: 12px; color: var(--muted); font-weight: 600; }
.chips { display: flex; gap: 6px; align-items: center; }
.chip {
    border: 1px solid var(--line); background: #fff; border-radius: 6px; padding: 6px 12px;
    cursor: pointer; font-weight: 600; min-width: 40px;
}
.chip--on { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); }
.ratio { display: flex; align-items: center; gap: 8px; }

.splitter__result {
    background: var(--strong-bg); border: 1px solid var(--line); border-radius: var(--radius);
    padding: 20px; min-height: 100%;
}
.result-head { font-size: 13px; color: var(--muted); font-weight: 600; margin-bottom: 6px; }
.result-dims { display: flex; align-items: baseline; gap: 8px; font-variant-numeric: tabular-nums; }
.result-dims .dim { font-size: 34px; font-weight: 700; color: var(--ink); }
.result-dims .by { font-size: 22px; color: var(--muted); }
.result-dims .unit { font-size: 16px; color: var(--muted); }
.result-dims--sub { margin-top: 2px; }
.result-dims--sub span { font-size: 14px; color: var(--muted); }
.result-facts { margin: 16px 0 0; display: flex; flex-direction: column; gap: 8px; }
.result-facts > div { display: flex; justify-content: space-between; gap: 12px; border-top: 1px solid var(--line); padding-top: 8px; }
.result-facts dt { color: var(--muted); font-size: 13px; margin: 0; }
.result-facts dd { margin: 0; font-weight: 600; font-variant-numeric: tabular-nums; }

/* ---- misc ---- */
.note { color: var(--muted); font-size: 12.5px; margin: 12px 2px 0; }

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

/* ---- header auth ---- */
.app-header__right { display: flex; align-items: center; gap: 14px; }
.user-chip { color: var(--muted); font-size: 13px; }
.logout-form { margin: 0; }
.link-btn {
    border: none; background: transparent; color: var(--accent); cursor: pointer;
    font: inherit; font-size: 13px; font-weight: 600; padding: 0;
}
.link-btn:hover { text-decoration: underline; }

/* ---- login page ---- */
.login-wrap {
    min-height: 100vh; display: flex; align-items: center; justify-content: center;
    padding: 24px;
}
.login-card {
    background: var(--card); border: 1px solid var(--line); border-radius: var(--radius);
    box-shadow: var(--shadow); padding: 32px; width: 100%; max-width: 380px;
}
.login-badge {
    display: inline-block; background: var(--accent); color: var(--accent-ink);
    font-weight: 700; letter-spacing: .5px; padding: 4px 10px; border-radius: 6px;
    font-size: 13px; margin-bottom: 18px;
}
.login-card h1 { margin: 0 0 2px; font-size: 22px; }
.login-sub { margin: 0 0 22px; color: var(--muted); font-size: 13px; }
.login-error {
    background: #fdecea; border: 1px solid #f5c2bb; color: #a32d1c;
    padding: 9px 12px; border-radius: 6px; font-size: 13px; margin-bottom: 16px;
}
.form-field { display: flex; flex-direction: column; gap: 5px; margin-bottom: 16px; }
.form-field > label { font-size: 12px; color: var(--muted); font-weight: 600; }
.form-field .validation-message { color: #a32d1c; font-size: 12px; }
.btn--full { width: 100%; padding: 9px; font-size: 14px; margin-top: 4px; }
