:root {
  --bg: #f5f6f8;
  --surface: #ffffff;
  --surface-2: #f0f2f5;
  --border: #e3e6ea;
  --text: #16181d;
  --text-2: #5b6270;
  --text-3: #8a91a0;
  --accent: #2563eb;
  --accent-2: #1d4ed8;
  --accent-soft: #e8efff;
  --danger: #dc2626;
  --danger-soft: #fdecec;
  --success: #16a34a;
  --success-soft: #e7f6ec;
  --warn: #d97706;
  --warn-soft: #fdf3e3;
  --shadow: 0 1px 2px rgba(16, 24, 40, .05), 0 4px 16px rgba(16, 24, 40, .06);
  --shadow-lg: 0 12px 40px rgba(16, 24, 40, .18);
  --radius: 14px;
  --header-h: 60px;
  --nav-h: 64px;
  color-scheme: light;
}
[data-theme="dark"] {
  --bg: #0f1115;
  --surface: #171a21;
  --surface-2: #1f232c;
  --border: #2a2f3a;
  --text: #eceef2;
  --text-2: #a5acba;
  --text-3: #727a8a;
  --accent: #4f8cff;
  --accent-2: #6b9dff;
  --accent-soft: #1c2a47;
  --danger: #f05252;
  --danger-soft: #3a1d1f;
  --success: #34c26b;
  --success-soft: #16301f;
  --warn: #f0a33a;
  --warn-soft: #3a2b14;
  --shadow: 0 1px 2px rgba(0, 0, 0, .3), 0 4px 16px rgba(0, 0, 0, .25);
  --shadow-lg: 0 12px 40px rgba(0, 0, 0, .55);
  --today: rgba(79, 140, 255, .09);
  color-scheme: dark;
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body {
  background: var(--bg);
  color: var(--text);
  font: 15px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
}
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
a { color: var(--accent); }
.hidden { display: none !important; }

/* ---------- zagon ---------- */
.boot { height: 100vh; display: grid; place-items: center; }
.spinner { width: 34px; height: 34px; border: 3px solid var(--border); border-top-color: var(--accent); border-radius: 50%; animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

/* ---------- prijava ---------- */
.login-wrap { min-height: 100vh; display: grid; place-items: center; padding: 24px 16px; }
.login-card { width: 100%; max-width: 380px; background: var(--surface); border: 1px solid var(--border); border-radius: 20px; padding: 32px 28px; box-shadow: var(--shadow); }
.login-logo { width: 56px; height: 56px; border-radius: 16px; background: var(--accent); display: grid; place-items: center; margin: 0 auto 14px; color: #fff; }
.login-card h1 { text-align: center; font-size: 22px; margin: 0 0 4px; }
.login-card p.sub { text-align: center; color: var(--text-2); margin: 0 0 22px; }
.login-theme { position: fixed; top: 14px; right: 14px; }

/* ---------- obrazci ---------- */
.field { margin-bottom: 14px; }
.field label { display: block; font-size: 13px; font-weight: 600; color: var(--text-2); margin-bottom: 6px; }
.input, select.input, textarea.input {
  width: 100%; padding: 11px 12px; background: var(--surface); border: 1px solid var(--border);
  border-radius: 10px; outline: none; transition: border-color .15s, box-shadow .15s; min-height: 44px;
}
textarea.input { min-height: 84px; resize: vertical; }
.input:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.row { display: flex; gap: 10px; }
.row > * { flex: 1; min-width: 0; }
.check { display: flex; align-items: center; gap: 10px; padding: 6px 0; font-weight: 500; cursor: pointer; }
.check input { width: 20px; height: 20px; accent-color: var(--accent); }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  padding: 10px 16px; min-height: 42px; border-radius: 10px; border: 1px solid var(--border);
  background: var(--surface); font-weight: 600; transition: background .15s, border-color .15s, transform .05s;
}
.btn:hover { background: var(--surface-2); }
.btn:active { transform: scale(.98); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn.primary:hover { background: var(--accent-2); }
.btn.danger { color: var(--danger); }
.btn.danger:hover { background: var(--danger-soft); border-color: var(--danger-soft); }
.btn.block { width: 100%; }
.btn.ghost { border-color: transparent; background: transparent; }
.btn.ghost:hover { background: var(--surface-2); }
.icon-btn { width: 40px; height: 40px; padding: 0; border-radius: 10px; border: 0; background: transparent; display: inline-grid; place-items: center; color: var(--text-2); }
.icon-btn:hover { background: var(--surface-2); color: var(--text); }
.icon-btn svg, .btn svg { width: 20px; height: 20px; }
.error-msg { background: var(--danger-soft); color: var(--danger); padding: 10px 12px; border-radius: 10px; margin-bottom: 14px; font-size: 14px; }

/* ---------- glava ---------- */
.header {
  position: sticky; top: 0; z-index: 20; height: var(--header-h);
  display: flex; align-items: center; gap: 12px; padding: 0 16px;
  background: color-mix(in srgb, var(--surface) 88%, transparent); backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border);
  padding-top: env(safe-area-inset-top);
  height: calc(var(--header-h) + env(safe-area-inset-top));
}
.brand { display: flex; align-items: center; gap: 10px; font-weight: 700; font-size: 17px; white-space: nowrap; }
.brand-mark { width: 32px; height: 32px; border-radius: 9px; background: var(--accent); color: #fff; display: grid; place-items: center; }
.brand-mark svg { width: 18px; height: 18px; }
.tabs { display: flex; gap: 4px; margin-left: 20px; }
.tab {
  position: relative; display: inline-flex; align-items: center; gap: 8px; border: 0; background: transparent;
  padding: 8px 14px; border-radius: 10px; color: var(--text-2); font-weight: 600;
}
.tab svg { width: 18px; height: 18px; }
.tab:hover { background: var(--surface-2); color: var(--text); }
.tab.active { background: var(--accent-soft); color: var(--accent); }
.badge { min-width: 20px; height: 20px; padding: 0 6px; border-radius: 10px; background: var(--danger); color: #fff; font-size: 12px; font-weight: 700; display: inline-grid; place-items: center; }
.spacer { flex: 1; }
.avatar { width: 36px; height: 36px; border-radius: 50%; background: var(--accent-soft); color: var(--accent); font-weight: 700; display: grid; place-items: center; border: 0; font-size: 14px; }

/* ---------- spodnja navigacija (mobilno) ---------- */
.bottom-nav {
  display: none; position: fixed; left: 0; right: 0; bottom: 0; z-index: 20;
  background: var(--surface); border-top: 1px solid var(--border);
  padding-bottom: env(safe-area-inset-bottom);
}
.bottom-nav .tab { flex: 1; flex-direction: column; gap: 2px; font-size: 11px; padding: 8px 4px; border-radius: 0; height: var(--nav-h); justify-content: center; }
.bottom-nav .tab.active { background: transparent; }
.bottom-nav .tab svg { width: 24px; height: 24px; }
.bottom-nav .badge { position: absolute; top: 6px; left: calc(50% + 6px); min-width: 18px; height: 18px; font-size: 11px; }

/* ---------- vsebina ---------- */
.main { max-width: 1280px; margin: 0 auto; padding: 18px 16px 32px; }
.view { display: none; }
.view.active { display: block; }
.page-head { display: flex; align-items: center; gap: 12px; margin-bottom: 14px; flex-wrap: wrap; }
.page-head h2 { margin: 0; font-size: 22px; }
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); }

/* ---------- koledar ---------- */
.cal-toolbar { display: flex; align-items: center; gap: 8px; margin-bottom: 12px; flex-wrap: wrap; }
.cal-title { font-size: 20px; font-weight: 700; margin: 0 8px; text-transform: capitalize; min-width: 0; }
.seg { display: inline-flex; background: var(--surface-2); border-radius: 10px; padding: 3px; }
.seg button { border: 0; background: transparent; padding: 7px 12px; border-radius: 8px; font-weight: 600; color: var(--text-2); font-size: 14px; }
.seg button.active { background: var(--surface); color: var(--text); box-shadow: 0 1px 3px rgba(0,0,0,.12); }
.cal-card { padding: 8px; }
.fab {
  position: fixed; right: 20px; bottom: 24px; z-index: 15; width: 58px; height: 58px; border-radius: 18px;
  border: 0; background: var(--accent); color: #fff; box-shadow: var(--shadow-lg); display: grid; place-items: center;
}
.fab svg { width: 26px; height: 26px; }

/* FullCalendar tema */
.fc {
  --fc-border-color: var(--border);
  --fc-page-bg-color: var(--surface);
  --fc-neutral-bg-color: var(--surface-2);
  --fc-neutral-text-color: var(--text-2);
  --fc-today-bg-color: var(--today, var(--accent-soft));
  --fc-now-indicator-color: var(--danger);
  --fc-event-bg-color: var(--accent);
  --fc-event-border-color: var(--accent);
  --fc-list-event-hover-bg-color: var(--surface-2);
  --fc-highlight-color: color-mix(in srgb, var(--accent) 18%, transparent);
  --fc-small-font-size: .8em;
  font-size: 14px;
}
.fc .fc-scrollgrid { border-radius: 10px; overflow: hidden; }
.fc-theme-standard .fc-scrollgrid { border-color: var(--border); }
.fc .fc-col-header-cell-cushion { color: var(--text-2); font-weight: 600; text-transform: uppercase; font-size: 12px; padding: 8px 4px; text-decoration: none; }
.fc .fc-daygrid-day-number { color: var(--text-2); text-decoration: none; font-weight: 500; padding: 6px 8px; }
.fc .fc-day-today .fc-daygrid-day-number { background: var(--accent); color: #fff; border-radius: 50%; width: 28px; height: 28px; display: grid; place-items: center; padding: 0; margin: 4px; }
.fc .fc-day-other .fc-daygrid-day-number { color: var(--text-3); opacity: .6; }
.fc .fc-daygrid-event { border-radius: 6px; padding: 1px 4px; font-weight: 500; }
.fc .fc-daygrid-dot-event .fc-event-title { font-weight: 500; }
.fc .fc-daygrid-dot-event:hover, .fc .fc-daygrid-event:hover { background: var(--surface-2); }
.fc .fc-h-event, .fc .fc-v-event { border-radius: 6px; }
.fc .fc-h-event:hover, .fc .fc-v-event:hover { filter: brightness(1.08); }
.fc .fc-timegrid-slot-label-cushion, .fc .fc-timegrid-axis-cushion { color: var(--text-3); font-size: 12px; }
.fc .fc-timegrid-slot { height: 2.6em; }
.fc .fc-list { border-radius: 10px; overflow: hidden; }
.fc .fc-list-day-cushion { background: var(--surface-2) !important; }
.fc .fc-list-day-text, .fc .fc-list-day-side-text { color: var(--text); text-decoration: none; font-weight: 700; }
.fc .fc-list-event-time { color: var(--text-2); }
.fc .fc-list-empty { background: var(--surface); color: var(--text-3); }
.fc .fc-daygrid-more-link { color: var(--accent); font-weight: 600; }
.fc .fc-popover { background: var(--surface); border-color: var(--border); border-radius: 10px; box-shadow: var(--shadow-lg); overflow: hidden; }
.fc .fc-popover-header { background: var(--surface-2); }
.fc a { color: inherit; }
.fc-event-bell { margin-left: 3px; opacity: .75; font-size: .85em; }

/* ---------- naloge ---------- */
.filters { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; margin-bottom: 14px; }
.filters select.input { width: auto; min-height: 38px; padding: 7px 10px; }
.task-list { display: flex; flex-direction: column; gap: 8px; }
.task {
  display: flex; gap: 12px; align-items: flex-start; padding: 14px; background: var(--surface);
  border: 1px solid var(--border); border-radius: 12px; cursor: pointer; transition: border-color .15s, box-shadow .15s;
  border-left: 4px solid var(--border);
}
.task:hover { box-shadow: var(--shadow); }
.task.p2 { border-left-color: var(--danger); }
.task.p1 { border-left-color: var(--accent); }
.task.p0 { border-left-color: var(--text-3); }
.task.done { opacity: .62; }
.task.done .task-title { text-decoration: line-through; }
.task-check {
  flex: none; width: 26px; height: 26px; border-radius: 50%; border: 2px solid var(--text-3); background: transparent;
  display: grid; place-items: center; padding: 0; margin-top: 1px; color: transparent; transition: all .15s;
}
.task-check:hover { border-color: var(--success); color: var(--success); }
.task.done .task-check { background: var(--success); border-color: var(--success); color: #fff; }
.task-check svg { width: 15px; height: 15px; }
.task-body { flex: 1; min-width: 0; }
.task-title { font-weight: 600; word-wrap: break-word; }
.task-desc { color: var(--text-2); font-size: 14px; margin-top: 3px; white-space: pre-wrap; word-wrap: break-word; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.task-meta { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px; }
.chip { display: inline-flex; align-items: center; gap: 5px; padding: 3px 9px; border-radius: 999px; background: var(--surface-2); color: var(--text-2); font-size: 12.5px; font-weight: 600; }
.chip svg { width: 13px; height: 13px; }
.chip.overdue { background: var(--danger-soft); color: var(--danger); }
.chip.soon { background: var(--warn-soft); color: var(--warn); }
.chip.ok { background: var(--success-soft); color: var(--success); }
.chip.person { background: var(--accent-soft); color: var(--accent); }
.empty { text-align: center; padding: 48px 16px; color: var(--text-3); }
.empty svg { width: 48px; height: 48px; margin-bottom: 8px; opacity: .5; }
.group-title { font-size: 13px; font-weight: 700; text-transform: uppercase; letter-spacing: .04em; color: var(--text-3); margin: 14px 4px 4px; }

a.chip.loc { text-decoration: none; background: var(--success-soft); color: var(--success); max-width: 100%; }
a.chip.loc:hover { filter: brightness(1.05); }
.chip { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 100%; }
.nav-btn { text-decoration: none; color: var(--success); border-color: var(--success-soft); background: var(--success-soft); }
.nav-btn:hover { background: var(--success-soft); filter: brightness(1.05); }
.nav-btn.disabled { opacity: .4; pointer-events: none; }
.loc-link { display: inline-flex; align-items: center; gap: 3px; margin-left: 8px; color: var(--success) !important; text-decoration: none; font-size: .92em; font-weight: 600; }
.loc-link svg { width: 13px; height: 13px; }
@media (max-width: 760px) { .nav-btn span { display: none; } .nav-btn { padding: 10px 12px; } }

button.chip.phone { border: 0; cursor: pointer; background: var(--accent-soft); color: var(--accent); font: inherit; font-size: 12.5px; font-weight: 600; }
.call-btn { color: var(--accent); background: var(--accent-soft); border-color: var(--accent-soft); padding: 10px 12px; }
.call-btn.disabled { opacity: .4; pointer-events: none; }
.ph-link { color: var(--accent) !important; }
.phone-num { font-size: 24px; font-weight: 700; letter-spacing: .02em; margin-top: 4px; user-select: all; }
.phone-sheet { max-width: 360px; }
@media (max-width: 760px) {
  .contact-row { flex-wrap: wrap; }
  .contact-row input:first-child { flex: 1 1 100%; }
}

select.input.cal-scope { width: auto; min-height: 38px; padding: 6px 10px; font-size: 14px; font-weight: 600; }
.who-tag { display: inline-flex; align-items: center; gap: 3px; margin-left: 8px; color: var(--warn); font-weight: 600; font-size: .92em; }
.who-tag svg { width: 13px; height: 13px; }
@media (max-width: 760px) { select.input.cal-scope { flex: 1 1 100%; order: 0; } }

/* ---------- uporabniki ---------- */
.user-list { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 10px; }
.user-card { display: flex; gap: 12px; align-items: center; padding: 14px; cursor: pointer; }
.user-card:hover { border-color: var(--accent); }
.user-card .avatar { width: 44px; height: 44px; font-size: 16px; flex: none; }
.user-card .info { flex: 1; min-width: 0; }
.user-card .name { font-weight: 700; }
.user-card .uname { color: var(--text-3); font-size: 13px; }
.user-card.inactive { opacity: .55; }

/* ---------- modal ---------- */
.modal-back {
  position: fixed; inset: 0; z-index: 50; background: rgba(10, 12, 16, .5); display: flex; align-items: center; justify-content: center;
  padding: 16px; animation: fade .15s ease-out;
}
.modal {
  width: 100%; max-width: 520px; max-height: calc(100vh - 32px); overflow: auto; background: var(--surface);
  border-radius: 18px; box-shadow: var(--shadow-lg); animation: pop .18s ease-out;
}
.modal-head { display: flex; align-items: center; gap: 8px; padding: 18px 20px 4px; }
.modal-head h3 { margin: 0; font-size: 18px; flex: 1; }
.modal-body { padding: 12px 20px; }
.modal-foot { display: flex; gap: 8px; padding: 8px 20px 20px; }
.modal-foot .spacer { flex: 1; }
@keyframes fade { from { opacity: 0; } }
@keyframes pop { from { opacity: 0; transform: translateY(12px) scale(.98); } }

.colors { display: flex; gap: 10px; flex-wrap: wrap; }
.color-dot { width: 32px; height: 32px; border-radius: 50%; border: 3px solid transparent; padding: 0; outline: 2px solid transparent; }
.color-dot.sel { outline-color: var(--text); border-color: var(--surface); }

.menu { position: absolute; right: 12px; top: calc(var(--header-h) + env(safe-area-inset-top) - 4px); z-index: 40; min-width: 240px; background: var(--surface); border: 1px solid var(--border); border-radius: 14px; box-shadow: var(--shadow-lg); padding: 6px; animation: pop .14s ease-out; }
.menu .who { padding: 10px 12px 8px; border-bottom: 1px solid var(--border); margin-bottom: 4px; }
.menu .who b { display: block; }
.menu .who span { color: var(--text-3); font-size: 13px; }
.menu button { display: flex; align-items: center; gap: 10px; width: 100%; padding: 10px 12px; border: 0; background: transparent; border-radius: 9px; text-align: left; font-weight: 500; }
.menu button:hover { background: var(--surface-2); }
.menu button svg { width: 18px; height: 18px; color: var(--text-2); }

.notice { display: flex; gap: 12px; align-items: center; padding: 12px 14px; margin-bottom: 14px; border-radius: 12px; background: var(--accent-soft); color: var(--text); }
.notice svg { width: 22px; height: 22px; color: var(--accent); flex: none; }
.notice .txt { flex: 1; font-size: 14px; }
.setting-row { display: flex; align-items: center; gap: 12px; padding: 12px 0; border-bottom: 1px solid var(--border); }
.setting-row:last-child { border-bottom: 0; }
.setting-row .lbl { flex: 1; }
.setting-row .lbl small { display: block; color: var(--text-3); }
.muted { color: var(--text-3); font-size: 13px; }

#toast {
  position: fixed; left: 50%; bottom: 28px; transform: translateX(-50%) translateY(20px); z-index: 100; opacity: 0; pointer-events: none;
  background: var(--text); color: var(--bg); padding: 11px 18px; border-radius: 12px; font-weight: 600; font-size: 14px; transition: all .2s; max-width: calc(100% - 32px);
}
#toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }
#toast.err { background: var(--danger); color: #fff; }

/* ---------- mobilno ---------- */
@media (max-width: 760px) {
  .tabs { display: none; }
  .bottom-nav { display: flex; }
  .main { padding: 12px 10px calc(var(--nav-h) + 90px + env(safe-area-inset-bottom)); }
  .fab { bottom: calc(var(--nav-h) + 16px + env(safe-area-inset-bottom)); right: 16px; }
  #toast { bottom: auto; top: calc(12px + env(safe-area-inset-top)); transform: translateX(-50%) translateY(-20px); }
  #toast.show { transform: translateX(-50%) translateY(0); }
  .cal-title { font-size: 18px; flex: 0 0 100%; order: -1; margin: 0 0 2px; }
  .cal-toolbar .seg { margin-left: auto; }
  .seg button { padding: 7px 9px; font-size: 13px; }
  .cal-card { padding: 4px; border-radius: 12px; }
  .fc { font-size: 12.5px; }
  .fc .fc-daygrid-day-number { padding: 3px 4px; font-size: 12px; }
  .fc .fc-day-today .fc-daygrid-day-number { width: 22px; height: 22px; margin: 2px; }
  .fc .fc-daygrid-event { font-size: 11px; }
  .modal-back { align-items: flex-end; padding: 0; }
  .modal { max-width: none; border-radius: 20px 20px 0 0; max-height: 92vh; padding-bottom: env(safe-area-inset-bottom); animation: slideup .22s ease-out; }
  .page-head h2 { font-size: 20px; }
  .brand span.name { font-size: 16px; }
}
@keyframes slideup { from { transform: translateY(100%); } }
