:root {
  --bg: #0f1115;
  --surface: #181b22;
  --surface-2: #20242e;
  --border: #2b303b;
  --text: #e8eaf0;
  --muted: #9aa3b2;
  --primary: #6c5ce7;
  --primary-2: #8b7bf0;
  --green: #00b894;
  --red: #e74c5e;
  --amber: #f0a020;
  --radius: 14px;
  --shadow: 0 6px 24px rgba(0,0,0,.35);
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font-family: "Segoe UI", "Assistant", "Heebo", system-ui, Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
  -webkit-font-smoothing: antialiased;
}

/* ---------- Topbar / tabs ---------- */
.topbar {
  position: sticky; top: 0; z-index: 50;
  background: linear-gradient(180deg, #1b1f29, #14171e);
  border-bottom: 1px solid var(--border);
  padding: 10px 18px;
  display: flex; align-items: center; gap: 20px; flex-wrap: wrap;
}
.brand { display: flex; align-items: center; gap: 12px; }
.brand .logo { font-size: 30px; }
.brand h1 { margin: 0; font-size: 20px; letter-spacing: .5px; }
.brand small { color: var(--muted); }
.tabs { display: flex; gap: 6px; flex-wrap: wrap; margin-inline-start: auto; }
.tabs button {
  background: transparent; color: var(--muted); border: 1px solid transparent;
  padding: 9px 15px; border-radius: 10px; cursor: pointer; font-size: 15px;
  font-family: inherit; transition: .15s;
}
.tabs button:hover { color: var(--text); background: var(--surface-2); }
.tabs button.active { color: #fff; background: var(--primary); box-shadow: 0 4px 14px rgba(108,92,231,.4); }

main { max-width: 1100px; margin: 0 auto; padding: 22px 16px 80px; }

/* ---------- Cards / grid ---------- */
.grid { display: grid; gap: 16px; }
.cols-4 { grid-template-columns: repeat(4, 1fr); }
.cols-3 { grid-template-columns: repeat(3, 1fr); }
.cols-2 { grid-template-columns: repeat(2, 1fr); }
@media (max-width: 820px) { .cols-4 { grid-template-columns: repeat(2,1fr);} .cols-3,.cols-2 { grid-template-columns: 1fr; } }

.card {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 18px;
}
.card h2 { margin: 0 0 14px; font-size: 17px; }
.section-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 16px; gap: 12px; flex-wrap: wrap; }
.section-head h2 { margin: 0; font-size: 22px; }

.stat { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 16px 18px; }
.stat .label { color: var(--muted); font-size: 13px; }
.stat .value { font-size: 26px; font-weight: 700; margin-top: 6px; }
.stat .value.green { color: var(--green); }
.stat .value.red { color: var(--red); }
.stat .value.amber { color: var(--amber); }
.stat small { color: var(--muted); font-size: 12px; }

/* ---------- Buttons ---------- */
.btn {
  background: var(--primary); color: #fff; border: none; border-radius: 10px;
  padding: 10px 16px; font-size: 15px; cursor: pointer; font-family: inherit; transition: .15s;
}
.btn:hover { background: var(--primary-2); }
.btn.ghost { background: var(--surface-2); color: var(--text); border: 1px solid var(--border); }
.btn.ghost:hover { background: var(--border); }
.btn.green { background: var(--green); }
.btn.red { background: var(--red); }
.btn.sm { padding: 6px 11px; font-size: 13px; border-radius: 8px; }
.btn.block { width: 100%; }
.btn:disabled { opacity: .5; cursor: not-allowed; }

/* ---------- Tables ---------- */
table { width: 100%; border-collapse: collapse; }
th, td { text-align: right; padding: 11px 10px; border-bottom: 1px solid var(--border); font-size: 14px; }
th { color: var(--muted); font-weight: 600; font-size: 13px; }
tr:hover td { background: var(--surface-2); }
.table-wrap { overflow-x: auto; }

/* ---------- Badges / chips ---------- */
.badge { display: inline-block; padding: 3px 9px; border-radius: 999px; font-size: 12px; font-weight: 600; }
.badge.green { background: rgba(0,184,148,.18); color: #2ee6b6; }
.badge.red { background: rgba(231,76,94,.18); color: #ff8a96; }
.badge.amber { background: rgba(240,160,32,.18); color: #ffc868; }
.badge.muted { background: var(--surface-2); color: var(--muted); }
.chip { display: inline-block; padding: 2px 9px; border-radius: 999px; font-size: 12px; background: var(--surface-2); margin: 0 0 0 4px; }
.dot { display:inline-block; width:10px; height:10px; border-radius:50%; margin-inline-start:6px; vertical-align: middle; }

/* ---------- Forms ---------- */
.field { margin-bottom: 14px; }
.field label { display: block; font-size: 13px; color: var(--muted); margin-bottom: 6px; }
input, select, textarea {
  width: 100%; background: var(--surface-2); border: 1px solid var(--border);
  color: var(--text); border-radius: 10px; padding: 10px 12px; font-size: 15px; font-family: inherit;
}
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--primary); }
.row { display: flex; gap: 12px; flex-wrap: wrap; }
.row > .field { flex: 1; min-width: 140px; }

/* ---------- Modal ---------- */
.modal-bg {
  position: fixed; inset: 0; background: rgba(0,0,0,.6); display: flex;
  align-items: flex-start; justify-content: center; padding: 40px 16px; z-index: 100; overflow-y: auto;
}
.modal {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  width: 100%; max-width: 520px; box-shadow: var(--shadow); padding: 22px;
}
.modal.wide { max-width: 760px; }
.modal h3 { margin: 0 0 18px; font-size: 19px; }
.modal-actions { display: flex; gap: 10px; justify-content: flex-start; margin-top: 18px; }

/* ---------- Attendance ---------- */
.att-row { display: flex; align-items: center; gap: 10px; padding: 10px; border-bottom: 1px solid var(--border); }
.att-row .name { flex: 1; font-size: 15px; }
.seg { display: inline-flex; border: 1px solid var(--border); border-radius: 10px; overflow: hidden; }
.seg button { background: var(--surface-2); border: none; color: var(--muted); padding: 8px 12px; cursor: pointer; font-family: inherit; font-size: 13px; }
.seg button.on-present { background: var(--green); color: #fff; }
.seg button.on-absent { background: var(--red); color: #fff; }
.seg button.on-late { background: var(--amber); color: #111; }

.list-item { display: flex; align-items: center; gap: 12px; padding: 14px; border: 1px solid var(--border); border-radius: 12px; background: var(--surface); margin-bottom: 10px; }
.list-item .grow { flex: 1; }
.list-item .title { font-size: 16px; font-weight: 600; }
.list-item .sub { color: var(--muted); font-size: 13px; margin-top: 3px; }

.empty { text-align: center; color: var(--muted); padding: 40px 20px; }
.muted { color: var(--muted); }
.right { text-align: left; } /* בכיוון RTL = שמאל */
.nowrap { white-space: nowrap; }
.progress { height: 7px; background: var(--surface-2); border-radius: 999px; overflow: hidden; margin-top: 8px; }
.progress > div { height: 100%; background: var(--primary); }

#toast { position: fixed; bottom: 22px; left: 50%; transform: translateX(-50%); z-index: 200; display: flex; flex-direction: column; gap: 8px; }
.toast-msg { background: #2a2f3a; color: #fff; padding: 12px 18px; border-radius: 10px; box-shadow: var(--shadow); border: 1px solid var(--border); animation: pop .2s; }
.toast-msg.err { border-color: var(--red); }
.toast-msg.ok { border-color: var(--green); }
@keyframes pop { from { opacity: 0; transform: translateY(10px);} }

a.link { color: var(--primary-2); text-decoration: none; }
a.link:hover { text-decoration: underline; }

/* ---------- Mobile: טבלאות הופכות לכרטיסים מוערמים (בלי גלילה צדדית) ---------- */
@media (max-width: 640px) {
  main { padding: 14px 10px 80px; }
  .table-wrap { overflow-x: visible; }
  .table-wrap table, .table-wrap tbody, .table-wrap tr, .table-wrap td { display: block; width: 100%; }
  .table-wrap thead { display: none; }
  .table-wrap tr {
    border: 1px solid var(--border); border-radius: 12px;
    margin-bottom: 10px; padding: 8px 12px; background: var(--surface);
  }
  .table-wrap tr:hover td { background: transparent; }
  .table-wrap td {
    border: none; padding: 5px 0; white-space: normal; text-align: right;
    display: flex; flex-wrap: wrap; justify-content: space-between; align-items: center; gap: 8px;
  }
  .table-wrap td[data-label]::before {
    content: attr(data-label); color: var(--muted); font-size: 12px; font-weight: 600; flex-shrink: 0;
  }
  /* שורת השם בולטת ומפרידה בין כרטיסים */
  .table-wrap td.cell-primary { font-size: 16px; font-weight: 700; border-bottom: 1px solid var(--border); padding-bottom: 8px; margin-bottom: 4px; }
  .topbar { padding: 8px 12px; }
  .tabs button { padding: 7px 11px; font-size: 14px; }
  .section-head h2 { font-size: 19px; }
}
