:root {
  --green-900: #0f3d22;
  --green-800: #14532d;
  --green-600: #1f7a45;
  --green-100: #dcf3e4;
  --green-50: #f0faf3;
  --ink: #17201b;
  --ink-2: #4b5650;
  --ink-3: #7b857f;
  --line: #e2e6e3;
  --bg: #f5f6f4;
  --card: #ffffff;
  --amber: #b45309;
  --amber-bg: #fef3c7;
  --red: #b42318;
  --red-bg: #fde8e6;
  --blue: #1d4ed8;
  --blue-bg: #e3ebff;
  --radius: 14px;
  --shadow: 0 1px 2px rgba(16, 24, 20, .06), 0 2px 8px rgba(16, 24, 20, .05);
  --tabbar-h: 64px;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  color: var(--ink);
  background: var(--bg);
  -webkit-text-size-adjust: 100%;
}

* { box-sizing: border-box; }
html, body { margin: 0; min-height: 100%; background: var(--bg); }
body { padding-bottom: calc(var(--tabbar-h) + env(safe-area-inset-bottom)); }
body.no-tabbar { padding-bottom: 0; }
button, input, select, textarea { font: inherit; color: inherit; }
a { color: var(--green-600); }
h1 { font-size: 1.45rem; margin: .2rem 0 1rem; letter-spacing: -.01em; }
h2 { font-size: 1.05rem; margin: 1.4rem 0 .6rem; color: var(--ink-2); font-weight: 600; }
h3 { font-size: 1rem; margin: 0; }
p { line-height: 1.5; }
code { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: .85em; background: #eef0ee; padding: .1em .35em; border-radius: 5px; }
code.break { word-break: break-all; display: inline-block; margin-top: .3rem; }
.muted { color: var(--ink-3); }
.small { font-size: .85rem; }
[hidden] { display: none !important; }

.wrap { max-width: 720px; margin: 0 auto; padding: 16px 16px 24px; }

/* ---------- top bar ---------- */
.topbar {
  position: sticky; top: 0; z-index: 20;
  display: flex; align-items: center; gap: 6px;
  min-height: 56px; padding: calc(env(safe-area-inset-top) + 6px) 12px 6px;
  background: var(--green-800); color: #fff;
}
.topbar-title { flex: 1; min-width: 0; display: flex; flex-direction: column; padding-left: 4px; }
.topbar-title span { font-weight: 650; font-size: 1.05rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.topbar-title small { opacity: .8; font-size: .8rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.icon-btn { background: none; border: 0; color: inherit; width: 40px; height: 40px; border-radius: 10px; display: grid; place-items: center; cursor: pointer; }
.icon-btn:active { background: rgba(255, 255, 255, .15); }
.net { font-size: .75rem; background: var(--amber-bg); color: var(--amber); padding: 3px 8px; border-radius: 99px; font-weight: 600; }

/* ---------- tab bar ---------- */
.tabbar {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 20;
  display: flex; justify-content: space-around;
  height: calc(var(--tabbar-h) + env(safe-area-inset-bottom)); padding-bottom: env(safe-area-inset-bottom);
  background: #fff; border-top: 1px solid var(--line);
}
.tabbar a { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px; text-decoration: none; color: var(--ink-3); font-size: .72rem; font-weight: 600; }
.tabbar a svg { width: 24px; height: 24px; }
.tabbar a.active { color: var(--green-800); }

/* ---------- cards / lists ---------- */
.card { background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow); padding: 16px; margin-bottom: 12px; }
.card-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-bottom: 10px; }
.list { background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow); overflow: hidden; margin-bottom: 12px; }
.list-item { display: flex; align-items: center; gap: 12px; padding: 13px 16px; border-bottom: 1px solid var(--line); text-decoration: none; color: inherit; min-height: 56px; }
.list-item:last-child { border-bottom: 0; }
a.list-item:active, button.list-item:active { background: var(--green-50); }
button.list-item { width: 100%; text-align: left; background: none; border: 0; border-bottom: 1px solid var(--line); cursor: pointer; }
.li-main { flex: 1; min-width: 0; }
.li-title { font-weight: 600; }
.li-sub { color: var(--ink-3); font-size: .85rem; margin-top: 2px; }
.chev { color: var(--ink-3); flex: none; }
.empty { text-align: center; color: var(--ink-3); padding: 28px 12px; }

.badge { display: inline-flex; align-items: center; gap: 4px; font-size: .72rem; font-weight: 700; padding: 2px 8px; border-radius: 99px; background: #eef0ee; color: var(--ink-2); vertical-align: middle; white-space: nowrap; }
.badge.green { background: var(--green-100); color: var(--green-800); }
.badge.amber { background: var(--amber-bg); color: var(--amber); }
.badge.red { background: var(--red-bg); color: var(--red); }
.badge.blue { background: var(--blue-bg); color: var(--blue); }

/* ---------- buttons ---------- */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-height: 44px; padding: 10px 16px; border-radius: 12px; border: 1px solid var(--line); background: #fff; font-weight: 600; cursor: pointer; text-decoration: none; color: var(--ink); }
.btn:active { transform: translateY(1px); }
.btn.primary { background: var(--green-800); border-color: var(--green-800); color: #fff; }
.btn.primary:active { background: var(--green-900); }
.btn.danger { color: var(--red); border-color: #f2c4bf; }
.btn.ghost { border-color: transparent; background: transparent; color: var(--green-800); }
.btn.block { width: 100%; }
.btn.lg { min-height: 54px; font-size: 1.05rem; }
.btn:disabled { opacity: .55; cursor: default; }
.btn-row { display: flex; gap: 8px; flex-wrap: wrap; }
.btn-row > .btn { flex: 1; }

/* ---------- forms ---------- */
label.field { display: block; margin-bottom: 14px; }
label.field > span { display: block; font-size: .85rem; font-weight: 600; color: var(--ink-2); margin-bottom: 6px; }
input[type=text], input[type=email], input[type=password], input[type=date], input[type=time], input[type=number], input[type=search], select, textarea {
  width: 100%; min-height: 46px; padding: 10px 12px; border: 1px solid #cfd5d1; border-radius: 10px; background: #fff; font-size: 16px;
}
textarea { min-height: 80px; resize: vertical; }
input:focus, select:focus, textarea:focus { outline: 2px solid var(--green-600); outline-offset: 0; border-color: var(--green-600); }
.check { display: flex; align-items: center; gap: 10px; padding: 8px 0; font-weight: 500; }
.check input { width: 22px; height: 22px; accent-color: var(--green-800); }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.grid3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 10px; }

.alert { padding: 12px 14px; border-radius: 10px; font-size: .92rem; margin: 0 0 12px; }
.alert.err { background: var(--red-bg); color: var(--red); }
.alert.ok { background: var(--green-100); color: var(--green-800); }
.alert.warn { background: var(--amber-bg); color: var(--amber); }
.alert.info { background: var(--blue-bg); color: var(--blue); }
ul.plain { padding-left: 1.1rem; } ul.plain li { margin-bottom: .8rem; }

/* ---------- login ---------- */
.login { max-width: 420px; margin: 8vh auto 0; }
.login .brand { text-align: center; margin-bottom: 18px; }
.login .brand img { width: 64px; height: 64px; }
.login .brand h1 { margin: 10px 0 2px; }

/* ---------- danas ---------- */
.date-hero { display: flex; align-items: baseline; justify-content: space-between; margin: 4px 2px 14px; }
.date-hero .d { font-size: 1.45rem; font-weight: 700; letter-spacing: -.01em; }
.group-card .termin-btn { display: flex; align-items: center; gap: 12px; width: 100%; padding: 12px; border: 1px solid var(--line); border-radius: 12px; background: #fff; margin-bottom: 8px; cursor: pointer; text-align: left; text-decoration: none; color: inherit; }
.group-card .termin-btn.done { border-color: #bfe3cc; background: var(--green-50); }
.termin-btn .t-time { font-weight: 700; font-size: 1.05rem; min-width: 52px; }
.termin-btn .t-main { flex: 1; }
.pill-count { font-weight: 700; font-variant-numeric: tabular-nums; }

/* ---------- termin / prisutnost ---------- */
.att-head { position: sticky; top: 56px; z-index: 10; background: var(--bg); padding: 10px 0 8px; margin: -6px 0 6px; }
.counter { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.counter .big { font-size: 1.6rem; font-weight: 800; font-variant-numeric: tabular-nums; letter-spacing: -.02em; }
.counter .big small { font-size: 1rem; color: var(--ink-3); font-weight: 600; }
.progress { height: 6px; background: #e3e7e4; border-radius: 99px; overflow: hidden; margin-top: 8px; }
.progress > i { display: block; height: 100%; background: var(--green-600); width: 0; transition: width .2s; }

.kid { display: flex; align-items: center; gap: 4px; background: #fff; border-radius: 12px; margin-bottom: 8px; box-shadow: var(--shadow); border: 2px solid transparent; transition: border-color .12s, background .12s; }
.kid .tap { flex: 1; display: flex; align-items: center; gap: 12px; min-height: 60px; padding: 8px 4px 8px 12px; background: none; border: 0; text-align: left; cursor: pointer; min-width: 0; }
.kid .mark { width: 32px; height: 32px; border-radius: 50%; border: 2px solid #c9d0cb; flex: none; display: grid; place-items: center; color: #fff; }
.kid .name { font-weight: 600; font-size: 1.02rem; min-width: 0; }
.kid .name small { display: block; font-weight: 500; color: var(--ink-3); font-size: .8rem; margin-top: 1px; }
.kid .more { width: 48px; align-self: stretch; border: 0; background: none; color: var(--ink-3); cursor: pointer; border-radius: 0 12px 12px 0; font-size: 1.3rem; letter-spacing: 1px; }
.kid.prisutan { border-color: #9ad5b0; background: var(--green-50); }
.kid.prisutan .mark { background: var(--green-600); border-color: var(--green-600); }
.kid.opravdano .mark { background: var(--blue); border-color: var(--blue); }
.kid.bolest .mark { background: var(--amber); border-color: var(--amber); }
.kid.readonly .tap { cursor: default; }
.kid-actions { display: flex; gap: 8px; margin: 4px 0 12px; }
.kid-actions .btn { flex: 1; min-height: 40px; font-size: .9rem; }
.save-bar { position: sticky; bottom: calc(var(--tabbar-h) + env(safe-area-inset-bottom) + 8px); z-index: 10; margin-top: 12px; }
body.no-tabbar .save-bar { bottom: calc(env(safe-area-inset-bottom) + 8px); }
.save-bar .btn { box-shadow: 0 6px 18px rgba(20, 83, 45, .28); }
details.more-box { margin-top: 18px; }
details.more-box summary { cursor: pointer; font-weight: 600; color: var(--ink-2); padding: 8px 2px; }

/* ---------- statistika ---------- */
.stat-row { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin-bottom: 12px; }
.stat { background: #fff; border-radius: 12px; box-shadow: var(--shadow); padding: 12px; }
.stat b { display: block; font-size: 1.35rem; font-variant-numeric: tabular-nums; }
.stat span { font-size: .78rem; color: var(--ink-3); font-weight: 600; }
.pct { font-weight: 700; font-variant-numeric: tabular-nums; min-width: 46px; text-align: right; }
.pct.low { color: var(--red); }
.bar { height: 5px; background: #e3e7e4; border-radius: 99px; overflow: hidden; margin-top: 6px; }
.bar > i { display: block; height: 100%; background: var(--green-600); }
.bar > i.low { background: var(--red); }
.seg { display: flex; background: #e8ebe9; border-radius: 10px; padding: 3px; margin-bottom: 12px; }
.seg button { flex: 1; border: 0; background: none; padding: 8px 6px; border-radius: 8px; font-weight: 600; font-size: .85rem; color: var(--ink-2); cursor: pointer; }
.seg button.on { background: #fff; color: var(--ink); box-shadow: var(--shadow); }
.hist { display: grid; grid-template-columns: auto 1fr auto; gap: 2px 12px; align-items: center; }

/* ---------- admin ---------- */
.chips { display: flex; gap: 6px; overflow-x: auto; padding: 2px 0 10px; margin: 0 -16px 4px; padding-left: 16px; padding-right: 16px; scrollbar-width: none; }
.chips::-webkit-scrollbar { display: none; }
.chips a { flex: none; padding: 8px 14px; border-radius: 99px; background: #fff; border: 1px solid var(--line); text-decoration: none; color: var(--ink-2); font-weight: 600; font-size: .88rem; }
.chips a.on { background: var(--green-800); border-color: var(--green-800); color: #fff; }
.limit { font-size: .85rem; color: var(--ink-3); }
.multi { display: flex; flex-wrap: wrap; gap: 6px; }
.multi label { display: inline-flex; align-items: center; gap: 6px; padding: 8px 12px; border: 1px solid var(--line); border-radius: 99px; cursor: pointer; font-weight: 500; font-size: .9rem; background: #fff; }
.multi input { accent-color: var(--green-800); width: 18px; height: 18px; }
.link-box { background: var(--green-50); border: 1px dashed #9ad5b0; border-radius: 10px; padding: 10px; word-break: break-all; font-size: .85rem; margin: 8px 0; user-select: all; }

/* ---------- sheet (modal) ---------- */
.sheet-backdrop { position: fixed; inset: 0; background: rgba(10, 20, 14, .45); z-index: 50; display: flex; align-items: flex-end; justify-content: center; animation: fade .15s ease; }
.sheet { background: #fff; width: 100%; max-width: 560px; max-height: 92vh; overflow-y: auto; border-radius: 18px 18px 0 0; padding: 8px 16px calc(16px + env(safe-area-inset-bottom)); animation: up .18s ease; }
.sheet .grab { width: 40px; height: 5px; border-radius: 99px; background: #d4d9d6; margin: 4px auto 10px; }
.sheet h2 { margin: 4px 0 14px; color: var(--ink); font-size: 1.15rem; }
.status-opts { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-bottom: 14px; }
.status-opts button { min-height: 52px; border-radius: 12px; border: 2px solid var(--line); background: #fff; font-weight: 650; cursor: pointer; }
.status-opts button.on { border-color: var(--green-800); background: var(--green-50); }
@media (min-width: 640px) { .sheet-backdrop { align-items: center; } .sheet { border-radius: 18px; } }
@keyframes fade { from { opacity: 0; } }
@keyframes up { from { transform: translateY(30px); opacity: .6; } }

.toast { position: fixed; left: 50%; bottom: calc(var(--tabbar-h) + env(safe-area-inset-bottom) + 18px); transform: translateX(-50%); background: #1d2620; color: #fff; padding: 12px 16px; border-radius: 12px; font-weight: 600; z-index: 60; max-width: calc(100% - 32px); box-shadow: 0 8px 24px rgba(0, 0, 0, .2); }
.toast.err { background: var(--red); }

.spinner { width: 28px; height: 28px; border: 3px solid #d6dcd8; border-top-color: var(--green-800); border-radius: 50%; animation: spin .8s linear infinite; margin: 40px auto; }
@keyframes spin { to { transform: rotate(360deg); } }

@media (min-width: 720px) {
  .wrap { padding-top: 24px; }
}
