:root {
  --bg: #0F1419;
  --card: #16212B;
  --line: #24323F;
  --text: #E8EDF2;
  --muted: #9AA7B4;
  --faint: #6F7D8A;
  --accent: #34D399;
  --ok-bg: #12352A;
  --ok: #7EE2B8;
  --warn-bg: #3D3214;
  --warn: #F5C451;
  --bad-bg: #3B1C1F;
  --bad: #FF9AA2;
}

* { box-sizing: border-box; }
html, body { margin: 0; background: var(--bg); color: var(--text); }
body {
  font-family: Inter, system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  -webkit-font-smoothing: antialiased;
  min-height: 100vh;
}
a { color: inherit; text-decoration: none; }
h1 { margin: 0; font-size: 24px; font-weight: 700; }
.muted { color: var(--muted); }
[hidden] { display: none !important; }

.screen {
  max-width: 560px;
  margin: 0 auto;
  min-height: 100vh;
  padding: calc(env(safe-area-inset-top) + 28px) 20px calc(env(safe-area-inset-bottom) + 24px);
  display: flex;
  flex-direction: column;
  gap: 22px;
}

/* ---------- Prijava ---------- */
.login { padding-top: calc(env(safe-area-inset-top) + 72px); gap: 32px; }
.brand { display: flex; flex-direction: column; align-items: center; gap: 12px; text-align: center; }
.brand img { border-radius: 20px; }
.brand p { margin: 0; font-size: 14px; }
form { display: flex; flex-direction: column; gap: 8px; }
label { font-size: 13px; color: var(--muted); margin-top: 8px; }
input:not([type=checkbox]) {
  height: 48px; padding: 0 14px; border-radius: 12px; border: 1px solid #2A3540;
  background: var(--card); color: var(--text); font: inherit; font-size: 16px;
}
input:focus-visible, button:focus-visible, a:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.check { display: flex; align-items: center; gap: 10px; font-size: 14px; color: #C9D2DB; min-height: 44px; }
.check input { width: 20px; height: 20px; accent-color: var(--accent); }
button { font: inherit; cursor: pointer; }
.primary {
  height: 50px; margin-top: 8px; border-radius: 12px; border: 0;
  background: var(--accent); color: var(--bg); font-weight: 600; font-size: 16px;
}
.primary:disabled { opacity: .6; }
.error { margin: 4px 0 0; color: var(--bad); font-size: 14px; }
.hint { margin-top: auto; text-align: center; font-size: 12px; color: var(--faint); }

/* ---------- Početni zaslon ---------- */
header { display: flex; justify-content: space-between; align-items: center; }
header > div { display: flex; flex-direction: column; gap: 2px; }
header .muted { font-size: 13px; }
.round {
  width: 44px; height: 44px; border-radius: 22px; border: 1px solid #2A3540;
  background: var(--card); color: var(--text); display: flex; align-items: center; justify-content: center;
}

.card {
  display: flex; flex-direction: column; gap: 14px; padding: 16px; border-radius: 18px;
  background: var(--card); border: 1px solid var(--line); min-height: 132px;
  transition: border-color .15s;
}
a.card:hover { border-color: #3A4C5D; }
.card.big { padding: 18px; min-height: 0; }
.card-head { display: flex; justify-content: space-between; align-items: center; gap: 12px; }
.card-title { display: flex; gap: 12px; align-items: center; min-width: 0; }
.card-title > div { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.name { font-size: 16px; font-weight: 600; }
.big .name { font-size: 17px; }
.sub { font-size: 13px; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.icon {
  width: 44px; height: 44px; border-radius: 12px; flex: none;
  display: flex; align-items: center; justify-content: center;
}
.pill { font-size: 12px; font-weight: 600; padding: 6px 10px; border-radius: 999px; white-space: nowrap; }
.pill.ok { background: var(--ok-bg); color: var(--ok); }
.pill.warn { background: var(--warn-bg); color: var(--warn); }
.pill.bad { background: var(--bad-bg); color: var(--bad); }
.status { font-size: 12px; }
.status.ok { color: var(--ok); }
.status.bad { color: var(--bad); }
.status.unknown { color: var(--faint); }
#primary { display: flex; flex-direction: column; gap: 12px; }
.stats { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 12px 8px; }
.stats div { display: flex; flex-direction: column; gap: 2px; }
.stats span:first-child { font-size: 12px; color: var(--muted); }
.stats span:last-child { font-size: 18px; font-weight: 600; }

.grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
.card.add { border-style: dashed; border-color: #33414F; background: none; color: var(--muted); }
.card.add .icon { border: 1px dashed #33414F; }

footer { margin-top: auto; display: flex; justify-content: space-between; font-size: 12px; color: var(--faint); }

@media (min-width: 720px) {
  .screen { max-width: 760px; }
  .grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
}

/* Kostur dok stižu prvi podaci, i zadnje poznato stanje dok stiže svježe */
.card.loading { gap: 12px; min-height: 132px; }
.card.big.loading { min-height: 150px; }
.bar { height: 14px; border-radius: 7px; background: linear-gradient(90deg, #1E2A35 0%, #26343F 50%, #1E2A35 100%); background-size: 200% 100%; animation: shimmer 1.4s infinite linear; }
.bar.w40 { width: 40%; height: 18px; } .bar.w60 { width: 60%; } .bar.w80 { width: 80%; }
@keyframes shimmer { from { background-position: 200% 0; } to { background-position: -200% 0; } }
.stale .stats span:last-child { opacity: .6; }
@media (prefers-reduced-motion: reduce) { .bar { animation: none; } }
