:root {
  --ink: #1c1d22;
  --red: #9c231f;
  --gold: #b5842a;
  --gold-soft: #e7d3a4;
  --navy: #1e3350;
  --paper: #faf7f2;
  --paper-dim: #f0ebe1;
  --line: #ddd3c2;
  --white: #ffffff;
  --ok: #3f7a4d;
  --warn: #9c621f;
  --danger: #9c231f;
  --radius: 4px;
  --shadow: 0 1px 2px rgba(28, 29, 34, 0.08), 0 4px 14px rgba(28, 29, 34, 0.06);
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--paper);
  color: var(--ink);
  font-family: "PT Sans", Arial, sans-serif;
  font-size: 16px;
  line-height: 1.5;
  overflow-x: hidden;
  max-width: 100%;
}

h1, h2, h3, h4 {
  font-family: "PT Serif", Georgia, serif;
  color: var(--ink);
  margin: 0 0 0.6em;
  line-height: 1.2;
}

a { color: var(--navy); text-decoration: none; }
a:hover { text-decoration: underline; }

.icon { width: 1.15em; height: 1.15em; flex-shrink: 0; vertical-align: -0.2em; }

/* ---------- Layout ---------- */

.app-header {
  background: var(--ink);
  color: var(--paper);
  border-bottom: 3px solid var(--red);
}

.app-header__inner {
  max-width: 1080px;
  margin: 0 auto;
  padding: 0 1.25rem;
  display: flex;
  align-items: center;
  gap: 1.5rem;
  min-height: 60px;
  flex-wrap: wrap;
}

.brand {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  color: var(--gold-soft);
  font-family: "PT Serif", serif;
  font-weight: 700;
  font-size: 1.05rem;
}
.brand:hover { text-decoration: none; color: var(--gold); }
.brand__icon { height: 34px; width: auto; display: block; }

.main-nav {
  display: flex;
  gap: 0.25rem;
  flex-wrap: wrap;
  margin-left: auto;
}

.main-nav a {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  color: #cfd3da;
  padding: 0.55rem 0.75rem;
  border-radius: var(--radius);
  font-size: 0.92rem;
}
.main-nav a:hover { color: var(--white); text-decoration: none; background: rgba(255,255,255,0.06); }
.main-nav a.is-active { color: var(--white); background: var(--navy); }

.header-right {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  color: #cfd3da;
  font-size: 0.9rem;
}

.btn-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 2rem;
  height: 2rem;
  color: #cfd3da;
  border-radius: var(--radius);
}
.btn-icon:hover { color: var(--white); background: rgba(255,255,255,0.08); text-decoration: none; }

.app-main {
  max-width: 1080px;
  margin: 0 auto;
  padding: 1.75rem 1.25rem 3rem;
}

/* ---------- Bottom tab bar (mobile) ---------- */

.bottom-nav {
  display: none;
}

@media (max-width: 720px) {
  .main-nav { display: none; }

  .app-main--s-donjom-trakom {
    padding-bottom: calc(5.6rem + env(safe-area-inset-bottom, 0px));
  }

  .bottom-nav {
    display: flex;
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 40;
    background: var(--ink);
    border-top: 1px solid #34353c;
    padding-bottom: env(safe-area-inset-bottom, 0px);
  }

  .bottom-nav a {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 0.2rem;
    padding: 0.6rem 0.1rem 0.7rem;
    color: #9ba0a8;
    font-size: 0.72rem;
    text-align: center;
    min-width: 0;
  }
  .bottom-nav a span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 100%; }
  .bottom-nav a:hover { text-decoration: none; }
  .bottom-nav a .icon { width: 1.65em; height: 1.65em; }
  .bottom-nav a.is-active { color: var(--gold); }
}

/* Vrlo uski ekrani (stari/manji telefoni) - malo manje da se 5-6 tabova ne stisne previše */
@media (max-width: 360px) {
  .bottom-nav a { font-size: 0.64rem; padding: 0.55rem 0.05rem 0.65rem; }
  .bottom-nav a .icon { width: 1.5em; height: 1.5em; }
}

.auth-page {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--ink);
  padding: 1.5rem;
}

/* ---------- Cards / panels ---------- */

.card {
  background: var(--white);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 1.5rem;
  margin-bottom: 1.5rem;
}

.card--narrow { max-width: 380px; width: 100%; }

.card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 1rem;
}

/* ---------- Forms ---------- */

label { display: block; font-weight: 700; font-size: 0.88rem; margin-bottom: 0.3rem; }

input[type=text], input[type=password], input[type=date], input[type=tel], input[type=number], select, textarea {
  width: 100%;
  padding: 0.55rem 0.7rem;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--white);
  color: var(--ink);
  font-family: inherit;
  font-size: 0.95rem;
}
input:focus, select:focus, textarea:focus {
  outline: 2px solid var(--navy);
  outline-offset: 1px;
}

.form-row { margin-bottom: 1rem; }
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 1rem; }
@media (max-width: 560px) { .form-grid { grid-template-columns: 1fr; } }

.hint { font-size: 0.82rem; color: #6b6f76; margin-top: 0.25rem; }

.btn {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.55rem 1.1rem;
  border-radius: var(--radius);
  border: 1px solid transparent;
  font-family: inherit;
  font-size: 0.92rem;
  font-weight: 700;
  cursor: pointer;
  background: var(--navy);
  color: var(--white);
}
.btn:hover { background: #16283f; text-decoration: none; }
.btn--red { background: var(--red); }
.btn--red:hover { background: #7d1c19; }
.btn--ghost { background: transparent; border-color: var(--line); color: var(--ink); }
.btn--ghost:hover { background: var(--paper-dim); }
.btn--sm { padding: 0.35rem 0.7rem; font-size: 0.82rem; }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }

.btn-row { display: flex; gap: 0.6rem; flex-wrap: wrap; }

/* ---------- Messages / badges ---------- */

.poruka {
  padding: 0.75rem 1rem;
  border-radius: var(--radius);
  margin-bottom: 1.25rem;
  font-size: 0.92rem;
  border: 1px solid transparent;
}
.poruka--uspjeh { background: #eaf3ec; color: var(--ok); border-color: #cfe4d3; }
.poruka--greska { background: #f7e6e5; color: var(--danger); border-color: #ecc7c4; }
.poruka--info { background: #eaf0f6; color: var(--navy); border-color: #cddaeb; }

.badge {
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  padding: 0.15rem 0.55rem;
  border-radius: 999px;
  font-size: 0.76rem;
  font-weight: 700;
  color: var(--white);
  white-space: nowrap;
}
.badge--status-na_cekanju { background: var(--warn); }
.badge--status-odobreno { background: var(--ok); }
.badge--status-odbijeno { background: var(--danger); }
.badge--status-otkazano { background: #8a8d93; }

/* ---------- Tables ---------- */

table { width: 100%; border-collapse: collapse; font-size: 0.92rem; }
th, td { text-align: left; padding: 0.6rem 0.6rem; border-bottom: 1px solid var(--line); vertical-align: middle; }
th { font-family: "PT Serif", serif; font-size: 0.85rem; color: #565a61; font-weight: 700; }
tr:last-child td { border-bottom: none; }
.table-wrap { overflow-x: auto; }

/* ---------- Calendar ---------- */

.kalendar-toolbar {
  display: flex;
  align-items: center;
  justify-content: center;
  margin-bottom: 1rem;
  gap: 0.75rem;
}
.kalendar-toolbar h2 {
  margin: 0;
  flex: 1;
  min-width: 0;
  max-width: 220px;
  text-align: center;
  font-size: 1.15rem;
}

.kalendar-grid {
  display: grid;
  grid-template-columns: repeat(7, minmax(0, 1fr));
  gap: 6px;
  width: 100%;
}

.kalendar-dan-naziv {
  text-align: center;
  font-size: 0.78rem;
  font-weight: 700;
  color: #6b6f76;
  padding-bottom: 0.3rem;
}

.kalendar-celija {
  background: var(--white);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  min-height: 92px;
  min-width: 0;
  padding: 0.4rem;
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
  overflow: hidden;
}
.kalendar-celija.izvan-mjeseca { background: var(--paper-dim); opacity: 0.55; }
.kalendar-celija.je-danas { border-color: var(--red); border-width: 2px; }
.kalendar-celija a { color: inherit; display: block; min-width: 0; }
.kalendar-celija a:hover { text-decoration: none; }

.kalendar-broj-dana { font-weight: 700; font-size: 0.85rem; }

.kalendar-smjena-red {
  font-size: 0.72rem;
  padding: 0.1rem 0.3rem;
  border-radius: 3px;
  display: flex;
  align-items: center;
  gap: 0.25rem;
  min-width: 0;
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
}
.kalendar-smjena-red .icon { flex-shrink: 0; width: 1em; height: 1em; }
.kalendar-smjena-red.tip-dan { background: var(--gold-soft); color: #4a3a12; }
.kalendar-smjena-red.tip-noc { background: #dfe4ec; color: var(--navy); }
.kalendar-smjena-broj { font-weight: 700; }
.kalendar-smjena-tekst { overflow: hidden; text-overflow: ellipsis; }

@media (max-width: 560px) {
  .app-main { padding-left: 0.6rem; padding-right: 0.6rem; }

  .kalendar-toolbar h2 { font-size: 1rem; }

  .kalendar-grid { gap: 3px; }

  .kalendar-dan-naziv { font-size: 0.62rem; padding-bottom: 0.2rem; }

  .kalendar-celija { min-height: 58px; padding: 0.25rem 0.2rem; border-radius: 3px; gap: 0.15rem; }

  .kalendar-broj-dana { font-size: 0.74rem; }

  .kalendar-smjena-red {
    font-size: 0; /* sakrij tekst, ostaje samo ikona + broj (koji imaju svoj font-size ispod) */
    padding: 0.1rem 0.15rem;
    gap: 0.1rem;
    justify-content: center;
  }
  .kalendar-smjena-red .icon { width: 0.85em; height: 0.85em; }
  .kalendar-smjena-broj { font-size: 0.68rem; }
  .kalendar-smjena-tekst { display: none; }
}

@media (max-width: 380px) {
  .kalendar-celija { min-height: 50px; }
  .kalendar-smjena-red .icon { display: none; } /* na jako uskim ekranima ostaje samo broj */
}

/* ---------- Shift day detail ---------- */

.smjena-blok { margin-bottom: 1.25rem; }
.smjena-naslov { display: flex; align-items: center; gap: 0.5rem; margin-bottom: 0.6rem; }
.osoba-chip {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  background: var(--paper-dim);
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 0.25rem 0.7rem 0.25rem 0.4rem;
  font-size: 0.86rem;
  margin: 0.15rem 0.3rem 0.15rem 0;
}
.uloga-tocka { width: 0.6rem; height: 0.6rem; border-radius: 50%; flex-shrink: 0; }

.stat-row { display: flex; gap: 1rem; flex-wrap: wrap; margin-bottom: 1.5rem; }
.stat-card {
  background: var(--white);
  border: 1px solid var(--line);
  border-left: 4px solid var(--navy);
  border-radius: var(--radius);
  padding: 1rem 1.25rem;
  flex: 1;
  min-width: 220px;
}
.stat-card.stat-card--dan { border-left-color: var(--gold); }
.stat-card.stat-card--noc { border-left-color: var(--navy); }
.stat-card .stat-label { font-size: 0.78rem; color: #6b6f76; text-transform: uppercase; letter-spacing: 0.03em; }
.stat-card .stat-value { font-family: "PT Serif", serif; font-size: 1.25rem; margin-top: 0.2rem; }

.upozorenje-box {
  display: flex;
  gap: 0.6rem;
  align-items: flex-start;
  background: #fbeee0;
  border: 1px solid #eccfa3;
  color: #6e4a12;
  padding: 0.75rem 1rem;
  border-radius: var(--radius);
  font-size: 0.88rem;
  margin: 0.75rem 0;
}
.upozorenje-box .icon { color: var(--warn); margin-top: 0.15em; }

.prazno-stanje { text-align: center; padding: 2.5rem 1rem; color: #6b6f76; }

.text-muted { color: #6b6f76; font-size: 0.85rem; }

/* ---------- Dan tehnike ---------- */

.sakriveno { display: none !important; }

.vozilo-tabovi {
  display: flex;
  gap: 0.4rem;
  overflow-x: auto;
  padding-bottom: 0.5rem;
  margin-bottom: 1rem;
  -webkit-overflow-scrolling: touch;
}

.vozilo-tab {
  flex-shrink: 0;
  display: flex;
  align-items: center;
  gap: 0.35rem;
  padding: 0.5rem 0.9rem;
  border-radius: 999px;
  background: var(--white);
  border: 1px solid var(--line);
  color: var(--ink);
  font-size: 0.86rem;
  white-space: nowrap;
}
.vozilo-tab:hover { text-decoration: none; background: var(--paper-dim); }
.vozilo-tab.is-active { background: var(--navy); border-color: var(--navy); color: var(--white); }
.vozilo-tab--dodaj { cursor: pointer; border-style: dashed; color: #6b6f76; font-family: inherit; }

.vozilo-tab__broj {
  background: var(--danger);
  color: var(--white);
  border-radius: 999px;
  font-size: 0.72rem;
  font-weight: 700;
  min-width: 1.2rem;
  height: 1.2rem;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0 0.3rem;
}
.vozilo-tab.is-active .vozilo-tab__broj { background: var(--white); color: var(--danger); }

.tehnika-lista { display: flex; flex-direction: column; gap: 0.5rem; }

.tehnika-red {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  padding: 0.6rem 0;
  border-bottom: 1px solid var(--line);
  flex-wrap: wrap;
}
.tehnika-red:last-child { border-bottom: none; }
.tehnika-red__naziv { font-size: 0.94rem; flex: 1; min-width: 180px; }
.tehnika-red__info { font-size: 0.78rem; margin-top: 0.1rem; }
.tehnika-red__napomena { font-style: italic; }

.tehnika-red__gumbi { display: flex; gap: 0.4rem; flex-shrink: 0; }

.tehnika-gumb {
  display: flex;
  align-items: center;
  gap: 0.3rem;
  padding: 0.4rem 0.75rem;
  border-radius: var(--radius);
  border: 1px solid var(--line);
  background: var(--white);
  color: #6b6f76;
  font-family: inherit;
  font-size: 0.82rem;
  font-weight: 700;
  cursor: pointer;
}
.tehnika-gumb--ok.is-odabrano { background: #eaf3ec; border-color: var(--ok); color: var(--ok); }
.tehnika-gumb--problem.is-odabrano { background: #f7e6e5; border-color: var(--danger); color: var(--danger); }

@media (max-width: 560px) {
  .tehnika-red { flex-direction: column; align-items: stretch; }
  .tehnika-red__gumbi { justify-content: stretch; }
  .tehnika-gumb { flex: 1; justify-content: center; }
}

/* ---------- Chat ---------- */

.chat-kartica { display: flex; flex-direction: column; height: 65vh; max-height: 640px; padding: 1rem; }

.chat-poruke {
  flex: 1;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
  padding: 0.25rem 0.25rem 0.75rem;
}

.chat-poruka {
  max-width: 80%;
  background: var(--paper-dim);
  border-radius: 10px;
  padding: 0.5rem 0.75rem;
  align-self: flex-start;
}
.chat-poruka--moja {
  align-self: flex-end;
  background: #e8eef5;
}
.chat-poruka__autor { font-size: 0.74rem; font-weight: 700; color: var(--navy); margin-bottom: 0.15rem; }
.chat-poruka__autor .text-muted { font-weight: 400; margin-left: 0.3rem; }
.chat-poruka__tekst { font-size: 0.92rem; white-space: pre-wrap; word-break: break-word; }

.chat-forma {
  display: flex;
  gap: 0.6rem;
  border-top: 1px solid var(--line);
  padding-top: 0.75rem;
  align-items: flex-end;
}
.chat-forma textarea { flex: 1; resize: none; }

@media (max-width: 560px) {
  .chat-poruka { max-width: 92%; }
}

/* ---------- Dnevni prikaz - raspored + drag&drop popis članova ---------- */

.dan-layout {
  display: grid;
  grid-template-columns: 1fr 260px;
  gap: 1.5rem;
  align-items: start;
}
@media (max-width: 860px) {
  .dan-layout { grid-template-columns: 1fr; }
}

.dan-layout__clanovi {
  position: sticky;
  top: 1rem;
}

.grupa-blok { margin-bottom: 1rem; }
.grupa-blok__naslov {
  font-family: "PT Serif", serif;
  font-size: 0.82rem;
  color: #6b6f76;
  margin-bottom: 0.4rem;
}
.grupa-blok .osoba-chip { display: flex; margin: 0 0 0.35rem; }

.osoba-chip--draggable {
  cursor: grab;
  background: var(--white);
  user-select: none;
}
.osoba-chip--draggable:active { cursor: grabbing; }

.smjena-drop {
  transition: outline-color 0.12s ease, background-color 0.12s ease;
  outline: 2px dashed transparent;
  outline-offset: -2px;
}
.smjena-drop--aktivna {
  outline-color: var(--gold);
  background: #fdf9f0;
}

.grupa-oznaka {
  font-size: 0.68rem;
  font-weight: 700;
  color: var(--navy);
  background: var(--paper-dim);
  border-radius: 3px;
  padding: 0.05rem 0.3rem;
}

.upozorenje-box--zamjena {
  background: #eaf0f6;
  border-color: #cddaeb;
  color: var(--navy);
  margin: 0.15rem 0 0.4rem;
  padding: 0.35rem 0.6rem;
  font-size: 0.8rem;
}
.upozorenje-box--zamjena .icon { color: var(--navy); }

.drop-hint { font-style: italic; }

@media (max-width: 860px) {
  .drop-hint, .dan-layout__clanovi { display: none; }
}
