:root {
  --bg: #0e1116;
  --bg-elev: #161b23;
  --bg-elev-2: #1d242e;
  --line: #262f3d;
  --text: #e9edf3;
  --muted: #8d98a9;
  --accent: #ff7a45;
  --accent-soft: rgba(255, 122, 69, 0.14);
  --green: #3ddc97;
  --radius: 14px;
  --maxw: 620px;
  /* Sigurne zone telefona (urez, statusna traka, zaobljeni uglovi).
     index.html koristi viewport-fit=cover, pa sadrzaj ide od ivice do ivice —
     zato se ovde mora ostaviti mesta, inace vrh zaglavlja zavrsi ispod
     statusne trake i dugmad tamo ne mogu da se pritisnu. */
  --safe-t: env(safe-area-inset-top, 0px);
  --safe-b: env(safe-area-inset-bottom, 0px);
  --safe-l: env(safe-area-inset-left, 0px);
  --safe-r: env(safe-area-inset-right, 0px);
}

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

html,
body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--text);
  font: 16px/1.45 -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue',
    Arial, sans-serif;
  overscroll-behavior-y: none;
}

body {
  min-height: 100dvh;
}

.app {
  max-width: var(--maxw);
  margin: 0 auto;
  padding: 0 calc(14px + var(--safe-r)) calc(120px + var(--safe-b)) calc(14px + var(--safe-l));
}

.loading {
  padding: calc(40px + var(--safe-t)) 0 40px;
  color: var(--muted);
  text-align: center;
}

/* ---------------------------------------------------------------- topbar */

.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  gap: 10px;
  /* gornja ivica ulazi ispod statusne trake — sadrzaj se spusta ispod nje */
  padding: calc(14px + var(--safe-t)) 0 10px;
  /* puna boja ispod teksta, bledi tek u donjoj ivici — inace sadrzaj
     koji se skroluje probija kroz naslov */
  background: linear-gradient(var(--bg) 88%, rgba(14, 17, 22, 0));
}

.topbar h1 {
  flex: 1;
  margin: 0;
  font-size: 19px;
  font-weight: 650;
  letter-spacing: -0.01em;
}

.topbar .sub {
  display: block;
  font-size: 12.5px;
  font-weight: 500;
  color: var(--muted);
  letter-spacing: 0;
}

.iconbtn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 38px;
  height: 38px;
  padding: 0 11px;
  border: 1px solid var(--line);
  border-radius: 11px;
  background: var(--bg-elev);
  color: var(--text);
  font-size: 14px;
  font-weight: 550;
  text-decoration: none;
  cursor: pointer;
}

.iconbtn:active {
  background: var(--bg-elev-2);
}

/* ------------------------------------------------------------------ cards */

.card {
  margin: 0 0 12px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--bg-elev);
}

.daycard {
  display: flex;
  align-items: center;
  gap: 12px;
  width: 100%;
  margin-bottom: 10px;
  padding: 15px 14px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--bg-elev);
  color: inherit;
  text-align: left;
  text-decoration: none;
  cursor: pointer;
}

.daycard:active {
  transform: scale(0.99);
}

.daycard .badge {
  display: grid;
  place-items: center;
  width: 44px;
  height: 44px;
  flex: 0 0 44px;
  border-radius: 12px;
  background: var(--accent-soft);
  color: var(--accent);
  font-size: 13px;
  font-weight: 700;
  text-transform: uppercase;
}

.daycard .body {
  flex: 1;
  min-width: 0;
}

.daycard .t {
  font-weight: 600;
  font-size: 16px;
}

.daycard .m {
  margin-top: 2px;
  font-size: 12.5px;
  color: var(--muted);
}

.daycard .chev {
  color: var(--muted);
  font-size: 20px;
}

.section-title {
  margin: 22px 0 10px;
  font-size: 12.5px;
  font-weight: 650;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

/* --------------------------------------------------------------- vezbe */

.ex {
  margin: 0 0 12px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--bg-elev);
  overflow: hidden;
}

.ex > header {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 13px 14px 11px;
}

.ex .num {
  display: grid;
  place-items: center;
  width: 23px;
  height: 23px;
  flex: 0 0 23px;
  margin-top: 1px;
  border-radius: 7px;
  background: var(--bg-elev-2);
  color: var(--muted);
  font-size: 12px;
  font-weight: 650;
}

.ex .name {
  flex: 1;
  min-width: 0;
  font-size: 15.5px;
  font-weight: 620;
  line-height: 1.3;
}

.ex .note {
  margin-top: 3px;
  font-size: 12.5px;
  color: var(--muted);
}

.ex .link {
  flex: 0 0 auto;
  padding: 2px 6px;
  color: var(--muted);
  font-size: 12px;
  text-decoration: none;
}

.sets {
  padding: 0 14px 6px;
}

.set {
  display: grid;
  grid-template-columns: 62px 1fr 1fr;
  gap: 8px;
  align-items: center;
  padding: 5px 0;
}

.set .lab {
  font-size: 12px;
  font-weight: 600;
  color: var(--muted);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.set.warm .lab {
  color: #6f7b8d;
}

.field {
  position: relative;
}

.field input {
  width: 100%;
  height: 46px;
  padding: 0 34px 0 11px;
  border: 1px solid var(--line);
  border-radius: 11px;
  background: var(--bg-elev-2);
  color: var(--text);
  font-size: 17px;
  font-weight: 560;
  font-variant-numeric: tabular-nums;
  appearance: none;
}

.field input::placeholder {
  color: #5d6878;
  font-weight: 500;
}

.field input:focus {
  outline: none;
  border-color: var(--accent);
  background: #212a36;
}

.field .unit {
  position: absolute;
  top: 50%;
  right: 10px;
  transform: translateY(-50%);
  color: var(--muted);
  font-size: 11.5px;
  font-weight: 600;
  pointer-events: none;
}

.field input.done {
  border-color: rgba(61, 220, 151, 0.4);
}

.prevrow {
  grid-column: 1 / -1;
  margin: -2px 0 2px;
  padding-left: 62px;
  color: #74808f;
  font-size: 11.5px;
  font-variant-numeric: tabular-nums;
}

.exfoot {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 4px 14px 13px;
}

.minibtn {
  padding: 7px 10px;
  border: 1px solid var(--line);
  border-radius: 9px;
  background: transparent;
  color: var(--muted);
  font-size: 12.5px;
  font-weight: 600;
  cursor: pointer;
}

.minibtn:active {
  background: var(--bg-elev-2);
}

.exfoot .vol {
  margin-left: auto;
  color: var(--muted);
  font-size: 12px;
  font-variant-numeric: tabular-nums;
}

.exnote {
  width: 100%;
  min-height: 40px;
  margin: 0 0 12px;
  padding: 9px 11px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--bg-elev-2);
  color: var(--text);
  font: inherit;
  font-size: 14px;
  resize: vertical;
}

.exnote:focus {
  outline: none;
  border-color: var(--accent);
}

.exnote-wrap {
  padding: 0 14px;
}

/* ------------------------------------------------------------------ meta */

.metagrid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

.metagrid label,
.labeled {
  display: block;
  font-size: 11.5px;
  font-weight: 650;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.metagrid input,
.labeled input {
  width: 100%;
  height: 44px;
  margin-top: 5px;
  padding: 0 11px;
  border: 1px solid var(--line);
  border-radius: 11px;
  background: var(--bg-elev-2);
  color: var(--text);
  font: inherit;
  font-size: 16px;
  appearance: none;
}

.metagrid input:focus,
.labeled input:focus {
  outline: none;
  border-color: var(--accent);
}

/* --------------------------------------------------------------- savebar */

.savebar {
  position: fixed;
  right: 0;
  bottom: 0;
  left: 0;
  z-index: 30;
  padding: 10px calc(14px + var(--safe-r)) calc(10px + var(--safe-b)) calc(14px + var(--safe-l));
  border-top: 1px solid var(--line);
  background: rgba(16, 20, 26, 0.94);
  backdrop-filter: blur(12px);
}

.savebar .inner {
  display: flex;
  align-items: center;
  gap: 12px;
  max-width: var(--maxw);
  margin: 0 auto;
}

.savebar .stat {
  flex: 1;
  min-width: 0;
  font-size: 12.5px;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
}

.savebar .stat b {
  display: block;
  color: var(--text);
  font-size: 14px;
  font-weight: 650;
}

.btn {
  height: 48px;
  padding: 0 22px;
  border: none;
  border-radius: 12px;
  background: var(--accent);
  color: #1a0d06;
  font-size: 16px;
  font-weight: 700;
  cursor: pointer;
}

.btn:active {
  filter: brightness(0.92);
}

.btn:disabled {
  opacity: 0.55;
}

.btn.ghost {
  border: 1px solid var(--line);
  background: transparent;
  color: var(--text);
  font-weight: 600;
}

.btn.danger {
  background: transparent;
  border: 1px solid rgba(255, 107, 107, 0.45);
  color: #ff8080;
  font-weight: 600;
}

.btn.block {
  width: 100%;
}

/* -------------------------------------------------------------- istorija */

.hist {
  display: flex;
  align-items: center;
  gap: 12px;
  width: 100%;
  margin-bottom: 8px;
  padding: 12px 14px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--bg-elev);
  color: inherit;
  text-align: left;
  text-decoration: none;
  cursor: pointer;
}

.hist .d {
  flex: 0 0 52px;
  color: var(--accent);
  font-size: 13px;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}

.hist .b {
  flex: 1;
  min-width: 0;
}

.hist .b .t {
  font-size: 15px;
  font-weight: 600;
}

.hist .b .m {
  margin-top: 2px;
  color: var(--muted);
  font-size: 12.5px;
}

table.view {
  width: 100%;
  border-collapse: collapse;
  font-variant-numeric: tabular-nums;
}

table.view td {
  padding: 5px 0;
  font-size: 14.5px;
}

table.view td.l {
  width: 72px;
  color: var(--muted);
  font-size: 12.5px;
}

table.view td.v {
  font-weight: 560;
}

.bars {
  display: flex;
  align-items: flex-end;
  gap: 6px;
  height: 86px;
  margin: 6px 0 2px;
}

.bars .b {
  flex: 1;
  min-width: 0;
  border-radius: 5px 5px 0 0;
  background: var(--accent);
  opacity: 0.85;
}

.bars .b.lo {
  background: #3b4654;
}

.barlabels {
  display: flex;
  gap: 6px;
  color: var(--muted);
  font-size: 10px;
}

.barlabels span {
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-align: center;
  white-space: nowrap;
}

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

.chips {
  display: flex;
  flex-wrap: wrap;
  gap: 7px;
  margin-top: 8px;
}

.chip {
  padding: 5px 10px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--bg-elev-2);
  color: var(--muted);
  font-size: 12px;
  font-variant-numeric: tabular-nums;
}

.chip b {
  color: var(--text);
  font-weight: 650;
}

/* ----------------------------------------------------------------- toast */

.toast {
  position: fixed;
  bottom: calc(86px + var(--safe-b));
  left: 50%;
  z-index: 60;
  max-width: 88vw;
  padding: 11px 16px;
  border-radius: 11px;
  background: #e9edf3;
  color: #12161c;
  font-size: 14px;
  font-weight: 600;
  transform: translateX(-50%);
  box-shadow: 0 8px 28px rgba(0, 0, 0, 0.45);
}

.toast.err {
  background: #ff7070;
  color: #2b0505;
}

/* ----------------------------------------------------------------- login */

.login {
  max-width: 340px;
  margin: 16vh auto 0;
  padding-top: var(--safe-t);
  text-align: center;
}

.login h1 {
  margin: 0 0 6px;
  font-size: 22px;
}

.login p {
  margin: 0 0 20px;
  color: var(--muted);
  font-size: 14px;
}

.login input {
  width: 100%;
  height: 48px;
  margin-bottom: 10px;
  padding: 0 13px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--bg-elev);
  color: var(--text);
  font: inherit;
  font-size: 16px;
}

.login input:focus {
  outline: none;
  border-color: var(--accent);
}

/* ----------------------------------------------------------------- kardio */

.ex.cardio {
  border-color: rgba(255, 122, 69, 0.3);
}

.ex .num.heart {
  background: var(--accent-soft);
  color: var(--accent);
  font-size: 13px;
}

.cardiogrid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  padding: 2px 14px 12px;
}

.cf span {
  display: block;
  margin-bottom: 5px;
  font-size: 11.5px;
  font-weight: 650;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.cardioview {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 8px;
  padding: 2px 14px 14px;
}

.cv {
  padding: 9px 4px;
  border: 1px solid var(--line);
  border-radius: 11px;
  background: var(--bg-elev-2);
  text-align: center;
}

.cv b {
  display: block;
  font-size: 17px;
  font-weight: 680;
  font-variant-numeric: tabular-nums;
}

.cv b i {
  margin-left: 2px;
  color: var(--muted);
  font-size: 10.5px;
  font-style: normal;
  font-weight: 600;
}

.cv span {
  display: block;
  margin-top: 1px;
  color: var(--muted);
  font-size: 10.5px;
}

/* ----------------------------------------------------------------- navrow */

.navrow {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin: 14px 0 12px;
}

.navrow a {
  padding: 12px 13px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--bg-elev);
  color: inherit;
  text-decoration: none;
}

.navrow a b {
  display: block;
  font-size: 14.5px;
  font-weight: 620;
}

.navrow a span {
  display: block;
  margin-top: 2px;
  color: var(--muted);
  font-size: 12px;
}

.navrow a:active {
  background: var(--bg-elev-2);
}

/* ------------------------------------------------------- slike progresa */

.minibtn.on {
  border-color: var(--accent);
  background: var(--accent-soft);
  color: var(--accent);
}

.photostrip {
  display: flex;
  gap: 8px;
  margin: 0 0 4px;
  padding-bottom: 4px;
  overflow-x: auto;
  scrollbar-width: none;
}

.photostrip::-webkit-scrollbar {
  display: none;
}

.photostrip .pt {
  position: relative;
  flex: 0 0 78px;
  border-radius: 11px;
  overflow: hidden;
  text-decoration: none;
}

.photostrip .pt img {
  display: block;
  width: 78px;
  height: 104px;
  background: var(--bg-elev-2);
  object-fit: cover;
}

.photostrip .pt span {
  position: absolute;
  right: 0;
  bottom: 0;
  left: 0;
  padding: 10px 5px 4px;
  background: linear-gradient(rgba(0, 0, 0, 0), rgba(0, 0, 0, 0.75));
  color: #fff;
  font-size: 10.5px;
  font-weight: 650;
  text-align: center;
}

.photogrid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
  gap: 10px;
  margin-bottom: 14px;
}

.pc {
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--bg-elev);
  overflow: hidden;
  color: inherit;
  text-decoration: none;
}

.pc img {
  display: block;
  width: 100%;
  aspect-ratio: 3 / 4;
  background: var(--bg-elev-2);
  object-fit: cover;
}

.pc .cap {
  padding: 8px 10px 10px;
}

.pc .cap b {
  display: block;
  font-size: 13px;
  font-weight: 620;
}

.pc .cap span {
  display: block;
  margin-top: 1px;
  color: var(--muted);
  font-size: 11.5px;
}

.shotone,
.compare {
  margin-bottom: 12px;
}

.compare {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}

.shot {
  margin: 0;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--bg-elev);
  overflow: hidden;
}

.shot img {
  display: block;
  width: 100%;
  background: #000;
  object-fit: contain;
}

.shotone .shot img {
  max-height: 68vh;
}

.compare .shot img {
  aspect-ratio: 3 / 4;
  object-fit: cover;
}

.shot figcaption {
  padding: 8px 10px;
  color: var(--muted);
  font-size: 11.5px;
  text-align: center;
}

.sel {
  width: 100%;
  height: 44px;
  padding: 0 11px;
  border: 1px solid var(--line);
  border-radius: 11px;
  background: var(--bg-elev-2);
  color: var(--text);
  font: inherit;
  font-size: 15px;
  appearance: none;
}

.sel:focus {
  outline: none;
  border-color: var(--accent);
}

/* Ispis datuma na srpskom ispod polja za datum (polje prati format telefona). */
.dhint {
  display: block;
  margin-top: 5px;
  color: var(--muted);
  font-size: 11.5px;
  font-weight: 500;
  letter-spacing: 0;
  text-transform: none;
}

/* Treci element u navrow-u (kad ih je neparan broj) uzima ceo red. */
.navrow a:last-child:nth-child(odd) {
  grid-column: 1 / -1;
}
