/* ==========================================================================
   פורטל אחוד · שפת עיצוב
   הפלטה משלבת את שני המותגים:
     OK Teck    → אינדיגו עמוק #1E1060 + סגול #6B33E8
     Hello שלום → טורקיז כהה #0E6E7F + ציאן #17AEC6
   הגרדיאנט הראשי סגול→ציאן הוא החוט שמחבר ביניהם.
   ========================================================================== */

@import url('https://fonts.googleapis.com/css2?family=Heebo:wght@400;500;700;800&family=Rubik:wght@400;500;600;700&display=swap');

:root {
  /* מותג */
  --ok-deep:    #1E1060;
  --ok-purple:  #6B33E8;
  --hs-teal:    #0E6E7F;
  --hs-cyan:    #17AEC6;
  --brand-grad: linear-gradient(135deg, var(--ok-purple) 0%, var(--hs-cyan) 100%);
  --chrome-grad: linear-gradient(180deg, #241456 0%, #16093F 55%, #102E42 100%);

  /* משטחים — בהיר */
  --bg:        #F4F6FB;
  --surface:   #FFFFFF;
  --surface-2: #FAFBFE;
  --border:    #E4E8F2;
  --text:      #1A1830;
  --muted:     #6B7290;
  --faint:     #9AA0B8;

  /* סטטוס — שמור לסטטוס בלבד, אף פעם לא לקישוט */
  --ok:   #16A34A;
  --warn: #E2900B;
  --bad:  #DC2626;

  --r-card: 14px;
  --r-btn:  9px;
  --shadow:    0 1px 2px rgba(20,16,60,.05), 0 6px 20px -8px rgba(20,16,60,.14);
  --shadow-lg: 0 2px 4px rgba(20,16,60,.06), 0 18px 40px -14px rgba(20,16,60,.28);
  --t: 170ms cubic-bezier(.22,.61,.36,1);
}

:root[data-theme="dark"] {
  --bg:        #0E0827;
  --surface:   #180F3D;
  --surface-2: #1E1449;
  --border:    #2C1F63;
  --text:      #EEEAFC;
  --muted:     #A69EDA;
  --faint:     #7B72B0;
  --shadow:    0 1px 2px rgba(0,0,0,.4), 0 6px 20px -8px rgba(0,0,0,.6);
  --shadow-lg: 0 2px 4px rgba(0,0,0,.5), 0 18px 40px -14px rgba(0,0,0,.7);
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  font-family: 'Rubik', 'Heebo', 'Segoe UI', system-ui, sans-serif;
  background: var(--bg);
  color: var(--text);
  direction: rtl;
  -webkit-font-smoothing: antialiased;
}
a { color: inherit; text-decoration: none; }
button, input, select { font-family: inherit; font-size: inherit; color: inherit; }

/* ---------------- פריסה ---------------- */

.shell { display: grid; grid-template-columns: 258px 1fr; min-height: 100vh; }

.sidebar {
  background: var(--chrome-grad);
  color: #EDEAFB;
  padding: 22px 18px;
  display: flex; flex-direction: column; gap: 26px;
  position: sticky; top: 0; height: 100vh;
}
.brand { display: flex; align-items: center; gap: 11px; }
.brand-mark {
  width: 40px; height: 40px; border-radius: 11px;
  background: var(--brand-grad);
  display: grid; place-items: center;
  box-shadow: 0 6px 18px -6px rgba(107,51,232,.7);
  flex-shrink: 0;
}
.brand-text b { display: block; font-family: 'Heebo'; font-weight: 800; font-size: 16px; letter-spacing: -.2px; }
.brand-text span { display: block; font-size: 11.5px; color: #A79FE0; margin-top: 1px; }

.nav { display: flex; flex-direction: column; gap: 3px; }
.nav-label {
  font-size: 10.5px; font-weight: 600; letter-spacing: .09em;
  color: #7E75BC; text-transform: uppercase; margin: 0 8px 7px;
}
.nav a {
  display: flex; align-items: center; gap: 10px;
  padding: 9px 11px; border-radius: 9px;
  font-size: 14px; font-weight: 500; color: #CFC9F0;
  transition: background var(--t), color var(--t), transform var(--t);
}
.nav a:hover { background: rgba(255,255,255,.07); color: #fff; }
.nav a.active { background: rgba(255,255,255,.12); color: #fff; }
.nav a.active::before {
  content: ''; position: absolute; right: 0; width: 3px; height: 22px;
  border-radius: 3px 0 0 3px; background: var(--hs-cyan);
}
.nav a { position: relative; }
.nav .dot { width: 7px; height: 7px; border-radius: 50%; margin-inline-start: auto; }

.side-foot { margin-top: auto; font-size: 11.5px; color: #7E75BC; line-height: 1.7; }
.side-user {
  display: flex; align-items: center; gap: 10px;
  padding: 11px; border-radius: 11px; background: rgba(255,255,255,.06);
  margin-bottom: 12px;
}
.side-user .av {
  width: 34px; height: 34px; border-radius: 9px; background: var(--brand-grad);
  display: grid; place-items: center; font-weight: 700; font-size: 13px; color: #fff; flex-shrink: 0;
}
.side-user b { font-size: 13px; font-weight: 600; color: #fff; display: block; }
.side-user small { font-size: 11px; color: #A79FE0; }

.main { padding: 26px 32px 44px; min-width: 0; }

/* ---------------- כותרת עליונה ---------------- */

.topbar { display: flex; align-items: center; gap: 14px; margin-bottom: 26px; }
.topbar h1 { font-family: 'Heebo'; font-size: 23px; font-weight: 800; margin: 0; letter-spacing: -.3px; }
.topbar .sub { font-size: 13.5px; color: var(--muted); margin-top: 3px; }
.topbar .spacer { flex: 1; }

.search-btn {
  display: flex; align-items: center; gap: 9px;
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--r-btn); padding: 8px 13px; cursor: pointer;
  color: var(--muted); font-size: 13.5px; transition: all var(--t);
}
.search-btn:hover { border-color: var(--ok-purple); color: var(--text); }
.search-btn kbd {
  font-family: inherit; font-size: 11px; padding: 2px 6px; border-radius: 5px;
  background: var(--bg); border: 1px solid var(--border); color: var(--faint);
}
.icon-btn {
  width: 38px; height: 38px; border-radius: var(--r-btn); cursor: pointer;
  background: var(--surface); border: 1px solid var(--border);
  display: grid; place-items: center; transition: all var(--t); color: var(--muted);
}
.icon-btn:hover { border-color: var(--ok-purple); color: var(--ok-purple); }

/* ---------------- כרטיסי מערכות ---------------- */

.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(268px, 1fr)); gap: 16px; }

.card {
  position: relative; overflow: hidden;
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--r-card); padding: 19px;
  box-shadow: var(--shadow);
  display: flex; flex-direction: column; gap: 13px;
  transition: transform var(--t), box-shadow var(--t), border-color var(--t);
  cursor: pointer;
}
.card::after {
  content: ''; position: absolute; inset-block-start: 0; inset-inline: 0; height: 3px;
  background: var(--accent, var(--ok-purple));
  opacity: 0; transition: opacity var(--t);
}
.card:hover { transform: translateY(-2px); box-shadow: var(--shadow-lg); border-color: transparent; }
.card:hover::after { opacity: 1; }
.card:focus-visible { outline: 2px solid var(--ok-purple); outline-offset: 2px; }

.card-head { display: flex; align-items: flex-start; gap: 12px; }
.card-icon {
  width: 42px; height: 42px; border-radius: 11px; flex-shrink: 0;
  display: grid; place-items: center;
  background: color-mix(in srgb, var(--accent) 13%, transparent);
  color: var(--accent);
}
.card h3 { margin: 0; font-family: 'Heebo'; font-size: 15.5px; font-weight: 700; }
.card .desc { font-size: 12.5px; color: var(--muted); margin-top: 3px; line-height: 1.45; }

.card-foot {
  display: flex; align-items: center; gap: 8px;
  padding-top: 12px; border-top: 1px solid var(--border);
  font-size: 12px; color: var(--muted);
}
.status { display: inline-flex; align-items: center; gap: 6px; font-weight: 500; }
.status .pip { width: 7px; height: 7px; border-radius: 50%; background: var(--faint); }
.status.up   .pip { background: var(--ok);  box-shadow: 0 0 0 3px color-mix(in srgb, var(--ok) 20%, transparent); }
.status.down .pip { background: var(--bad); box-shadow: 0 0 0 3px color-mix(in srgb, var(--bad) 20%, transparent); }
.status.up   { color: var(--ok); }
.status.down { color: var(--bad); }

.badge {
  margin-inline-start: auto; font-size: 11px; font-weight: 600;
  padding: 3px 9px; border-radius: 20px;
  background: color-mix(in srgb, var(--accent) 12%, transparent); color: var(--accent);
}

/* ---------------- טבלאות וניהול ---------------- */

.panel {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--r-card); box-shadow: var(--shadow); overflow: hidden;
  margin-bottom: 20px;
}
.panel-head {
  padding: 15px 19px; border-bottom: 1px solid var(--border);
  display: flex; align-items: center; gap: 12px; background: var(--surface-2);
}
.panel-head h2 { margin: 0; font-family: 'Heebo'; font-size: 15px; font-weight: 700; }
.panel-head .spacer { flex: 1; }
.panel-body { padding: 19px; }

table { width: 100%; border-collapse: collapse; font-size: 13.5px; }
th {
  text-align: right; font-weight: 600; font-size: 11.5px; letter-spacing: .04em;
  color: var(--muted); padding: 11px 14px; border-bottom: 1px solid var(--border);
  background: var(--surface-2); white-space: nowrap;
}
td { padding: 11px 14px; border-bottom: 1px solid var(--border); }
tbody tr:last-child td { border-bottom: 0; }
tbody tr { transition: background var(--t); }
tbody tr:hover { background: var(--surface-2); }
.mono { font-family: ui-monospace, 'Cascadia Code', Consolas, monospace; font-size: 12px; direction: ltr; text-align: right; }

.btn {
  display: inline-flex; align-items: center; gap: 7px; cursor: pointer;
  padding: 9px 16px; border-radius: var(--r-btn); border: 1px solid transparent;
  font-size: 13.5px; font-weight: 600; transition: all var(--t);
  background: var(--brand-grad); color: #fff;
  box-shadow: 0 4px 14px -6px rgba(107,51,232,.6);
}
.btn:hover { transform: translateY(-1px); box-shadow: 0 7px 18px -6px rgba(107,51,232,.7); }
.btn.ghost { background: var(--surface); border-color: var(--border); color: var(--text); box-shadow: none; }
.btn.ghost:hover { border-color: var(--ok-purple); color: var(--ok-purple); }
.btn.danger { background: none; border-color: color-mix(in srgb, var(--bad) 40%, transparent); color: var(--bad); box-shadow: none; }
.btn.sm { padding: 6px 11px; font-size: 12.5px; }

.field { display: flex; flex-direction: column; gap: 6px; }
.field label { font-size: 12.5px; font-weight: 600; color: var(--muted); }
input[type=text], input[type=password], input[type=email], select {
  padding: 10px 13px; border-radius: var(--r-btn);
  border: 1px solid var(--border); background: var(--surface);
  transition: border-color var(--t), box-shadow var(--t); width: 100%;
}
input:focus, select:focus {
  outline: none; border-color: var(--ok-purple);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--ok-purple) 15%, transparent);
}
select.lvl { padding: 5px 9px; font-size: 12.5px; border-radius: 7px; }
select.lvl[data-level="none"] { color: var(--faint); }
select.lvl[data-level="full"] { color: var(--ok-purple); font-weight: 600; }

.pill {
  font-size: 11px; font-weight: 600; padding: 3px 9px; border-radius: 20px;
  background: var(--bg); border: 1px solid var(--border); color: var(--muted);
}
.pill.admin { background: color-mix(in srgb, var(--ok-purple) 12%, transparent); color: var(--ok-purple); border-color: transparent; }
.pill.manager { background: color-mix(in srgb, var(--hs-teal) 14%, transparent); color: var(--hs-teal); border-color: transparent; }
.pill.off { background: color-mix(in srgb, var(--bad) 10%, transparent); color: var(--bad); border-color: transparent; }

/* ---------------- לוח פקודות ⌘K ---------------- */

.overlay {
  position: fixed; inset: 0; background: rgba(14,8,39,.5); backdrop-filter: blur(3px);
  display: none; align-items: flex-start; justify-content: center; padding-top: 14vh; z-index: 90;
}
.overlay.open { display: flex; }
.palette {
  width: min(560px, 92vw); background: var(--surface);
  border: 1px solid var(--border); border-radius: 15px; box-shadow: var(--shadow-lg);
  overflow: hidden; animation: pop 180ms cubic-bezier(.22,.61,.36,1);
}
@keyframes pop { from { opacity: 0; transform: translateY(-8px) scale(.98); } }
.palette input { border: 0; border-radius: 0; padding: 17px 19px; font-size: 15.5px; background: none; }
.palette input:focus { box-shadow: none; }
.palette .results { max-height: 340px; overflow-y: auto; border-top: 1px solid var(--border); }
.palette .row {
  display: flex; align-items: center; gap: 11px; padding: 11px 19px; cursor: pointer; font-size: 14px;
}
.palette .row:hover, .palette .row.sel { background: var(--surface-2); }
.palette .row .k { margin-inline-start: auto; font-size: 11px; color: var(--faint); }

.modal-card {
  width: min(460px, 92vw); background: var(--surface); border: 1px solid var(--border);
  border-radius: 15px; box-shadow: var(--shadow-lg); padding: 24px;
  animation: pop 180ms cubic-bezier(.22,.61,.36,1);
}
.modal-card h2 { margin: 0 0 4px; font-family: 'Heebo'; font-size: 18px; }
.modal-card p.hint { margin: 0 0 18px; font-size: 13px; color: var(--muted); }

.empty { text-align: center; padding: 50px 20px; color: var(--muted); }
.err { color: var(--bad); font-size: 13px; min-height: 18px; }

/* ---------------- מובייל ---------------- */

@media (max-width: 860px) {
  .shell { grid-template-columns: 1fr; }
  .sidebar {
    position: static; height: auto; flex-direction: row; align-items: center;
    gap: 14px; padding: 12px 16px; overflow-x: auto;
  }
  .sidebar .nav, .sidebar .side-foot, .sidebar .side-user { display: none; }
  .main { padding: 18px 15px 36px; }
  .grid { grid-template-columns: 1fr; }
  .topbar h1 { font-size: 19px; }
  .search-btn kbd { display: none; }
}

@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; animation: none !important; }
}

/* ---------------- צפיפות מידע בכרטיס ---------------- */
.card-body { display: flex; justify-content: space-between; align-items: flex-end; padding: 2px 0; }
.metric-label { font-size: 11.5px; color: var(--muted); display: block; margin-bottom: 3px; }
.metric-val { font-family: 'Heebo'; font-size: 19px; font-weight: 700; line-height: 1.15; color: var(--text); }
.metric-val.dim { font-size: 14px; font-weight: 500; color: var(--faint); }
.latency { font-size: 11.5px; color: var(--faint); font-variant-numeric: tabular-nums; }

/* ---------------- מקומות אחרונים ---------------- */
.recents-wrap { margin-bottom: 24px; }
.recents-title { font-size: 11.5px; font-weight: 600; letter-spacing: .04em; color: var(--muted); margin-bottom: 9px; }
.recents-row { display: flex; gap: 10px; overflow-x: auto; padding-bottom: 4px; }
.recent-item {
  display: flex; align-items: center; gap: 8px; padding: 8px 14px;
  background: var(--surface); border: 1px solid var(--border); border-radius: 11px;
  font-size: 13px; font-weight: 500; cursor: pointer; white-space: nowrap;
  box-shadow: var(--shadow); transition: all var(--t);
}
.recent-item:hover { border-color: var(--ok-purple); transform: translateY(-1px); box-shadow: var(--shadow-lg); }
.recent-item svg { color: var(--ok-purple); flex-shrink: 0; }

/* ---------------- מצבי טעינה / ריק / שגיאה ---------------- */
@keyframes shimmer { 0% { background-position: 200% 0; } 100% { background-position: -200% 0; } }
.skeleton {
  background: linear-gradient(90deg, var(--surface-2) 25%, var(--border) 50%, var(--surface-2) 75%);
  background-size: 400% 100%; animation: shimmer 1.5s infinite linear;
  border-color: transparent !important; pointer-events: none;
}
.skeleton .card-icon, .skeleton h3, .skeleton .desc, .skeleton .metric-val, .skeleton .badge {
  background: var(--border); color: transparent !important; border-radius: 5px;
}
.skeleton .card-icon { border-radius: 11px; }
.skeleton h3   { width: 60%; height: 15px; }
.skeleton .desc { width: 80%; height: 11px; margin-top: 6px; }
.skeleton .metric-val { width: 70px; height: 19px; }

.state-panel {
  display: none; flex-direction: column; align-items: center; gap: 11px;
  text-align: center; padding: 58px 20px;
  background: var(--surface); border: 1px dashed var(--border); border-radius: var(--r-card);
}
.state-panel.show { display: flex; }
.state-panel svg { width: 44px; height: 44px; color: var(--faint); }
.state-panel h3 { margin: 0; font-family: 'Heebo'; font-size: 17px; }
.state-panel p  { margin: 0; max-width: 330px; font-size: 13.5px; color: var(--muted); line-height: 1.6; }

/* ---------------- מטריצת הרשאות: ממשק שקט + כוונת ---------------- */
.matrix select.lvl {
  appearance: none; background: transparent; border-color: transparent;
  width: 100%; text-align: right; padding: 6px 8px; cursor: pointer; transition: all var(--t);
}
.matrix select.lvl:hover, .matrix select.lvl:focus { background: var(--surface); border-color: var(--ok-purple); }
.matrix select.lvl[data-level="none"] { color: var(--faint); }
.matrix select.lvl[data-level="view"] { color: var(--hs-teal);   font-weight: 600; }
.matrix select.lvl[data-level="edit"] { color: var(--warn);      font-weight: 600; }
.matrix select.lvl[data-level="full"] { color: var(--ok-purple); font-weight: 700; }
.matrix td.col-hover { background: color-mix(in srgb, var(--ok-purple) 4%, transparent); }
.matrix th.col-hover { color: var(--ok-purple); }
