:root {
  color-scheme: light;
  --bg: #f4f3f0;
  --surface: #fcfcfb;
  --border: #e3e1dc;
  --grid: #ebe9e4;
  --text: #0b0b0b;
  --text-2: #52514e;
  --muted: #85837d;
  --accent: #2a78d6;
  --accent-ink: #ffffff;
  --accent-soft: #e6f0fc;
  --danger: #c23b3a;
  --ok-bg: #e5f4ea;
  --ok-text: #1d6a35;
  --err-bg: #fbe8e8;
  --err-text: #9c2b2a;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    color-scheme: dark;
    --bg: #111110;
    --surface: #1a1a19;
    --border: #2e2d2b;
    --grid: #282826;
    --text: #f0efec;
    --text-2: #c3c2b7;
    --muted: #8d8c85;
    --accent: #3987e5;
    --accent-ink: #ffffff;
    --accent-soft: #1b2b40;
    --danger: #e66767;
    --ok-bg: #16301f;
    --ok-text: #8fd6a5;
    --err-bg: #3a1a1a;
    --err-text: #f1a3a3;
  }
}
:root[data-theme="dark"] {
  color-scheme: dark;
  --bg: #111110;
  --surface: #1a1a19;
  --border: #2e2d2b;
  --grid: #282826;
  --text: #f0efec;
  --text-2: #c3c2b7;
  --muted: #8d8c85;
  --accent: #3987e5;
  --accent-ink: #ffffff;
  --accent-soft: #1b2b40;
  --danger: #e66767;
  --ok-bg: #16301f;
  --ok-text: #8fd6a5;
  --err-bg: #3a1a1a;
  --err-text: #f1a3a3;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 16px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}
.wrap { max-width: 980px; margin: 0 auto; padding: 20px 16px 48px; }

header.top {
  display: flex; align-items: center; justify-content: space-between;
  gap: 12px; margin-bottom: 20px;
}
header.top h1 { font-size: 22px; margin: 0; letter-spacing: -0.01em; }
.actions { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }

a { color: var(--accent); }
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  min-height: 40px; padding: 0 14px; border-radius: 8px;
  border: 1px solid var(--border); background: var(--surface); color: var(--text);
  font: inherit; font-size: 15px; text-decoration: none; cursor: pointer;
}
.btn:hover { border-color: var(--muted); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); font-weight: 600; }
.btn.primary:hover { filter: brightness(1.07); }
.btn.big { min-height: 52px; font-size: 17px; width: 100%; }
.btn.link { border: 0; background: none; color: var(--text-2); padding: 0 8px; }

.card {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: 12px; padding: 16px;
}

/* login + formular */
.narrow { max-width: 420px; margin: 0 auto; }
.login { margin-top: 12vh; }
.login h1 { font-size: 22px; margin: 0 0 16px; text-align: center; }
label { display: block; font-size: 14px; color: var(--text-2); margin: 0 0 6px; }
input[type=text], input[type=password], input[type=date], input[type=time], input[type=number] {
  width: 100%; min-height: 50px; padding: 10px 12px;
  border: 1px solid var(--border); border-radius: 8px;
  background: var(--bg); color: var(--text); font: inherit; font-size: 18px;
}
input:focus { outline: 2px solid var(--accent); outline-offset: 1px; border-color: transparent; }
.field { margin-bottom: 16px; }
.row2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.unit { position: relative; }
.unit input { padding-right: 48px; }
.unit span { position: absolute; right: 14px; top: 50%; transform: translateY(-50%); color: var(--muted); }
.quick { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px; }
.quick button { min-height: 34px; padding: 0 10px; font-size: 14px; }
.msg { padding: 10px 12px; border-radius: 8px; margin-bottom: 16px; font-size: 15px; }
.msg.ok { background: var(--ok-bg); color: var(--ok-text); }
.msg.err { background: var(--err-bg); color: var(--err-text); }

/* statistici */
.range { display: flex; gap: 4px; margin-bottom: 12px; }
.range button {
  min-height: 34px; padding: 0 12px; border-radius: 8px; font: inherit; font-size: 14px;
  border: 1px solid var(--border); background: var(--surface); color: var(--text-2); cursor: pointer;
}
.range button[aria-pressed=true] { background: var(--accent-soft); border-color: var(--accent); color: var(--text); font-weight: 600; }
.tiles { display: grid; grid-template-columns: repeat(4, 1fr); gap: 12px; margin-bottom: 12px; }
.tile .k { font-size: 13px; color: var(--text-2); }
.tile .v { font-size: 26px; font-weight: 650; letter-spacing: -0.02em; margin-top: 2px; font-variant-numeric: tabular-nums; }
.tile .v small { font-size: 14px; font-weight: 500; color: var(--muted); margin-left: 2px; }
.tile .s { font-size: 12px; color: var(--muted); margin-top: 2px; }
.charts { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin-bottom: 28px; }
.chart h2 { font-size: 15px; margin: 0 0 2px; }
.chart p.sub { font-size: 13px; color: var(--muted); margin: 0 0 8px; }
.chart .plot { position: relative; height: 220px; }
.chart svg { display: block; width: 100%; height: 100%; overflow: visible; }
.chart text { fill: var(--muted); font-size: 11px; font-variant-numeric: tabular-nums; }
.chart .gridline { stroke: var(--grid); stroke-width: 1; }
#chart-hours .gridline:not(.major) { stroke-dasharray: 2 3; }
#chart-hours .gridline.major { stroke: var(--border); }
.chart .baseline { stroke: var(--border); stroke-width: 1; }
.chart .bar { fill: var(--accent); }
.chart .bar.hover, .chart .dot.hover { filter: brightness(1.15); }
.chart .dot { fill: var(--accent); stroke: var(--surface); stroke-width: 2; }
.chart .empty { fill: var(--muted); font-size: 13px; }
.tip {
  position: absolute; pointer-events: none; z-index: 5;
  background: var(--text); color: var(--bg); border-radius: 6px;
  padding: 6px 9px; font-size: 13px; line-height: 1.35; white-space: nowrap;
  transform: translate(-50%, calc(-100% - 10px)); display: none;
}
.tip b { font-variant-numeric: tabular-nums; }

/* listă zile */
h2.sect { font-size: 17px; margin: 0 0 10px; }
.days { padding: 0; overflow: hidden; }
.day {
  display: grid; grid-template-columns: 130px 1fr auto; gap: 12px; align-items: center;
  padding: 12px 16px; border-top: 1px solid var(--border);
}
.day:first-child { border-top: 0; }
.day .date { font-weight: 650; font-variant-numeric: tabular-nums; }
.day .date small { display: block; font-weight: 400; color: var(--muted); font-size: 13px; }
.day .items { display: flex; flex-wrap: wrap; gap: 6px; }
.chip {
  display: inline-flex; gap: 6px; align-items: baseline;
  padding: 4px 10px; border-radius: 999px; background: var(--bg); border: 1px solid var(--border);
  font-variant-numeric: tabular-nums; font-size: 15px; white-space: nowrap;
}
.chip .t { color: var(--text-2); }
.chip .v { font-weight: 600; }
.day .total { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.day .total b { display: block; }
.day .total small { color: var(--muted); font-size: 13px; }
.none { padding: 24px 16px; color: var(--muted); text-align: center; }

/* lista intrărilor pe pagina /add */
.entries { list-style: none; margin: 0; padding: 0; }
.entries li { display: flex; align-items: center; justify-content: space-between; padding: 8px 0; border-top: 1px solid var(--border); font-variant-numeric: tabular-nums; }
.entries li:first-child { border-top: 0; }
.entries form { margin: 0; }
.del { color: var(--danger); background: none; border: 0; font: inherit; font-size: 14px; cursor: pointer; padding: 6px 8px; }

@media (max-width: 720px) {
  .tiles { grid-template-columns: 1fr 1fr; }
  .charts { grid-template-columns: 1fr; }
  .day { grid-template-columns: 1fr auto; }
  .day .items { grid-column: 1 / -1; grid-row: 2; }
  .tile .v { font-size: 22px; }
  header.top h1 { white-space: nowrap; font-size: 20px; }
  .actions { gap: 4px; flex-wrap: nowrap; }
  .actions .print { display: none; }
}

@media print {
  body { background: #fff; color: #000; }
  .actions, .range, .no-print { display: none !important; }
  .card { border-color: #bbb; break-inside: avoid; }
  .day { break-inside: avoid; }
  .chip { background: #fff; }
}

/* pagina /add: oră 24h, calendar, editare */
.hm { display: flex; align-items: center; gap: 4px; }
.hm span { color: var(--muted); font-size: 18px; }
select {
  flex: 1 1 0; width: 0; min-width: 0; min-height: 50px; padding: 10px 8px;
  border: 1px solid var(--border); border-radius: 8px;
  background: var(--bg); color: var(--text); font: inherit; font-size: 18px;
  font-variant-numeric: tabular-nums; text-align: center;
}
select:focus { outline: 2px solid var(--accent); outline-offset: 1px; border-color: transparent; }
form.editing { border-color: var(--accent); box-shadow: 0 0 0 1px var(--accent); }

.cal-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 10px; }
.cal-head b { font-size: 16px; }
.cal-head .btn { min-width: 44px; font-size: 20px; padding: 0; }
.btn.disabled { opacity: .35; pointer-events: none; }
.cal { display: grid; grid-template-columns: repeat(7, 1fr); gap: 4px; }
.cal .wd { text-align: center; font-size: 12px; color: var(--muted); padding-bottom: 2px; }
.cal .c {
  position: relative; display: flex; flex-direction: column; align-items: center; justify-content: center;
  aspect-ratio: 1 / 1; max-height: 52px; border-radius: 8px; border: 1px solid transparent;
  color: var(--text); text-decoration: none; font-variant-numeric: tabular-nums; font-size: 15px;
}
.cal a.c:hover { border-color: var(--border); }
.cal .c small { font-size: 10px; line-height: 1; margin-top: 2px; color: var(--accent); font-weight: 600; }
.cal .c.has { background: var(--accent-soft); }
.cal .c.today { border-color: var(--accent); }
.cal .c.sel { background: var(--accent); color: var(--accent-ink); font-weight: 650; }
.cal .c.sel small { color: var(--accent-ink); }
.cal .c.future { color: var(--muted); opacity: .45; }

.row-actions { display: flex; align-items: center; gap: 2px; }
.row-actions .edit { font-size: 14px; padding: 6px 8px; text-decoration: none; }
.entries li.cur { background: var(--accent-soft); margin: 0 -8px; padding: 8px; border-radius: 8px; }
