/* ============================================================
   מערכת ארבעת היסודות — עיצוב משותף (RTL)
   ============================================================ */
:root {
  --fire: #E4572E;
  --water: #2A7DE1;
  --air: #7C6BD6;
  --earth: #6A8E3F;

  --bg: #f4f6fb;
  --panel: #ffffff;
  --ink: #1e2233;
  --muted: #6b7280;
  --line: #e6e9f2;
  --accent: #4f46e5;
  --accent-soft: #eef0ff;
  --radius: 14px;
  --shadow: 0 6px 24px rgba(30, 34, 51, 0.08);
  --shadow-sm: 0 2px 8px rgba(30, 34, 51, 0.06);
  font-family: system-ui, -apple-system, "Segoe UI", "Helvetica Neue", Arial, "Noto Sans Hebrew", sans-serif;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--ink);
  direction: rtl;
}

body { min-height: 100vh; line-height: 1.55; }

a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }

h1, h2, h3 { margin: 0 0 .4em; font-weight: 700; }
h1 { font-size: 1.5rem; }
h2 { font-size: 1.2rem; }
p { margin: 0 0 .6em; }
small { color: var(--muted); }

/* ---------- כותרת עליונה ---------- */
.topbar {
  background: linear-gradient(120deg, #1f2540, #2b3566);
  color: #fff;
  padding: 14px 22px;
  display: flex;
  align-items: center;
  gap: 16px;
  box-shadow: var(--shadow-sm);
}
.topbar .brand { font-weight: 800; font-size: 1.15rem; display: flex; align-items: center; gap: 10px; }
.topbar .brand .dots { letter-spacing: 2px; }
.topbar nav { margin-inline-start: auto; display: flex; gap: 8px; }
.topbar nav a {
  color: #dfe3ff; padding: 7px 14px; border-radius: 999px; font-size: .9rem;
}
.topbar nav a:hover, .topbar nav a.active { background: rgba(255,255,255,.16); color: #fff; text-decoration: none; }

/* ---------- פריסה ---------- */
.wrap { max-width: 1100px; margin: 0 auto; padding: 22px; }
.card {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
  padding: 20px;
  margin-bottom: 18px;
}
.grid { display: grid; gap: 16px; }
.grid.cols-2 { grid-template-columns: repeat(2, 1fr); }
.grid.cols-3 { grid-template-columns: repeat(3, 1fr); }
.grid.cols-4 { grid-template-columns: repeat(4, 1fr); }
@media (max-width: 760px) {
  .grid.cols-2, .grid.cols-3, .grid.cols-4 { grid-template-columns: 1fr; }
}
.row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.spacer { flex: 1; }

/* ---------- כפתורים ---------- */
button, .btn {
  font-family: inherit; font-size: .92rem; cursor: pointer;
  border: 1px solid var(--line); background: #fff; color: var(--ink);
  padding: 9px 16px; border-radius: 10px; transition: .15s; font-weight: 600;
}
button:hover, .btn:hover { border-color: #c9cee0; }
button.primary, .btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
button.primary:hover { background: #4338ca; }
button.ghost { background: transparent; }
button.danger { color: #b91c1c; border-color: #f3c9c9; }
button.danger:hover { background: #fdecec; }
button.small { padding: 5px 10px; font-size: .82rem; }
button:disabled { opacity: .5; cursor: not-allowed; }

/* ---------- טפסים ---------- */
label { font-size: .85rem; color: var(--muted); font-weight: 600; display: block; margin-bottom: 4px; }
input, select, textarea {
  font-family: inherit; font-size: .92rem; width: 100%;
  padding: 9px 11px; border: 1px solid var(--line); border-radius: 10px; background: #fff; color: var(--ink);
}
input:focus, select:focus, textarea:focus { outline: 2px solid var(--accent-soft); border-color: var(--accent); }
textarea { resize: vertical; min-height: 120px; font-family: ui-monospace, "SF Mono", Menlo, Consolas, monospace; font-size: .85rem; }
.field { margin-bottom: 12px; }

/* ---------- צ'יפים ליסודות ---------- */
.el-chip {
  display: inline-flex; align-items: center; gap: 6px; font-weight: 700; font-size: .85rem;
  padding: 3px 10px; border-radius: 999px; color: #fff;
}
.el-fire { background: var(--fire); }
.el-water { background: var(--water); }
.el-air { background: var(--air); }
.el-earth { background: var(--earth); }
.el-text-fire { color: var(--fire); }
.el-text-water { color: var(--water); }
.el-text-air { color: var(--air); }
.el-text-earth { color: var(--earth); }

/* ---------- מד אחוזים ---------- */
.meter { margin-bottom: 10px; }
.meter .meter-head { display: flex; justify-content: space-between; font-size: .85rem; margin-bottom: 4px; }
.meter .bar { height: 12px; background: #eef0f6; border-radius: 999px; overflow: hidden; }
.meter .bar > span { display: block; height: 100%; border-radius: 999px; transition: width .5s ease; }

/* ---------- מד אחוזים מיני (בטבלת סוגי אישיות) ---------- */
.mini-profile { display: flex; height: 8px; border-radius: 999px; overflow: hidden; width: 120px; }
.mini-profile > span { display: block; height: 100%; }

/* ---------- טבלאות ---------- */
table { width: 100%; border-collapse: collapse; font-size: .9rem; }
th, td { text-align: right; padding: 10px 8px; border-bottom: 1px solid var(--line); }
th { color: var(--muted); font-weight: 700; font-size: .8rem; }
tr:hover td { background: #fafbff; }

/* ---------- טאבים ---------- */
.tabs { display: flex; gap: 6px; flex-wrap: wrap; margin-bottom: 18px; border-bottom: 2px solid var(--line); }
.tabs button {
  border: none; background: none; padding: 10px 16px; border-radius: 0;
  color: var(--muted); font-weight: 700; border-bottom: 3px solid transparent; margin-bottom: -2px;
}
.tabs button.active { color: var(--accent); border-bottom-color: var(--accent); }
.tab-panel { display: none; }
.tab-panel.active { display: block; }

/* ---------- תגיות סטטיסטיקה ---------- */
.stat { text-align: center; padding: 16px; }
.stat .num { font-size: 2rem; font-weight: 800; color: var(--accent); }
.stat .lbl { color: var(--muted); font-size: .85rem; }

/* ---------- מודאל ---------- */
.modal-back {
  position: fixed; inset: 0; background: rgba(15,18,30,.45);
  display: none; align-items: flex-start; justify-content: center; padding: 40px 16px; z-index: 50; overflow: auto;
}
.modal-back.open { display: flex; }
.modal {
  background: #fff; border-radius: var(--radius); box-shadow: var(--shadow);
  width: 100%; max-width: 640px; padding: 22px;
}
.modal h2 { margin-bottom: 16px; }

/* ---------- הודעות ---------- */
.toast {
  position: fixed; bottom: 22px; left: 50%; transform: translateX(-50%);
  background: #1f2540; color: #fff; padding: 12px 20px; border-radius: 12px;
  box-shadow: var(--shadow); z-index: 100; opacity: 0; transition: .3s; pointer-events: none;
}
.toast.show { opacity: 1; }
.toast.error { background: #b91c1c; }

.badge { background: var(--accent-soft); color: var(--accent); padding: 2px 9px; border-radius: 999px; font-size: .78rem; font-weight: 700; }
.muted-box { background: #f8f9fc; border: 1px dashed var(--line); border-radius: 10px; padding: 12px; color: var(--muted); font-size: .85rem; }
.empty { text-align: center; color: var(--muted); padding: 30px; }
