:root {
  --primary:      #16283c;
  --primary-soft: #1f3a54;
  --accent:       #f0a428;
  --accent-soft:  #fdf3df;
  --success:      #1e8e5a;
  --success-soft: #e3f5ec;
  --danger:       #d64541;
  --danger-soft:  #fdeaea;
  --info-soft:    #e7f0fb;
  --info:         #2563a8;
  --bg:           #f2f4f8;
  --card:         #ffffff;
  --text:         #1c2733;
  --muted:        #7c8794;
  --border:       #e4e8ef;
  --radius:       14px;
  --shadow:       0 1px 3px rgba(22,40,60,.06), 0 8px 24px rgba(22,40,60,.07);
  --shadow-sm:    0 1px 2px rgba(22,40,60,.08);
}

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

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Inter', sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
}

/* ==================== NAV ==================== */
nav {
  background: linear-gradient(135deg, #14243a 0%, #1d3552 60%, #234160 100%);
  color: #fff;
  padding: 0 28px;
  display: flex;
  align-items: center;
  gap: 6px;
  height: 62px;
  position: sticky;
  top: 0;
  z-index: 100;
  box-shadow: 0 2px 16px rgba(20, 36, 58, .35);
}
nav .logo {
  font-weight: 800;
  font-size: 17px;
  margin-right: auto;
  letter-spacing: .2px;
  display: flex;
  align-items: center;
  gap: 8px;
  white-space: nowrap;
}
nav .logo span { color: var(--accent); }
nav a {
  color: rgba(255,255,255,.72);
  text-decoration: none;
  padding: 8px 15px;
  border-radius: 9px;
  font-size: 13.5px;
  font-weight: 600;
  transition: background .18s, color .18s;
  position: relative;
}
nav a:hover { background: rgba(255,255,255,.08); color: #fff; }
#nav-logout { margin-left: 8px; }
nav a.active {
  background: rgba(240,164,40,.16);
  color: var(--accent);
}
.nav-curs-bnr {
  font-size: 12px;
  font-weight: 700;
  color: rgba(255,255,255,.85);
  background: rgba(255,255,255,.08);
  border: 1px solid rgba(255,255,255,.14);
  border-radius: 8px;
  padding: 6px 11px;
  white-space: nowrap;
  margin-left: 4px;
}

/* ==================== LAYOUT ==================== */
main { max-width: 1360px; margin: 0 auto; padding: 30px 20px 60px; }
h1 { font-size: 24px; font-weight: 800; color: var(--primary); margin-bottom: 22px; letter-spacing: -.3px; }
h2 { font-size: 16px; font-weight: 700; color: var(--primary); margin-bottom: 16px; }

/* ==================== CARDS ==================== */
.card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
  padding: 24px;
  margin-bottom: 22px;
}

/* ==================== STATS ==================== */
.stats {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(190px, 1fr));
  gap: 16px;
  margin-bottom: 26px;
}
.stat {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px 22px;
  box-shadow: var(--shadow-sm);
  position: relative;
  overflow: hidden;
}
.stat::before {
  content: '';
  position: absolute;
  left: 0; top: 0; bottom: 0;
  width: 4px;
  background: var(--primary);
  border-radius: 4px 0 0 4px;
}
.stat.success::before { background: var(--success); }
.stat.danger::before  { background: var(--danger); }
.stat.accent::before  { background: var(--accent); }
.stat.muted::before   { background: #94a3b8; }
.stat.purple::before  { background: #8b5cf6; }
.stat label {
  font-size: 11px;
  font-weight: 700;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: .8px;
}
.stat value {
  display: block;
  font-size: 26px;
  font-weight: 800;
  margin-top: 6px;
  color: var(--primary);
  letter-spacing: -.5px;
  font-variant-numeric: tabular-nums;
}
.stat.success value { color: var(--success); }
.stat.danger value  { color: var(--danger); }
.stat.accent value  { color: #b97b12; }
.stat.muted value   { color: #64748b; }
.stat.purple value  { color: #8b5cf6; }

/* ==================== TABEL ==================== */
.table-wrap { overflow-x: auto; margin: 0 -24px; padding: 0 24px; }
table { width: 100%; border-collapse: collapse; font-size: 13.5px; }
th {
  background: transparent;
  color: var(--muted);
  padding: 10px 12px;
  text-align: left;
  font-weight: 700;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: .7px;
  white-space: nowrap;
  border-bottom: 2px solid var(--border);
}
td {
  padding: 11px 12px;
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
  font-variant-numeric: tabular-nums;
}
tbody tr:last-child td { border-bottom: none; }
tbody tr { transition: background .12s; }
tbody tr:hover td { background: #f7f9fc; }
.cod { font-weight: 800; color: var(--primary); }

/* ==================== BADGES ==================== */
.badge {
  display: inline-block;
  padding: 3px 11px;
  border-radius: 20px;
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .4px;
  white-space: nowrap;
}
.badge-achitata  { background: var(--success-soft); color: var(--success); }
.badge-emisa     { background: var(--accent-soft);  color: #a86e0d; }
.badge-restanta  { background: var(--danger-soft);  color: var(--danger); }
.badge-anulata   { background: #e5e7eb; color: #6b7280; text-decoration: line-through; }
.badge-neemisa   { background: #eceff3; color: #5b6672; }
.badge-forfetare { background: var(--info-soft);    color: var(--info); }
.badge-per_consum{ background: var(--accent-soft);  color: #9a650b; }

/* ==================== BUTTONS ==================== */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 9px 18px;
  border-radius: 9px;
  border: none;
  cursor: pointer;
  font-size: 13.5px;
  font-weight: 700;
  font-family: inherit;
  transition: transform .12s, box-shadow .12s, opacity .15s;
  text-decoration: none;
  line-height: 1.2;
}
.btn:hover { transform: translateY(-1px); box-shadow: 0 4px 12px rgba(22,40,60,.16); }
.btn:active { transform: translateY(0); box-shadow: none; }
.btn-primary { background: var(--primary); color: #fff; }
.btn-accent  { background: linear-gradient(135deg, #f0a428, #e08e10); color: #fff; }
.btn-success { background: var(--success); color: #fff; }
.btn-danger  { background: var(--danger);  color: #fff; }
.btn-outline {
  background: #fff;
  border: 1.5px solid var(--border);
  color: var(--primary);
}
.btn-outline:hover { border-color: var(--primary); }
.btn-sm { padding: 5px 12px; font-size: 12px; border-radius: 7px; }

/* ==================== FORMS ==================== */
.form-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(210px, 1fr));
  gap: 16px;
}
.form-group { display: flex; flex-direction: column; gap: 6px; }
label {
  font-size: 11.5px;
  font-weight: 700;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: .6px;
}
input, select, textarea {
  padding: 10px 13px;
  border: 1.5px solid var(--border);
  border-radius: 9px;
  font-size: 14px;
  font-family: inherit;
  background: #fff;
  color: var(--text);
  transition: border-color .15s, box-shadow .15s;
  width: 100%;
}
input:focus, select:focus, textarea:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(240,164,40,.18);
}

/* ==================== LUNA NAV ==================== */
.luna-nav {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 12px;
  margin-bottom: 22px;
}
.luna-nav select { width: auto; font-weight: 600; }

/* ==================== ALERT ==================== */
.alert {
  padding: 13px 17px;
  border-radius: 10px;
  margin-bottom: 16px;
  font-size: 14px;
  font-weight: 500;
}
.alert-info    { background: var(--info-soft);    color: var(--info); }
.alert-success { background: var(--success-soft); color: var(--success); }
.alert-danger  { background: var(--danger-soft);  color: var(--danger); }

/* ==================== MODAL ==================== */
.modal-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(16, 28, 42, .55);
  backdrop-filter: blur(3px);
  z-index: 200;
  align-items: center;
  justify-content: center;
  padding: 16px;
}
.modal-overlay.open { display: flex; animation: fadeIn .18s ease; }
.modal {
  background: #fff;
  border-radius: 18px;
  padding: 30px;
  max-width: 500px;
  width: 100%;
  box-shadow: 0 20px 60px rgba(16,28,42,.3);
  animation: slideUp .22s ease;
  max-height: 90vh;
  overflow-y: auto;
}
#dash-tabel .col-util-detaliu { display: none; }
#dash-tabel.arata-detalii .col-util-detaliu { display: table-cell; }
.modal-header { display: flex; align-items: flex-start; justify-content: space-between; margin-bottom: 20px; gap: 12px; }
.modal-header h2 { margin: 0; font-size: 18px; line-height: 1.3; }
.modal-close-x {
  flex-shrink: 0;
  background: none; border: none; cursor: pointer;
  font-size: 18px; line-height: 1; color: var(--muted);
  padding: 2px 6px; border-radius: 6px;
  transition: background .15s, color .15s;
}
.modal-close-x:hover { background: #f0f0f0; color: var(--text); }
.modal-footer { margin-top: 24px; display: flex; gap: 10px; justify-content: flex-end; }
.modal.modal-wide { max-width: 1100px; }

/* ==================== PREVIEW FACTURARE ==================== */
.pv-tabel { width: 100%; border-collapse: collapse; font-size: 12.5px; }
.pv-tabel th {
  position: sticky; top: 0; background: #f7f9fc; z-index: 1;
  padding: 8px 6px; text-align: left; font-size: 10.5px;
  text-transform: uppercase; letter-spacing: .4px; color: var(--muted);
  border-bottom: 2px solid var(--border);
}
.pv-tabel td { padding: 6px; border-bottom: 1px solid var(--border); vertical-align: middle; }
.pv-tabel .pv-field {
  width: 68px; padding: 5px 6px; font-size: 12px; border-radius: 6px;
  border: 1.5px solid var(--border); text-align: right;
}
.pv-tabel .pv-field:focus { border-color: var(--accent); outline: none; }
.pv-tabel tr:has(.pv-include:not(:checked)) { opacity: .4; }
.pv-tabel tr:has(.pv-include:not(:checked)) .pv-field { text-decoration: line-through; }

@keyframes fadeIn  { from { opacity: 0; } to { opacity: 1; } }
@keyframes slideUp { from { opacity: 0; transform: translateY(14px); } to { opacity: 1; transform: none; } }

/* ==================== TABEL COMPACT DASHBOARD ==================== */
#dash-tabel { font-size: 12.5px; }
#dash-tabel th { padding: 8px 7px; font-size: 10px; letter-spacing: .4px; }
#dash-tabel td { padding: 8px 7px; }
#dash-tabel .badge { padding: 2px 8px; font-size: 10px; }
#dash-tabel .btn-sm { padding: 4px 9px; font-size: 11.5px; }

/* ==================== SECTION LABEL ==================== */
.section-label {
  font-size: 11px;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 1px;
  color: var(--muted);
  border-bottom: 1px solid var(--border);
  padding-bottom: 6px;
  margin-bottom: 12px;
  margin-top: 4px;
}

/* ==================== CALENDAR BLOCARI (stil booking) ==================== */
.calg { min-width: 940px; }
.calg-row {
  display: flex;
  align-items: stretch;
  border-bottom: 1px solid var(--border);
}
.calg-row:last-child { border-bottom: none; }
.calg-head { border-bottom: 2px solid var(--border); }
.calg-label {
  flex: 0 0 64px;
  padding: 6px 8px;
  font-size: 12px;
  display: flex;
  align-items: center;
  background: #f7f9fc;
  border-right: 1px solid var(--border);
  position: sticky;
  left: 0;
  z-index: 2;
}
.calg-head .calg-label {
  font-size: 10px;
  font-weight: 700;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: .5px;
}
.calg-head .calg-track { min-height: 44px; }
.calg-track {
  flex: 1;
  display: flex;
  position: relative;
  min-height: 30px;
}
.calg-day {
  flex: 1;
  border-right: 1px solid #eef1f6;
  font-size: 10px;
  color: var(--muted);
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
}
.calg-day:last-child { border-right: none; }
.calg-azi { background: var(--accent-soft); box-shadow: inset 0 0 0 1px rgba(240,164,40,.4); }
.calg-day-head {
  flex-direction: column;
  gap: 1px;
  padding: 5px 2px;
  line-height: 1.15;
}
.calg-day-nr { font-size: 12px; font-weight: 800; color: var(--primary); }
.calg-day-luna { font-size: 8.5px; font-weight: 700; text-transform: uppercase; color: var(--muted); letter-spacing: .3px; }
.calg-day-sapt { font-size: 8.5px; font-weight: 600; color: var(--muted); }
.calg-day-head.calg-azi .calg-day-nr,
.calg-day-head.calg-azi .calg-day-luna,
.calg-day-head.calg-azi .calg-day-sapt { color: #a86e0d; }
.calg-bar {
  position: absolute;
  top: 3px;
  bottom: 3px;
  background: linear-gradient(135deg, #7c5cd6, #6947c5);
  border-radius: 12px;
  color: #fff;
  font-size: 10.5px;
  font-weight: 700;
  display: flex;
  align-items: center;
  padding: 0 8px;
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
  cursor: grab;
  box-shadow: 0 1px 4px rgba(105, 71, 197, .35);
  transition: filter .15s, transform .1s;
  z-index: 1;
}
.calg-bar:hover { filter: brightness(1.15); transform: translateY(-1px); }
.calg-bar:active { cursor: grabbing; }
.calg-track-over { background: var(--success-soft); box-shadow: inset 0 0 0 2px var(--success); border-radius: 4px; }
.calg-bar.cont-st { border-top-left-radius: 0; border-bottom-left-radius: 0; }
.calg-bar.cont-dr { border-top-right-radius: 0; border-bottom-right-radius: 0; }

/* ==================== AUTENTIFICARE ==================== */
#auth-screen {
  min-height: 100vh;
  align-items: center;
  justify-content: center;
  background: var(--bg, #f4f6f8);
  padding: 20px;
}
.auth-box {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
  padding: 32px 28px;
  width: 100%;
  max-width: 360px;
}
.auth-logo { font-size: 18px; font-weight: 800; color: var(--primary); margin-bottom: 18px; }
.auth-box .form-group { margin-bottom: 14px; }
.auth-link { display: block; text-align: center; margin-top: 16px; color: var(--primary); font-size: 13px; font-weight: 600; }

/* ==================== RESPONSIVE ==================== */
@media (max-width: 720px) {
  nav { gap: 2px; padding: 0 12px; height: 56px; overflow-x: auto; }
  nav .logo { font-size: 15px; }
  nav a { padding: 6px 10px; font-size: 12.5px; white-space: nowrap; }
  main { padding: 20px 12px 50px; }
  h1 { font-size: 20px; }
  .card { padding: 18px; border-radius: 12px; }
  .table-wrap { margin: 0 -18px; padding: 0 18px; }
  .stat value { font-size: 22px; }
}
