/* Layout: two modes on one page. "Programare" = date bar + entry form + day list. "Ecran TV" = full-screen board, big condensed type, auto-rotating pages. */
:root {
  --bg: #eceff3;
  --surface: #ffffff;
  --fg: #14202b;
  --muted: #566677;
  --line: #d2d9e0;
  --accent: #1b4fd6;
  --accent-fg: #ffffff;
  --todo: #566677;
  --doing: #a85f00;
  --done: #17774a;
  --danger: #b3261e;
  --f-display: "Barlow Condensed", "Arial Narrow", sans-serif;
  --f-body: "Barlow", system-ui, sans-serif;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0d151e; --surface: #15202c; --fg: #f2f5f8; --muted: #9fb0c0; --line: #263545;
    --accent: #6f9bff; --accent-fg: #0b1220; --todo: #9fb0c0; --doing: #ffb020; --done: #4fd08a; --danger: #ff8a80;
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #0d151e; --surface: #15202c; --fg: #f2f5f8; --muted: #9fb0c0; --line: #263545;
  --accent: #6f9bff; --accent-fg: #0b1220; --todo: #9fb0c0; --doing: #ffb020; --done: #4fd08a; --danger: #ff8a80;
  color-scheme: dark;
}
* { box-sizing: border-box; }
body {
  background: var(--bg); color: var(--fg); font-family: var(--f-body); font-size: 16px; line-height: 1.4;
  padding-block: 16px 40px;
  padding-left: max(16px, env(safe-area-inset-left, 0px));
  padding-right: max(16px, env(safe-area-inset-right, 0px));
}
button, input, select { font: inherit; color: inherit; }
button:focus-visible, input:focus-visible, select:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; }
.wrap { max-width: 920px; margin: 0 auto; display: grid; gap: 16px; }
.top { display: flex; flex-wrap: wrap; gap: 12px; align-items: center; justify-content: space-between; }
h1 { font-family: var(--f-display); font-weight: 700; font-size: 34px; letter-spacing: .01em; margin: 0; line-height: 1; text-transform: uppercase; }
.btn { border: 1px solid var(--line); background: var(--surface); padding: 10px 16px; border-radius: 6px; cursor: pointer; font-weight: 600; min-height: 44px; }
.btn.primary { background: var(--accent); color: var(--accent-fg); border-color: var(--accent); }
.btn.ghost { background: transparent; }
.btn.danger { color: var(--danger); }
.btn:disabled { opacity: .5; cursor: default; }
.datebar { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.datebar input { min-height: 44px; padding: 8px 12px; border: 1px solid var(--line); border-radius: 6px; background: var(--surface); }
.dayname { font-family: var(--f-display); font-size: 22px; font-weight: 600; text-transform: capitalize; color: var(--muted); margin-left: 4px; }
form.add { background: var(--surface); border: 1px solid var(--line); border-radius: 8px; padding: 16px; display: grid; gap: 12px; grid-template-columns: repeat(6, 1fr); }
form.add label { display: grid; gap: 4px; font-size: 13px; font-weight: 600; color: var(--muted); text-transform: uppercase; letter-spacing: .06em; min-width: 0; }
form.add input, form.add select { min-height: 44px; padding: 8px 10px; border: 1px solid var(--line); border-radius: 6px; background: var(--bg); text-transform: none; letter-spacing: 0; font-weight: 500; color: var(--fg); width: 100%; min-width: 0; }
.f-ora { grid-column: span 2; } .f-nr { grid-column: span 2; } .f-masina { grid-column: span 2; }
.f-lucrare { grid-column: span 3; } .f-mecanic { grid-column: span 2; } .f-go { grid-column: span 1; align-self: end; }
.f-go .btn { width: 100%; }
@media (max-width: 640px) {
  form.add { grid-template-columns: 1fr 1fr; }
  .f-ora, .f-nr { grid-column: span 1; } .f-masina, .f-lucrare, .f-mecanic, .f-go { grid-column: span 2; }
}
.list { display: grid; gap: 8px; }
.item { background: var(--surface); border: 1px solid var(--line); border-radius: 8px; padding: 12px 14px; display: grid; grid-template-columns: 64px minmax(0, 1fr) auto; gap: 12px; align-items: center; }
.item .ora { font-family: var(--f-display); font-size: 30px; font-weight: 700; font-variant-numeric: tabular-nums; line-height: 1; }
.item .main { min-width: 0; }
.item .l1 { font-weight: 600; overflow-wrap: anywhere; }
.item .l2 { color: var(--muted); font-size: 14px; overflow-wrap: anywhere; }
.plate { font-family: var(--f-display); font-weight: 700; letter-spacing: .08em; border: 1.5px solid currentColor; border-radius: 4px; padding: 0 6px; display: inline-block; font-size: 17px; line-height: 1.4; }
.actions { display: flex; gap: 6px; flex-wrap: wrap; justify-content: flex-end; }
.status { border: 0; border-radius: 999px; padding: 8px 14px; min-height: 44px; font-weight: 700; cursor: pointer; background: transparent; border: 2px solid currentColor; }
.s-de_facut { color: var(--todo); } .s-in_lucru { color: var(--doing); } .s-gata { color: var(--done); }
.item.gata .l1 { text-decoration: line-through; text-decoration-thickness: 1.5px; color: var(--muted); }
.tag-ex { font-size: 11px; text-transform: uppercase; letter-spacing: .08em; border: 1px dashed var(--muted); color: var(--muted); border-radius: 4px; padding: 0 5px; margin-left: 6px; }
.empty { text-align: center; padding: 36px 16px; color: var(--muted); border: 2px dashed var(--line); border-radius: 8px; }
.empty strong { display: block; font-family: var(--f-display); font-size: 24px; color: var(--fg); margin-bottom: 4px; }
.note { color: var(--muted); font-size: 14px; }
.msg { color: var(--danger); font-weight: 600; }
@media (max-width: 520px) { .item { grid-template-columns: 52px minmax(0, 1fr); } .item .actions { grid-column: 1 / -1; justify-content: flex-start; } }

/* TV mode */
body.tv { padding: 0; }
.tvwrap { position: fixed; inset: 0; display: grid; grid-template-rows: auto 1fr auto; background: var(--bg); color: var(--fg); padding: 2.2vw 3vw 1.6vw; gap: 1.6vw; overflow: hidden; }
.tvhead { display: flex; justify-content: space-between; align-items: baseline; gap: 2vw; border-bottom: .3vw solid var(--fg); padding-bottom: 1vw; }
.tvhead .d { font-family: var(--f-display); font-weight: 700; font-size: 5.2vw; line-height: 1; text-transform: uppercase; letter-spacing: .02em; color: var(--accent); }
.tvhead .dd { flex: 1; font-family: var(--f-display); font-weight: 600; font-size: 3.2vw; line-height: 1; color: var(--muted); text-transform: capitalize; }
.tvhead .c { font-family: var(--f-display); font-weight: 600; font-size: 5.2vw; line-height: 1; font-variant-numeric: tabular-nums; color: var(--muted); }
.tvrows { display: grid; align-content: start; gap: 1vw; min-height: 0; }
.tvrow { --fw: .7vw; display: grid; grid-template-columns: 11vw 17vw minmax(0, 1fr) 19vw; gap: 2vw; align-items: center; background: var(--surface); border-left: .8vw solid var(--todo); padding: .8vw 2vw; min-height: 0; }
.tvrow.in_lucru { border-left-color: var(--doing); } .tvrow.gata { border-left-color: var(--done); opacity: .6; }
.tvrow .o { font-family: var(--f-display); font-weight: 700; font-size: 4.2vw; font-variant-numeric: tabular-nums; line-height: 1; }
.tvrow .n { font-family: var(--f-display); font-weight: 700; font-size: 3.4vw; letter-spacing: .06em; line-height: 1; white-space: nowrap; }
.tvrow .w { min-width: 0; }
.tvrow .w b { display: block; font-weight: 600; font-size: 2.8vw; line-height: 1.1; overflow-wrap: anywhere; }
.tvrow .w span { display: block; color: var(--muted); font-size: 2.1vw; line-height: 1.15; }
.tvrow .s { font-family: var(--f-display); font-weight: 700; font-size: 2.8vw; text-transform: uppercase; text-align: right; line-height: 1; }
.tvrow.gata .w b { text-decoration: line-through; }
.tvfoot { display: flex; justify-content: space-between; color: var(--muted); font-size: 1.6vw; min-height: 2vw; }
.tvempty { align-self: center; justify-self: center; text-align: center; font-family: var(--f-display); font-size: 6vw; font-weight: 600; color: var(--muted); text-transform: uppercase; }
.tvexit { position: fixed; top: 10px; right: 10px; opacity: 0; transition: opacity .3s; }
.tvexit.show, .tvexit:focus-visible { opacity: 1; }
@media (prefers-reduced-motion: reduce) { .tvexit { transition: none; } }

/* Login */
.login { max-width: 360px; margin: 12vh auto 0; background: var(--surface); border: 1px solid var(--line); border-radius: 8px; padding: 20px; display: grid; gap: 12px; }
.login input { min-height: 44px; padding: 8px 10px; border: 1px solid var(--line); border-radius: 6px; background: var(--bg); width: 100%; }
a.btn { text-decoration: none; display: inline-flex; align-items: center; color: inherit; }

/* Categorii */
.tabs { display: flex; gap: 8px; }
.tab { flex: 1; min-height: 48px; border: 2px solid var(--line); background: var(--surface); border-radius: 8px; font-family: var(--f-display); font-size: 22px; font-weight: 700; text-transform: uppercase; letter-spacing: .04em; cursor: pointer; color: var(--muted); }
.tab.on { border-color: var(--accent); color: var(--accent); background: var(--surface); box-shadow: inset 0 -4px 0 var(--accent); }

/* Mecanicul care preia lucrarea: verde */
.mec { color: var(--done); font-weight: 700; margin-left: 6px; }
.tvrow .w span i.mec { font-style: normal; font-size: 2.3vw; margin-left: 0; }
.tvrow .w span { font-size: 2.1vw; }

/* Lucrare suplimentară pe aceeași mașină: roșu */
.item.supl { border-color: var(--danger); }
.item.supl .l1 { color: var(--danger); }
.tag-supl { margin-left: 8px; font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: .08em; color: var(--danger); border: 1.5px solid var(--danger); border-radius: 4px; padding: 0 5px; }
.tvrow.supl { border-left-color: var(--danger); }
.tvrow.supl .w b { color: var(--danger); }
.tv-supl { font-style: normal; margin-left: 1vw; font-size: 1.5vw; font-weight: 700; text-transform: uppercase; letter-spacing: .08em; border: .2vw solid var(--danger); border-radius: .4vw; padding: 0 .5vw; vertical-align: middle; }

/* Se apropie ora următoarei mașini: chenar roșu care clipește tot mai repede */
.item { --fw: 4px; }
@keyframes frameblink {
  0%, 100% { box-shadow: inset 0 0 0 var(--fw) var(--danger); }
  50% { box-shadow: inset 0 0 0 var(--fw) transparent; }
}
.item.alert, .tvrow.alert { animation-name: frameblink; animation-iteration-count: infinite; animation-timing-function: steps(1, end); animation-duration: 1s; }
.l2.warn { color: var(--danger); font-weight: 700; }
.tvrow .s small { display: block; margin-top: .3vw; font-family: var(--f-body); font-weight: 600; font-size: 1.5vw; text-transform: none; color: var(--danger); line-height: 1.1; }
@media (prefers-reduced-motion: reduce) {
  .item.alert, .tvrow.alert { animation: none; box-shadow: inset 0 0 0 var(--fw) var(--danger); }
}
.formnote { margin: 0; color: var(--accent); font-weight: 600; }
.formnote.edit { color: var(--doing); }
form.add.editing { border-color: var(--doing); }
.item.beingedited { outline: 2px dashed var(--doing); outline-offset: 2px; }
.f-go { display: flex; gap: 8px; flex-wrap: wrap; }
.f-go .btn { flex: 1; }
