:root {
  --navy: #1c3a52;
  --navy-light: #2d5a7c;
  --accent: #d97a3f;
  --bg: #f4f6f8;
  --card-bg: #ffffff;
  --border: #e0e4e8;
  --text: #1f2937;
  --text-muted: #6b7280;
  --radius: 10px;
}
* { box-sizing: border-box; }
body { margin: 0; font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif; background: var(--bg); color: var(--text); }
.hidden { display: none !important; }

.app-header { background: var(--navy); color: white; padding: 14px 20px; }
.header-inner { max-width: 1200px; margin: 0 auto; display: flex; justify-content: space-between; align-items: center; }
.logo-text { font-weight: 600; font-size: 15px; }
.user-badge { display: flex; align-items: center; gap: 12px; font-size: 14px; }

.app-main { max-width: 1200px; margin: 0 auto; padding: 24px 16px 60px; }
h1 { font-size: 22px; margin-bottom: 16px; }
h3 { font-size: 15px; margin: 12px 0 8px; color: var(--navy); }

.login-card { max-width: 360px; margin: 40px auto; background: var(--card-bg); border: 1px solid var(--border); border-radius: var(--radius); padding: 28px; }
.tabs { display: flex; gap: 6px; margin-bottom: 18px; flex-wrap: wrap; }
.tab-btn { background: none; border: 1px solid var(--border); padding: 8px 14px; border-radius: 20px; cursor: pointer; font-size: 13px; color: var(--text-muted); }
.tab-btn.active { background: var(--navy); color: white; border-color: var(--navy); }

.login-form { display: flex; flex-direction: column; gap: 6px; }
.login-form label, .field-label { font-size: 13px; color: var(--text-muted); margin-top: 8px; display: block; }
.login-form input, .modal-body input, .modal-body select, #datumUpita { padding: 9px 11px; border: 1px solid var(--border); border-radius: 8px; font-size: 14px; width: 100%; margin-top: 4px; }

.btn-primary { margin-top: 14px; background: var(--accent); color: white; border: none; padding: 9px 16px; border-radius: 8px; font-size: 14px; cursor: pointer; font-weight: 600; }
.btn-primary:hover { opacity: 0.9; }
.btn-ghost { background: none; border: 1px solid rgba(255,255,255,0.4); color: white; padding: 6px 12px; border-radius: 6px; cursor: pointer; font-size: 13px; }
.btn-danger { background: #fee2e2; color: #b91c1c; border: none; padding: 5px 10px; border-radius: 6px; cursor: pointer; font-size: 12px; }
.btn-danger-outline { background: white; color: #b91c1c; border: 1px solid #fca5a5; padding: 9px 16px; border-radius: 8px; cursor: pointer; font-size: 14px; font-weight: 600; }
.icon-btn { background: none; border: 1px solid var(--border); border-radius: 6px; padding: 4px 10px; cursor: pointer; font-size: 15px; }

.greska { color: #b91c1c; font-size: 13px; margin-top: 10px; }
.muted { color: var(--text-muted); font-size: 13px; }

.cards-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); gap: 12px; margin-bottom: 14px; }
.stat-card { background: var(--card-bg); border: 1px solid var(--border); border-radius: var(--radius); padding: 16px; text-align: center; }
.stat-broj { font-size: 22px; font-weight: 700; color: var(--navy); }
.stat-label { font-size: 12px; color: var(--text-muted); margin-top: 4px; }

.calendar-card, .detail-card, .grid-card { background: var(--card-bg); border: 1px solid var(--border); border-radius: var(--radius); padding: 16px; margin-bottom: 14px; }
.cal-nav { display: flex; justify-content: space-between; align-items: center; margin-bottom: 10px; font-weight: 600; color: var(--navy); }
.cal-weekdays { display: grid; grid-template-columns: repeat(7, 1fr); text-align: center; font-size: 11px; color: var(--text-muted); margin-bottom: 4px; }
.cal-grid { display: grid; grid-template-columns: repeat(7, 1fr); gap: 4px; }
.cal-day { aspect-ratio: 1; border-radius: 8px; display: flex; flex-direction: column; align-items: center; justify-content: center; font-size: 12px; font-weight: 500; cursor: pointer; border: none; background: #f8fafc; color: #334155; padding: 2px; overflow: hidden; }
.cal-day:hover { opacity: 0.8; }
.cal-day.today { outline: 2px solid var(--navy); }
.cal-day.selected { outline: 2px solid var(--accent); }
.cal-day.empty { background: transparent; cursor: default; }

.detail-row { display: flex; justify-content: space-between; font-size: 13px; padding: 5px 0; border-bottom: 1px solid #f1f5f9; }
.detail-label { color: var(--text-muted); }
.badge { padding: 2px 8px; border-radius: 12px; font-size: 11px; font-weight: 600; }
.badge-teren { background: #dbeafe; color: #1e40af; }
.badge-ured { background: #f1f5f9; color: #475569; }
.badge-rezija { background: #e7e5e4; color: #57534e; }

table { width: 100%; border-collapse: collapse; font-size: 13px; }
th, td { padding: 8px 10px; text-align: left; border-bottom: 1px solid var(--border); white-space: nowrap; }
th { background: #f9fafb; color: var(--text-muted); font-weight: 600; font-size: 11px; text-transform: uppercase; }
.table-wrap { overflow-x: auto; background: var(--card-bg); border: 1px solid var(--border); border-radius: var(--radius); }

.inline-form { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 14px; background: var(--card-bg); border: 1px solid var(--border); border-radius: var(--radius); padding: 14px; }
.inline-form input, .inline-form select { padding: 8px 10px; border: 1px solid var(--border); border-radius: 6px; font-size: 13px; flex: 1; min-width: 100px; }
.inline-form button { margin-top: 0; }

.two-col { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; }
@media (max-width: 700px) { .two-col { grid-template-columns: 1fr; } }

/* Grid (mreza za admina) */
.grid-scroll { overflow: auto; max-height: 70vh; }
#gridTablica { border-collapse: collapse; }
#gridTablica th, #gridTablica td { border: 1px solid var(--border); padding: 0; text-align: center; font-size: 11px; }
#gridTablica th.ime-col, #gridTablica td.ime-col { position: sticky; left: 0; background: white; z-index: 2; padding: 6px 10px; text-align: left; white-space: nowrap; font-weight: 600; }
#gridTablica thead th { position: sticky; top: 0; background: #f8fafc; z-index: 1; padding: 4px; }
#gridTablica thead th.ime-col { z-index: 3; }
.grid-cell-btn { width: 30px; height: 26px; border: none; background: transparent; cursor: pointer; font-size: 10px; font-weight: 700; position: relative; }
.grid-cell-btn:hover { opacity: 0.7; }
.vikend-header { background: #fca5a5 !important; color: #b91c1c; font-weight: 700; }
.vikend-cell { background: #fee2e2; }
.legend-row { display: flex; flex-wrap: wrap; gap: 10px; font-size: 11px; margin-bottom: 10px; max-height: 60px; overflow-y: auto; }
.legend-dot { width: 10px; height: 10px; border-radius: 50%; display: inline-block; margin-right: 4px; vertical-align: middle; }

/* Modal */
.modal { position: fixed; inset: 0; background: rgba(0,0,0,0.4); display: flex; align-items: center; justify-content: center; z-index: 50; padding: 16px; }
.modal-box { background: white; border-radius: 12px; max-width: 420px; width: 100%; max-height: 90vh; overflow-y: auto; }
.modal-header { display: flex; justify-content: space-between; align-items: center; padding: 14px 18px; border-bottom: 1px solid var(--border); font-weight: 600; color: var(--navy); }
.modal-body { padding: 16px 18px; }
.modal-actions { display: flex; gap: 10px; margin-top: 16px; }
.toggle-group { display: flex; border: 1px solid var(--border); border-radius: 8px; overflow: hidden; margin-top: 4px; }
.toggle-btn { flex: 1; padding: 8px; border: none; background: white; cursor: pointer; font-size: 13px; color: var(--text-muted); }
.toggle-btn.active { background: var(--navy); color: white; }
.toggle-btn:disabled, select:disabled, input:disabled { opacity: 0.5; cursor: not-allowed; background: #f1f5f9; }
.two-field-row { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
