:root {
  --bg: #0b1220;
  --panel: #121c2e;
  --panel-2: #172438;
  --line: #24354f;
  --text: #e8eef8;
  --muted: #93a4bd;
  --accent: #3b82f6;
  --verde: #22c55e;
  --galben: #eab308;
  --portocaliu: #f97316;
  --rosu: #ef4444;
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 16px/1.45 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Arial, sans-serif;
  padding-top: var(--safe-top);
  padding-bottom: var(--safe-bottom);
  overscroll-behavior-y: contain;
}

.hidden { display: none !important; }
.muted { color: var(--muted); font-weight: 400; }
.error { color: #fca5a5; min-height: 1.2em; margin: 6px 0 0; font-size: 14px; }

/* ---------- login ---------- */
.login { min-height: 100vh; display: grid; place-items: center; padding: 20px; }
.login-box { width: 100%; max-width: 420px; background: var(--panel); border: 1px solid var(--line); border-radius: 16px; padding: 22px; }
.login-box h1 { margin: 0; font-size: 30px; letter-spacing: .5px; }
.login-box > p { margin-top: 4px; }
.chips { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 10px; }
.chip { background: var(--panel-2); border: 1px solid var(--line); color: var(--text); border-radius: 999px; padding: 7px 13px; font-size: 14px; cursor: pointer; }
.chip small { color: var(--muted); margin-left: 5px; }

/* ---------- login ---------- */
.login-cine { display: flex; align-items: center; gap: 10px; margin: 14px 0 4px; }
.login-cine b { flex: 1; font-size: 17px; overflow: hidden; text-overflow: ellipsis; }
.login-sau { display: flex; align-items: center; gap: 10px; color: var(--muted); font-size: 13px; margin: 16px 0 4px; }
.login-sau::before, .login-sau::after { content: ''; flex: 1; height: 1px; background: var(--line); }

.btn.google { background: #fff; color: #1f1f1f; border-color: #dadce0; font-weight: 600; display: flex; align-items: center; justify-content: center; gap: 10px; }
.btn.google:hover { background: #f5f5f5; }
.g-logo {
  display: grid; place-items: center; width: 22px; height: 22px; border-radius: 50%;
  background: conic-gradient(#ea4335 0 25%, #fbbc05 0 50%, #34a853 0 75%, #4285f4 0);
  color: #fff; font-weight: 800; font-size: 13px; font-family: Arial, sans-serif;
}

label { display: block; margin: 14px 0 6px; font-size: 13px; text-transform: uppercase; letter-spacing: .6px; color: var(--muted); font-weight: 600; }

input, select, textarea {
  width: 100%; background: var(--panel-2); border: 1px solid var(--line); color: var(--text);
  border-radius: 10px; padding: 12px; font-size: 16px; font-family: inherit;
}
input:focus, select:focus, textarea:focus { outline: 2px solid var(--accent); outline-offset: 0; }
textarea { resize: vertical; }
.num { max-width: 90px; }
.row { display: flex; gap: 8px; align-items: center; }
.unit-text { color: var(--muted); }

.seg { display: flex; gap: 6px; flex-wrap: wrap; }
.seg button {
  flex: 1 1 auto; background: var(--panel-2); border: 1px solid var(--line); color: var(--muted);
  padding: 11px 10px; border-radius: 10px; font-size: 14px; cursor: pointer; font-family: inherit;
}
.seg button.active { background: var(--accent); border-color: var(--accent); color: #fff; font-weight: 600; }

.btn {
  background: var(--panel-2); border: 1px solid var(--line); color: var(--text);
  padding: 10px 15px; border-radius: 10px; font-size: 15px; cursor: pointer; font-family: inherit;
}
.btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; font-weight: 600; }
.btn.ghost { background: transparent; }
.btn.danger { color: #fca5a5; border-color: #7f1d1d; }
.btn.small { padding: 6px 10px; font-size: 13px; }
.btn.big { width: 100%; margin-top: 18px; padding: 14px; font-size: 17px; }
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: .5; }

/* ---------- shell ---------- */
.topbar {
  position: sticky; top: 0; z-index: 20;
  display: flex; align-items: center; justify-content: space-between;
  gap: 10px; padding: 10px 14px; background: var(--bg); border-bottom: 1px solid var(--line);
}
/* Pe laptop, bara de sus si filele se aliniaza cu continutul, nu cu marginile ecranului. */
.topbar > *, .tabs { max-width: 100%; }
@media (min-width: 960px) {
  .topbar { padding-left: calc((100vw - 900px) / 2); padding-right: calc((100vw - 900px) / 2); }
  .tabs { padding-left: calc((100vw - 900px) / 2); padding-right: calc((100vw - 900px) / 2); }
}
.brand { display: flex; align-items: center; gap: 8px; font-size: 17px; }
.dot { width: 9px; height: 9px; border-radius: 50%; background: var(--rosu); }
.dot.on { background: var(--verde); }
.who { display: flex; align-items: center; gap: 7px; font-size: 14px; min-width: 0; }
#me-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 22vw; }

/* butonul de tura ON/OFF */
.duty {
  border: 1px solid transparent; border-radius: 999px; padding: 5px 12px;
  font-size: 12px; font-weight: 700; letter-spacing: .4px; cursor: pointer;
  font-family: inherit; white-space: nowrap;
}
.duty.on { background: rgba(34,197,94,.16); border-color: #166534; color: #86efac; }
.duty.off { background: rgba(148,163,184,.16); border-color: var(--line); color: var(--muted); }

/* ecranul de pauza */
.login-box.center { text-align: center; }
.pauza-icon { width: 46px; height: 46px; color: var(--muted); margin-bottom: 4px; }
.btn.wide { width: 100%; margin-top: 10px; }
#pauza-logout { margin-top: 16px; }

/* bulina de prezenta */
.pres-dot { width: 10px; height: 10px; flex: 0 0 10px; border-radius: 50%; background: var(--line); }
.pres-dot.on { background: var(--verde); box-shadow: 0 0 0 3px rgba(34,197,94,.18); }
#online-count { color: var(--verde); }
.badge { background: var(--panel-2); border: 1px solid var(--line); border-radius: 999px; padding: 2px 9px; font-size: 12px; color: var(--muted); }

.tabs { position: sticky; top: 49px; z-index: 19; display: flex; background: var(--bg); border-bottom: 1px solid var(--line); }
.tabs button {
  flex: 1; background: none; border: none; border-bottom: 3px solid transparent; color: var(--muted);
  padding: 12px 4px; font-size: 13px; cursor: pointer; font-family: inherit; position: relative;
}
.tabs button.active { color: var(--text); border-bottom-color: var(--accent); font-weight: 600; }
.tab-badge { display: none; }
.tab-badge.on {
  display: inline-block; background: var(--rosu); color: #fff; border-radius: 999px;
  font-size: 11px; font-style: normal; padding: 1px 6px; margin-left: 5px; vertical-align: 1px;
}
.tab-badge.warn { background: var(--accent); }

main { padding: 14px 14px 60px; max-width: 900px; margin: 0 auto; }
.view-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 12px; }
.view-head h2 { margin: 0; font-size: 20px; }

.inline-form { display: flex; gap: 8px; margin-bottom: 14px; }
.inline-form input { flex: 1; }

.cards { display: flex; flex-direction: column; gap: 10px; }
.card { background: var(--panel); border: 1px solid var(--line); border-left: 4px solid var(--line); border-radius: 12px; padding: 12px 14px; }
/* Ordinea de importanta: shuttle > urgent > programat > al meu. Clasa o pune JS. */
.card.p-shuttle { border-left-color: #a78bfa; border-left-width: 7px; background: linear-gradient(90deg, rgba(167,139,250,.10), transparent 55%); }
.card.p-urgent { border-left-color: var(--rosu); }
.card.p-programat { border-left-color: #60a5fa; }
.card.p-mine { border-left-color: var(--accent); }
/* Livrare peste timpul din setari. Pusa dupa celelalte, deci bate orice dunga.
   Portocaliul e liber: rosul inseamna urgent, albastrul programat, mov shuttle. */
.card.intarziat {
  border-left-color: var(--portocaliu); border-left-width: 7px;
  border-color: rgba(249,115,22,.45);
  background: linear-gradient(90deg, rgba(249,115,22,.16), transparent 60%);
}
.card.intarziat .card-title::after {
  content: 'INTARZIAT'; margin-left: 8px; vertical-align: middle;
  font-size: 11px; font-weight: 800; letter-spacing: .6px;
  color: #fdba74; background: rgba(249,115,22,.16);
  border: 1px solid #9a3412; border-radius: 999px; padding: 2px 8px;
}
.card-top { display: flex; justify-content: space-between; align-items: flex-start; gap: 10px; }
.card-title { font-size: 18px; font-weight: 700; }
.card-sub { color: var(--muted); font-size: 14px; margin-top: 2px; }
.card-note { margin-top: 6px; font-size: 15px; }
.card-actions { display: flex; gap: 8px; margin-top: 10px; flex-wrap: wrap; }
.card.done { opacity: .6; }
.card.done .card-title { text-decoration: line-through; }
.compact .card { padding: 8px 12px; }
.compact .card-title { font-size: 15px; font-weight: 600; }

.pill { display: inline-block; border-radius: 999px; padding: 2px 9px; font-size: 12px; font-weight: 700; }
.pill.urgent { background: rgba(239,68,68,.15); color: #fca5a5; border: 1px solid #7f1d1d; }
.pill.nou { background: rgba(59,130,246,.15); color: #93c5fd; border: 1px solid #1e40af; }
.pill.preluat { background: rgba(234,179,8,.15); color: #fde047; border: 1px solid #854d0e; }
.pill.gata { background: rgba(34,197,94,.15); color: #86efac; border: 1px solid #166534; }
.pill.atribuit { background: rgba(234,179,8,.15); color: #fde047; border: 1px solid #854d0e; }
.pill.extern { background: rgba(148,163,184,.15); color: var(--muted); border: 1px solid var(--line); font-weight: 600; }
.seg.wrap button { flex: 0 1 auto; }

.empty { color: var(--muted); text-align: center; padding: 26px 10px; border: 1px dashed var(--line); border-radius: 12px; }

.hint { font-size: 13px; margin: 6px 0 0; line-height: 1.35; }

/* joburi programate */
.sched-wrap { margin-top: 18px; border-top: 1px solid var(--line); padding-top: 12px; }
.sched-title { margin: 0 0 10px; font-size: 15px; color: var(--muted); font-weight: 600; }
.sched-line { margin-top: 5px; font-size: 14px; font-weight: 600; color: #60a5fa; }
.sched-line .pana { color: #60a5fa; font-weight: 600; }
.sched-line.late, .sched-line.late .pana { color: #fdba74; }
.card.done .sched-line, .card.done .sched-line .pana { color: var(--muted); font-weight: 400; }

.pill.shuttle { background: rgba(167,139,250,.18); color: #c4b5fd; border: 1px solid #6d28d9; }

/* cronometrul coletelor */
.timer-line { margin-top: 5px; font-size: 14px; color: var(--muted); }
.timer { font-variant-numeric: tabular-nums; font-weight: 600; color: var(--text); }
.timer.over { color: #fdba74; }
.card.done .timer, .card.done .timer.over { color: var(--muted); font-weight: 400; }

/* echipa */
.team-list { margin: 10px 0 4px; }
.team-row { display: flex; align-items: center; gap: 10px; padding: 9px 0; border-bottom: 1px solid var(--line); }
.team-row:last-child { border-bottom: none; }
.team-row.off { opacity: .5; }
.team-who { flex: 1; min-width: 0; }
.team-who b { display: block; font-size: 15px; }
.team-who small { color: var(--muted); font-size: 12px; word-break: break-all; }
.team-row select { width: auto; padding: 7px 8px; font-size: 13px; }
.team-auth { display: block; margin-top: 2px; }
.team-actiuni { display: flex; gap: 5px; flex-wrap: wrap; justify-content: flex-end; }
.sheet h4 { margin: 20px 0 0; font-size: 15px; border-top: 1px solid var(--line); padding-top: 16px; }

.done-wrap { margin-top: 16px; border-top: 1px solid var(--line); padding-top: 10px; }
.done-wrap summary { color: var(--muted); cursor: pointer; font-size: 14px; padding: 4px 0; }
.done-wrap[open] summary { margin-bottom: 10px; }

/* ---------- calendar shuttle ---------- */
.cal-zi { margin-bottom: 18px; }
.cal-zi h3 {
  margin: 0 0 8px; font-size: 14px; text-transform: uppercase; letter-spacing: .6px;
  color: var(--muted); border-bottom: 1px solid var(--line); padding-bottom: 6px;
}
.cal-zi.fara-ora h3 { color: #fdba74; }

.cal-rand {
  position: relative; display: flex; align-items: center; gap: 12px;
  padding: 10px 12px; border-radius: 10px; border-left: 5px solid #a78bfa;
  background: var(--panel); margin-bottom: 6px; cursor: default;
}
.cal-rand:hover { background: var(--panel-2); }
.cal-rand.tarziu { border-left-color: var(--portocaliu); }
.cal-rand.gata { opacity: .55; border-left-color: var(--verde); }
.cal-ora { font-size: 18px; font-weight: 700; font-variant-numeric: tabular-nums; flex: 0 0 62px; }
.cal-ap { font-size: 16px; font-weight: 700; flex: 0 0 76px; }
.cal-dir { color: #c4b5fd; font-size: 14px; flex: 1; }
.cal-stare { color: var(--muted); font-size: 13px; white-space: nowrap; }

/* detaliile care apar la trecerea cu mouse-ul */
.cal-tip {
  display: none; position: absolute; z-index: 40; left: 60px; top: calc(100% - 4px);
  background: #0b1220; border: 1px solid var(--accent); border-radius: 10px;
  padding: 10px 12px; min-width: 280px; box-shadow: 0 12px 32px rgba(0,0,0,.6);
}
.cal-rand:hover .cal-tip { display: block; }
.cal-tip > div { display: flex; gap: 10px; font-size: 13px; padding: 3px 0; }
.cal-tip b { flex: 0 0 96px; color: var(--muted); font-weight: 600; }
.cal-tip span { flex: 1; color: var(--text); }
@media (max-width: 620px) {
  .cal-rand { flex-wrap: wrap; }
  .cal-dir { flex: 1 1 100%; }
  .cal-tip { left: 0; right: 0; min-width: 0; }
}

/* arhiva: cursele terminate, tinute 30 de zile */
#calendar-arhiva { margin-top: 22px; border-top: 1px solid var(--line); padding-top: 12px; }
#calendar-arhiva summary { color: var(--muted); cursor: pointer; font-size: 14px; padding: 4px 0; }
#calendar-arhiva[open] summary { margin-bottom: 12px; }
#calendar-arhiva .cal-rand.gata { opacity: .8; }

/* ---------- liste de inchis ---------- */
.list-block { background: var(--panel); border: 1px solid var(--line); border-radius: 12px; padding: 14px; margin-bottom: 14px; }
.list-block.closed { opacity: .65; }
.list-head { display: flex; justify-content: space-between; align-items: center; gap: 10px; flex-wrap: wrap; }
.list-head-actions { display: flex; gap: 6px; }

/* editarea inline a unui text (To Do, item, titlu de lista) */
.edit-inline { display: flex; gap: 6px; flex: 1 1 220px; flex-wrap: wrap; margin: 2px 0; }
.edit-inline input { flex: 1 1 160px; padding: 8px 10px; font-size: 15px; }
.list-head h3 { margin: 0; font-size: 17px; }
.progress { height: 8px; background: var(--panel-2); border-radius: 999px; margin: 10px 0; overflow: hidden; }
.progress i { display: block; height: 100%; background: var(--verde); border-radius: 999px; transition: width .2s; }
.progress-text { font-size: 13px; color: var(--muted); }
.item { padding: 9px 2px; border-bottom: 1px solid var(--line); }
.item:last-child { border-bottom: none; }
.item-main { display: flex; align-items: flex-start; gap: 10px; }
.item .box { width: 24px; height: 24px; flex: 0 0 24px; border: 2px solid var(--line); border-radius: 6px; display: grid; place-items: center; cursor: pointer; font-size: 15px; }
.item.done .box { background: var(--verde); border-color: var(--verde); color: #04240f; }
.item-text { flex: 1; }
/* Se taie doar textul itemului, nu si comentariul din prelungirea lui. */
.item.done .item-txt { text-decoration: line-through; color: var(--muted); }
.item small { color: var(--muted); font-size: 12px; }
.list-add { display: flex; gap: 8px; margin-top: 10px; }
.list-add input { flex: 1; }

/* comentariul curge in prelungirea itemului, pe acelasi rand */
.item-note { color: #93c5fd; }
.item-note small { color: var(--muted); }
.item-note-edit { display: flex; gap: 6px; margin: 7px 0 2px 34px; flex-wrap: wrap; }
.item-note-edit input { flex: 1 1 160px; padding: 8px 10px; font-size: 15px; }

/* ---------- housekeeping ---------- */
.legend { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 12px; font-size: 12px; }
.lg { padding: 3px 9px; border-radius: 999px; border: 1px solid var(--line); color: var(--muted); }
.lg::before { content: ''; display: inline-block; width: 8px; height: 8px; border-radius: 50%; margin-right: 6px; }
.lg.rosu::before { background: var(--rosu); }
.lg.portocaliu::before { background: var(--portocaliu); }
.lg.galben::before { background: var(--galben); }
.lg.verde::before { background: var(--verde); }

.hk { border-left-width: 6px; }
.hk.rosu { border-left-color: var(--rosu); background: linear-gradient(90deg, rgba(239,68,68,.12), transparent 60%); }
.hk.portocaliu { border-left-color: var(--portocaliu); background: linear-gradient(90deg, rgba(249,115,22,.12), transparent 60%); }
.hk.galben { border-left-color: var(--galben); background: linear-gradient(90deg, rgba(234,179,8,.12), transparent 60%); }
.hk.verde { border-left-color: var(--verde); }
.hk-state { font-weight: 700; font-size: 14px; }
.hk.rosu .hk-state { color: #fca5a5; }
.hk.portocaliu .hk-state { color: #fdba74; }
.hk.galben .hk-state { color: #fde047; }
.hk.verde .hk-state { color: #86efac; }

.preview { margin-top: 14px; background: var(--panel-2); border: 1px solid var(--line); border-radius: 10px; padding: 10px 12px; font-size: 14px; color: var(--muted); min-height: 44px; }
.preview b { color: var(--text); font-weight: 600; }

/* ---------- modale ---------- */
.modal { position: fixed; inset: 0; background: rgba(3,7,18,.7); z-index: 50; display: flex; align-items: flex-end; justify-content: center; }
.sheet {
  background: var(--panel); border: 1px solid var(--line); border-radius: 16px 16px 0 0;
  width: 100%; max-width: 560px; padding: 18px 18px calc(18px + var(--safe-bottom));
  max-height: 92vh; overflow-y: auto;
}
.sheet h3 { margin: 0 0 4px; font-size: 19px; }
.sheet-actions { display: flex; gap: 8px; justify-content: flex-end; margin-top: 18px; }
.sheet-actions .btn { flex: 1; }
@media (min-width: 620px) {
  .modal { align-items: center; }
  .sheet { border-radius: 16px; }
  .sheet-actions .btn { flex: 0 0 auto; }
}

/* ---------- date si statistici ---------- */
.sheet.wide { max-width: 980px; }
.stats-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.stats-head h3 { margin: 0; }
.stats-interval { color: var(--muted); font-size: 13px; margin: 10px 0 14px; }

.stats-tabs { display: flex; gap: 2px; margin-top: 14px; border-bottom: 1px solid var(--line); overflow-x: auto; }
.stats-tabs button {
  background: none; border: none; border-bottom: 2px solid transparent; color: var(--muted);
  padding: 10px 14px; font-size: 14px; font-family: inherit; cursor: pointer; white-space: nowrap;
}
.stats-tabs button.active { color: var(--text); border-bottom-color: var(--accent); font-weight: 600; }
#stats-body h4 { margin: 20px 0 8px; font-size: 14px; color: var(--muted); font-weight: 600; }

.tiles { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 10px; }
.tile { background: var(--panel-2); border: 1px solid var(--line); border-radius: 12px; padding: 12px 14px; }
.tile b { display: block; font-size: 24px; line-height: 1.1; font-variant-numeric: tabular-nums; }
.tile span { display: block; font-size: 12px; color: var(--muted); margin-top: 4px; }
.tile em { display: block; font-size: 11px; color: var(--muted); opacity: .8; font-style: normal; margin-top: 2px; }

.bars { display: flex; flex-direction: column; gap: 6px; }
.bar-row { display: flex; align-items: center; gap: 10px; font-size: 13px; }
.bar-lbl { flex: 0 0 120px; color: var(--muted); text-align: right; }
.bar { flex: 1; background: var(--panel-2); border-radius: 999px; height: 16px; overflow: hidden; }
.bar i { display: block; height: 100%; background: var(--accent); border-radius: 999px; }
.bar-val { flex: 0 0 44px; font-variant-numeric: tabular-nums; font-weight: 600; }

.vbars { display: flex; align-items: flex-end; gap: 3px; height: 120px; padding-top: 6px; }
.vbar { flex: 1; display: flex; flex-direction: column; justify-content: flex-end; align-items: center; height: 100%; min-width: 0; }
.vbar i { display: block; width: 100%; background: var(--accent); border-radius: 3px 3px 0 0; min-height: 0; }
.vbar span { font-size: 10px; color: var(--muted); margin-top: 4px; white-space: nowrap; }

.tbl-wrap { overflow-x: auto; }
.tbl { width: 100%; border-collapse: collapse; font-size: 13px; }
.tbl th { text-align: left; color: var(--muted); font-weight: 600; padding: 7px 10px 7px 0; border-bottom: 1px solid var(--line); white-space: nowrap; }
.tbl td { padding: 8px 10px 8px 0; border-bottom: 1px solid var(--line); font-variant-numeric: tabular-nums; }
.tbl tr:last-child td { border-bottom: none; }
.tbl .bun { color: #86efac; }
.tbl .mediu { color: #fde047; }
.tbl .slab { color: #fca5a5; }

#eroare-fatala {
  background: #7f1d1d; color: #fff; padding: 14px 16px; font-size: 15px; line-height: 1.4;
}

/* ---------- toasts ---------- */
#toasts { position: fixed; left: 0; right: 0; bottom: calc(14px + var(--safe-bottom)); z-index: 80; display: flex; flex-direction: column; align-items: center; gap: 8px; pointer-events: none; }
.toast {
  background: var(--panel-2); border: 1px solid var(--accent); color: var(--text);
  padding: 11px 16px; border-radius: 12px; max-width: 92vw; box-shadow: 0 10px 30px rgba(0,0,0,.5);
  animation: pop .18s ease-out;
}
.toast.urgent { border-color: var(--rosu); }
.toast b { display: block; }
.toast small { color: var(--muted); }
@keyframes pop { from { transform: translateY(12px); opacity: 0; } to { transform: none; opacity: 1; } }
