/* ==========================================================
   Design tokenek
   Paletta: tompa tinta-teál + meszelt háttér, letisztult
   klinikai regiszter. Az esetlapszám és mennyiségek monospace
   kiemelést kapnak — ez a felület "jelzésrendszere".
   ========================================================== */
:root {
    --ink-900: #14302e;
    --teal-700: #1f5f57;
    --teal-600: #2c7a6d;
    --teal-500: #3d9384;
    --teal-100: #e2efec;
    --teal-050: #f2f7f6;
    --paper: #f7f8f6;
    --surface: #ffffff;
    --line: #dde4e1;
    --line-soft: #eaeeec;
    --text: #1e2b29;
    --text-muted: #5c6d69;
    --text-faint: #8a9a96;
    --amber: #b8792f;
    --red: #a13f3a;
    --red-bg: #fbeeed;

    --font-sans: 'IBM Plex Sans', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    --font-mono: 'IBM Plex Mono', 'SFMono-Regular', Consolas, monospace;

    --radius-s: 4px;
    --radius-m: 8px;
    --shadow-card: 0 1px 2px rgba(20, 48, 46, 0.06), 0 1px 8px rgba(20, 48, 46, 0.04);
}

* { box-sizing: border-box; }

html, body {
    margin: 0;
    padding: 0;
    background: var(--paper);
    color: var(--text);
    font-family: var(--font-sans);
    font-size: 15px;
    line-height: 1.5;
}

a { color: inherit; }

/* ---------- App shell ---------- */
.app-shell {
    display: flex;
    min-height: 100vh;
}

.sidebar {
    width: 232px;
    flex-shrink: 0;
    background: var(--ink-900);
    color: #dce9e6;
    display: flex;
    flex-direction: column;
    padding: 24px 16px;
    position: sticky;
    top: 0;
    height: 100vh;
}

.brand {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 0 8px 24px;
    margin-bottom: 8px;
    border-bottom: 1px solid rgba(255,255,255,0.08);
}

.brand-mark {
    width: 10px;
    height: 10px;
    border-radius: 2px;
    background: var(--teal-500);
    box-shadow: 0 0 0 3px rgba(61, 147, 132, 0.25);
    flex-shrink: 0;
}

.brand-text {
    font-weight: 600;
    font-size: 14.5px;
    letter-spacing: 0.01em;
}

.nav {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.nav-link {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 9px 12px;
    border-radius: var(--radius-s);
    text-decoration: none;
    color: #b7cac6;
    font-size: 14px;
    font-weight: 500;
    transition: background 0.12s ease, color 0.12s ease;
}

.nav-link:hover {
    background: rgba(255,255,255,0.06);
    color: #fff;
}

.nav-link.is-active {
    background: var(--teal-600);
    color: #fff;
}

.nav-icon {
    font-size: 13px;
    width: 16px;
    text-align: center;
    opacity: 0.85;
}

.main {
    flex: 1;
    padding: 32px 40px 60px;
    max-width: 1180px;
}

/* ---------- Page header ---------- */
.page-head {
    margin-bottom: 28px;
}

.page-eyebrow {
    font-family: var(--font-mono);
    font-size: 11.5px;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: var(--teal-600);
    font-weight: 600;
    margin: 0 0 6px;
}

.page-head h1 {
    margin: 0;
    font-size: 24px;
    font-weight: 600;
    color: var(--ink-900);
}

.page-sub {
    margin: 6px 0 0;
    color: var(--text-muted);
    font-size: 14px;
}

/* ---------- Cards ---------- */
.card {
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: var(--radius-m);
    box-shadow: var(--shadow-card);
    padding: 24px;
    margin-bottom: 24px;
}

.card h2 {
    font-size: 15px;
    font-weight: 600;
    margin: 0 0 16px;
    color: var(--ink-900);
}

/* ---------- Forms ---------- */
.form-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 16px 20px;
}

.field {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.field.full { grid-column: 1 / -1; }

.field label {
    font-size: 12.5px;
    font-weight: 600;
    color: var(--text-muted);
    letter-spacing: 0.01em;
}

.field .hint {
    font-size: 11.5px;
    color: var(--text-faint);
}

input, select, textarea {
    font-family: var(--font-sans);
    font-size: 14px;
    color: var(--text);
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: var(--radius-s);
    padding: 9px 11px;
    width: 100%;
    transition: border-color 0.12s ease, box-shadow 0.12s ease;
}

input:focus, select:focus, textarea:focus {
    outline: none;
    border-color: var(--teal-500);
    box-shadow: 0 0 0 3px rgba(61, 147, 132, 0.15);
}

input[data-esetlapszam], .esetlapszam-input {
    font-family: var(--font-mono);
    font-weight: 500;
    letter-spacing: 0.02em;
}

/* ---------- Buttons ---------- */
.btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    font-family: var(--font-sans);
    font-size: 13.5px;
    font-weight: 600;
    padding: 9px 16px;
    border-radius: var(--radius-s);
    border: 1px solid transparent;
    cursor: pointer;
    text-decoration: none;
    transition: background 0.12s ease, border-color 0.12s ease;
}

.btn-primary {
    background: var(--teal-600);
    color: #fff;
}
.btn-primary:hover { background: var(--teal-700); }

.btn-ghost {
    background: transparent;
    border-color: var(--line);
    color: var(--text);
}
.btn-ghost:hover { border-color: var(--teal-500); color: var(--teal-700); }

.btn-danger-ghost {
    background: transparent;
    border-color: var(--line);
    color: var(--red);
    font-size: 12.5px;
    padding: 6px 10px;
}
.btn-danger-ghost:hover { background: var(--red-bg); border-color: var(--red); }

.btn-sm { padding: 6px 11px; font-size: 12.5px; }

/* ---------- Tétel sorok (dinamikus anyag sorok) ---------- */
.tetel-sorok { display: flex; flex-direction: column; gap: 10px; margin-bottom: 12px; }

.tetel-sor {
    display: grid;
    grid-template-columns: 1fr 140px auto;
    gap: 10px;
    align-items: end;
    padding: 12px;
    background: var(--teal-050);
    border: 1px solid var(--line-soft);
    border-radius: var(--radius-s);
}

.tetel-sor .field { margin: 0; }

/* ---------- Táblázat ---------- */
.table-wrap {
    overflow-x: auto;
    border: 1px solid var(--line);
    border-radius: var(--radius-m);
    background: var(--surface);
}

table {
    width: 100%;
    border-collapse: collapse;
    font-size: 13.5px;
}

thead th {
    text-align: left;
    font-size: 11.5px;
    font-weight: 600;
    letter-spacing: 0.04em;
    text-transform: uppercase;
    color: var(--text-muted);
    background: var(--teal-050);
    padding: 11px 14px;
    border-bottom: 1px solid var(--line);
    white-space: nowrap;
}

tbody td {
    padding: 11px 14px;
    border-bottom: 1px solid var(--line-soft);
    vertical-align: top;
    color: var(--text);
}

tbody tr:last-child td { border-bottom: none; }
tbody tr:hover { background: var(--teal-050); }

.badge-eset {
    font-family: var(--font-mono);
    font-size: 12.5px;
    font-weight: 600;
    color: var(--teal-700);
    background: var(--teal-100);
    padding: 3px 8px;
    border-radius: 4px;
    letter-spacing: 0.01em;
}

.mennyiseg {
    font-family: var(--font-mono);
    font-weight: 600;
}

.szemely-lista { color: var(--text-muted); font-size: 13px; }

/* ---------- Szűrő sáv ---------- */
.filter-bar {
    display: grid;
    grid-template-columns: repeat(4, 1fr) auto;
    gap: 12px;
    align-items: end;
    margin-bottom: 20px;
}

/* ---------- Összesítő kártyák ---------- */
.stat-row {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 16px;
    margin-bottom: 24px;
}

.stat-card {
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: var(--radius-m);
    padding: 18px 20px;
}

.stat-card .stat-label {
    font-size: 12px;
    color: var(--text-muted);
    font-weight: 600;
    margin-bottom: 6px;
}

.stat-card .stat-value {
    font-family: var(--font-mono);
    font-size: 26px;
    font-weight: 600;
    color: var(--ink-900);
}

/* ---------- Üzenetek ---------- */
.alert {
    padding: 12px 16px;
    border-radius: var(--radius-s);
    font-size: 13.5px;
    margin-bottom: 20px;
    border: 1px solid transparent;
}

.alert-success {
    background: var(--teal-100);
    color: var(--teal-700);
    border-color: rgba(44,122,109,0.25);
}

.alert-error {
    background: var(--red-bg);
    color: var(--red);
    border-color: rgba(161,63,58,0.25);
}

.empty-state {
    padding: 48px 20px;
    text-align: center;
    color: var(--text-faint);
    font-size: 14px;
}

/* ---------- Responsive ---------- */
@media (max-width: 860px) {
    .app-shell { flex-direction: column; }
    .sidebar { width: auto; height: auto; position: relative; flex-direction: row; align-items: center; padding: 12px 16px; }
    .brand { border-bottom: none; padding: 0; margin: 0; margin-right: 16px; }
    .nav { flex-direction: row; }
    .main { padding: 24px 20px 40px; }
    .form-grid { grid-template-columns: 1fr; }
    .filter-bar { grid-template-columns: 1fr; }
    .stat-row { grid-template-columns: 1fr; }
    .tetel-sor { grid-template-columns: 1fr; }
}

/* Accessibility: visible focus for keyboard nav on interactive elements */
a:focus-visible, button:focus-visible, input:focus-visible, select:focus-visible {
    outline: 2px solid var(--teal-600);
    outline-offset: 2px;
}

@media (prefers-reduced-motion: reduce) {
    * { transition: none !important; animation: none !important; }
}
