:root {
  --bg: #2c2c2c;
  --clipboard: #1a1a1a;
  --paper: #f7f4ec;
  --paper-ink: #1a1a1a;
  --paper-line: #222;
  --paper-head: #ebe6da;
  --muted: #6b6560;
  --accent: #2a4a7a;
  --danger: #a33;
  --ok: #2a7a4a;
  --gold: #8a7040;
  --safe: env(safe-area-inset-bottom, 0px);
  --font: "Segoe UI", Candara, Calibri, sans-serif;
  --font-sheet: "Segoe UI", Candara, Calibri, sans-serif;
}

* { box-sizing: border-box; }
html, body {
  margin: 0;
  min-height: 100%;
  color: #eee;
  font-family: var(--font);
  background:
    radial-gradient(ellipse 80% 50% at 50% 0%, #3a3a3a, transparent 60%),
    var(--bg);
}

.app {
  width: min(960px, 100%);
  margin: 0 auto;
  padding: 14px 12px calc(28px + var(--safe));
}

.view-tabs {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 6px;
  margin-bottom: 14px;
}
.view-tabs .tab {
  border: 1px solid #555;
  background: transparent;
  color: #bbb;
  border-radius: 8px;
  padding: 10px 8px;
  font-weight: 700;
  font-size: 0.88rem;
  cursor: pointer;
}
.view-tabs .tab.active {
  background: rgba(42, 74, 122, 0.45);
  border-color: #6a8ec0;
  color: #fff;
}
.admin-detail {
  margin-top: 8px;
  padding-top: 4px;
}
.admin-detail #adminDetailClose {
  margin-bottom: 10px;
}
.driver-card .meta b { color: #d4b56a; }

.top {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 10px;
  margin-bottom: 14px;
}
.top-right {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 8px;
}
.lang-flags {
  display: flex;
  align-items: center;
  gap: 4px;
}
.lang-flag {
  appearance: none;
  border: 1px solid transparent;
  background: transparent;
  padding: 4px 6px;
  margin: 0;
  font-size: 1.35rem;
  line-height: 1;
  cursor: pointer;
  border-radius: 8px;
  opacity: 0.45;
  filter: grayscale(0.35);
  transition: opacity 0.15s ease, transform 0.15s ease, border-color 0.15s ease, background 0.15s ease;
}
.lang-flag:hover {
  opacity: 0.85;
  filter: none;
  background: rgba(255, 255, 255, 0.06);
}
.lang-flag.active {
  opacity: 1;
  filter: none;
  border-color: rgba(212, 181, 106, 0.55);
  background: rgba(212, 181, 106, 0.12);
  transform: scale(1.08);
}
.lang-wrap {
  display: none;
}
.lang-wrap select {
  width: auto;
  min-width: 110px;
  padding: 6px 8px;
  font-size: 0.85rem;
  border-radius: 6px;
  border: 1px solid #555;
  background: #222;
  color: #eee;
}
.brand {
  display: block;
  font-size: 1.25rem;
  letter-spacing: 0.01em;
}
.top em {
  display: block;
  color: #aaa;
  font-style: normal;
  font-size: 0.85rem;
  margin-top: 2px;
}

.panel.login {
  background: #333;
  border: 1px solid #555;
  border-radius: 12px;
  padding: 18px;
}
.panel.login h1 { margin: 0 0 6px; font-size: 1.2rem; }
.panel.login label,
.dlg-body label {
  display: block;
  margin: 12px 0 6px;
  color: #aaa;
  font-size: 0.82rem;
}
.panel.login label:first-of-type { margin-top: 14px; }
input, textarea, select {
  width: 100%;
  padding: 11px 12px;
  border-radius: 8px;
  border: 1px solid #555;
  background: #1e1e1e;
  color: #eee;
  font-size: 1rem;
}
textarea { resize: vertical; }
input:focus, textarea:focus, select:focus {
  outline: none;
  border-color: #6a8ec0;
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  border: none;
  border-radius: 8px;
  padding: 12px 16px;
  font-weight: 700;
  font-size: 0.95rem;
  cursor: pointer;
  text-decoration: none;
}
.btn.sm { padding: 7px 10px; font-size: 0.82rem; }
.btn.primary { background: var(--accent); color: #fff; width: 100%; margin-top: 14px; }
.btn.ghost {
  background: transparent;
  color: #eee;
  border: 1px solid #555;
}
.btn.danger { color: #f88; border-color: rgba(170, 50, 50, 0.5); }
.btn.danger:not(.ghost) {
  background: var(--danger);
  color: #fff;
  border: none;
}

.export-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  margin: 12px 0 18px;
}
.export-row .btn { width: 100%; margin: 0; }
.tools-row {
  grid-template-columns: 1.15fr 1fr 1fr;
}
.action-duo {
  display: grid;
  grid-template-columns: 1.3fr 1fr;
  gap: 8px;
  margin-top: 4px;
}
.action-duo .btn { width: 100%; margin: 0; }
.btn.accent {
  border-color: #8a7040;
  color: #e8d5a0;
  background: rgba(138, 112, 64, 0.18);
}
.btn.accent:hover { background: rgba(138, 112, 64, 0.32); }

.section-title {
  margin: 0 0 10px;
  font-size: 0.95rem;
  color: #aaa;
  font-weight: 600;
}

/* --- Papír fejléc --- */
.card-sheet.sheet-head {
  background: var(--paper);
  color: var(--paper-ink);
  border: 1px solid #888;
  border-radius: 4px;
  padding: 12px 14px;
  display: flex;
  gap: 20px;
  flex-wrap: wrap;
  margin-bottom: 12px;
  font-family: var(--font-sheet);
  box-shadow: 0 8px 24px rgba(0,0,0,.35);
}
.sheet-head .line {
  flex: 1;
  min-width: 160px;
  border-bottom: 1px solid #333;
  padding: 2px 0 6px;
  font-size: 1rem;
}
.sheet-head .lbl {
  font-weight: 800;
  margin-right: 8px;
  letter-spacing: 0.02em;
}

.month-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 12px;
}
.month-bar strong { font-size: 1.05rem; }

.totals {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
  margin-bottom: 12px;
}
.totals > div {
  background: #333;
  border: 1px solid #555;
  border-radius: 10px;
  padding: 10px 12px;
}
.totals span {
  display: block;
  color: #aaa;
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}
.totals strong {
  font-size: 1.2rem;
  color: #d4b56a;
}

.live-panel {
  background: var(--paper);
  color: var(--paper-ink);
  border: 2px solid #444;
  border-radius: 6px;
  padding: 14px;
  margin: 12px 0;
  box-shadow: 0 8px 24px rgba(0,0,0,.3);
  font-family: var(--font-sheet);
}
.live-head {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  flex-wrap: wrap;
  margin-bottom: 10px;
}
.live-badge {
  display: inline-block;
  background: var(--accent);
  color: #fff;
  font-size: 0.68rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  padding: 3px 8px;
  border-radius: 4px;
  margin-right: 8px;
  vertical-align: middle;
}
.live-times {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 2px;
  color: var(--muted);
  font-size: 0.85rem;
}
.live-times b { color: var(--paper-ink); }
.bau-label {
  margin: 0 0 6px;
  font-size: 0.75rem;
  font-weight: 700;
  text-transform: uppercase;
  color: var(--muted);
}
.live-stops {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 4px 6px;
  margin-bottom: 12px;
  min-height: 40px;
  border: 1px solid #bbb;
  background: #fff;
  padding: 8px 10px;
}
.stop-chip {
  text-align: left;
  background: #f3f3f3;
  border: 1px solid #ccc;
  border-radius: 6px;
  padding: 6px 10px;
  color: var(--paper-ink);
  cursor: pointer;
  display: inline-flex;
  flex-direction: column;
  gap: 1px;
  width: auto;
  max-width: 100%;
  font-family: inherit;
  font-size: 0.9rem;
}
.stop-chip:hover { background: #eaeaea; border-color: #999; }
.stop-sep {
  color: #888;
  font-weight: 700;
  user-select: none;
  padding: 0 2px;
}
.stop-chip span { color: var(--muted); font-size: 0.78rem; }
.close-summary {
  margin: 0 0 12px;
  padding: 10px 12px;
  border: 1px solid #ccc;
  background: #f7f7f7;
  font-size: 0.9rem;
  color: #333;
  line-height: 1.4;
}
.close-summary b { font-weight: 700; color: #111; }
.place-suggest-wrap { position: relative; }
.place-suggest {
  position: absolute;
  left: 0;
  right: 0;
  top: calc(100% - 4px);
  z-index: 40;
  max-height: 220px;
  overflow: auto;
  background: #fff;
  border: 1px solid #888;
  border-radius: 8px;
  box-shadow: 0 8px 20px rgba(0,0,0,0.18);
}
.place-suggest button {
  display: block;
  width: 100%;
  text-align: left;
  padding: 10px 12px;
  border: none;
  border-bottom: 1px solid #eee;
  background: #fff;
  color: #111;
  font: inherit;
  cursor: pointer;
}
.place-suggest button:last-child { border-bottom: none; }
.place-suggest button:hover,
.place-suggest button.active { background: #eef3fa; }
.place-suggest em {
  display: block;
  font-style: normal;
  color: #777;
  font-size: 0.8rem;
  margin-top: 2px;
}

.live-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}
.live-actions .btn { width: 100%; margin: 0; color: #111; border-color: #888; }
.live-actions .btn.primary { color: #fff; }
.live-actions .btn.danger { color: #fff; }
.live-actions #closeDayBtn { grid-column: 1 / -1; }

.start-panel {
  background: linear-gradient(160deg, #3a3a3a, #2e2e2e);
  border: 1px solid #555;
  border-radius: 12px;
  padding: 16px;
  margin: 12px 0;
}
.start-panel .hint { margin: 0 0 12px; line-height: 1.4; }
.tools-hint {
  margin: -10px 0 14px;
  font-size: 0.75rem;
}
.start-panel .btn.primary { margin: 0; }

/* --- Papír tábla --- */
.blatt-scroll {
  overflow-x: auto;
  background: var(--paper);
  border: 1px solid #777;
  border-radius: 4px;
  box-shadow: 0 10px 28px rgba(0,0,0,.4);
  padding: 0;
  -webkit-overflow-scrolling: touch;
}
table.blatt {
  width: 100%;
  min-width: 720px;
  border-collapse: collapse;
  table-layout: fixed;
  font-size: 11px;
  color: var(--paper-ink);
  font-family: var(--font-sheet);
  background: var(--paper);
}
table.blatt th, table.blatt td {
  border: 1px solid var(--paper-line);
  padding: 5px 4px;
  vertical-align: top;
}
table.blatt th {
  background: var(--paper-head);
  font-weight: 700;
  text-align: center;
  font-size: 9.5px;
  line-height: 1.25;
}
.col-datum { width: 7%; }
.col-abf { width: 8%; }
.col-bau { width: 28%; }
.col-son { width: 12%; }
.col-ank { width: 8%; }
.col-ges { width: 9%; }
.col-ls { width: 9%; }
.col-std { width: 7%; }
.col-dia { width: 7%; }
.col-act { width: 9%; }
.bau-lines {
  white-space: normal;
  line-height: 1.35;
  font-weight: 600;
  word-break: break-word;
}
.num { text-align: center; white-space: nowrap; }
.blatt tr.is-open { background: #eef4ff; }
.blatt tr.empty-row td {
  text-align: center;
  padding: 22px;
  color: var(--muted);
}
.blatt .row-act {
  display: flex;
  flex-direction: column;
  gap: 5px;
  min-width: 76px;
}
.blatt .row-act button {
  padding: 6px 8px;
  font-size: 0.72rem;
  font-weight: 700;
  border: 1px solid #888;
  background: #fff;
  color: #222;
  border-radius: 5px;
  cursor: pointer;
  white-space: nowrap;
}
.blatt .row-act button:hover { background: #eef2f8; }
.blatt .row-act .reopen-btn { color: #555; font-weight: 600; }

.list { display: grid; gap: 10px; }
.card {
  background: #333;
  border: 1px solid #555;
  border-radius: 12px;
  padding: 12px 14px;
}
.card .d {
  display: flex;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 6px;
}
.card .d strong { font-size: 0.95rem; }
.card .d span { color: #aaa; font-size: 0.85rem; }
.card .meta {
  display: flex;
  flex-wrap: wrap;
  gap: 8px 12px;
  color: #aaa;
  font-size: 0.82rem;
}
.card .meta b { color: #d4b56a; font-weight: 600; }
.card-actions { margin-top: 10px; }
.empty {
  text-align: center;
  color: #aaa;
  padding: 28px 12px;
  border: 1px dashed #666;
  border-radius: 10px;
}
.status {
  font-size: 0.72rem;
  font-weight: 700;
  padding: 2px 6px;
  border-radius: 4px;
}
.status.open { background: #cde; color: #246; }
.status.closed { background: #cfc; color: #163; }

.dlg {
  border: none;
  border-radius: 12px;
  padding: 0;
  width: min(96vw, 440px);
  background: #2a2a2a;
  color: #eee;
  box-shadow: 0 20px 60px rgba(0,0,0,.55);
}
.dlg.dlg-wide { width: min(96vw, 560px); }
.dlg.dlg-paper {
  background: #f7f4ec;
  color: #1a1a1a;
}
.dlg.dlg-paper .dlg-body h2 { color: #111; }
.dlg.dlg-paper .hint { color: #6b6560; }
.dlg.dlg-paper .err { color: #a33; }
.dlg.dlg-paper .check { color: #555 !important; }
.dlg.dlg-paper .btn.ghost {
  color: #222;
  border-color: #888;
}
.blatt-form {
  border: 1px solid #222;
  background: #fff;
  margin: 12px 0 0;
}
.blatt-form .bf-row {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  border-bottom: 1px solid #222;
}
.blatt-form .bf-row:last-child { border-bottom: none; }
.blatt-form .bf-cell {
  border-right: 1px solid #222;
  padding: 6px 8px;
  display: flex;
  flex-direction: column;
  gap: 4px;
  min-width: 0;
}
.blatt-form .bf-cell:last-child { border-right: none; }
.blatt-form .bf-wide {
  border-right: none;
  border-bottom: 1px solid #222;
  padding: 6px 8px;
}
.blatt-form .bf-row.bf-tail {
  grid-template-columns: 2fr 1fr 1fr 1fr;
}
.blatt-form .bf-flex2 { grid-column: auto; }
.blatt-form .bf-lbl {
  font-size: 0.68rem;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  color: #444;
}
.blatt-form .bf-lbl em { font-weight: 500; text-transform: none; color: #888; }
.blatt-form input,
.blatt-form textarea,
.blatt-form select {
  width: 100%;
  border: none;
  border-bottom: 1px dashed #bbb;
  border-radius: 0;
  background: transparent;
  color: #111;
  padding: 6px 2px;
  font-size: 0.95rem;
}
.blatt-form input:focus,
.blatt-form textarea:focus {
  outline: none;
  border-bottom-color: #2a4a7a;
  background: #f5f8fc;
}
.blatt-form .bf-ges {
  background: #f3f3f3;
  justify-content: center;
}
.blatt-form .bf-ges-val {
  font-size: 1.15rem;
  color: #111;
  text-align: center;
  padding: 6px 0;
}
@media (max-width: 640px) {
  .blatt-form .bf-row {
    grid-template-columns: 1fr 1fr;
  }
  .blatt-form .bf-flex2 { grid-column: span 2; }
}
.dlg::backdrop { background: rgba(0,0,0,.55); }
.dlg-body { padding: 18px 16px 16px; margin: 0; }
.dlg-body h2 { margin: 0 0 8px; font-size: 1.1rem; }
.row2 {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}
.row3 {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  gap: 10px;
}
.ges-preview {
  margin: 10px 0 0;
  padding: 8px 10px;
  background: rgba(212, 181, 106, 0.12);
  border: 1px solid rgba(212, 181, 106, 0.35);
  border-radius: 8px;
  color: #d4b56a;
  font-size: 0.9rem;
}
.ges-preview b { color: #fff; }
.check {
  display: flex !important;
  align-items: center;
  gap: 8px;
  margin: 8px 0 0 !important;
  color: #aaa;
  font-size: 0.82rem !important;
}
.check input { width: auto; }
.hr-box {
  margin: 16px 0 0;
  border: 1px dashed rgba(212, 181, 106, 0.4);
  border-radius: 10px;
  padding: 8px 12px 12px;
}
.hr-box legend {
  color: #d4b56a;
  font-size: 0.8rem;
  padding: 0 6px;
}
.dlg-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  justify-content: flex-end;
  margin-top: 16px;
}
.dlg-actions .btn { width: auto; margin: 0; min-width: 88px; }
.dlg-actions .btn.primary { flex: 1; }

.hint { color: #aaa; font-size: 0.8rem; margin: 0; }
.err { color: #f88; font-size: 0.88rem; margin: 10px 0 0; }
.toast {
  position: fixed;
  left: 50%;
  bottom: calc(18px + var(--safe));
  transform: translateX(-50%);
  background: #222;
  border: 1px solid #555;
  color: #eee;
  padding: 10px 16px;
  border-radius: 999px;
  font-size: 0.88rem;
  z-index: 40;
}

.rank-list {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 12px;
  min-height: 28px;
}
.rank-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: #1e1e1e;
  border: 1px solid #555;
  border-radius: 999px;
  padding: 5px 8px 5px 12px;
  font-size: 0.85rem;
  color: #eee;
}
.rank-chip button {
  appearance: none;
  border: none;
  background: transparent;
  color: #f88;
  cursor: pointer;
  font-size: 0.9rem;
  padding: 0 4px;
  line-height: 1;
}
.rank-add-row {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 8px;
  align-items: center;
}
.rank-add-row .btn { margin: 0; width: auto; }
.driver-meta-row {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 8px;
  margin-top: 10px;
  align-items: center;
}
.driver-meta-row select {
  width: 100%;
  padding: 8px 10px;
  font-size: 0.88rem;
}
.driver-meta-row .check {
  margin: 0 !important;
  white-space: nowrap;
}
.profile-badge {
  display: inline-block;
  font-size: 0.72rem;
  font-weight: 700;
  padding: 2px 8px;
  border-radius: 4px;
  background: rgba(212, 181, 106, 0.18);
  color: #d4b56a;
  margin-left: 6px;
}
.driver-card .card-actions.export-row:has(.adm-revoke) {
  grid-template-columns: 1fr 1fr 1fr;
}
@media (max-width: 640px) {
  .live-actions { grid-template-columns: 1fr; }
  .app { padding-left: 8px; padding-right: 8px; }
  .action-duo { grid-template-columns: 1fr; }
  .tools-row { grid-template-columns: 1fr; }
  .row3 { grid-template-columns: 1fr; }
  .driver-card .card-actions.export-row:has(.adm-revoke) {
    grid-template-columns: 1fr;
  }
}
