:root, body[data-tema="roz"] {
  --bg: #faf7f5; --text: #3a3335; --card: #fff;
  --accent: #8d5b6e; --on-accent: #fff;
  --border: #e8dfe3; --muted: #8a7f84; --thead: #f5eef1;
  --secondary: #eee4e9; --secondary-text: #5a4a52;
  --line: #f0e8ec; --input-border: #d8ccd1;
  --ok: #2e7d4f; --no: #b3423a; --wait: #b07d2b;
  --ok-bg: #ddf2e4; --no-bg: #f7dedc; --wait-bg: #f7ecd8; --overfull-bg: #fdf3f2;
  --gold: #b08d57;
}
body[data-tema="verde"] {
  --bg: #f5faf6; --text: #33403a; --card: #fff;
  --accent: #5e8d6e; --on-accent: #fff;
  --border: #dfe8e2; --muted: #7d8a81; --thead: #eef5f0;
  --secondary: #e2efe7; --secondary-text: #47584e;
  --line: #e9f1ec; --input-border: #c8d8cd;
  --gold: #a8935c;
}
body[data-tema="albastru"] {
  --bg: #f5f8fb; --text: #333a44; --card: #fff;
  --accent: #5b7a9d; --on-accent: #fff;
  --border: #dfe5ec; --muted: #7d8794; --thead: #edf2f7;
  --secondary: #e2eaf2; --secondary-text: #47536a;
  --line: #e8eef4; --input-border: #c6d3e0;
  --gold: #a8935c;
}
body[data-tema="auriu"] {
  --bg: #fbf9f3; --text: #403a2c; --card: #fff;
  --accent: #a07c2e; --on-accent: #fff;
  --border: #eae3d0; --muted: #8f8770; --thead: #f6f1e3;
  --secondary: #f0e9d6; --secondary-text: #6a5c33;
  --line: #f1ebdb; --input-border: #d8cfae;
  --gold: #8a6a24;
}
body[data-tema="dark"] {
  --bg: #211d1f; --text: #e9e1e5; --card: #2c2629;
  --accent: #b07d95; --on-accent: #fff;
  --border: #3d363a; --muted: #a3959c; --thead: #362f33;
  --secondary: #3d363a; --secondary-text: #d9cdd3;
  --line: #3a3336; --input-border: #4c4348;
  --ok: #6fca94; --no: #e08078; --wait: #d9a856;
  --ok-bg: #24382c; --no-bg: #402724; --wait-bg: #3d3222; --overfull-bg: #402724;
  --gold: #d4b06a;
}

* { box-sizing: border-box; margin: 0; }
/* atributul hidden invinge ORICE display din clase (altfel .ev/.detalii-ev raman vizibile goale) */
[hidden] { display: none !important; }
body {
  font-family: system-ui, -apple-system, sans-serif;
  background: var(--bg);
  color: var(--text);
  padding: 1rem;
  max-width: 900px;
  margin: 0 auto;
}
header { text-align: center; margin-bottom: 1rem; }
h1 {
  font-family: Georgia, "Times New Roman", serif;
  font-size: 1.7rem;
  font-weight: 600;
  letter-spacing: .02em;
  color: var(--accent);
}

.counters {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
  gap: .6rem;
  margin-bottom: 1rem;
}
.card {
  position: relative;
  background: linear-gradient(180deg, var(--card) 55%, var(--soft, var(--thead)));
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 1rem .7rem .8rem;
  text-align: center;
  display: flex;
  flex-direction: column;
  box-shadow: 0 6px 16px rgba(0, 0, 0, .06);
  overflow: hidden;
}
/* firul auriu discret de sus - accentul metalic din papetaria eleganta */
.card::before {
  content: '';
  position: absolute;
  top: 0; left: 50%;
  transform: translateX(-50%);
  width: 44px; height: 2px;
  border-radius: 0 0 3px 3px;
  background: var(--gold);
}
.card .num {
  font-family: Georgia, "Times New Roman", serif;
  font-size: 1.9rem;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  line-height: 1.15;
}
.card .lbl {
  font-size: .62rem;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: .1em;
  margin-top: .2rem;
}
.card.big {
  background: linear-gradient(160deg, var(--accent), color-mix(in srgb, var(--accent) 78%, #000));
  border-color: var(--accent);
}
.card.big::before { background: var(--gold); width: 56px; }
.card.big .num, .card.big .lbl { color: var(--on-accent); }
.card.big .lbl { opacity: .85; }
.card.ok .num { color: var(--ok); }
.card.no .num { color: var(--no); }
.card.wait .num { color: var(--wait); }

.toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: .5rem;
  margin-bottom: 1rem;
  align-items: center;
}
.toolbar input[type=search] { flex: 1; min-width: 140px; }
input, select {
  padding: .55rem .7rem;
  border: 1px solid var(--input-border);
  border-radius: 8px;
  font-size: 1rem;
  background: var(--card);
  color: var(--text);
}
.btn {
  padding: .55rem 1rem;
  border-radius: 10px;
  border: none;
  font-size: 1rem;
  cursor: pointer;
  text-decoration: none;
  display: inline-block;
  transition: transform .12s ease, box-shadow .12s ease, filter .12s ease;
}
.btn.primary {
  background: linear-gradient(160deg, var(--accent), color-mix(in srgb, var(--accent) 82%, #000));
  color: var(--on-accent);
  box-shadow: 0 3px 10px color-mix(in srgb, var(--accent) 35%, transparent);
}
.btn.secondary { background: var(--secondary); color: var(--secondary-text); }
.btn:hover { transform: translateY(-1px); filter: brightness(1.05); }
.btn:active { transform: translateY(0); filter: brightness(.97); }
.btn:focus-visible, .tab:focus-visible, input:focus-visible, select:focus-visible {
  outline: 2px solid var(--gold);
  outline-offset: 2px;
}
input:focus, select:focus { border-color: var(--accent); }

.table-scroll { overflow-x: auto; -webkit-overflow-scrolling: touch; border-radius: 10px; }
table { width: 100%; border-collapse: collapse; background: var(--card); border-radius: 12px; overflow: hidden; box-shadow: 0 4px 14px rgba(0, 0, 0, .05); }
th, td { padding: .6rem .5rem; text-align: left; border-bottom: 1px solid var(--line); font-size: .95rem; }
th { background: var(--thead); font-size: .74rem; text-transform: uppercase; letter-spacing: .07em; color: var(--muted); }
tbody tr { transition: background .12s ease; }
tbody tr:hover { background: var(--thead); }
td { font-variant-numeric: tabular-nums; }
td.actions-cell { white-space: nowrap; text-align: right; }
td .mini {
  border: none; background: none; cursor: pointer; font-size: 1.1rem; padding: .2rem .35rem;
}
td a { color: var(--accent); }
.badge {
  padding: .2rem .6rem .2rem .5rem;
  border-radius: 99px;
  font-size: .8rem;
  white-space: nowrap;
  display: inline-flex;
  align-items: center;
  gap: .35rem;
}
.badge::before { content: ''; width: 6px; height: 6px; border-radius: 99px; background: currentColor; }
.badge.confirmat { background: var(--ok-bg); color: var(--ok); }
.badge.refuzat { background: var(--no-bg); color: var(--no); }
.badge.asteptare { background: var(--wait-bg); color: var(--wait); }

.empty { text-align: center; color: var(--muted); padding: 2rem 0; }

.tabs { display: flex; justify-content: center; gap: .5rem; margin-top: .7rem; flex-wrap: wrap; }
.tab {
  padding: .5rem 1.2rem;
  border: 1px solid var(--border);
  border-radius: 99px;
  background: var(--card);
  color: var(--secondary-text);
  font-size: 1rem;
  cursor: pointer;
  transition: border-color .15s ease, box-shadow .15s ease, background .15s ease;
}
.tab:hover { border-color: var(--gold); }
.tab.active {
  background: linear-gradient(160deg, var(--accent), color-mix(in srgb, var(--accent) 82%, #000));
  border-color: var(--accent);
  color: var(--on-accent);
  box-shadow: 0 3px 10px color-mix(in srgb, var(--accent) 35%, transparent);
}

dialog {
  border: none;
  border-top: 3px solid var(--gold);
  border-radius: 16px;
  margin: auto; /* resetul global de margini anula centrarea implicita */
  padding: 1.2rem;
  width: min(420px, 92vw);
  box-shadow: 0 18px 60px rgba(0, 0, 0, .3);
  background: var(--card);
  color: var(--text);
}
dialog::backdrop { background: rgba(0, 0, 0, .45); backdrop-filter: blur(3px); }
dialog h2 {
  margin-bottom: .8rem;
  color: var(--accent);
  font-size: 1.25rem;
  font-family: Georgia, "Times New Roman", serif;
}
dialog label { display: block; margin-bottom: .7rem; font-size: .85rem; color: var(--secondary-text); }
dialog label input, dialog label select { display: block; width: 100%; margin-top: .25rem; }
dialog .row { display: flex; gap: .6rem; }
dialog .row label { flex: 1; }
dialog .actions { display: flex; justify-content: flex-end; gap: .5rem; margin-top: .5rem; }

/* Task-uri */
tr.done td { color: var(--muted); text-decoration: line-through; }
tr.done td:first-child, tr.done td:last-child { text-decoration: none; }
tr.overdue td:nth-child(3) { color: var(--no); font-weight: 700; }
.inline-setting { display: flex; align-items: center; gap: .4rem; font-size: .85rem; color: var(--secondary-text); }
.check-label { display: flex !important; align-items: center; gap: .5rem; }
.check-label input { width: auto !important; display: inline !important; margin-top: 0 !important; }

/* Mese - vederea de sus a salonului */
.salon-wrap {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: .6rem;
  margin-bottom: 1rem;
  box-shadow: 0 6px 16px rgba(0, 0, 0, .06);
}
.salon-hint { text-align: center; color: var(--muted); font-size: .8rem; margin-bottom: .3rem; }
.salon-legenda {
  display: flex; flex-wrap: wrap; justify-content: center; gap: .4rem 1.1rem;
  font-size: .74rem; color: var(--muted); margin-top: .5rem;
}
.salon-legenda span { display: inline-flex; align-items: center; gap: .35rem; }
.pct { width: 9px; height: 9px; border-radius: 99px; display: inline-block; }
.pct.ocupat { background: var(--accent); }
.pct.liber { background: var(--card); border: 1px solid var(--input-border); }
.pct.depasit { background: var(--no); }
.pct.colt { background: var(--gold); border-radius: 3px; }
.zoom-bar { display: flex; align-items: center; gap: .45rem; margin-bottom: .3rem; }
.mini-zoom {
  width: 30px; height: 30px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--card);
  color: var(--accent);
  font-size: 1.15rem;
  line-height: 1;
  cursor: pointer;
}
.mini-zoom:hover { border-color: var(--gold); }
#zoom-val { font-size: .8rem; color: var(--muted); min-width: 42px; text-align: center; }
.salon-scroll { overflow: auto; max-height: 78vh; border-radius: 10px; }
#salon {
  width: 100%;
  height: auto;
  display: block;
  touch-action: none;
  background:
    radial-gradient(circle, var(--line) 1px, transparent 1px);
  background-size: 26px 26px;
  border-radius: 10px;
}

/* Mese */
.mese-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: .8rem;
}
.masa-card {
  background: var(--card);
  border: 1px solid var(--border);
  border-top: 2px solid var(--gold);
  border-radius: 12px;
  padding: .8rem;
  box-shadow: 0 4px 14px rgba(0, 0, 0, .05);
}
.masa-card.overfull { border-color: var(--no); background: var(--overfull-bg); }
.masa-head { display: flex; align-items: center; gap: .5rem; margin-bottom: .5rem; }
.masa-head strong { flex: 1; color: var(--accent); }
.masa-seats { font-size: .8rem; color: var(--muted); white-space: nowrap; }
.masa-card.overfull .masa-seats { color: var(--no); font-weight: 700; }
.masa-acts { white-space: nowrap; }
.masa-acts .mini { border: none; background: none; cursor: pointer; font-size: 1.1rem; padding: .2rem .35rem; }
.masa-guests { list-style: none; font-size: .9rem; padding: 0; }
.masa-guests li { padding: .15rem 0; border-bottom: 1px dashed var(--line); }
.masa-guests li:last-child { border-bottom: none; }
.masa-empty { color: var(--muted); font-style: italic; }

.meniuri-strip { text-align: center; color: var(--muted); font-size: .85rem; margin: -.4rem 0 1rem; }

/* bare de progres (buget platit, taskuri facute) */
.bar-bg { height: 4px; background: var(--line); border-radius: 99px; margin-top: 4px; overflow: hidden; }
.bar-bg.mare { height: 7px; margin: -.4rem 0 1rem; }
.bar-fill { height: 100%; border-radius: 99px; background: var(--gold); transition: width .3s ease; }
.bar-fill.plin { background: var(--ok); }
.bar-bg.mare .bar-fill { background: var(--ok); }

/* ecranul de incarcare + notificarile toast */
#incarcare {
  position: fixed; inset: 0; z-index: 99;
  background: var(--bg);
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: .9rem;
  color: var(--muted); font-size: .9rem;
}
#incarcare .inel {
  width: 42px; height: 42px;
  border: 3px solid var(--line);
  border-top-color: var(--gold);
  border-radius: 50%;
  animation: rotire 1s linear infinite;
}
@keyframes rotire { to { transform: rotate(360deg); } }

.toast {
  position: fixed; left: 50%; bottom: 1.2rem; z-index: 100;
  transform: translate(-50%, 150%);
  background: var(--card); color: var(--text);
  border: 1px solid var(--no); border-left-width: 4px;
  border-radius: 10px; padding: .7rem 1.1rem;
  box-shadow: 0 10px 30px rgba(0, 0, 0, .25);
  font-size: .92rem; max-width: min(90vw, 420px);
  transition: transform .25s ease;
  pointer-events: none;
}
.toast.vizibil { transform: translate(-50%, 0); }

/* Jurnalul confirmarilor */
.noutati {
  background: var(--card);
  border: 1px solid var(--border);
  border-left: 3px solid var(--gold);
  border-radius: 10px;
  padding: .7rem .9rem;
  margin-bottom: 1rem;
}
.noutati-titlu { font-size: .8rem; text-transform: uppercase; letter-spacing: .08em; color: var(--muted); margin-bottom: .4rem; }
.noutati ul { list-style: none; padding: 0; }
.noutati li { font-size: .9rem; padding: .2rem 0; border-bottom: 1px dashed var(--line); }
.noutati li:last-child { border-bottom: none; }
.noutati .cand { color: var(--muted); font-size: .78rem; }
.noutati .msj { color: var(--secondary-text); font-style: italic; }

/* Persoanele dintr-o invitatie (cuplu/familie) */
.pers-sectiune { margin-bottom: .7rem; }
.pers-titlu { font-size: .85rem; color: var(--secondary-text); margin-bottom: .35rem; }
.pers-titlu span { color: var(--muted); font-size: .75rem; }
.pers-rand { display: flex; gap: .4rem; margin-bottom: .4rem; align-items: center; }
.pers-rand input { flex: 2; min-width: 0; }
.pers-rand select { flex: 1; min-width: 0; }
.btn-pers { padding: .35rem .8rem; font-size: .85rem; }
.pers-nume-mici { font-size: .78rem; color: var(--muted); margin-top: .15rem; }

/* Setari */
.linkuri p { font-size: .85rem; color: var(--secondary-text); margin-bottom: .4rem; word-break: break-all; }
.linkuri a { color: var(--accent); }
.setari-form {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 1.2rem;
  max-width: 560px;
  margin: 0 auto;
}
.setari-form h2 { color: var(--accent); font-size: 1.05rem; margin: 1rem 0 .6rem; }
.setari-form h2:first-child { margin-top: 0; }
.setari-form label { display: block; margin-bottom: .7rem; font-size: .85rem; color: var(--secondary-text); }
.setari-form label input, .setari-form label select { display: block; width: 100%; margin-top: .25rem; }
.setari-form .row { display: flex; gap: .6rem; flex-wrap: wrap; }
.setari-form .row label { flex: 1; min-width: 120px; }
.col-grup { display: grid; grid-template-columns: 1fr 1fr; gap: .1rem .8rem; margin-bottom: .6rem; }
.col-grup label { display: flex; align-items: center; gap: .45rem; margin: 0; padding: .2rem 0; }
.col-grup input { width: auto; }
.setari-save { margin-top: 1rem; text-align: right; }

/* Tiparire program */
.print-only { display: none; }
@media print {
  body { padding: 0; background: #fff; color: #000; }
  header, .no-print, #view-invitati, #view-buget, #view-taskuri, #view-furnizori, #view-mese, #view-setari { display: none !important; }
  #view-program { display: block !important; }
  .print-only { display: block; text-align: center; margin-bottom: 1rem; color: #000; }
  table { border: 1px solid #ccc; background: #fff; }
  th, td { color: #000; }
}

/* Telefon: totul mare, glisabil si usor de atins */
@media (max-width: 640px) {
  body { padding: .6rem .6rem 2rem; }
  h1 { font-size: 1.25rem; }
  header { margin-bottom: .7rem; }

  /* taburile gliseaza orizontal, nu se ingramadesc */
  .tabs {
    flex-wrap: nowrap;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    justify-content: flex-start;
    padding-bottom: .35rem;
    scrollbar-width: none;
  }
  .tabs::-webkit-scrollbar { display: none; }
  .tab { padding: .45rem .9rem; font-size: .9rem; white-space: nowrap; flex: 0 0 auto; }

  .counters { grid-template-columns: repeat(3, 1fr); gap: .4rem; }
  .card { padding: .7rem .3rem .55rem; }
  .card .num { font-size: 1.35rem; }
  .card .lbl { font-size: .55rem; }

  /* 16px previne zoom-ul automat pe iPhone la focus */
  input, select { font-size: 16px; padding: .6rem .7rem; }
  .toolbar .btn { flex: 1 1 auto; text-align: center; padding: .7rem .6rem; }
  .inline-setting { width: 100%; }
  .inline-setting input { flex: 1; }

  /* tabelele nu se strivesc: gliseaza orizontal */
  #tbl { min-width: 640px; }
  #tbl-f { min-width: 680px; }
  #tbl-b { min-width: 540px; }
  #tbl-t { min-width: 460px; }
  th, td { padding: .55rem .45rem; font-size: .9rem; }
  td .mini { font-size: 1.25rem; padding: .3rem .4rem; }
  #tbl-t input[type=checkbox] { width: 1.25rem; height: 1.25rem; }

  /* dialogurile devin foi de jos, pe tot ecranul */
  dialog {
    width: 100vw;
    max-width: 100vw;
    margin: 0;
    position: fixed;
    bottom: 0;
    top: auto;
    border-radius: 16px 16px 0 0;
    max-height: 92dvh;
    overflow-y: auto;
    padding: 1rem 1rem calc(1rem + env(safe-area-inset-bottom));
  }
  dialog .actions .btn { padding: .75rem 1.2rem; }

  .mese-grid { grid-template-columns: 1fr 1fr; gap: .5rem; }
  .masa-card { padding: .6rem; }
  .setari-form { padding: .9rem; }
  .col-grup { grid-template-columns: 1fr; }
}

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

@media (max-width: 400px) {
  .mese-grid { grid-template-columns: 1fr; }
  .counters { grid-template-columns: repeat(2, 1fr); }
}
