:root{
  --bg-color:#f4f4f4;
  --text-color:#333;
  --header-bg:#0077cc;
  --header-text:#fff;
  --row-hover:#f1f1f1;
  --accent:#0077cc;
  --card:#ffffff;
  --muted:#6b7280;
  --table-border:#ddd;
  --active-col:#005a9e;
  --footer-bg:#f8fafc;
  --footer-accent:#e5eff8;
  --shadow: 0 10px 30px rgba(0,0,0,.08);
}

body.dark{
  --bg-color:#1e1e1e;
  --text-color:#ddd;
  --header-bg:#333;
  --header-text:#0077cc;
  --row-hover:#2c2c2c;
  --accent:#0077cc;
  --card:#2b2b2b;
  --muted:#9ca3af;
  --table-border:#444;
  --active-col:#3ea0ff;
  --footer-bg:#151718;
  --footer-accent:#0f1720;
}

/* Layout */
html,body{height:100%}
body{
  background-color:var(--bg-color);
  color:var(--text-color);
  font-family:'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
  margin:0;
}

/* Header fix */
.site-header{
  position:sticky; top:0; z-index:10;
  background:linear-gradient(180deg,var(--card),rgba(0,0,0,0));
  backdrop-filter:saturate(120%) blur(6px);
  border-bottom:1px solid var(--table-border);
}
.site-header .wrap{
  display:flex; align-items:center; justify-content:space-between; gap:1rem;
  max-width:1100px; margin:0 auto; padding:10px 16px;
}
.site-title{ font-size:1.25rem; color:var(--accent); margin:0; }
.theme-toggle{
  padding:8px 12px; font-size:1rem; cursor:pointer;
  background-color:var(--accent); color:#fff; border:0; border-radius:8px;
}
.theme-toggle:hover{opacity:.9}

/* Main */
.site-main{ max-width:1100px; margin:0 auto; padding:16px; }

/* Controls */
.controls{
  display:flex; flex-wrap:wrap; align-items:center; justify-content:space-between;
  gap:12px; margin:8px 0 12px;
}
.search-group{ display:flex; align-items:center; gap:8px; }
.search-group input[type="text"], .search-group select{
  padding:8px 12px; border:1px solid #ccc; border-radius:8px;
  background:var(--card); color:inherit;
}
.search-group input[type="text"]:focus, .search-group select:focus{
  outline:none; border-color:var(--accent);
}
.export-group button{
  padding:8px 12px; border:0; border-radius:8px; background:var(--accent); color:#fff; cursor:pointer;
}
.export-group .secondary{ background:#475569; }
.export-group .ghost{ background:transparent; color:inherit; border:1px solid var(--table-border); }
.export-group button:hover{opacity:.9}

/* Table */
.table-container{ overflow-x:auto }
table{
  width:100%; border-collapse:collapse; background:var(--card); box-shadow:var(--shadow);
}
th,td{ padding:10px; text-align:left; border-bottom:1px solid var(--table-border); }
thead th{
  background-color:var(--header-bg); color:var(--header-text);
  cursor:pointer; position:sticky; top:58px; z-index:5; user-select:none;
}
tbody tr:hover{ background-color:var(--row-hover); transition:background .2s; }

/* Alternate rows */
tbody tr:nth-child(even){ background-color:rgba(0,0,0,.03) }
body.dark tbody tr:nth-child(even){ background-color:rgba(255,255,255,.05) }

/* Sort indicator */
.sort-indicator{ color:var(--header-text); font-weight:bold; font-size:1.1em; vertical-align:middle; margin-left:4px; }
th.active{ background-color:var(--active-col); }

/* No results */
.no-results td{ text-align:center; color:var(--muted); padding:14px; }

/* Footer (stilizat) */
.site-footer{ margin-top:24px; background:linear-gradient(180deg, var(--footer-accent), var(--footer-bg)); border-top:1px solid var(--table-border); }
.site-footer .wrap{ max-width:1100px; margin:0 auto; padding:18px 16px 24px; color:var(--muted); }
.footer-grid{ display:grid; grid-template-columns: 1fr auto auto; gap:12px 24px; align-items:center; }
.footer-brand{ font-weight:700; letter-spacing:.2px; color:var(--accent); margin-bottom:4px; }
.footer-links{ display:flex; gap:12px; }
.footer-links a{ text-decoration:none; color:inherit; padding:6px 10px; border-radius:8px; background:transparent; border:1px solid transparent; }
.footer-links a:hover{ border-color:var(--table-border); background:var(--card); }
.footer-license{ justify-self:end; }
@media (max-width: 720px){
  .footer-grid{ grid-template-columns: 1fr; text-align:center; }
  .footer-license{ justify-self:center }
}

/* Modal */
.modal[hidden]{ display:none; }
.modal{
  position:fixed; inset:0; display:grid; place-items:center; background:rgba(0,0,0,.4);
  padding:16px;
}
.modal-card{
  width:min(720px, 100%); background:var(--card); color:inherit; border-radius:14px;
  box-shadow:var(--shadow); overflow:hidden; border:1px solid var(--table-border);
}
.modal-header{
  display:flex; align-items:center; justify-content:space-between; padding:12px 16px;
  background:linear-gradient(180deg,var(--footer-accent),transparent);
  border-bottom:1px solid var(--table-border);
}
.modal-header h2{ margin:0; font-size:1.1rem; color:var(--accent); }
.modal-close{
  background:transparent; border:0; font-size:1.1rem; cursor:pointer; color:inherit;
}
.modal-body{ display:grid; gap:8px; padding:16px; }
.modal-body label{ font-size:.95rem; }
.modal-body input, .modal-body textarea{
  padding:10px 12px; border:1px solid #ccc; border-radius:10px; background:var(--card); color:inherit;
}
.modal-body input:focus, .modal-body textarea:focus{ outline:none; border-color:var(--accent); }
.modal-actions{ display:flex; flex-wrap:wrap; gap:8px; margin-top:8px; }
.modal-actions button{
  padding:8px 12px; border:0; border-radius:10px; cursor:pointer; background:var(--accent); color:#fff;
}
.modal-actions .secondary{ background:#475569; }
.modal-actions .ghost{ background:transparent; color:inherit; border:1px solid var(--table-border); }
.modal-note{ margin:0; font-size:.85rem; color:var(--muted); }

/* Honeypot anti-spam */
.hp{ position:absolute; left:-9999px; top:auto; width:1px; height:1px; overflow:hidden; }

/* Utilities */
.sr-only{
  position:absolute!important; width:1px; height:1px; padding:0; margin:-1px;
  overflow:hidden; clip:rect(0,0,0,0); white-space:nowrap; border:0;
}

/* Responsive */
@media (max-width: 600px){
  .site-title{ font-size:1rem }
  thead th{ top:54px }
}

/* ===== Brand / Logo (layout compact, HQ style) ===== */
.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  text-align: left;
}

.site-logo {
  width: 42px;
  height: auto;
  display: block;
  border-radius: 50%;
  box-shadow: 0 2px 8px rgba(0,0,0,0.15);
}

.site-title {
  font-size: 1.25rem;
  color: var(--accent);
  margin: 0;
  font-weight: 600;
  line-height: 1.2;
}

@media (max-width: 720px) {
  .site-logo { width: 34px; }
  .site-title { font-size: 1.05rem; }
}

/* === Fix spațiu alb între titlu și tabel, păstrând textul === */
caption {
  margin: 0;
  padding: 6px 0;
  background: var(--header-bg);
  color: var(--header-text);
  font-weight: 500;
  text-align: center;
  border-top-left-radius: 8px;
  border-top-right-radius: 8px;
}

.table-container {
  margin-top: 0;
}

thead th {
  top: 0;
}

/* ===== Layout mobil (max 720px) ===== */
@media (max-width: 720px) {
  /* header mai compact */
  .site-header .wrap {
    flex-direction: column;
    align-items: flex-start;
    gap: 10px;
    padding: 10px 12px;
  }

  .brand {
    flex-direction: row;
    align-items: center;
    gap: 8px;
  }

  .site-logo {
    width: 34px;
    height: auto;
  }

  .site-title {
    font-size: 1.05rem;
    line-height: 1.3;
  }

  .theme-toggle {
    align-self: flex-end;
    font-size: 0.9rem;
    padding: 6px 10px;
  }

  /* controale (search + select + buton) — stivuite vertical */
  .controls {
    flex-direction: column;
    align-items: stretch;
    gap: 10px;
  }

  .search-group {
    flex-direction: column;
    align-items: stretch;
    width: 100%;
  }

  .search-group input,
  .search-group select,
  .export-group button,
  .export-group a {
    width: 100%;
    font-size: 0.95rem;
  }

  /* tabel responsiv */
  .table-container {
    overflow-x: auto;
    margin-top: 0;
    border-radius: 10px;
  }

  table {
    min-width: 600px; /* permite derulare orizontală */
    font-size: 0.9rem;
  }

  thead th {
    position: sticky;
    top: 0;
    z-index: 5;
  }

  /* footer centrat */
  .footer-grid {
    grid-template-columns: 1fr;
    text-align: center;
    gap: 12px;
  }

  .footer-links {
    justify-content: center;
    flex-wrap: wrap;
  }
}

/* ===== Fix suprapunere modal / tabel pe mobil ===== */
@media (max-width: 720px) {
  .modal {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.75);
    overflow-y: auto;
    padding: 12px;
    z-index: 9999; /* forțăm să fie peste sticky headers */
  }

  .modal-card {
    width: 100%;
    max-width: 480px;
    margin: 60px auto;
    border-radius: 14px;
    box-shadow: 0 8px 20px rgba(0,0,0,0.25);
  }

  .modal-body {
    padding: 16px;
  }

  .modal-header {
    position: sticky;
    top: 0;
    background: var(--card);
    z-index: 10000; /* mai sus decât antetul tabelului */
    border-bottom: 1px solid var(--table-border);
  }

  .modal-actions {
    display: flex;
    flex-direction: column;
    align-items: stretch;
  }

  .modal-actions button {
    width: 100%;
  }

  .modal-note {
    text-align: center;
  }
}

/* ===== General fix pentru toate modalele ===== */
.modal {
  z-index: 9999;
}

.modal-card {
  position: relative;
  z-index: 10000;
}
