:root {
  /* culorile ALON TRANS */
  --navy: #23578a;   /* albastrul din logo */
  --navy-2: #1c4a77;
  --ink: #4d4e50;    /* griul din logo */
  --bg: #f3f5f8;
  --card: #ffffff;
  --text: #1c2430;
  --muted: #6b7684;
  --line: #d9e0e7;
  --stripe: #edf2f6;
  --total: #dbe5ec;
  --oil: #b45309;
  --energy: #0f766e;
  --danger: #b42318;
  --radius: 10px;
}
* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  background: var(--bg); color: var(--text);
  font: 15px/1.45 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Arial, sans-serif;
}
[hidden] { display: none !important; }
h1, h2 { margin: 0 0 .5rem; }
h2 { font-size: 1.05rem; }
.muted { color: var(--muted); }
.small { font-size: .85rem; }
.error { color: var(--danger); }

/* Top bar */
.topbar {
  background: #fff; color: var(--ink);
  display: flex; flex-wrap: wrap; align-items: center; gap: .5rem 1.5rem;
  padding: .55rem 16px; position: sticky; top: 0; z-index: 5;
  border-bottom: 1px solid var(--line); box-shadow: 0 1px 3px rgba(20,40,70,.05);
}
.brand { display: flex; align-items: center; gap: .6rem; }
.brand .mark { height: 38px; width: auto; display: block; }
.brand .wordmark { height: 17px; width: auto; display: block; }
.brand .sub { font-size: .72rem; color: var(--muted); letter-spacing: .08em; text-transform: uppercase; margin-top: .3rem; }
.month-picker { display: flex; align-items: center; gap: .4rem; font-weight: 600; color: var(--ink); }
.month-picker span { min-width: 9.5rem; text-align: center; }
.icon-btn {
  background: var(--stripe); color: var(--ink); border: 0; border-radius: 6px;
  width: 32px; height: 32px; font-size: 1.2rem; cursor: pointer;
}
.icon-btn:hover { background: #e1e8ef; }
.tabs { display: flex; gap: .25rem; margin-left: auto; }
.tabs button {
  background: transparent; color: var(--ink); border: 0; padding: .45rem .85rem;
  border-radius: 8px; font: inherit; cursor: pointer;
}
.tabs button:hover { background: var(--stripe); }
.tabs button.active { background: var(--navy); color: #fff; font-weight: 600; }

.banner { background: #fff7e6; color: #7a4b00; padding: .5rem 16px; font-size: .88rem; border-bottom: 1px solid #f1dfb8; }

main { max-width: 1100px; margin: 0 auto; padding: 16px; }

/* Buttons & inputs */
.btn {
  font: inherit; border: 1px solid var(--line); background: #fff; color: var(--text);
  padding: .5rem .9rem; border-radius: 8px; cursor: pointer; white-space: nowrap;
}
.btn:hover { border-color: #b7c2cd; }
.btn.primary { background: var(--navy); border-color: var(--navy); color: #fff; }
.btn.primary:hover { background: var(--navy-2); }
.btn.danger { color: var(--danger); border-color: #f0c6c2; }
.btn.small { padding: .3rem .7rem; font-size: .88rem; }
input, select, textarea {
  font: inherit; color: var(--text); width: 100%;
  border: 1px solid var(--line); border-radius: 8px; padding: .5rem .6rem; background: #fff;
}
input:focus, select:focus, textarea:focus { outline: 2px solid #8fb1d3; outline-offset: 0; border-color: #8fb1d3; }
label { display: flex; flex-direction: column; gap: .25rem; font-size: .88rem; color: var(--muted); }
label > input, label > textarea { color: var(--text); font-size: 15px; }

.toolbar { display: flex; flex-wrap: wrap; gap: .5rem; align-items: center; margin: 0 0 12px; }
.toolbar select { width: auto; }
.toolbar .btn.primary { margin-left: auto; }

/* Summary */
.summary { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 10px; margin-bottom: 14px; }
@media (max-width: 480px) {
  .summary .stat { padding: .6rem .7rem; }
  .summary .stat .v { font-size: 1rem; }
  .summary .stat .s { font-size: .75rem; }
}
.stat { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: .7rem .9rem; }
.stat .k { font-size: .8rem; color: var(--muted); text-transform: uppercase; letter-spacing: .04em; }
.stat .v { font-size: clamp(1.05rem, 2.1vw, 1.3rem); font-weight: 700; margin-top: .15rem; font-variant-numeric: tabular-nums; white-space: nowrap; }
.stat .s { font-size: .82rem; color: var(--muted); }

/* Trips table */
.trips { width: 100%; border-collapse: collapse; background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; }
.trips th, .trips td { padding: .55rem .7rem; border-bottom: 1px solid var(--line); text-align: left; vertical-align: top; }
.trips th { background: var(--navy); color: #fff; font-weight: 600; font-size: .85rem; }
.trips tr:last-child td { border-bottom: 0; }
.trips tbody tr { cursor: pointer; }
.trips tbody tr:hover { background: #f6f9fc; }
.trips .num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.route b { font-weight: 600; }
.route .arrow { color: var(--muted); margin: 0 .25rem; }
.tag { display: inline-block; font-size: .75rem; font-weight: 700; padding: .1rem .45rem; border-radius: 99px; white-space: nowrap; }
.tag.ARTOIL { background: #fdf0e1; color: var(--oil); }
.tag.ARTENERGY { background: #e2f4f1; color: var(--energy); }
.note { color: var(--muted); font-size: .84rem; margin-top: .15rem; }
.empty { background: var(--card); border: 1px dashed var(--line); border-radius: var(--radius); padding: 2rem; text-align: center; color: var(--muted); }

@media (max-width: 720px) {
  .trips, .trips tbody, .trips tr, .trips td { display: block; width: 100%; }
  .trips thead { display: none; }
  .trips { background: transparent; border: 0; }
  .trips tr { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); margin-bottom: 8px; padding: .5rem .7rem; position: relative; }
  .trips td { border: 0; padding: .15rem 0; }
  .trips td.num { position: absolute; top: .55rem; right: .7rem; font-weight: 700; }
  .trips td.c-nr { display: none; }
  .tabs { margin-left: 0; width: 100%; }
  .tabs button { flex: 1; }
  .toolbar select { flex: 1; min-width: 0; }
  .toolbar .btn.primary { width: 100%; }
}

/* Acasă */
.period { display: flex; flex-wrap: wrap; align-items: flex-end; justify-content: space-between; gap: .75rem; margin-bottom: 14px; }
.presets { display: flex; flex-wrap: wrap; gap: .35rem; }
.presets button {
  font: inherit; font-size: .88rem; border: 1px solid var(--line); background: #fff; color: var(--text);
  padding: .4rem .75rem; border-radius: 99px; cursor: pointer;
}
.presets button.active { background: var(--navy); border-color: var(--navy); color: #fff; }
.range { display: flex; gap: .5rem; }
.range label { min-width: 0; }
.range input { width: 150px; }
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.grid-2 > .card { margin-bottom: 0; min-width: 0; }
.grid-2 + .card { margin-top: 12px; }
@media (max-width: 860px) { .grid-2 { grid-template-columns: 1fr; } .grid-2 > .card { margin-bottom: 0; } }
.tbl-wrap { overflow-x: auto; }
.mini { width: 100%; border-collapse: collapse; font-variant-numeric: tabular-nums; }
.mini th, .mini td { padding: .45rem .5rem; border-bottom: 1px solid var(--line); text-align: left; white-space: nowrap; }
.mini th { font-size: .78rem; color: var(--muted); font-weight: 600; text-transform: uppercase; letter-spacing: .03em; }
.mini .num { text-align: right; }
.mini tfoot td { font-weight: 700; border-bottom: 0; border-top: 2px solid var(--navy); }
.swatch { display: inline-block; width: 10px; height: 10px; border-radius: 3px; margin-right: .45rem; vertical-align: 0; }
.share { display: flex; align-items: center; justify-content: flex-end; gap: .45rem; }
.sharebar { width: 56px; height: 6px; background: var(--stripe); border-radius: 99px; overflow: hidden; }
.sharebar i { display: block; height: 100%; background: var(--navy); border-radius: 99px; }
.toplist { list-style: none; margin: 0; padding: 0; display: grid; gap: .35rem; }
.toplist li { display: grid; grid-template-columns: minmax(90px, 160px) 1fr 2.5rem; align-items: center; gap: .6rem; }
.tp-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tp-bar { height: 8px; background: var(--stripe); border-radius: 99px; overflow: hidden; }
.tp-bar i { display: block; height: 100%; background: var(--navy); border-radius: 99px; }
.tp-n { text-align: right; color: var(--muted); font-variant-numeric: tabular-nums; }

/* Grafic */
.chart-card { position: relative; }
.chart-head { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: baseline; gap: .5rem; margin-bottom: .6rem; }
.chart-head h2 { margin: 0; }
.legend { display: flex; gap: .9rem; font-size: .85rem; color: var(--text); }
.legend span { display: inline-flex; align-items: center; gap: .35rem; }
.legend i { width: 10px; height: 10px; border-radius: 3px; display: inline-block; }
.chart { display: flex; gap: .4rem; height: 220px; }
.yaxis { display: flex; flex-direction: column; justify-content: space-between; font-size: .72rem; color: var(--muted);
  text-align: right; padding-bottom: 20px; margin-top: -.45em; font-variant-numeric: tabular-nums; min-width: 3.2rem; }
.yaxis span { line-height: 1; }
.plot { position: relative; flex: 1; min-width: 0; }
.grid { position: absolute; inset: 0 0 20px 0; display: flex; flex-direction: column; justify-content: space-between; pointer-events: none; }
.grid i { display: block; height: 1px; background: #e7ecf0; }
.grid i:last-child { background: #c9d2db; }
.cols { position: absolute; inset: 0; display: flex; }
.col { flex: 1; min-width: 0; display: flex; flex-direction: column; align-items: center; cursor: default; outline: none; }
.col .stack { flex: 1; width: 100%; max-width: 24px; display: flex; flex-direction: column-reverse; gap: 2px; margin-bottom: 20px; position: relative; }
.col .seg { width: 100%; flex: none; }
.col .seg:last-child { border-radius: 4px 4px 0 0; }
.col.on .stack::before { content: ""; position: absolute; inset: 0 -4px; background: rgba(27,49,73,.06); border-radius: 4px; z-index: -1; }
.col .xl { position: absolute; bottom: 0; font-size: .72rem; color: var(--muted); white-space: nowrap; transform: translateX(-50%); }
.col { position: relative; }
.col .xl { left: 50%; }
.tooltip { position: absolute; z-index: 3; background: #fff; border: 1px solid var(--line); border-radius: 8px;
  box-shadow: 0 6px 20px rgba(15,25,40,.12); padding: .5rem .65rem; font-size: .82rem; pointer-events: none; white-space: nowrap; }
.tooltip b { display: block; margin-bottom: .15rem; }

/* Cards (settings) */
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 1rem; margin-bottom: 12px; }
.truck-list { list-style: none; padding: 0; margin: 0 0 .75rem; }
.truck-list li { display: flex; align-items: center; justify-content: space-between; padding: .45rem 0; border-bottom: 1px solid var(--line); font-weight: 600; letter-spacing: .03em; }
.inline-form { display: flex; gap: .5rem; }
.chips { display: flex; flex-wrap: wrap; gap: .4rem; margin: 0 0 .75rem; }
.chip {
  display: inline-flex; align-items: center; gap: .2rem;
  background: var(--stripe); border: 1px solid var(--line); border-radius: 99px;
  padding: .2rem .25rem .2rem .7rem; font-weight: 500;
}
.chip button {
  border: 0; background: transparent; color: var(--muted); cursor: pointer;
  width: 24px; height: 24px; border-radius: 50%; font-size: .8rem; line-height: 1;
}
.chip button:hover { background: #f6dcda; color: var(--danger); }

/* Dialog */
dialog { border: 0; border-radius: 14px; padding: 0; width: min(560px, calc(100vw - 32px)); max-height: calc(100vh - 32px); box-shadow: 0 20px 60px rgba(0,0,0,.25); }
dialog::backdrop { background: rgba(15, 25, 40, .45); }
#tripForm { padding: 1.1rem; display: flex; flex-direction: column; gap: .8rem; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: .6rem; }
@media (max-width: 480px) { .grid2 { grid-template-columns: 1fr; } }
fieldset { border: 0; padding: 0; margin: 0; }
legend, .label-row { font-size: .88rem; color: var(--muted); margin-bottom: .25rem; padding: 0; }
.seg { display: flex; flex-wrap: wrap; gap: .4rem; }
.seg label { flex: 1; min-width: 110px; }
.seg input { position: absolute; opacity: 0; width: 0; }
.seg span {
  display: block; text-align: center; padding: .55rem .5rem; border: 1px solid var(--line);
  border-radius: 8px; color: var(--text); font-weight: 600; cursor: pointer; font-size: 15px;
}
.seg input:checked + span { background: var(--navy); border-color: var(--navy); color: #fff; }
.seg input:focus-visible + span { outline: 2px solid #8fb1d3; }
.unload-list { display: flex; flex-direction: column; gap: .4rem; margin-bottom: .4rem; }
.unload-row { display: flex; gap: .4rem; align-items: center; }
.unload-row .idx { width: 1.4rem; color: var(--muted); font-size: .85rem; text-align: right; flex: none; }
.unload-row .rm { flex: none; width: 36px; height: 36px; border: 1px solid var(--line); background: #fff; border-radius: 8px; cursor: pointer; color: var(--muted); }
.dialog-actions { display: flex; gap: .5rem; align-items: center; }
.spacer { flex: 1; }

/* Anexa preview (mimics the PDF) */
.paper-wrap { overflow-x: auto; }
.paper {
  background: #fff; border: 1px solid var(--line); border-radius: 4px;
  min-width: 760px; padding: 36px 40px; color: #222;
  font-family: Arial, Helvetica, sans-serif; font-size: 13px;
}
.paper h1 { text-align: center; color: var(--navy); font-size: 24px; margin: 0; }
.paper .sub { text-align: center; color: #6b7684; margin: 4px 0 20px; }
.paper h3 { color: var(--navy); font-size: 16px; margin: 18px 0 6px; }
.ax { width: 100%; border-collapse: collapse; }
.ax th { background: var(--navy); color: #fff; padding: 6px 8px; font-size: 12px; }
.ax td { padding: 5px 8px; border: 1px solid #dfe5ea; }
.ax tbody tr:nth-child(even) td { background: var(--stripe); }
.ax .c { text-align: center; }
.ax .r { text-align: right; font-variant-numeric: tabular-nums; }
.ax tfoot td { background: var(--total); font-weight: 700; color: var(--navy); border: 1px solid #cdd8e1; }
.ax tfoot tr.grand td { border-top: 2px solid var(--navy); }

/* Login */
.login { min-height: 100vh; display: grid; place-items: center; padding: 16px; }
.login-card { background: #fff; border: 1px solid var(--line); border-radius: 14px; padding: 1.5rem; width: min(380px, 100%); display: flex; flex-direction: column; gap: .8rem; }
.login-card h1 { color: var(--ink); font-size: 1.1rem; text-align: center; font-weight: 600; }
.login-logo { width: 190px; height: auto; display: block; margin: 0 auto .4rem; }
.ax-head { display: grid; grid-template-columns: 130px 1fr 130px; align-items: center; margin-bottom: 18px; }
.ax-head img { width: 120px; height: auto; display: block; }
.ax-head .sub { margin-bottom: 0; }

/* Buton plutitor „Cursă nouă” */
.fab {
  position: fixed; right: 20px; bottom: 20px; z-index: 20;
  display: inline-flex; align-items: center; gap: .5rem;
  background: var(--navy); color: #fff; border: 0; border-radius: 99px;
  padding: .85rem 1.3rem .85rem 1.05rem; font: inherit; font-weight: 600; cursor: pointer;
  box-shadow: 0 8px 24px rgba(35,87,138,.35), 0 2px 6px rgba(0,0,0,.12);
  transition: transform .15s ease, background .15s ease;
}
.fab span { font-size: 1.5rem; line-height: 1; font-weight: 400; margin-top: -2px; }
.fab:hover { background: var(--navy-2); transform: translateY(-1px); }
.fab:focus-visible { outline: 3px solid #8fb1d3; outline-offset: 2px; }
main { padding-bottom: 96px; }
@media (max-width: 520px) {
  .fab { right: 16px; bottom: 16px; padding: .8rem 1.1rem .8rem .95rem; }
}
.toast { position: fixed; left: 50%; bottom: 84px; transform: translateX(-50%); background: var(--navy); color: #fff; padding: .6rem 1rem; border-radius: 8px; z-index: 50; box-shadow: 0 6px 20px rgba(0,0,0,.2); }
@media (max-width: 520px) { .hide-sm { display: none; } .mini th, .mini td { padding: .45rem .35rem; } }
@media (max-width: 520px) {
  .mini { font-size: .84rem; }
  .mini th { font-size: .7rem; }
  .mini .small { display: none; }
  .mini td:first-child { white-space: normal; }
  .sharebar { width: 28px; }
  .swatch { margin-right: .3rem; }
  .card { padding: .85rem; }
}
.col .stack .cap { position: absolute; left: 50%; transform: translateX(-50%); font-size: .75rem; font-weight: 600;
  color: var(--text); white-space: nowrap; font-variant-numeric: tabular-nums; }
.tag.late { background: #eef1f5; color: var(--muted); font-weight: 600; margin-top: .2rem; }
#tripForm .grid2 { grid-template-columns: 1fr 1fr 1fr; }
@media (max-width: 480px) { #tripForm .grid2 { grid-template-columns: 1fr 1fr; } #tripForm .grid2 label:first-child { grid-column: 1 / -1; } }
/* logo-ul e JPG pe alb: „multiply” face fundalul alb să dispară pe orice fundal deschis */
.brand img, .login-logo, .ax-head img { mix-blend-mode: multiply; filter: brightness(1.04) contrast(1.08); }

/* ---------- iPad / tabletă și ecrane tactile ---------- */
/* zonele sigure (bara de sus / indicatorul home) când rulează ca aplicație pe ecranul principal */
.topbar { padding-top: max(.55rem, env(safe-area-inset-top)); padding-left: max(16px, env(safe-area-inset-left)); padding-right: max(16px, env(safe-area-inset-right)); }
.fab { bottom: max(20px, calc(env(safe-area-inset-bottom) + 12px)); right: max(20px, calc(env(safe-area-inset-right) + 12px)); }
html { -webkit-text-size-adjust: 100%; }
button, .chip button, .col, .presets button { -webkit-tap-highlight-color: transparent; touch-action: manipulation; }

/* Pe ecrane tactile: ținte de atingere de minim 44px și text de 16px în câmpuri (altfel Safari face zoom) */
@media (pointer: coarse) {
  input, select, textarea, label > input, label > textarea { font-size: 16px; min-height: 44px; }
  .btn { min-height: 44px; padding: .55rem 1rem; }
  .btn.small { min-height: 38px; }
  .tabs button { min-height: 44px; padding: .5rem 1rem; }
  .icon-btn { width: 44px; height: 44px; }
  .presets button { min-height: 40px; padding: .45rem .95rem; }
  .seg span { padding: .75rem .5rem; }
  .chip { padding: .3rem .3rem .3rem .8rem; }
  .chip button { width: 32px; height: 32px; }
  .unload-row .rm { width: 44px; height: 44px; }
  .trips td { padding-top: .75rem; padding-bottom: .75rem; }
  .fab { padding: 1rem 1.4rem 1rem 1.15rem; font-size: 1.05rem; }
}

/* Tabletă cu ecran tactil (iPad portret și peisaj) — calculatorul și telefonul nu sunt afectate */
@media (min-width: 740px) and (pointer: coarse) {
  body { font-size: 16px; }
  main { padding: 20px 24px 110px; }
  .chart { height: 280px; }
  dialog { width: min(640px, calc(100vw - 48px)); }
  #tripForm { padding: 1.4rem; gap: 1rem; }
}
/* Ecrane medii și mari: cifrele principale de pe Acasă pe un singur rând */
@media (min-width: 740px) { #homeBody .summary { grid-template-columns: repeat(4, 1fr); } }
/* iPad în peisaj: tabelele „Pe firme” și „Pe camioane” una lângă alta */
@media (min-width: 1000px) { .grid-2 { grid-template-columns: 1fr 1fr; } }
