* { margin: 0; padding: 0; box-sizing: border-box; -webkit-tap-highlight-color: transparent; }

:root {
  --primary: #2E7D32;
  --primary-dark: #1B5E20;
  --primary-light: #4CAF50;
  --accent: #FF8F00;
  --bg: #F5F5F5;
  --surface: #FFFFFF;
  --text: #212121;
  --text-secondary: #757575;
  --border: #E0E0E0;
  --error: #D32F2F;
  --success: #388E3C;
  --white: #FFFFFF;
  --pink: #E91E63;
  --orange: #FF9800;
  --red: #F44336;
  --green: #4CAF50;
  --purple: #7C4DFF;
  --safe-bottom: env(safe-area-inset-bottom, 0px);
}

html, body { 
  height: 100%; 
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
  overflow: hidden;
}

#app {
  display: flex;
  flex-direction: column;
  height: 100%;
  max-width: 480px;
  margin: 0 auto;
  background: var(--bg);
  position: relative;
}

/* Header */
#header {
  background: var(--primary);
  color: var(--white);
  padding: 14px 16px;
  font-size: 18px;
  font-weight: 600;
  display: flex;
  align-items: center;
  min-height: 52px;
  flex-shrink: 0;
}
#header .back-btn {
  background: none; border: none; color: var(--white);
  font-size: 24px; margin-right: 12px; cursor: pointer;
  display: flex; align-items: center;
}
#header .header-title { flex: 1; }

/* Content */
#content {
  flex: 1;
  overflow-y: auto;
  overflow-x: hidden;
  -webkit-overflow-scrolling: touch;
}

/* Bottom Tabs */
#tabs {
  display: flex;
  background: var(--surface);
  border-top: 1px solid var(--border);
  padding-bottom: var(--safe-bottom);
  flex-shrink: 0;
}
.tab {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 8px 0;
  cursor: pointer;
  color: var(--text-secondary);
  font-size: 12px;
  font-weight: 500;
  transition: color 0.2s;
}
.tab ion-icon { font-size: 22px; margin-bottom: 2px; }
.tab.active { color: var(--primary); }

/* Cards */
.card {
  background: var(--surface);
  border-radius: 12px;
  padding: 14px;
  margin: 4px 12px;
  box-shadow: 0 1px 3px rgba(0,0,0,0.1);
}
.card-row { display: flex; align-items: center; }
.card-info { flex: 1; }
.card-title { font-size: 16px; font-weight: 600; }
.card-detail { font-size: 13px; color: var(--text-secondary); margin-top: 2px; }
.card-owner { font-size: 13px; color: var(--purple); font-weight: 600; margin-top: 2px; }
.card-note { font-size: 13px; color: var(--text-secondary); font-style: italic; margin-top: 3px; }

/* Badge */
.badge {
  width: 44px; height: 44px; border-radius: 12px;
  display: flex; align-items: center; justify-content: center;
  margin-right: 12px; font-size: 14px; font-weight: 600;
}

/* Icon wrap */
.icon-wrap {
  width: 46px; height: 46px; border-radius: 14px;
  display: flex; align-items: center; justify-content: center;
  margin-right: 12px;
}

/* Actions */
.actions { display: flex; gap: 4px; }
.action-btn {
  background: none; border: none; padding: 8px; cursor: pointer;
  font-size: 18px; display: flex; align-items: center;
}
.action-btn.edit { color: var(--primary); }
.action-btn.delete { color: var(--error); }

/* FAB */
.fab {
  position: fixed;
  bottom: calc(70px + var(--safe-bottom));
  right: calc(50% - 220px);
  width: 56px; height: 56px; border-radius: 28px;
  border: none; color: var(--white); font-size: 28px;
  display: flex; align-items: center; justify-content: center;
  cursor: pointer; box-shadow: 0 4px 12px rgba(0,0,0,0.25);
  z-index: 10;
}
@media (max-width: 480px) {
  .fab { right: 20px; }
}

/* Search */
.search-row {
  display: flex; align-items: center;
  background: var(--surface); margin: 12px;
  border-radius: 12px; padding: 0 12px;
  box-shadow: 0 1px 3px rgba(0,0,0,0.1);
}
.search-row ion-icon { font-size: 20px; color: var(--text-secondary); margin-right: 8px; }
.search-row input {
  flex: 1; height: 46px; border: none; outline: none;
  font-size: 15px; color: var(--text); background: transparent;
}
.count-text {
  font-size: 13px; color: var(--text-secondary);
  margin: 0 16px 4px; font-weight: 600;
}

/* Forms */
.form-container { padding: 20px; padding-bottom: 40px; }
.form-label { font-size: 16px; font-weight: 600; margin-bottom: 6px; margin-top: 14px; }
.form-input {
  width: 100%; background: var(--surface); border-radius: 12px;
  padding: 14px; font-size: 15px; color: var(--text);
  border: 1px solid var(--border); outline: none;
  font-family: inherit;
}
.form-input:focus { border-color: var(--primary); }
.form-input.textarea { height: 80px; resize: vertical; }
.form-btn {
  width: 100%; border: none; border-radius: 12px; padding: 16px;
  font-size: 16px; font-weight: 600; color: var(--white);
  cursor: pointer; margin-top: 24px;
}

/* Section Title */
.section-title {
  font-size: 16px; font-weight: 600; margin-top: 14px; margin-bottom: 10px;
  padding-bottom: 8px; border-bottom: 1px solid var(--border);
}

/* Select items (radio/checkbox) */
.select-item {
  display: flex; align-items: center; padding: 12px;
  background: var(--surface); border-radius: 10px; margin-bottom: 6px;
  border: 1px solid var(--border); cursor: pointer; transition: all 0.15s;
}
.select-item.active { background: rgba(46,125,50,0.03); }
.select-item ion-icon { font-size: 22px; color: var(--text-secondary); }
.select-item.active ion-icon { color: var(--primary); }
.select-item span { font-size: 14px; margin-left: 10px; flex: 1; }

/* Month grid */
.month-grid { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 10px; }
.month-btn {
  padding: 10px 14px; border-radius: 10px; border: 1px solid var(--border);
  background: var(--surface); cursor: pointer; min-width: 60px;
  text-align: center; font-size: 13px; color: var(--text-secondary);
  font-weight: 600; transition: all 0.15s;
}
.month-btn.active { background: var(--orange); border-color: var(--orange); color: var(--white); }

/* Month filter row */
.filter-row {
  display: flex; overflow-x: auto; padding: 10px 12px;
  gap: 8px; -webkit-overflow-scrolling: touch;
}
.filter-row::-webkit-scrollbar { display: none; }
.filter-btn {
  padding: 8px 14px; border-radius: 20px; border: 1px solid var(--border);
  background: var(--surface); cursor: pointer; white-space: nowrap;
  font-size: 13px; color: var(--text-secondary); font-weight: 500;
}
.filter-btn.active { background: var(--accent); border-color: var(--accent); color: var(--white); }

/* Stats row */
.stats-text { font-size: 13px; font-weight: 600; color: var(--primary); margin: 0 16px 6px; }

/* Home screen */
.home-header {
  background: var(--primary); padding: 30px 20px;
  text-align: center; border-radius: 0 0 25px 25px;
}
.home-header ion-icon { font-size: 40px; color: var(--white); }
.home-header h1 { color: var(--white); font-size: 26px; margin-top: 8px; }
.home-header p { color: rgba(255,255,255,0.8); font-size: 16px; margin-top: 4px; }
.home-grid {
  display: flex; flex-wrap: wrap; padding: 12px;
  justify-content: space-between;
}
.home-card {
  background: var(--surface); border-radius: 16px; padding: 20px;
  width: 47%; margin-bottom: 16px; cursor: pointer;
  box-shadow: 0 2px 6px rgba(0,0,0,0.08);
  transition: transform 0.15s;
}
.home-card:active { transform: scale(0.97); }
.home-card .icon-box {
  width: 56px; height: 56px; border-radius: 16px;
  display: flex; align-items: center; justify-content: center;
  margin-bottom: 12px;
}
.home-card .icon-box ion-icon { font-size: 32px; }
.home-card h3 { font-size: 16px; font-weight: 600; margin-bottom: 4px; }
.home-card p { font-size: 12px; color: var(--text-secondary); }

/* Stats card */
.stats-card {
  background: var(--primary); margin: 12px; border-radius: 16px; padding: 16px;
}
.stats-card h3 { color: var(--white); font-size: 15px; font-weight: 600; margin-bottom: 12px; }
.stats-grid { display: flex; justify-content: space-around; }
.stat-item { text-align: center; }
.stat-value { font-size: 20px; font-weight: 700; color: var(--white); }
.stat-label { font-size: 12px; color: rgba(255,255,255,0.73); margin-top: 2px; }

/* Korisnik detail */
.detail-header {
  background: var(--purple); padding: 28px 20px;
  text-align: center; border-radius: 0 0 25px 25px;
}
.detail-avatar {
  width: 64px; height: 64px; border-radius: 32px;
  background: rgba(255,255,255,0.2); display: flex;
  align-items: center; justify-content: center;
  margin: 0 auto 10px; font-size: 24px; font-weight: 700; color: var(--white);
}
.detail-header h2 { color: var(--white); font-size: 22px; }
.detail-header p { color: rgba(255,255,255,0.8); margin-top: 4px; }
.detail-section {
  background: var(--surface); margin: 12px 12px 0; border-radius: 14px;
  padding: 16px; box-shadow: 0 1px 3px rgba(0,0,0,0.1);
}
.section-header { display: flex; align-items: center; margin-bottom: 12px; }
.section-icon {
  width: 36px; height: 36px; border-radius: 10px;
  display: flex; align-items: center; justify-content: center; margin-right: 10px;
}
.section-header h3 { font-size: 16px; font-weight: 600; }
.detail-item { padding: 8px 0; border-bottom: 1px solid var(--border); }
.detail-item:last-child { border-bottom: none; }
.detail-item strong { font-size: 14px; font-weight: 600; }
.detail-item p { font-size: 13px; color: var(--text-secondary); margin-top: 2px; }
.detail-empty { font-size: 13px; color: var(--text-secondary); font-style: italic; padding: 8px 0; }

/* Ovce badges in sparivanje */
.ovce-badges { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 6px; }
.ovce-badge {
  background: rgba(46,125,50,0.1); padding: 4px 10px;
  border-radius: 8px; font-size: 13px; color: var(--primary); font-weight: 500;
}

/* Tip buttons */
.tip-row { display: flex; gap: 10px; }
.tip-btn {
  flex: 1; padding: 12px; border-radius: 10px; border: 1px solid var(--border);
  background: var(--surface); cursor: pointer; text-align: center;
  font-size: 14px; font-weight: 600; color: var(--text-secondary);
}
.tip-btn.active { background: var(--red); border-color: var(--red); color: var(--white); }

/* Avatar */
.avatar {
  width: 48px; height: 48px; border-radius: 24px;
  display: flex; align-items: center; justify-content: center;
  margin-right: 12px; font-size: 16px; font-weight: 700;
}

/* Inactive badge */
.inactive-badge { color: var(--error); font-weight: 600; font-size: 12px; margin-top: 2px; }

/* Toast */
.toast {
  position: fixed; bottom: 80px; left: 50%; transform: translateX(-50%);
  background: #333; color: white; padding: 12px 24px; border-radius: 8px;
  font-size: 14px; z-index: 1000; transition: opacity 0.3s;
}
.toast.hidden { opacity: 0; pointer-events: none; }

/* Modal */
.modal-overlay {
  position: fixed; top: 0; left: 0; right: 0; bottom: 0;
  background: rgba(0,0,0,0.5); z-index: 100;
  display: flex; align-items: center; justify-content: center;
}
.modal-overlay.hidden { display: none; }
.modal-box {
  background: var(--surface); border-radius: 16px; padding: 24px;
  width: 85%; max-width: 360px; text-align: center;
}
.modal-box p { font-size: 16px; margin-bottom: 20px; }
.modal-actions { display: flex; gap: 12px; }
.modal-btn {
  flex: 1; padding: 12px; border-radius: 10px; border: none;
  font-size: 15px; font-weight: 600; cursor: pointer;
}
.modal-btn.cancel { background: var(--border); color: var(--text); }
.modal-btn.confirm { background: var(--error); color: var(--white); }

/* Loading */
.empty-text {
  text-align: center; margin-top: 40px; font-size: 16px; color: var(--text-secondary);
}

/* Scroll padding bottom */
.list-container { padding-bottom: 100px; }

/* Pull to refresh hint text */
.refresh-hint {
  text-align: center; padding: 8px; font-size: 12px; color: var(--text-secondary);
}
