:root {
  --yellow: #ffde00;
  --yellow-soft: #fff6b8;
  --black: #111111;
  --ink: #1c1917;
  --muted: #6b6560;
  --line: #e7e3dc;
  --bg: #f6f4ef;
  --card: #ffffff;
  --red: #d64545;
  --orange: #e08a1e;
  --green: #3f9a5a;
  --radius: 14px;
  color-scheme: light;
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  font-family: ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  color: var(--ink);
  background: var(--bg);
  line-height: 1.45;
}
.icon { width: 20px; height: 20px; flex: none; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }

/* ---------- Belépés ---------- */
body.login {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 16px;
  background: var(--black) radial-gradient(circle at 50% 0%, #2a2400 0%, var(--black) 60%);
}
.login-box {
  width: 100%;
  max-width: 380px;
  background: var(--card);
  border-radius: 20px;
  padding: 36px 32px 32px;
  text-align: center;
  box-shadow: 0 20px 60px rgba(0, 0, 0, .45);
  border-top: 6px solid var(--yellow);
}
.login-box .logo { width: 120px; height: auto; }
.login-box h1 { margin: 12px 0 2px; font-size: 1.5rem; }
.login-box .sub { margin: 0 0 24px; color: var(--muted); }
.login-box form { display: grid; gap: 14px; text-align: left; }
.login-box label { display: grid; gap: 6px; font-size: .9rem; font-weight: 600; }
.login-box input {
  font: inherit;
  padding: 11px 12px;
  border: 1.5px solid var(--line);
  border-radius: 10px;
  background: #fff;
}
.login-box input:focus { outline: none; border-color: var(--black); box-shadow: 0 0 0 3px var(--yellow); }
.login-box button {
  margin-top: 6px;
  font: inherit;
  font-weight: 700;
  padding: 12px;
  border: 0;
  border-radius: 10px;
  background: var(--yellow);
  color: var(--black);
  cursor: pointer;
}
.login-box button:hover { filter: brightness(.95); }
.login-box button:focus-visible { outline: 3px solid var(--black); outline-offset: 2px; }
.error {
  margin: 0 0 16px;
  padding: 10px 12px;
  border-radius: 10px;
  background: #fdecec;
  color: #8f1f1f;
  font-size: .9rem;
}

/* ---------- Alkalmazás ---------- */
body.app { display: grid; grid-template-columns: 250px 1fr; min-height: 100vh; }
.sidebar {
  position: sticky;
  top: 0;
  height: 100vh;
  display: flex;
  flex-direction: column;
  background: var(--black);
  color: #d9d6cf;
  padding: 18px 12px;
}
.brand { display: flex; align-items: center; gap: 10px; padding: 4px 8px 20px; color: #fff; text-decoration: none; font-weight: 800; letter-spacing: .02em; }
.brand small { display: block; font-weight: 500; color: #9d988f; letter-spacing: 0; font-size: .75rem; }
.sidebar nav { display: grid; gap: 2px; overflow-y: auto; }
.sidebar nav a {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 12px;
  border-radius: 10px;
  color: inherit;
  text-decoration: none;
  font-size: .95rem;
}
.sidebar nav a:hover { background: #1f1f1f; color: #fff; }
.sidebar nav a.active { background: var(--yellow); color: var(--black); font-weight: 700; }
.user { margin-top: auto; display: flex; align-items: center; gap: 10px; padding: 14px 8px 4px; border-top: 1px solid #262626; }
.avatar { width: 34px; height: 34px; border-radius: 50%; display: grid; place-items: center; background: var(--yellow); color: var(--black); font-weight: 800; flex: none; }
.user .name { flex: 1; color: #fff; font-size: .9rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.user form { margin: 0; }
button.link { font: inherit; font-size: .85rem; background: none; border: 0; color: #9d988f; cursor: pointer; padding: 4px; }
button.link:hover { color: var(--yellow); }

.content { padding: 28px 36px 48px; min-width: 0; }
.topbar h1 { margin: 0 0 4px; font-size: 1.6rem; }
.greeting { margin: 0 0 24px; font-size: 1.05rem; }
.greeting span { display: block; color: var(--muted); font-size: .9rem; }

.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 20px; }
.card h2 { margin: 0 0 14px; font-size: 1.05rem; }

.stats { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 16px; margin-bottom: 16px; }
.stat { display: grid; gap: 2px; border-top: 4px solid var(--yellow); }
.stat .label { color: var(--muted); font-size: .85rem; }
.stat strong { font-size: 1.9rem; line-height: 1.2; font-variant-numeric: tabular-nums; }
.stat .hint { color: var(--muted); font-size: .8rem; }

.grid { display: grid; grid-template-columns: 3fr 2fr; gap: 16px; }
.tasks, .events { list-style: none; margin: 0; padding: 0; }
.tasks li { display: flex; align-items: center; gap: 12px; padding: 11px 0; border-top: 1px solid var(--line); }
.tasks li:first-child { border-top: 0; }
.tasks .task { flex: 1; }
.tasks .due { color: var(--muted); font-size: .85rem; white-space: nowrap; }
.dot { width: 9px; height: 9px; border-radius: 50%; flex: none; }
.dot.high { background: var(--red); }
.dot.mid { background: var(--orange); }
.dot.low { background: var(--green); }
.events li { display: flex; gap: 14px; align-items: center; padding: 10px 0; border-top: 1px solid var(--line); }
.events li:first-child { border-top: 0; }
.events .date { width: 48px; flex: none; text-align: center; background: var(--yellow-soft); border-radius: 10px; padding: 6px 0; font-size: .75rem; text-transform: uppercase; color: var(--muted); }
.events .date b { display: block; font-size: 1.15rem; color: var(--black); }
.events small { display: block; color: var(--muted); }

.empty { text-align: center; padding: 56px 20px; color: var(--muted); }
.empty .icon { width: 40px; height: 40px; color: var(--black); }
.empty h2 { margin: 12px 0 4px; color: var(--ink); }
.demo-note { margin-top: 20px; color: var(--muted); font-size: .8rem; }

/* ---------- Kisebb képernyők ---------- */
@media (max-width: 1100px) {
  .stats { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .grid { grid-template-columns: 1fr; }
}
@media (max-width: 760px) {
  body.app { grid-template-columns: 1fr; }
  .sidebar { position: static; height: auto; padding: 12px 16px; }
  .brand { padding: 0 0 10px; }
  .sidebar nav { display: flex; overflow-x: auto; gap: 4px; padding-bottom: 4px; }
  .sidebar nav a { white-space: nowrap; padding: 8px 10px; }
  .sidebar nav a .icon { width: 18px; height: 18px; }
  .user { padding-top: 10px; }
  .content { padding: 20px 16px 40px; }
  .stats { gap: 12px; }
  .stat strong { font-size: 1.5rem; }
}

/* ---------- Közös elemek ---------- */
a { color: inherit; }
.content a:not(.btn):not(.card) { color: #6b5a00; text-decoration-color: #e6c800; text-underline-offset: 2px; }
.content a:not(.btn):not(.card):hover { color: var(--black); }
a.card { text-decoration: none; color: inherit; }
a.card.stat:hover { border-color: #d6cfbf; box-shadow: 0 2px 10px rgba(0,0,0,.05); }
.muted { color: var(--muted); }
.mono { font-family: ui-monospace, "SF Mono", Menlo, Consolas, monospace; font-size: .92em; letter-spacing: .01em; }
.lead { margin: 0 0 20px; color: var(--muted); max-width: 70ch; }
.back { margin: 0 0 14px; font-size: .9rem; }
.meta { margin: 16px 0 0; color: var(--muted); font-size: .8rem; }
.content > .card + .card, .content > section + section { margin-top: 16px; }
.card-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; margin-bottom: 14px; }
.card-head h2 { margin: 0; }

.flash { margin: 0 0 14px; padding: 10px 14px; border-radius: 10px; font-size: .92rem; }
.flash.ok { background: #e8f5ec; color: #1f5f33; }
.flash.error { background: #fdecec; color: #8f1f1f; }
.flash.info { background: var(--yellow-soft); color: #5c4f00; }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  font: inherit; font-weight: 600; font-size: .92rem;
  padding: 9px 16px; border-radius: 10px;
  border: 1.5px solid var(--line); background: #fff; color: var(--ink);
  cursor: pointer; text-decoration: none; white-space: nowrap;
}
.btn:hover { border-color: #cfc8b8; }
.btn.primary { background: var(--yellow); border-color: var(--yellow); color: var(--black); }
.btn.primary:hover { filter: brightness(.96); }
.btn:disabled { opacity: .45; cursor: not-allowed; filter: none; }
.btn:focus-visible, button.link:focus-visible { outline: 3px solid var(--black); outline-offset: 2px; }
.content button.link { color: #6b5a00; font-size: .9rem; }
.content button.link:hover { color: var(--black); text-decoration: underline; }
button.link.danger, .content button.link.danger { color: var(--red); }

label { display: grid; gap: 5px; font-size: .88rem; font-weight: 600; }
input:not([type=checkbox]):not([type=file]), select {
  font: inherit; font-weight: 400; font-size: .95rem;
  padding: 9px 11px; border: 1.5px solid var(--line); border-radius: 10px; background: #fff; color: var(--ink);
  min-width: 0; width: 100%;
}
input:focus, select:focus { outline: none; border-color: var(--black); box-shadow: 0 0 0 3px var(--yellow); }
input[readonly] { background: #f7f6f2; }
.has-error input, .has-error select { border-color: var(--red); }
.field-error { color: var(--red); font-weight: 500; font-size: .82rem; }
input[type=checkbox] { width: 17px; height: 17px; accent-color: var(--black); }
fieldset { border: 0; padding: 0; margin: 0; }
legend { font-size: .88rem; font-weight: 600; margin-bottom: 6px; padding: 0; }

.stack { display: grid; gap: 14px; }
.row { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.actions { display: flex; gap: 10px; flex-wrap: wrap; }
.inline-form { display: flex; gap: 12px; align-items: end; flex-wrap: wrap; margin-top: 14px; }
.inline-form label { flex: 1 1 180px; }
.inline-form label.grow { flex: 3 1 260px; }
.danger-zone { margin-top: 18px; padding-top: 14px; border-top: 1px dashed var(--line); }

.table-wrap { overflow-x: auto; margin: 0 -4px; }
.table { width: 100%; border-collapse: collapse; font-size: .92rem; }
.table th { text-align: left; font-size: .78rem; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); font-weight: 600; padding: 8px 4px; border-bottom: 1.5px solid var(--line); white-space: nowrap; }
.table td { padding: 10px 4px; border-bottom: 1px solid var(--line); vertical-align: middle; }
.table tr:last-child td { border-bottom: 0; }
.table .num { text-align: right; white-space: nowrap; font-variant-numeric: tabular-nums; }
.table tr.inactive td { color: var(--muted); }
.table form { margin: 0; }

.badge { display: inline-block; padding: 3px 9px; border-radius: 999px; font-size: .75rem; font-weight: 700; white-space: nowrap; }
.badge.uj { background: #fdeede; color: #8a4a00; }
.badge.utalhato { background: #e3f3e8; color: #1f5f33; }
.badge.csomagban { background: #111; color: var(--yellow); }
.badge.off { background: #eeebe5; color: var(--muted); }

.org h2 small { font-weight: 500; color: var(--muted); }
.org-edit summary { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; cursor: pointer; list-style: none; margin-bottom: 8px; }
.org-edit summary::-webkit-details-marker { display: none; }
.org-edit summary h2 { margin: 0; }
.org-edit summary .link { color: #6b5a00; font-size: .85rem; }
.org-edit[open] summary .link { display: none; }

.upload { display: grid; grid-template-columns: minmax(180px, 260px) 1fr auto; gap: 14px; align-items: stretch; }
.upload > label:first-of-type { align-self: start; }
.upload > .btn { align-self: end; }
.dropzone { position: relative; display: grid; place-items: center; text-align: center; min-height: 110px; padding: 16px; border: 2px dashed #d6cfbf; border-radius: 12px; background: #fbfaf6; cursor: pointer; font-weight: 400; transition: background .15s, border-color .15s; }
.dropzone:hover, .dropzone.over { border-color: var(--black); background: var(--yellow-soft); }
.dropzone input[type=file] { position: absolute; inset: 0; opacity: 0; cursor: pointer; }
.dz-text small { color: var(--muted); }
.dz-files:not(:empty) { margin-top: 6px; font-size: .85rem; font-weight: 600; }

.filters { display: flex; gap: 8px; flex-wrap: wrap; }
.filters select { width: auto; padding: 6px 10px; font-size: .88rem; }

.invoice-layout { display: grid; grid-template-columns: minmax(0, 1.2fr) minmax(320px, 1fr); gap: 16px; align-items: start; }
.preview { position: sticky; top: 16px; }
.preview iframe, .preview img { display: block; width: 100%; height: calc(100vh - 180px); min-height: 480px; border: 1px solid var(--line); border-radius: 10px; background: #f0eee8; }
.preview img { height: auto; min-height: 0; }
.filename { font-size: .95rem !important; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 60%; }

.facts { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 12px; margin: 0 0 16px; }
.facts div { background: #fbfaf6; border: 1px solid var(--line); border-radius: 10px; padding: 12px; }
.facts dt { font-size: .78rem; color: var(--muted); text-transform: uppercase; letter-spacing: .04em; }
.facts dd { margin: 4px 0 0; }

@media (max-width: 1100px) {
  .invoice-layout { grid-template-columns: 1fr; }
  .preview { position: static; }
  .preview iframe { height: 70vh; }
  .facts { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 760px) {
  .upload { grid-template-columns: 1fr; }
  .row { grid-template-columns: 1fr; }
  .filename { max-width: 100%; }
}

/* ---------- AI-kiolvasás ---------- */
.badge.ellenorzendo { background: var(--yellow); color: var(--black); }
.badge.ai { background: #e8eefc; color: #28407a; }
.warn { color: #b25e00; cursor: help; }
.flash.warn { background: #fff3e0; color: #6b3a00; }
.flash.warn ul { margin: 6px 0 0; padding-left: 20px; }
.flash.warn li + li { margin-top: 2px; }
.date-change { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; margin: 0; }
.date-change input { width: auto; padding: 5px 8px; }
