:root {
  --bg: #f5f5f3;
  --surface: #ffffff;
  --ink: #16181d;
  --ink-2: #4a4f5a;
  --muted: #7a808c;
  --line: #e4e4e0;
  --line-2: #d3d3ce;
  --accent: #1f3a5f;
  --accent-ink: #ffffff;
  --accent-soft: #e8eef6;
  --ok: #1d7a4d; --ok-soft: #e4f4ea;
  --warn: #9a6200; --warn-soft: #fcf1dc;
  --bad: #b3261e; --bad-soft: #fbe7e5;
  --radius: 10px;
  --shadow: 0 1px 2px rgba(20, 22, 28, .05), 0 1px 1px rgba(20, 22, 28, .03);
  font-family: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  font-size: 15px;
  color: var(--ink);
  background: var(--bg);
}
* { box-sizing: border-box; }
body { margin: 0; line-height: 1.5; }
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
h1 { font-size: 1.6rem; margin: 0 0 .25rem; letter-spacing: -.01em; display: flex; align-items: center; gap: .6rem; flex-wrap: wrap; }
h2 { font-size: 1.05rem; margin: 0 0 .75rem; }
.muted { color: var(--muted); }
.small { font-size: .87rem; }
.prewrap { white-space: pre-wrap; }
.nowrap { white-space: nowrap; }
[hidden] { display: none !important; }

/* Elrendezés */
body.app { display: grid; grid-template-columns: 250px 1fr; min-height: 100vh; }
.sidebar { background: #111318; color: #d9dbe0; display: flex; flex-direction: column; padding: 1.25rem .9rem; position: sticky; top: 0; height: 100vh; }
.brand { display: flex; gap: .7rem; align-items: center; color: #fff; padding: 0 .4rem 1.25rem; border-bottom: 1px solid #262a33; margin-bottom: 1rem; }
.brand:hover { text-decoration: none; }
.brand-mark { width: 36px; height: 36px; border-radius: 9px; background: #fff; color: #111318; display: grid; place-items: center; font-weight: 800; font-size: 1.1rem; flex: none; }
.brand-text, .auth-brand div { display: flex; flex-direction: column; line-height: 1.2; }
.brand-text small { color: #8d929c; font-size: .72rem; }
.sidebar nav { display: flex; flex-direction: column; gap: 2px; flex: 1; }
.sidebar nav a { color: #c4c7ce; padding: .55rem .75rem; border-radius: 7px; display: flex; align-items: center; justify-content: space-between; }
.sidebar nav a:hover { background: #1d2028; color: #fff; text-decoration: none; }
.sidebar nav a.active { background: #262a35; color: #fff; font-weight: 600; }
.nav-section { font-size: .7rem; text-transform: uppercase; letter-spacing: .08em; color: #6c717c; margin: 1.1rem .75rem .35rem; }
.pill { background: #e0a526; color: #1a1300; border-radius: 999px; font-size: .72rem; font-weight: 700; padding: 0 .5rem; }
.me { border-top: 1px solid #262a33; padding: 1rem .4rem 0; font-size: .85rem; }
.me-name { color: #fff; font-weight: 600; }
.me-role { color: #8d929c; font-size: .76rem; overflow: hidden; text-overflow: ellipsis; }
.me-actions { display: flex; gap: 1rem; margin-top: .5rem; }
.me-actions a, .linklike { color: #b9bdc6; background: none; border: 0; padding: 0; font: inherit; cursor: pointer; }
.me-actions a:hover, .linklike:hover { color: #fff; text-decoration: underline; }
.me-actions form { margin: 0; }

.content { padding: 2rem clamp(1rem, 3vw, 2.5rem) 3rem; min-width: 0; }
.page { max-width: 1280px; margin: 0 auto; display: flex; flex-direction: column; gap: 1.25rem; }
.page.narrow { max-width: 860px; }
.page-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 1rem; flex-wrap: wrap; }
.page-head p { margin: 0; }
.crumbs { font-size: .85rem; color: var(--muted); margin: 0 0 .3rem !important; }

/* Kártyák */
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 1.25rem; box-shadow: var(--shadow); min-width: 0; }
.card-head { display: flex; justify-content: space-between; align-items: baseline; gap: 1rem; margin-bottom: .75rem; }
.card-head h2 { margin: 0; }
.stack { display: flex; flex-direction: column; gap: 1rem; }
fieldset.card { margin: 0; display: flex; flex-direction: column; gap: 1rem; }
legend { font-weight: 700; padding: 0 .4rem; margin-left: -.4rem; float: left; width: 100%; margin-bottom: .25rem; }
.grid-2, .grid-3, .grid-4 { display: grid; gap: 1rem; }
.grid-2 { grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); }
.grid-3 { grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); }
.grid-4 { grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); }

/* Űrlapok */
label { display: flex; flex-direction: column; gap: .35rem; font-size: .88rem; font-weight: 600; color: var(--ink-2); }
input, select, textarea { font: inherit; font-weight: 400; color: var(--ink); background: #fff; border: 1px solid var(--line-2); border-radius: 7px; padding: .55rem .7rem; width: 100%; }
input:focus, select:focus, textarea:focus { outline: 2px solid var(--accent-soft); border-color: var(--accent); }
input[type=file] { padding: .45rem; background: #fafaf8; }
input[type=radio] { width: auto; accent-color: var(--accent); }
.choice-row { display: flex; gap: .75rem; flex-wrap: wrap; }
.choice { flex-direction: row; align-items: center; gap: .5rem; border: 1px solid var(--line-2); border-radius: 8px; padding: .65rem .9rem; cursor: pointer; font-weight: 500; color: var(--ink); }
.choice:has(input:checked) { border-color: var(--accent); background: var(--accent-soft); }
.choice:has(input:disabled) { opacity: .55; cursor: not-allowed; }
.hint { margin: -.4rem 0 0; font-size: .85rem; color: var(--muted); min-height: 1.2em; }
.form-actions { display: flex; justify-content: flex-end; gap: .75rem; }

.btn { display: inline-flex; align-items: center; justify-content: center; gap: .4rem; font: inherit; font-weight: 600; font-size: .9rem; padding: .6rem 1.1rem; border-radius: 8px; border: 1px solid var(--line-2); background: #fff; color: var(--ink); cursor: pointer; white-space: nowrap; }
.btn:hover { background: #f0f0ed; text-decoration: none; }
.btn-primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.btn-primary:hover { background: #172d4b; }
.btn-block { width: 100%; }
.btn-small { padding: .3rem .65rem; font-size: .8rem; }
.btn-approve { background: var(--ok); border-color: var(--ok); color: #fff; }
.btn-approve:hover { background: #166240; }
.btn-reject { background: #fff; border-color: var(--bad); color: var(--bad); }
.btn-reject:hover { background: var(--bad-soft); }
.btn-reject-outline { color: var(--bad); }

/* Üzenetek */
.flash { border-radius: 8px; padding: .8rem 1rem; margin-bottom: 1.25rem; border: 1px solid; max-width: 1280px; margin-inline: auto; }
.page .flash, .auth-card .flash { margin: 0; }
.flash ul { margin: 0; padding-left: 1.1rem; }
.flash-success { background: var(--ok-soft); border-color: #b8dfc7; color: #124d31; }
.flash-error { background: var(--bad-soft); border-color: #f1c2bd; color: #7d1a14; }
.flash-info { background: var(--accent-soft); border-color: #c7d5e8; color: var(--accent); }
.credentials { margin-top: .75rem; background: #fff; border: 1px dashed #8fbfa2; border-radius: 8px; padding: .75rem 1rem; display: flex; flex-direction: column; gap: .3rem; color: var(--ink); }
.credentials code { font-size: .95rem; font-family: ui-monospace, SFMono-Regular, Menlo, monospace; }

/* Státusz */
.status { display: inline-block; font-size: .75rem; font-weight: 700; padding: .15rem .6rem; border-radius: 999px; white-space: nowrap; letter-spacing: .01em; vertical-align: middle; }
.status-pending { background: var(--warn-soft); color: var(--warn); }
.status-approved { background: var(--ok-soft); color: var(--ok); }
.status-rejected { background: var(--bad-soft); color: var(--bad); }

/* Statisztika */
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 1rem; }
.stat { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 1rem 1.15rem; display: flex; flex-direction: column; gap: .2rem; color: var(--ink); box-shadow: var(--shadow); }
a.stat:hover { border-color: var(--line-2); text-decoration: none; }
.stat-label { font-size: .8rem; color: var(--muted); font-weight: 600; }
.stat-value { font-size: 1.75rem; font-weight: 700; letter-spacing: -.02em; font-variant-numeric: tabular-nums; }
.small-value { font-size: 1.15rem; }
.stat-pending { border-left: 4px solid #e0a526; }
.stat-wide { grid-column: span 2; }

/* Táblázatok */
.table-wrap { overflow-x: auto; margin: 0 -1.25rem; padding: 0 1.25rem; }
table { width: 100%; border-collapse: collapse; font-size: .9rem; }
th { text-align: left; font-size: .75rem; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); font-weight: 700; padding: .5rem .6rem; border-bottom: 1px solid var(--line); white-space: nowrap; }
td { padding: .7rem .6rem; border-bottom: 1px solid var(--line); vertical-align: middle; }
tbody tr:last-child td { border-bottom: 0; }
.num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
tr.row-link { cursor: pointer; }
tr.row-link:hover td, tbody tr:hover td { background: #fafaf8; }
tr.inactive td { color: var(--muted); }
.actions-cell { width: 1%; white-space: nowrap; }
.actions { display: flex; gap: .4rem; justify-content: flex-end; }
.actions form { margin: 0; }
.empty { color: var(--muted); text-align: center; padding: 1.5rem 0; margin: 0; }

.tabs { display: flex; gap: .25rem; border-bottom: 1px solid var(--line); }
.tabs a { padding: .55rem .9rem; color: var(--ink-2); border-bottom: 2px solid transparent; margin-bottom: -1px; font-weight: 500; }
.tabs a:hover { text-decoration: none; color: var(--ink); }
.tabs a.active { color: var(--accent); border-color: var(--accent); font-weight: 700; }

.filters { display: flex; gap: .6rem; align-items: center; flex-wrap: wrap; }
.filters input[type=search] { flex: 1; min-width: 220px; }
.filters select { width: auto; }
.totals { display: flex; gap: 1rem; flex-wrap: wrap; }
.totals > div { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: .75rem 1rem; display: flex; flex-direction: column; }
.totals strong { font-size: 1.25rem; font-variant-numeric: tabular-nums; }

/* Részletek */
.detail-grid { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 1.25rem; align-items: start; }
.facts { display: grid; grid-template-columns: 150px 1fr; gap: .55rem 1rem; margin: 0; }
.facts dt { color: var(--muted); font-size: .85rem; font-weight: 600; }
.facts dd { margin: 0; }
.amount { font-variant-numeric: tabular-nums; }
.strong { font-weight: 700; font-size: 1.1rem; }
.doc iframe { width: 100%; height: 640px; border: 1px solid var(--line); border-radius: 8px; background: #f0f0ed; }
.doc img { max-width: 100%; border: 1px solid var(--line); border-radius: 8px; }
.decision { border-color: #c7d5e8; background: linear-gradient(#fbfcfe, #fff); }
.decision-forms { display: grid; grid-template-columns: 1fr 1fr; gap: 1rem; }
.timeline { list-style: none; margin: 0; padding: 0 0 0 1rem; border-left: 2px solid var(--line); display: flex; flex-direction: column; gap: .8rem; }
.timeline li { position: relative; font-size: .9rem; }
.timeline li::before { content: ""; position: absolute; left: -1.4rem; top: .4rem; width: 10px; height: 10px; border-radius: 50%; background: var(--line-2); }
.tl-approved::before { background: var(--ok) !important; }
.tl-rejected::before { background: var(--bad) !important; }
.tl-submitted::before { background: var(--accent) !important; }

/* Belépés */
body.bare { min-height: 100vh; display: grid; place-items: center; background: #111318; }
.bare-content { width: 100%; padding: 1.5rem; }
.auth-card { background: #fff; max-width: 420px; margin: 0 auto; border-radius: 14px; padding: 2rem; display: flex; flex-direction: column; gap: 1rem; box-shadow: 0 20px 60px rgba(0,0,0,.35); }
.auth-card h1 { font-size: 1.35rem; margin: 0; }
.auth-card p { margin: 0; }
.auth-brand { display: flex; gap: .75rem; align-items: center; }
.auth-brand .brand-mark { background: #111318; color: #fff; }
.auth-brand small { color: var(--muted); font-size: .78rem; }

@media (max-width: 980px) {
  .detail-grid, .decision-forms { grid-template-columns: 1fr; }
  .stat-wide { grid-column: auto; }
}
@media (max-width: 760px) {
  body.app { grid-template-columns: 1fr; }
  .sidebar { position: static; height: auto; }
  .facts { grid-template-columns: 1fr; gap: .1rem; }
  .facts dd { margin-bottom: .5rem; }
}

/* Besorolás, kifizetés */
.tag { display: inline-block; font-size: .72rem; font-weight: 700; padding: .1rem .5rem; border-radius: 5px; margin-right: .3rem; white-space: nowrap; }
.tag-cost { background: #eef0f3; color: #3b4250; }
.tag-investment { background: #ece6f8; color: #5b3b9a; }
.pay-overdue { background: var(--bad-soft); color: var(--bad); }
.pay-due_soon { background: var(--warn-soft); color: var(--warn); }
.pay-open { background: #eef0f3; color: #3b4250; }
.pay-paid { background: var(--ok-soft); color: var(--ok); }
.pay-closed { background: #eef0f3; color: var(--muted); }
.due-overdue { color: var(--bad); font-weight: 600; }
.due-due_soon { color: var(--warn); font-weight: 600; }
.due-open { color: var(--muted); }
.pill-bad { background: #e5484d; color: #fff; }
.stat-bad { border-left: 4px solid var(--bad); }
.stat-bad .stat-value { color: var(--bad); }
.card-alert { border-color: #f1c9b0; }
.subform { border-top: 1px solid var(--line); margin-top: 1rem; padding-top: 1rem; }
.subform h3 { margin: 0; font-size: .95rem; }
.inline-form { display: flex; gap: .6rem; align-items: center; flex-wrap: wrap; margin-top: .75rem; }
.inline-form input { flex: 1; min-width: 180px; width: auto; }
.card.inline-form { margin-top: 0; }
.rename { margin: 0; }
.rename input { border-color: transparent; background: transparent; font-weight: 600; padding: .35rem .5rem; }
.rename input:hover, .rename input:focus { border-color: var(--line-2); background: #fff; }
.linklike-dark { background: none; border: 0; padding: 0; font: inherit; color: var(--accent); cursor: pointer; }
.linklike-dark:hover { text-decoration: underline; }
.summary-grid { display: grid; grid-template-columns: minmax(220px, auto) 1fr; gap: 1.25rem; align-items: start; }
.summary-grid .totals { flex-direction: column; }
table.compact td { padding: .45rem .6rem; }
@media (max-width: 980px) { .summary-grid { grid-template-columns: 1fr; } }
.field { display: flex; flex-direction: column; gap: .35rem; }
.field-label { font-size: .88rem; font-weight: 600; color: var(--ink-2); }
.picker-row { display: flex; gap: .5rem; }
.picker-row select { flex: 1; }
.cat-add { display: flex; gap: .5rem; flex-wrap: wrap; padding: .75rem; background: var(--accent-soft); border-radius: 8px; }
.cat-add input { flex: 1; min-width: 200px; width: auto; }
.field .hint { margin: 0; }
.hint-error { color: var(--bad); font-weight: 600; }
