/* app.css — AETR tervező, iPad (portrait + landscape) */
:root {
  --bg: #14213D; --panel: #1E2A4A; --panel2: #263553; --text: #F1F5F9; --muted: #A7B3C8;
  --red: #E63946; --amber: #F4A261; --green: #2A9D8F; --green-dark: #1F6F66;
  --sky: #2B7DE9; --violet: #7C5CD6; --grey: #6B7A90;
}
/* --- noćni režim: zatamnjeno, crveno-tonirano (manje zaslepljuje, čuva noćni vid) --- */
html.night {
  --bg: #0A0202; --panel: #1A0808; --panel2: #240D0D; --text: #C97B6B; --muted: #7A4A42;
  --red: #A8433A; --amber: #8A6035; --green: #5A4A38; --green-dark: #4A3A2C;
  --sky: #5A4038; --violet: #5A4048; --grey: #4A3A38;
}
* { box-sizing: border-box; }
html, body { margin: 0; background: var(--bg); color: var(--text);
  font-family: -apple-system, "SF Pro Display", "Segoe UI", system-ui, sans-serif; -webkit-text-size-adjust: 100%; }
body { padding: max(16px, env(safe-area-inset-top)) 16px 24px; user-select: none; -webkit-user-select: none; }
button { font: inherit; color: inherit; border: 0; cursor: pointer; border-radius: 16px; touch-action: manipulation; }
button:active { transform: scale(0.97); }
input { font: inherit; color: var(--text); background: var(--panel2); border: 0; border-radius: 8px; padding: 8px 10px; }
input[type=number] { width: 84px; text-align: right; }
input.delayed { background: rgba(244,162,97,.35); }
h2 { margin: 0 0 12px; font-size: 20px; }
b { color: var(--text); }
.panel { background: var(--panel); border-radius: 24px; padding: 20px; margin-bottom: 16px; }

/* --- PIN login --- */
.login-screen { min-height: 80vh; display: flex; align-items: center; justify-content: center; }
.login-box { width: 100%; max-width: 320px; display: flex; flex-direction: column; gap: 14px; }
.login-box input { text-align: center; font-size: 26px; letter-spacing: 8px; padding: 14px; }
.login-box button { padding: 14px; font-size: 16px; font-weight: 700; }

/* --- jezik --- */
.lang-bar { display: flex; justify-content: space-between; align-items: center; flex-wrap: wrap; gap: 8px; margin-bottom: 12px; }
.tools { display: flex; gap: 8px; flex-wrap: wrap; }
.tool { background: var(--panel); color: var(--muted); padding: 10px 14px; border-radius: 999px; font-size: 14px; font-weight: 600; }
.tool.on { background: var(--green); color: #fff; }
body.flash-warn { animation: flashW 1s 3; } body.flash-crit { animation: flashC .6s 6; }
@keyframes flashW { 50% { background: #7A4A1E; } } @keyframes flashC { 50% { background: #7A1E26; } }
.lang-toggle { display: inline-flex; background: var(--panel); border-radius: 999px; padding: 4px; }
.lang-toggle button { display: flex; align-items: center; gap: 8px; padding: 8px 16px; border-radius: 999px; font-weight: 600; font-size: 14px; background: transparent; color: var(--muted); }
.lang-toggle button.active { background: var(--text); color: var(--bg); }
.lang-toggle .flag { font-size: 20px; line-height: 1; }

/* --- alarm --- */
.alarm { border-radius: 16px; padding: 12px 20px; font-size: 18px; font-weight: 600; margin-bottom: 16px; }
.alarm.crit { background: var(--red); animation: pulse 1.2s infinite; }
.alarm.warn { background: var(--amber); color: #111; }
.error { background: rgba(230,57,70,.35); border-radius: 16px; padding: 12px 20px; margin-bottom: 16px; }
@keyframes pulse { 50% { opacity: .55; } }
@media (prefers-reduced-motion: reduce) { .alarm.crit { animation: none; } }

/* --- podsetnik: prebaci tahograf --- */
.tacho-banner { position: sticky; top: max(8px, env(safe-area-inset-top)); z-index: 40; background: var(--amber); color: #111;
  border-radius: 16px; padding: 14px 18px; margin-bottom: 16px; display: flex; align-items: center; justify-content: space-between;
  gap: 14px; flex-wrap: wrap; box-shadow: 0 6px 20px rgba(0,0,0,.4); animation: pulse 1.2s infinite; }
.tacho-msg { font-size: 17px; font-weight: 700; }
.tacho-btn { background: #111; color: #fff; padding: 14px 20px; font-size: 16px; font-weight: 700; white-space: nowrap; }
@media (prefers-reduced-motion: reduce) { .tacho-banner { animation: none; } }

/* --- hero --- */
.hero-top { display: flex; justify-content: space-between; align-items: flex-end; flex-wrap: wrap; gap: 8px; }
.hero-label { color: var(--muted); font-size: 14px; }
.hero-big { font-size: 64px; font-weight: 700; line-height: 1; font-variant-numeric: tabular-nums; }
.hero-meta { text-align: right; font-size: 14px; color: var(--muted); line-height: 1.6; }
.bar { height: 20px; border-radius: 999px; background: #3A4763; overflow: hidden; margin-top: 16px; }
.bar > div { height: 100%; transition: width .5s; }
.bar .ok { background: var(--green); } .bar .warn { background: var(--amber); } .bar .crit { background: var(--red); }
.acts { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; margin-top: 16px; }
.acts button { padding: 14px 4px 12px; font-weight: 600; font-size: 15px; opacity: .8; }
.acts .ico { display: block; width: 40px; height: 40px; margin: 0 auto 6px; }
.acts .ico svg { width: 100%; height: 100%; }
.acts button.active { opacity: 1; box-shadow: 0 0 0 4px #fff; }
.acts small { display: block; font-weight: 400; font-size: 12px; margin-top: 2px; }
.a-driving { background: var(--sky); } .a-work { background: var(--violet); } .a-availability { background: var(--grey); }
.a-break { background: var(--green); } .a-rest { background: var(--green-dark); }

/* --- obaveze / mogućnosti --- */
.two-col { display: grid; grid-template-columns: 1fr; gap: 16px; }
@media (min-width: 900px) { .two-col { grid-template-columns: 1fr 1fr; } }
.two-col .panel { margin: 0; }
h2.red { color: #FCA5A5; } h2.green { color: #86EFAC; }
ul.list { list-style: none; margin: 0; padding: 0; display: grid; gap: 8px; }
ul.list li { border-radius: 12px; padding: 12px 16px; border-left: 4px solid; }
ul.list li .d { font-size: 14px; color: var(--muted); margin-top: 2px; }
li.crit { border-color: var(--red); background: rgba(230,57,70,.12); }
li.warn { border-color: var(--amber); background: rgba(244,162,97,.12); }
li.info { border-color: var(--grey); background: rgba(107,122,144,.12); }
li.ok   { border-color: var(--green); background: rgba(42,157,143,.12); }
.stats { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin-top: 16px; text-align: center; }
.stats div { background: var(--panel2); border-radius: 12px; padding: 12px; }
.stats span { display: block; font-size: 12px; color: var(--muted); }
.stats strong { font-size: 24px; }

/* --- planer --- */
.planner-head { display: flex; justify-content: space-between; align-items: center; flex-wrap: wrap; gap: 12px; margin-bottom: 12px; }
.planner-head label { font-size: 14px; }
.planner-head input { margin-left: 8px; }
.planner-opts { display: flex; flex-wrap: wrap; gap: 12px; }
.planner-opts input[type=number] { width: 64px; }
table { width: 100%; border-collapse: collapse; font-size: 14px; }
th { text-align: left; color: var(--muted); font-weight: 500; padding: 4px; }
td { padding: 6px 4px; border-top: 1px solid #3A4763; font-variant-numeric: tabular-nums; }
td input.name { width: 100%; background: transparent; border-radius: 0; border-bottom: 1px solid #56658A; padding: 6px 2px; }
td button.del { background: transparent; color: #FCA5A5; padding: 4px 8px; font-size: 16px; }
.planner-foot { display: flex; flex-wrap: wrap; gap: 12px; align-items: center; margin-top: 12px; font-size: 14px; color: var(--muted); }
.btn-grey { background: #3A4763; padding: 8px 16px; border-radius: 12px; }
.route-warn { margin-top: 8px; background: rgba(230,57,70,.3); border-radius: 12px; padding: 8px 16px; }
ul.timeline { list-style: none; margin: 12px 0 0; padding: 0; display: grid; grid-template-columns: 1fr; gap: 4px; font-size: 14px; }
@media (min-width: 700px) { ul.timeline { grid-template-columns: 1fr 1fr; } }
ul.timeline li { border-radius: 8px; padding: 8px 12px; }
ul.timeline li.work { background: rgba(124,92,214,.45); } ul.timeline li.break { background: rgba(42,157,143,.4); } ul.timeline li.rest { background: rgba(31,111,102,.6); }

/* --- export --- */
.export { display: flex; flex-wrap: wrap; gap: 12px; }
.export button { padding: 16px 24px; font-size: 18px; font-weight: 600; }
.b-sky { background: var(--sky); } .b-grey { background: #4A5878; } .b-dark { background: var(--panel); font-weight: 400; }

/* --- kraj dana --- */
.end-day { display: flex; align-items: center; justify-content: center; gap: 10px; width: 100%; margin-top: 12px;
  padding: 16px; font-size: 18px; font-weight: 700; background: #8B2635; color: #fff; }
.end-day .ico-inline { width: 28px; height: 28px; }
.day-closed { background: rgba(31,111,102,.35); border: 2px solid var(--green-dark); border-radius: 16px; padding: 16px; margin-top: 16px; }
.dc-title { font-size: 18px; font-weight: 700; margin-bottom: 12px; }
.dc-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px; }
@media (min-width: 900px) { .dc-grid { grid-template-columns: repeat(4, 1fr); } }
.dc-grid div { background: var(--panel2); border-radius: 12px; padding: 10px 12px; }
.dc-grid span { display: block; font-size: 12px; color: var(--muted); }
.dc-grid strong { font-size: 20px; }
.dc-grid em { display: block; font-size: 12px; color: var(--amber); font-style: normal; }
.dc-sub { margin: 14px 0 6px; font-weight: 600; }
table.fc td, table.fc th { padding: 6px 8px; }
table.fc tr.wr td { background: rgba(230,57,70,.2); }

/* --- radno vreme + savetnik --- */
.stats.four { grid-template-columns: repeat(2, 1fr); margin-top: 0; }
@media (min-width: 900px) { .stats.four { grid-template-columns: repeat(4, 1fr); } }
.stats strong.bad { color: #FCA5A5; }
.stats em { display: block; font-size: 12px; color: var(--amber); font-style: normal; }
.adv { display: grid; grid-template-columns: 1fr; gap: 12px; }
@media (min-width: 900px) { .adv { grid-template-columns: repeat(3, 1fr); } }
.adv-col { background: var(--panel2); border-radius: 16px; padding: 14px; }
.adv-col.now { outline: 2px solid var(--green); }
.adv-col h3 { margin: 0 0 10px; font-size: 17px; }
.adv-col h3 small { display: block; font-weight: 400; font-size: 12px; color: var(--muted); }
.adv-col ul.list li { padding: 8px 12px; font-size: 14px; }

/* --- dnevnik --- */
.seg { display: inline-flex; background: var(--panel2); border-radius: 999px; padding: 4px; }
.seg button { padding: 8px 14px; border-radius: 999px; font-size: 14px; background: transparent; color: var(--muted); }
.seg button.active { background: var(--text); color: var(--bg); }
table.log td { vertical-align: middle; }
table.log .ico-s { display: inline-block; width: 20px; height: 20px; vertical-align: -4px; margin-right: 6px; }
table.log .ico-s svg { width: 100%; height: 100%; }
table.log tr.t-driving .ico-s { color: #7FB3F5; } table.log tr.t-work .ico-s { color: #B9A5F0; }
table.log tr.t-availability .ico-s { color: #B0BACB; } table.log tr.t-break .ico-s, table.log tr.t-rest .ico-s { color: #7FD6C8; }
table.log td.note { color: var(--muted); font-size: 13px; }
table.log tr.edit td { background: rgba(43,125,233,.12); }
table.log select { font: inherit; color: var(--text); background: var(--panel2); border: 0; border-radius: 8px; padding: 8px; }
table.log input[type=text] { width: 100%; }
.acts-cell { white-space: nowrap; }
.acts-cell button { margin-right: 4px; }
.btn-save { background: var(--green); padding: 8px 16px; border-radius: 12px; font-weight: 600; }

/* --- povratna informacija na pritisak --- */
.acts button.pending, .end-day.pending { opacity: 1; box-shadow: 0 0 0 4px #fff; animation: pendPulse .7s infinite; }
@keyframes pendPulse { 50% { box-shadow: 0 0 0 4px rgba(255,255,255,.35); } }
button[disabled] { cursor: default; }
#toast { position: fixed; left: 50%; bottom: 28px; transform: translateX(-50%) translateY(20px); opacity: 0; pointer-events: none;
  padding: 14px 24px; border-radius: 999px; font-size: 18px; font-weight: 600; color: #fff; background: var(--green); box-shadow: 0 6px 24px rgba(0,0,0,.4);
  transition: opacity .15s, transform .15s; z-index: 50; max-width: 90vw; text-align: center; }
#toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }
#toast.bad { background: var(--red); }

/* --- dvostepena potvrda --- */
.end-day.confirm { background: var(--red); animation: pendPulse .7s infinite; }
td button.del.confirm { background: var(--red); color: #fff; border-radius: 12px; padding: 8px 12px; font-size: 14px; font-weight: 600; }

/* --- planer po vremenima --- */
.table-wrap { overflow-x: auto; }
table.plan th, table.plan td { white-space: nowrap; }
table.plan td.real, table.plan td.status { white-space: normal; min-width: 120px; }
.tin { display: inline-flex; align-items: center; gap: 4px; }
.tin input[type=datetime-local] { width: 170px; }
.tin .now { background: var(--panel2); color: var(--muted); padding: 6px 8px; border-radius: 8px; font-size: 14px; }
.muted { color: var(--muted); font-size: 12px; display: block; }
.st-ok { color: #86EFAC; font-weight: 600; } .st-late { color: #FCA5A5; font-weight: 700; } .st-none { color: var(--muted); }
.ins { font-size: 12px; color: var(--amber); }
.sel { font: inherit; color: var(--text); background: var(--panel2); border: 0; border-radius: 8px; padding: 8px 10px; max-width: 220px; }
ul.timeline li.availability { background: rgba(107,122,144,.35); }
.tin input.auto { color: var(--muted); background: rgba(38,53,83,.6); }
