/* Harvest — nyugodt, meleg felület. Színek tokenként, világos és sötét módban. */

:root {
  --bg: #f6f3ec;
  --surface: #fffdf8;
  --surface-2: #f0ebe0;
  --ink: #2a2823;
  --ink-2: #6b665b;
  --line: #e2dccd;
  --accent: #a8691a;
  --accent-ink: #ffffff;
  --accent-soft: #f4e6cf;
  --ok: #3f7a52;
  --ok-soft: #e1efe4;
  --warn: #9a6a00;
  --warn-soft: #fbf0d6;
  --late: #b03a2e;
  --late-soft: #f8e1dd;
  --radius: 12px;
  --shadow: 0 1px 2px rgba(60, 50, 30, .06), 0 2px 8px rgba(60, 50, 30, .05);
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #1b1a17;
    --surface: #24221e;
    --surface-2: #2d2a25;
    --ink: #ece7dc;
    --ink-2: #a8a194;
    --line: #3a372f;
    --accent: #e0a24a;
    --accent-ink: #1b1a17;
    --accent-soft: #3d3020;
    --ok: #7cc293;
    --ok-soft: #22352a;
    --warn: #e6b54d;
    --warn-soft: #3a3020;
    --late: #f08a7e;
    --late-soft: #3d2420;
    --shadow: none;
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font: 16px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}

a { color: var(--accent); text-underline-offset: 2px; }
h1, h2, h3 { line-height: 1.25; margin: 0 0 .5rem; }
h1 { font-size: 1.6rem; letter-spacing: -.01em; }
h2 { font-size: 1.15rem; }
h3 { font-size: 1rem; }
p { margin: 0 0 .75rem; }
code { background: var(--surface-2); padding: 1px 5px; border-radius: 4px; font-size: .9em; }

.muted { color: var(--ink-2); }
.small { font-size: .875rem; }
.num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.danger-text { color: var(--late); }

/* ---------------------------------------------------------------- fejléc */

.topbar {
  display: flex;
  align-items: center;
  gap: 1rem;
  padding: .6rem 1rem;
  background: var(--surface);
  border-bottom: 1px solid var(--line);
  position: sticky;
  top: 0;
  z-index: 10;
}
.brand {
  display: flex; align-items: center; gap: .5rem;
  font-weight: 700; color: var(--ink); text-decoration: none; white-space: nowrap;
}
.brand-mark {
  display: inline-block; width: 18px; height: 18px; border-radius: 50%;
  background: radial-gradient(circle at 35% 35%, #e9b24f, var(--accent));
}
.mainnav { display: flex; gap: .15rem; overflow-x: auto; flex: 1; scrollbar-width: none; }
.mainnav::-webkit-scrollbar { display: none; }
.mainnav a {
  padding: .4rem .7rem; border-radius: 8px; color: var(--ink-2);
  text-decoration: none; white-space: nowrap; font-size: .95rem;
}
.mainnav a:hover { background: var(--surface-2); color: var(--ink); }
.mainnav a.active { background: var(--accent-soft); color: var(--ink); font-weight: 600; }
.logout { margin: 0; }

/* ---------------------------------------------------------------- oldal */

.page { max-width: 1040px; margin: 0 auto; padding: 1.25rem 1rem 3rem; }
.page.narrow { max-width: 420px; padding-top: 12vh; }

.pagehead {
  display: flex; align-items: center; justify-content: space-between;
  flex-wrap: wrap; gap: .75rem; margin-bottom: 1rem;
}
.pagehead h1 { margin: 0; }
.pagehead p { margin: 0; }

.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 1rem 1.15rem;
  margin-bottom: 1rem;
}
.card.flush { padding: 0; overflow-x: auto; }
.card.empty { text-align: center; padding: 2rem 1rem; color: var(--ink-2); }
.card.empty p { margin: 0; }
.card.calm { background: var(--ok-soft); border-color: transparent; }
.card.calm p { margin: 0; }
.warnbox { background: var(--warn-soft); border-color: transparent; }
.warnbox p:last-child { margin-bottom: 0; }

.hint { color: var(--ink-2); font-size: .9rem; margin: -.25rem 0 1rem; }

/* ---------------------------------------------------------------- üzenetek */

.flash { padding: .65rem .9rem; border-radius: 10px; margin-bottom: 1rem; }
.flash-ok { background: var(--ok-soft); }
.flash-info { background: var(--surface-2); }
.flash-warn { background: var(--warn-soft); }
.flash-error { background: var(--late-soft); color: var(--ink); }

/* ---------------------------------------------------------------- gombok */

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: .35rem;
  padding: .5rem .9rem; min-height: 40px;
  border: 1px solid var(--line); border-radius: 9px;
  background: var(--surface); color: var(--ink);
  font: inherit; font-weight: 500; text-decoration: none; cursor: pointer;
}
.btn:hover { background: var(--surface-2); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.btn.primary:hover { filter: brightness(1.05); }
.btn.danger { color: var(--late); }
.btn.small { padding: .3rem .65rem; min-height: 32px; font-size: .875rem; }
.btn:disabled { opacity: .6; cursor: default; }

.linkbtn {
  background: none; border: 0; padding: .2rem .3rem; color: var(--accent);
  font: inherit; font-size: .9rem; cursor: pointer; text-decoration: underline; text-underline-offset: 2px;
}
.linkbtn.danger { color: var(--late); }

.chip {
  display: inline-block; padding: .25rem .6rem; border-radius: 999px;
  border: 1px solid var(--line); background: var(--surface);
  color: var(--ink-2); font: inherit; font-size: .8rem; cursor: pointer; list-style: none;
}
.chip:hover { background: var(--surface-2); color: var(--ink); }
summary.chip::-webkit-details-marker { display: none; }

button:focus-visible, a:focus-visible, summary:focus-visible, input:focus-visible, select:focus-visible {
  outline: 2px solid var(--accent); outline-offset: 2px;
}

/* ---------------------------------------------------------------- űrlapok */

label { display: flex; flex-direction: column; gap: .3rem; font-size: .9rem; font-weight: 500; }
label .muted { font-weight: 400; }
input, select {
  font: inherit; font-weight: 400; color: var(--ink);
  padding: .5rem .65rem; min-height: 40px;
  border: 1px solid var(--line); border-radius: 8px; background: var(--bg);
  width: 100%;
}
input[type="checkbox"] { width: 18px; height: 18px; min-height: 0; accent-color: var(--accent); }
label.check { flex-direction: row; align-items: center; gap: .5rem; font-weight: 400; }

.stack { display: flex; flex-direction: column; gap: .9rem; }
.stack-tight { display: flex; flex-direction: column; gap: .5rem; margin-bottom: .75rem; }
.grid-form { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: .8rem 1rem; align-items: end; }
.grid-form .span2 { grid-column: 1 / -1; }
.grid-form p { margin: 0; }
.actions { display: flex; gap: .5rem; }
.inline { display: inline; margin: 0; }
.inline-form { display: flex; gap: .5rem; align-items: end; margin-top: .5rem; }
.code-input { font-size: 1.4rem; letter-spacing: .2em; text-align: center; font-variant-numeric: tabular-nums; }

details.addbox { margin-top: .75rem; border-top: 1px dashed var(--line); padding-top: .75rem; }
details.addbox > summary { cursor: pointer; color: var(--accent); font-weight: 500; }
details.addbox[open] > summary { margin-bottom: .75rem; }
.card > details.addbox:first-child { margin-top: 0; padding-top: 0; border-top: 0; }
details.inline { position: relative; display: inline-block; }
details.inline > summary { list-style: none; cursor: pointer; }
details.inline > summary::-webkit-details-marker { display: none; }
.popover {
  position: absolute; z-index: 5; right: 0; top: calc(100% + 6px);
  width: min(260px, 80vw); padding: .85rem;
  background: var(--surface); border: 1px solid var(--line); border-radius: 10px;
  box-shadow: 0 8px 24px rgba(0, 0, 0, .14);
}

/* ---------------------------------------------------------------- táblázatok */

.table { width: 100%; border-collapse: collapse; }
.table th, .table td { padding: .6rem .75rem; text-align: left; border-bottom: 1px solid var(--line); vertical-align: top; }
.table th { font-size: .8rem; font-weight: 600; color: var(--ink-2); text-transform: uppercase; letter-spacing: .03em; }
.table th.num, .table td.num { text-align: right; }
.table tbody tr:last-child td { border-bottom: 0; }
.table tfoot td { font-weight: 700; border-top: 2px solid var(--line); border-bottom: 0; }
.table.compact td { padding: .4rem .5rem; }
.card > .table th:first-child, .card > .table td:first-child { padding-left: 0; }
.card > .table th:last-child, .card > .table td:last-child { padding-right: 0; }
.card.flush > .table th:first-child, .card.flush > .table td:first-child { padding-left: 1.15rem; }
.card.flush > .table th:last-child, .card.flush > .table td:last-child { padding-right: 1.15rem; }
tr.inactive td { color: var(--ink-2); }
tr.row-late td { background: var(--late-soft); }
.row-actions { white-space: nowrap; text-align: right; }
.row-actions > * { margin-left: .25rem; }
.scroll-x { overflow-x: auto; }

ul.plain { list-style: none; padding: 0; margin: 0; }
ul.plain li { padding: .35rem 0; border-bottom: 1px solid var(--line); }
ul.plain li:last-child { border-bottom: 0; }

/* ---------------------------------------------------------------- címkék, állapotok */

.tag {
  display: inline-block; margin-left: .35rem; padding: 0 .45rem; border-radius: 6px;
  background: var(--surface-2); color: var(--ink-2); font-size: .75rem; font-weight: 600; vertical-align: 1px;
}
.tag-new { background: var(--accent-soft); color: var(--accent); }
.tag-ok { background: var(--ok-soft); color: var(--ok); }

.status { display: inline-block; padding: .15rem .55rem; border-radius: 999px; font-size: .8rem; font-weight: 600; white-space: nowrap; }
.status-paid { background: var(--ok-soft); color: var(--ok); }
.status-open { background: var(--surface-2); color: var(--ink-2); }
.status-overdue { background: var(--late-soft); color: var(--late); }

.tabs { display: flex; gap: .25rem; background: var(--surface-2); padding: .2rem; border-radius: 10px; }
.tabs a { padding: .35rem .8rem; border-radius: 8px; text-decoration: none; color: var(--ink-2); font-size: .9rem; }
.tabs a.active { background: var(--surface); color: var(--ink); font-weight: 600; box-shadow: var(--shadow); }

/* ---------------------------------------------------------------- belépés */

.login-card { padding: 1.75rem; }
.login-title { display: flex; align-items: center; gap: .6rem; font-size: 1.4rem; margin-bottom: 1.25rem; }

/* ---------------------------------------------------------------- kezdőlap */

.tiles { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: .75rem; margin-bottom: 1rem; }
.tile {
  display: flex; flex-direction: column; gap: .15rem;
  padding: .9rem 1rem; border-radius: var(--radius);
  background: var(--surface); border: 1px solid var(--line); border-left-width: 4px;
  color: var(--ink); text-decoration: none; box-shadow: var(--shadow);
}
.tile:hover { background: var(--surface-2); }
.tile-label { font-size: .8rem; color: var(--ink-2); text-transform: uppercase; letter-spacing: .04em; font-weight: 600; }
.tile-value { font-size: 1.1rem; font-weight: 650; }
.tile-sub { font-size: .85rem; color: var(--late); font-weight: 600; }
.tile-ok { border-left-color: var(--ok); }
.tile-warn { border-left-color: var(--warn); }
.tile-late { border-left-color: var(--late); }

ul.todo { list-style: none; margin: 0; padding: 0; }
ul.todo li {
  display: flex; flex-wrap: wrap; gap: .25rem .75rem; align-items: baseline;
  padding: .55rem 0 .55rem .75rem; border-left: 3px solid var(--warn); margin-bottom: .4rem;
}
ul.todo li.late { border-left-color: var(--late); }
ul.todo li a { font-weight: 600; }

.codes { columns: 2; list-style: none; padding: 0; font: 1.05rem/1.9 ui-monospace, Menlo, Consolas, monospace; }

/* ---------------------------------------------------------------- naptár */

.weeknav { display: flex; gap: .35rem; }
.weekhead { display: flex; justify-content: space-between; align-items: center; flex-wrap: wrap; gap: .75rem; border-left: 4px solid var(--warn); }
.weekhead h2 { margin: 0; }
.weekhead p { margin: 0; }
.weekhead.is-closed { border-left-color: var(--ok); }
.weekhead.is-late { border-left-color: var(--late); }
.weekstate { display: flex; align-items: center; gap: .6rem; flex-wrap: wrap; }
.deadline { font-size: .9rem; color: var(--ink-2); }
.is-late .deadline { color: var(--late); font-weight: 600; }

.week { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: .6rem; margin-bottom: 1rem; }
.day { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: .65rem; min-height: 120px; }
.day.today { border-color: var(--accent); }
.day h3 { font-size: .85rem; text-transform: uppercase; letter-spacing: .04em; margin-bottom: .5rem; }
.empty-day { margin: 0; }

.sess {
  border-radius: 9px; padding: .5rem .55rem; margin-bottom: .45rem;
  background: var(--accent-soft); border-left: 3px solid var(--accent);
}
.sess-main { display: flex; gap: .4rem; align-items: baseline; }
.sess-time { font-variant-numeric: tabular-nums; font-weight: 700; font-size: .9rem; }
.sess-name { font-weight: 600; overflow-wrap: anywhere; }
.sess-meta { font-size: .8rem; color: var(--ink-2); margin-top: .1rem; }
.sess-meta .tag { margin-left: 0; }
.sess-actions { display: flex; flex-wrap: wrap; gap: .3rem; margin-top: .4rem; }
.sess.status-held { background: var(--ok-soft); border-left-color: var(--ok); }
.sess.status-missed, .sess.status-cancelled { background: var(--surface-2); border-left-color: var(--line); }
.sess.status-missed .sess-name, .sess.status-cancelled .sess-name { text-decoration: line-through; color: var(--ink-2); }
.sess.status-missed .sess-status { color: var(--late); font-weight: 600; }

/* ---------------------------------------------------------------- számlázás */

.bill { border-left: 4px solid var(--warn); }
.bill.is-late { border-left-color: var(--late); }
.bill-head { display: flex; justify-content: space-between; align-items: flex-start; gap: .75rem; flex-wrap: wrap; margin-bottom: .75rem; }
.bill-head h2, .bill-head p { margin: 0; }
.bill-grid { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1.3fr); gap: 1.25rem; }
.bill-grid h3 { font-size: .8rem; text-transform: uppercase; letter-spacing: .04em; color: var(--ink-2); }
.copylist { display: grid; grid-template-columns: auto 1fr; gap: .25rem .75rem; margin: 0; }
.copylist dt { color: var(--ink-2); font-size: .875rem; }
.copylist dd { margin: 0; user-select: all; overflow-wrap: anywhere; }
.record-form { margin-top: 1rem; padding-top: 1rem; border-top: 1px dashed var(--line); }

.danger-zone .row-actions { text-align: left; }
.danger-zone .row-actions > * { margin: 0 .5rem 0 0; }

/* ---------------------------------------------------------------- mobil */

@media (max-width: 860px) {
  .week { grid-template-columns: 1fr; }
  .day { min-height: 0; }
  .bill-grid { grid-template-columns: 1fr; }
}

@media (max-width: 640px) {
  .topbar { flex-wrap: wrap; gap: .35rem .75rem; padding: .5rem .75rem; }
  .mainnav { order: 3; flex-basis: 100%; }
  .logout { margin-left: auto; }
  .page { padding: 1rem .75rem 3rem; }
  .tiles { grid-template-columns: 1fr; }
  .grid-form { grid-template-columns: 1fr; }
  .hide-sm { display: none; }
  .row-actions { white-space: normal; }
  .popover { right: auto; left: 0; }
  h1 { font-size: 1.4rem; }
}
