* { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --blue: #1a73e8;
  --blue-dark: #1557b0;
  --green: #2e7d32;
  --red: #c62828;
  --orange: #f57c00;
  --bg: #f8f9fa;
  --bg-secondary: #f1f3f4;
  --bg-card: #ffffff;
  --border: #e0e0e0;
  --border-strong: #bdbdbd;
  --text-primary: #202124;
  --text-secondary: #5f6368;
  --text-tertiary: #9aa0a6;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  background: var(--bg);
  color: var(--text-primary);
  font-size: 14px;
  line-height: 1.5;
}

.screen { display: none; min-height: 100vh; }
.screen.active { display: block; }

/* LOGIN */
.login-container {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  padding: 1rem;
}
.login-box {
  background: var(--bg-card);
  border-radius: 16px;
  padding: 2rem;
  width: 360px;
  max-width: 100%;
  box-shadow: 0 4px 24px rgba(0,0,0,0.08);
  text-align: center;
}
.logo-big {
  width: 60px; height: 60px;
  background: var(--blue);
  color: white;
  border-radius: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 20px;
  font-weight: 600;
  margin: 0 auto 1rem;
}
.login-box h1 { font-size: 20px; font-weight: 500; margin-bottom: 4px; }
.login-box .muted { color: var(--text-secondary); font-size: 13px; margin-bottom: 1.5rem; }

.tab-switcher {
  display: flex;
  background: var(--bg-secondary);
  border-radius: 8px;
  padding: 3px;
  margin-bottom: 1.5rem;
  gap: 2px;
}
.tab-btn {
  flex: 1;
  padding: 6px 10px;
  border: none;
  border-radius: 6px;
  background: transparent;
  cursor: pointer;
  font-size: 12px;
  font-weight: 500;
  color: var(--text-secondary);
}
.tab-btn.active {
  background: var(--bg-card);
  color: var(--text-primary);
  box-shadow: 0 1px 3px rgba(0,0,0,0.1);
}

label {
  display: block;
  font-size: 12px;
  font-weight: 500;
  color: var(--text-secondary);
  margin-bottom: 5px;
  text-align: left;
}
input[type="text"], input[type="email"], input[type="password"], input[type="number"], input[type="time"], input[type="date"], select, textarea {
  width: 100%;
  padding: 9px 12px;
  border: 1px solid var(--border);
  border-radius: 8px;
  font-size: 14px;
  margin-bottom: 1rem;
  background: white;
  font-family: inherit;
}
input:focus, select:focus, textarea:focus {
  outline: none;
  border-color: var(--blue);
}

.btn {
  padding: 9px 18px;
  border: none;
  border-radius: 8px;
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-family: inherit;
}
.btn-primary { background: var(--blue); color: white; width: 100%; }
.btn-primary:hover { background: var(--blue-dark); }
.btn-success { background: var(--green); color: white; }
.btn-danger { background: var(--red); color: white; }
.btn-warning { background: var(--orange); color: white; }
.btn-outline {
  background: transparent;
  border: 1px solid var(--border-strong);
  color: var(--text-secondary);
}
.btn-outline:hover { background: var(--bg-secondary); }
.btn-sm { padding: 4px 10px; font-size: 12px; }

.error-msg {
  color: var(--red);
  font-size: 12px;
  min-height: 18px;
  margin-top: 5px;
}

/* PIN */
.pin-display {
  font-size: 28px;
  letter-spacing: 12px;
  height: 50px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-bottom: 1px solid var(--border);
  margin-bottom: 1.25rem;
}
.pin-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
}
.pin-btn {
  aspect-ratio: 1;
  border: 1px solid var(--border);
  background: white;
  border-radius: 10px;
  font-size: 22px;
  font-weight: 500;
  color: var(--blue);
  cursor: pointer;
}
.pin-btn:hover { background: #e8f0fe; }
.pin-btn:active { transform: scale(0.95); }
.pin-btn.red { color: var(--red); }

/* TOPBAR */
.topbar {
  background: white;
  border-bottom: 1px solid var(--border);
  height: 56px;
  padding: 0 1.5rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  position: sticky;
  top: 0;
  z-index: 100;
}
.brand { display: flex; align-items: center; gap: 10px; font-weight: 500; }
.logo-sm {
  width: 30px; height: 30px;
  background: var(--blue);
  color: white;
  border-radius: 6px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 12px;
  font-weight: 600;
}
.top-right { display: flex; align-items: center; gap: 12px; font-size: 13px; }

/* APP LAYOUT */
.app-layout { display: flex; min-height: calc(100vh - 56px); }
.sidebar {
  width: 220px;
  background: white;
  border-right: 1px solid var(--border);
  padding: 0.5rem 0;
  flex-shrink: 0;
}
.nav-section {
  padding: 0.5rem 1rem 0.25rem;
  font-size: 11px;
  font-weight: 500;
  color: var(--text-tertiary);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}
.nav-item {
  padding: 9px 1rem;
  cursor: pointer;
  font-size: 13px;
  color: var(--text-secondary);
  border-left: 3px solid transparent;
}
.nav-item:hover { background: var(--bg-secondary); }
.nav-item.active {
  background: #e8f0fe;
  color: var(--blue);
  border-left-color: var(--blue);
  font-weight: 500;
}

.main-content {
  flex: 1;
  padding: 1.5rem;
  overflow: auto;
  min-width: 0;
}

/* CARDS */
.card {
  background: white;
  border: 1px solid var(--border);
  border-radius: 10px;
  margin-bottom: 1rem;
  overflow: hidden;
}
.card-header {
  padding: 0.875rem 1.25rem;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 8px;
}
.card-title { font-size: 14px; font-weight: 500; }
.card-body { padding: 1.25rem; }

.page-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  margin-bottom: 1.5rem;
  gap: 10px;
  flex-wrap: wrap;
}
.page-title { font-size: 22px; font-weight: 500; }
.page-subtitle { font-size: 13px; color: var(--text-secondary); margin-top: 3px; }

/* STATS ROW */
.stats-row {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 12px;
  margin-bottom: 1.5rem;
}
.stat-card {
  background: white;
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 1rem;
}
.stat-label {
  font-size: 11px;
  color: var(--text-tertiary);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  margin-bottom: 6px;
}
.stat-value { font-size: 24px; font-weight: 500; }
.stat-value.blue { color: var(--blue); }
.stat-value.green { color: var(--green); }
.stat-value.red { color: var(--red); }
.stat-value.orange { color: var(--orange); }
.stat-sub { font-size: 11px; color: var(--text-tertiary); margin-top: 3px; }

/* TABLES */
table { width: 100%; border-collapse: collapse; }
th {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--text-tertiary);
  font-weight: 500;
  padding: 10px 1rem;
  text-align: left;
  border-bottom: 1px solid var(--border);
  background: var(--bg-secondary);
}
td {
  padding: 10px 1rem;
  font-size: 13px;
  border-bottom: 1px solid var(--border);
}
tr:last-child td { border-bottom: none; }
tr.clickable { cursor: pointer; }
tr.clickable:hover td { background: var(--bg-secondary); }

/* BADGES */
.badge {
  display: inline-flex;
  align-items: center;
  padding: 2px 8px;
  border-radius: 4px;
  font-size: 11px;
  font-weight: 500;
  white-space: nowrap;
}
.badge-blue { background: #e8f0fe; color: #185fa5; }
.badge-green { background: #e8f5e9; color: var(--green); }
.badge-red { background: #ffebee; color: var(--red); }
.badge-orange { background: #fff3e0; color: #854f0b; }
.badge-gray { background: var(--bg-secondary); color: var(--text-secondary); }

/* PROGRESS BAR */
.progress {
  height: 5px;
  background: var(--border);
  border-radius: 3px;
  overflow: hidden;
  margin-top: 3px;
}
.progress-fill { height: 100%; border-radius: 3px; }

/* AVATAR */
.avatar {
  border-radius: 50%;
  background: #e8f0fe;
  color: #185fa5;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 500;
  flex-shrink: 0;
}

/* WORKER SCREEN */
.worker-topbar {
  background: var(--blue);
  color: white;
  padding: 1rem 1.25rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.worker-name { font-size: 16px; font-weight: 500; }
.worker-role { font-size: 12px; opacity: 0.85; }
.btn-worker-logout {
  background: rgba(255,255,255,0.2);
  border: none;
  color: white;
  padding: 6px 12px;
  border-radius: 6px;
  font-size: 12px;
  cursor: pointer;
}
.worker-content {
  padding: 1.25rem;
  max-width: 520px;
  margin: 0 auto;
  background: var(--bg);
  min-height: calc(100vh - 64px);
}

/* NOTICES */
.notice {
  border-radius: 8px;
  padding: 1rem;
  margin-bottom: 1rem;
  border: 1px solid;
}
.notice-amber { background: #fff3e0; border-color: var(--orange); color: #854f0b; }
.notice-green { background: #e8f5e9; border-color: var(--green); color: #1b5e20; }
.notice-red { background: #ffebee; border-color: var(--red); color: #8b0000; }
.notice-blue { background: #e8f0fe; border-color: var(--blue); color: #185fa5; }

.loading {
  text-align: center;
  padding: 3rem;
  color: var(--text-tertiary);
  font-size: 13px;
}

.muted { color: var(--text-secondary); }
.flex { display: flex; }
.flex-1 { flex: 1; }
.gap-sm { gap: 8px; }
.gap-md { gap: 12px; }
.mt-sm { margin-top: 8px; }
.mt-md { margin-top: 1rem; }
.hidden { display: none !important; }

/* MODAL */
.modal-overlay {
  position: fixed;
  top: 0; left: 0; right: 0; bottom: 0;
  background: rgba(0,0,0,0.5);
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1rem;
  animation: fadeIn 0.15s ease-out;
}
.modal-box {
  background: white;
  border-radius: 12px;
  width: 480px;
  max-width: 100%;
  max-height: 90vh;
  display: flex;
  flex-direction: column;
  box-shadow: 0 10px 40px rgba(0,0,0,0.2);
  animation: slideUp 0.2s ease-out;
}
.modal-header {
  padding: 1rem 1.25rem;
  border-bottom: 1px solid var(--border);
  display: flex;
  justify-content: space-between;
  align-items: center;
}
.modal-title { font-size: 16px; font-weight: 500; }
.modal-close {
  background: none;
  border: none;
  font-size: 24px;
  cursor: pointer;
  color: var(--text-secondary);
  line-height: 1;
  padding: 0 8px;
}
.modal-close:hover { color: var(--text-primary); }
.modal-body {
  padding: 1.25rem;
  overflow-y: auto;
  flex: 1;
}
.modal-footer {
  padding: 1rem 1.25rem;
  border-top: 1px solid var(--border);
  display: flex;
  justify-content: flex-end;
  gap: 10px;
}

/* TABS */
.tabs {
  display: inline-flex;
  background: var(--bg-secondary);
  border-radius: 8px;
  padding: 3px;
  gap: 2px;
}
.tab {
  padding: 5px 14px;
  border: none;
  border-radius: 6px;
  background: transparent;
  cursor: pointer;
  font-size: 12px;
  font-weight: 500;
  color: var(--text-secondary);
  font-family: inherit;
}
.tab.on {
  background: white;
  color: var(--text-primary);
  box-shadow: 0 1px 3px rgba(0,0,0,0.08);
}

/* FIELDS */
.field { margin-bottom: 1rem; }
.field label {
  display: block;
  font-size: 12px;
  font-weight: 500;
  color: var(--text-secondary);
  margin-bottom: 5px;
}
.field input, .field select, .field textarea {
  margin-bottom: 0;
}
.field-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

/* ANIMACIJE */
@keyframes fadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}
@keyframes slideUp {
  from { opacity: 0; transform: translateY(20px); }
  to { opacity: 1; transform: translateY(0); }
}
@keyframes slideIn {
  from { opacity: 0; transform: translateX(20px); }
  to { opacity: 1; transform: translateX(0); }
}

.loading::after {
  content: '';
  display: inline-block;
  width: 16px;
  height: 16px;
  margin-left: 8px;
  border: 2px solid var(--border);
  border-top-color: var(--blue);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
  vertical-align: middle;
}
@keyframes spin {
  to { transform: rotate(360deg); }
}

@media (max-width: 768px) {
  .stats-row { grid-template-columns: repeat(2, 1fr); }
  .sidebar { width: 180px; }
  .main-content { padding: 1rem; }
  .modal-box { width: 100%; }
}

/* ══════════════════════════════════════════════
   VERSION PILL
   ══════════════════════════════════════════════ */
.version-pill {
  background: var(--bg-secondary);
  color: var(--text-tertiary);
  font-size: 10px;
  padding: 2px 8px;
  border-radius: 10px;
  margin-left: 8px;
  font-weight: 500;
}

/* ══════════════════════════════════════════════
   WORKER-ONLY stranice (radnik.html)
   ══════════════════════════════════════════════ */
body.worker-body {
  background: #f1f3f4;
}
.pin-container {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  padding: 1rem;
}
.pin-box {
  background: white;
  border-radius: 16px;
  padding: 2rem;
  width: 340px;
  max-width: 100%;
  box-shadow: 0 4px 24px rgba(0,0,0,0.1);
  text-align: center;
}


/* iOS Safari fix — sprječava zoom na fokus inputa (font < 16px = zoom) */
@media (max-width: 768px) {
  input[type="text"],
  input[type="number"],
  input[type="password"],
  input[type="email"],
  input[type="tel"],
  input[type="search"],
  input[type="date"],
  input[type="time"],
  textarea,
  select {
    font-size: 16px !important;
  }
}

/* iOS Safari fix — sprječava double-tap zoom */
* {
  touch-action: manipulation;
}
