/* ============================================================
   BERNAPT – Teljes reszponziv stiluslap
   ============================================================ */
:root {
  --primary: #2E2B5E;
  --primary-dark: #2E2B5E;
  --secondary: #5573B5;
  --success: #16a34a;
  --danger: #dc2626;
  --warning: #d97706;
  --info: #0891b2;
  --bg: #f1f5f9;
  --card: #ffffff;
  --border: #e2e8f0;
  --text: #1e293b;
  --text-muted: #64748b;
  --radius: 8px;
  --shadow: 0 1px 3px rgba(0,0,0,.1), 0 1px 2px rgba(0,0,0,.06);
  --shadow-md: 0 4px 6px rgba(0,0,0,.07), 0 2px 4px rgba(0,0,0,.06);
  --nav-height: 56px;
}

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

body {
  font-family: 'Segoe UI', system-ui, -apple-system, sans-serif;
  background: var(--bg);
  color: var(--text);
  font-size: 14px;
  line-height: 1.5;
  min-height: 100vh;
}

/* ============================================================
   NAVBAR
   ============================================================ */
.navbar {
  background: var(--primary);
  color: #fff;
  padding: 0 1.25rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: var(--nav-height);
  position: sticky;
  top: 0;
  z-index: 200;
  box-shadow: var(--shadow-md);
}

.nav-brand {
  display: flex;
  align-items: center;
  gap: .5rem;
  font-weight: 700;
  font-size: 1rem;
  white-space: nowrap;
  color: #fff;
  text-decoration: none;
}

.nav-toggle {
  display: none;
  flex-direction: column;
  justify-content: center;
  gap: 5px;
  background: none;
  border: none;
  cursor: pointer;
  padding: .4rem;
  border-radius: 4px;
  transition: background .15s;
  -webkit-tap-highlight-color: transparent;
}
.nav-toggle:hover { background: rgba(255,255,255,.15); }
.nav-toggle span {
  display: block;
  width: 22px;
  height: 2px;
  background: #fff;
  border-radius: 2px;
  transition: all .25s;
}
.nav-toggle.open span:nth-child(1) { transform: translateY(7px) rotate(45deg); }
.nav-toggle.open span:nth-child(2) { opacity: 0; transform: scaleX(0); }
.nav-toggle.open span:nth-child(3) { transform: translateY(-7px) rotate(-45deg); }

.nav-links {
  display: flex;
  align-items: center;
  gap: .1rem;
  flex: 1;
  padding: 0 .75rem;
}
.nav-links a {
  color: rgba(255,255,255,.85);
  text-decoration: none;
  padding: .4rem .65rem;
  border-radius: var(--radius);
  font-size: .83rem;
  white-space: nowrap;
  transition: background .15s, color .15s;
}
.nav-links a:hover,
.nav-links a.active {
  background: rgba(255,255,255,.2);
  color: #fff;
}

.nav-user {
  display: flex;
  align-items: center;
  gap: .4rem;
  font-size: .78rem;
  white-space: nowrap;
}
.nav-user .nav-user-name {
  opacity: .8;
  max-width: 130px;
  overflow: hidden;
  text-overflow: ellipsis;
}
.nav-user a {
  color: rgba(255,255,255,.85);
  text-decoration: none;
  padding: .28rem .55rem;
  border-radius: var(--radius);
  border: 1px solid rgba(255,255,255,.3);
  font-size: .76rem;
  transition: background .15s;
}
.nav-user a:hover { background: rgba(255,255,255,.2); color: #fff; }

.nav-user-mobile { display: none; }

/* ============================================================
   MOBIL NAV
   ============================================================ */
@media (max-width: 768px) {
  .nav-toggle { display: flex; }
  .nav-user { display: none; }

  .nav-links {
    display: none;
    position: fixed;
    top: var(--nav-height);
    left: 0;
    right: 0;
    background: var(--primary-dark);
    flex-direction: column;
    align-items: stretch;
    padding: .25rem 0 .5rem;
    gap: 0;
    box-shadow: 0 8px 24px rgba(0,0,0,.25);
    z-index: 199;
    max-height: calc(100vh - var(--nav-height));
    overflow-y: auto;
  }
  .nav-links.open { display: flex; }
  .nav-links a {
    padding: .85rem 1.25rem;
    border-radius: 0;
    font-size: .95rem;
    border-bottom: 1px solid rgba(255,255,255,.07);
  }
  .nav-links a:last-child { border-bottom: none; }

  .nav-user-mobile {
    display: flex;
    flex-direction: column;
    gap: 0;
    padding: .5rem 0 0;
    border-top: 1px solid rgba(255,255,255,.15);
    margin-top: .25rem;
  }
  .nav-user-mobile .user-label {
    font-size: .75rem;
    color: rgba(255,255,255,.6);
    padding: .4rem 1.25rem .2rem;
  }
  .nav-user-mobile a {
    color: rgba(255,255,255,.9);
    text-decoration: none;
    font-size: .9rem;
    padding: .75rem 1.25rem;
    border-bottom: 1px solid rgba(255,255,255,.07);
    display: block;
  }
}

/* ============================================================
   CONTAINER
   ============================================================ */
.container {
  max-width: 1200px;
  margin: 0 auto;
  padding: 1.25rem 1rem;
}

@media (max-width: 480px) {
  .container { padding: .75rem; }
}

/* ============================================================
   PAGE HEADER
   ============================================================ */
.page-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  margin-bottom: 1.25rem;
  gap: .75rem;
  flex-wrap: wrap;
}
.page-header h1 { font-size: 1.35rem; font-weight: 700; }

@media (max-width: 480px) {
  .page-header { flex-direction: column; align-items: stretch; }
  .page-header h1 { font-size: 1.15rem; }
  .page-header .btn-group { width: 100%; }
  .page-header .btn-group .btn,
  .page-header > .btn { flex: 1; justify-content: center; }
}

/* ============================================================
   CARDS
   ============================================================ */
.card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  overflow: hidden;
}
.card-header {
  padding: .8rem 1.1rem;
  border-bottom: 1px solid var(--border);
  font-weight: 600;
  font-size: .9rem;
  background: #f8fafc;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: .5rem;
  flex-wrap: wrap;
}
.card-body { padding: 1.1rem; }

/* ============================================================
   STAT CARDS
   ============================================================ */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: .875rem;
  margin-bottom: 1.25rem;
}
.stat-card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1rem;
  box-shadow: var(--shadow);
  border-top: 3px solid var(--primary);
}
.stat-card .stat-value { font-size: 1.8rem; font-weight: 700; line-height: 1; color: var(--primary); }
.stat-card .stat-label { color: var(--text-muted); font-size: .78rem; margin-top: .25rem; }

@media (max-width: 900px) {
  .stats-grid { grid-template-columns: 1fr 1fr; }
}
@media (max-width: 480px) {
  .stats-grid { grid-template-columns: 1fr 1fr; }
  .stat-card .stat-value { font-size: 1.5rem; }
}

/* ============================================================
   GRID
   ============================================================ */
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 1.25rem; }
.grid-3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 1rem; }

@media (max-width: 900px) { .grid-3 { grid-template-columns: 1fr 1fr; } }
@media (max-width: 768px) { .grid-2 { grid-template-columns: 1fr; } }
@media (max-width: 580px) { .grid-3 { grid-template-columns: 1fr; } }

/* ============================================================
   TABLES
   ============================================================ */
.table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }
table { width: 100%; border-collapse: collapse; font-size: .875rem; }
thead th {
  background: #f8fafc;
  padding: .55rem .8rem;
  text-align: left;
  font-weight: 600;
  color: var(--text-muted);
  border-bottom: 2px solid var(--border);
  white-space: nowrap;
}
tbody td {
  padding: .6rem .8rem;
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
}
tbody tr:hover { background: #f8fafc; }
tbody tr:last-child td { border-bottom: none; }

@media (max-width: 600px) {
  .hide-mobile { display: none !important; }
  thead th, tbody td { padding: .5rem .6rem; font-size: .8rem; }
}

/* Detail tabla (key-value) */
table.detail-table { width: 100%; }
table.detail-table td { padding: .45rem 0; border-bottom: 1px solid var(--border); vertical-align: top; }
table.detail-table td:first-child { width: 44%; color: var(--text-muted); font-weight: 500; padding-right: .75rem; font-size: .85rem; }
table.detail-table tr:last-child td { border-bottom: none; }

/* ============================================================
   BADGES
   ============================================================ */
.badge {
  display: inline-block;
  padding: .18rem .5rem;
  border-radius: 999px;
  font-size: .72rem;
  font-weight: 600;
  white-space: nowrap;
}
.badge-success { background: #dcfce7; color: #166534; }
.badge-danger  { background: #fee2e2; color: #991b1b; }
.badge-warning { background: #fef3c7; color: #92400e; }
.badge-info    { background: #e0f2fe; color: #075985; }
.badge-gray    { background: #f1f5f9; color: #475569; }
.badge-primary { background: #dbeafe; color: #1e40af; }

/* ============================================================
   BUTTONS
   ============================================================ */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: .3rem;
  padding: .48rem .9rem;
  border: none;
  border-radius: var(--radius);
  font-size: .875rem;
  font-weight: 500;
  cursor: pointer;
  text-decoration: none;
  transition: background .15s, opacity .15s;
  white-space: nowrap;
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
  min-height: 36px;
  line-height: 1.4;
}
.btn:active { opacity: .85; }
.btn-primary   { background: var(--primary); color: #fff; }
.btn-primary:hover   { background: var(--primary-dark); }
.btn-success   { background: var(--success); color: #fff; }
.btn-success:hover   { background: #15803d; }
.btn-danger    { background: var(--danger); color: #fff; }
.btn-danger:hover    { background: #b91c1c; }
.btn-warning   { background: var(--warning); color: #fff; }
.btn-warning:hover   { background: #b45309; }
.btn-secondary { background: var(--secondary); color: #fff; }
.btn-secondary:hover { background: #475569; }
.btn-outline   { background: transparent; color: var(--primary); border: 1px solid var(--primary); }
.btn-outline:hover   { background: var(--primary); color: #fff; }
.btn-sm  { padding: .28rem .6rem; font-size: .78rem; min-height: 30px; }
.btn-xs  { padding: .18rem .44rem; font-size: .72rem; min-height: 26px; }
.btn-group { display: flex; gap: .3rem; flex-wrap: wrap; align-items: center; }

@media (max-width: 480px) {
  .btn { min-height: 40px; }
}

/* ============================================================
   FORMS
   ============================================================ */
.form-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 1rem; }
.form-group { display: flex; flex-direction: column; gap: .3rem; }
.form-group label { font-weight: 500; font-size: .84rem; color: var(--text); }
.form-group label .req { color: var(--danger); }

.form-control {
  padding: .55rem .75rem;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  font-size: .875rem;
  background: #fff;
  color: var(--text);
  transition: border-color .15s, box-shadow .15s;
  width: 100%;
  -webkit-appearance: none;
  appearance: none;
  line-height: 1.5;
}
.form-control:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(37,99,235,.12);
}
textarea.form-control { resize: vertical; min-height: 80px; }
select.form-control {
  cursor: pointer;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='7' viewBox='0 0 10 7'%3E%3Cpath fill='%2364748b' d='M0 0l5 7 5-7z'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right .7rem center;
  padding-right: 2rem;
}

.form-section { margin-bottom: 1.5rem; }
.form-section-title {
  font-weight: 700;
  font-size: .78rem;
  text-transform: uppercase;
  letter-spacing: .05em;
  color: var(--text-muted);
  margin-bottom: .75rem;
  padding-bottom: .35rem;
  border-bottom: 1px solid var(--border);
}
.form-actions {
  display: flex;
  gap: .75rem;
  justify-content: flex-end;
  padding-top: 1rem;
  border-top: 1px solid var(--border);
  margin-top: 1rem;
  flex-wrap: wrap;
}
.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 1rem; }

@media (max-width: 600px) {
  .form-row  { grid-template-columns: 1fr; }
  .form-grid { grid-template-columns: 1fr; }
  .form-actions { flex-direction: column-reverse; }
  .form-actions .btn { width: 100%; }
  /* iOS: 16px megakadalyozza az auto-zoomot */
  .form-control { font-size: 16px; }
  select.form-control { font-size: 16px; }
}

/* ============================================================
   ALERTS
   ============================================================ */
.alert {
  padding: .7rem 1rem;
  border-radius: var(--radius);
  margin-bottom: 1rem;
  font-size: .875rem;
  border: 1px solid transparent;
}
.alert-success { background: #dcfce7; color: #166534; border-color: #bbf7d0; }
.alert-danger  { background: #fee2e2; color: #991b1b; border-color: #fecaca; }
.alert-warning { background: #fef3c7; color: #92400e; border-color: #fde68a; }
.alert-info    { background: #e0f2fe; color: #075985; border-color: #bae6fd; }

/* ============================================================
   CALENDAR
   ============================================================ */
.calendar-wrap {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  box-shadow: var(--shadow);
}
.cal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: .8rem 1rem;
  background: var(--primary);
  color: #fff;
}
.cal-header h2 { font-size: 1rem; font-weight: 700; }
.cal-header .btn { background: rgba(255,255,255,.2); color: #fff; border: none; min-height: 32px; }
.cal-header .btn:hover { background: rgba(255,255,255,.3); }
.cal-weekdays {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  background: #f8fafc;
  border-bottom: 1px solid var(--border);
}
.cal-weekdays div {
  text-align: center;
  padding: .4rem .2rem;
  font-size: .68rem;
  font-weight: 700;
  color: var(--text-muted);
  text-transform: uppercase;
}
.cal-grid { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); }
.cal-day {
  min-height: 80px;
  border-right: 1px solid var(--border);
  border-bottom: 1px solid var(--border);
  padding: .3rem;
  overflow: hidden;
  min-width: 0;      /* grid cellák ne fújják fel a sort */
  max-width: 100%;
}
.cal-day:nth-child(7n) { border-right: none; }
.cal-day-num {
  font-size: .7rem;
  font-weight: 600;
  color: var(--text-muted);
  margin-bottom: .2rem;
  width: 20px;
  height: 20px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
}
.cal-day.today .cal-day-num { background: var(--primary); color: #fff; }
.cal-day.other-month { background: #f8fafc; }
.cal-day.other-month .cal-day-num { color: #cbd5e1; }
.cal-event {
  font-size: .62rem;
  padding: .1rem .3rem;
  border-radius: 3px;
  margin-bottom: .1rem;
  cursor: pointer;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  width: 100%;         /* szülő szélességéhez igazodik */
  max-width: 100%;
  box-sizing: border-box;
  text-decoration: none;
  display: block;
  transition: opacity .15s;
}
.cal-event:hover { opacity: .75; }
.cal-event.ev-aktiv    { background: #dbeafe; color: #1e40af; border-left: 3px solid #2563eb; }
.cal-event.ev-foglalt  { background: #fef3c7; color: #92400e; border-left: 3px solid #d97706; }
.cal-event.ev-lezart   { background: #dcfce7; color: #166534; border-left: 3px solid #16a34a; }
.cal-event.ev-lemondott{ background: #f1f5f9; color: #64748b; border-left: 3px solid #94a3b8; text-decoration: line-through; }

@media (max-width: 600px) {
  .cal-day { min-height: 48px; padding: .18rem; }
  .cal-day-num { font-size: .62rem; width: 17px; height: 17px; }
  .cal-event { font-size: .52rem; padding: .06rem .18rem; }
  .cal-weekdays div { font-size: .6rem; padding: .3rem .1rem; }
}

/* ============================================================
   MODAL
   ============================================================ */
.modal-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.5);
  z-index: 1000;
  align-items: flex-end;
  justify-content: center;
}
.modal-overlay.open { display: flex; }
.modal {
  background: #fff;
  border-radius: var(--radius) var(--radius) 0 0;
  box-shadow: 0 -4px 32px rgba(0,0,0,.18);
  width: 100%;
  max-height: 92vh;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
}

@media (min-width: 640px) {
  .modal-overlay { align-items: center; padding: 1rem; }
  .modal { border-radius: var(--radius); max-width: 680px; box-shadow: 0 20px 60px rgba(0,0,0,.2); }
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: .9rem 1.1rem;
  border-bottom: 1px solid var(--border);
  font-weight: 700;
  font-size: .95rem;
  position: sticky;
  top: 0;
  background: #fff;
  z-index: 1;
}
.modal-close {
  background: none;
  border: none;
  font-size: 1.4rem;
  cursor: pointer;
  color: var(--text-muted);
  line-height: 1;
  padding: .2rem .35rem;
  border-radius: 4px;
}
.modal-close:hover { background: #f1f5f9; color: var(--danger); }
.modal-body { padding: 1.1rem; }
.modal-footer {
  padding: .8rem 1.1rem;
  border-top: 1px solid var(--border);
  display: flex;
  gap: .6rem;
  justify-content: flex-end;
  position: sticky;
  bottom: 0;
  background: #fff;
}
@media (max-width: 480px) {
  .modal-footer { flex-direction: column-reverse; }
  .modal-footer .btn { width: 100%; }
}

/* ============================================================
   FILTER BAR
   ============================================================ */
.filter-bar {
  display: flex;
  gap: .6rem;
  flex-wrap: wrap;
  align-items: flex-end;
}
.filter-bar .form-control { max-width: 200px; }

@media (max-width: 600px) {
  .filter-bar { flex-direction: column; align-items: stretch; }
  .filter-bar .form-control { max-width: 100%; }
  .filter-bar .btn { width: 100%; }
}

/* ============================================================
   EXPIRY
   ============================================================ */
.expiry-ok      { color: var(--success); }
.expiry-warn    { color: var(--warning); font-weight: 600; }
.expiry-expired { color: var(--danger);  font-weight: 700; }

/* ============================================================
   PRINT
   ============================================================ */
@media print {
  .navbar, .no-print, .page-header .btn,
  .btn-group, .filter-bar, .footer { display: none !important; }
  body { background: #fff; font-size: 12px; }
  .card { box-shadow: none; border: 1px solid #ccc; }
  .container { padding: 0; max-width: 100%; }
}

/* ============================================================
   FOOTER
   ============================================================ */
.footer {
  text-align: center;
  padding: 1rem;
  color: var(--text-muted);
  font-size: .75rem;
  border-top: 1px solid var(--border);
  margin-top: 2rem;
}

/* ============================================================
   UTILITIES
   ============================================================ */
.text-muted    { color: var(--text-muted); }
.text-right    { text-align: right; }
.text-center   { text-align: center; }
.mt-1 { margin-top: .5rem; }
.mt-2 { margin-top: 1rem; }
.mb-1 { margin-bottom: .5rem; }
.mb-2 { margin-bottom: 1rem; }
.flex { display: flex; }
.flex-wrap { flex-wrap: wrap; }
.gap-1 { gap: .5rem; }
.items-center { align-items: center; }
.justify-between { justify-content: space-between; }