:root{
    --bg:#eef3f3;
    --pn:#ffffff;
    --ink:#17383a;
    --mu:#6b8486;
    --ln:#dbe5e5;
    --ac:#4d9496;
    --ac2:#e3f0f0;
    --sb:#17383a;
    --rd:#c0463b;
    --gd:#e2a73b;
    --shadow: 0 4px 20px rgba(0,0,0,0.05);
}
* { box-sizing: border-box; }
html, body { height: 100%; }
body { margin: 0; font: 15px/1.5 Rubik, system-ui, sans-serif; background: var(--bg); color: var(--ink); }

/* תיקון קריטי - מבטיח שאלמנטים מוסתרים באמת יוסתרו ולא יידרסו על ידי הגדרות ה-Grid */
[hidden] { display: none !important; }

button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1); }
button:hover:not(:disabled) { transform: translateY(-1px); filter: brightness(1.05); }
button:active:not(:disabled) { transform: translateY(1px); }
:focus-visible { outline: 2px solid var(--gd); outline-offset: 2px; }

.mu { color: var(--mu); }
.er { color: var(--rd); min-height: 22px; font-size: 14px; }

.btn { background: var(--ac); color: #fff; border: 0; border-radius: 10px; padding: 10px 22px; font-weight: 500; display: inline-flex; align-items: center; justify-content: center; transition: 0.3s; }
.btn:disabled { opacity: 0.7; cursor: not-allowed; transform: none; }
.btn.g { background: transparent; color: var(--ink); border: 1px solid var(--ln); }
.btn.g:hover { background: var(--pn); }
.btn.r { background: transparent; color: var(--rd); border: 1px solid #c0463b44; }
.btn.r:hover { background: #c0463b11; }
.btn.s { padding: 5px 14px; font-size: 13px; background: var(--ac2); color: var(--ac); }
.btn.big { width: 100%; padding: 12px; font-size: 16px; }

input, select, textarea { width: 100%; padding: 11px 14px; border: 1px solid var(--ln); border-radius: 12px; background: var(--pn); transition: 0.2s; }
input:focus, select:focus, textarea:focus { border-color: var(--ac); outline: none; box-shadow: 0 0 0 3px rgba(77, 148, 150, 0.15); }
input::placeholder { color: #b4c4c5; text-align: center; }
label.l { display: block; font-weight: 500; font-size: 13px; margin: 18px 0 8px; color: var(--ink); }
.h { font-size: 13px; color: var(--mu); margin-top: 6px; }

.pills { display: flex; flex-wrap: wrap; gap: 8px; }
.pill { border: 1px solid var(--ln); background: var(--pn); border-radius: 22px; padding: 7px 18px; font-weight: 500; transition: 0.2s; }
.pill.on { background: var(--ac); border-color: var(--ac); color: #fff; box-shadow: 0 4px 10px rgba(77, 148, 150, 0.25); }
.pg { margin: 10px 0 4px; font-size: 12px; color: var(--mu); }
.ck { display: flex; gap: 8px; align-items: center; margin-top: 16px; cursor: pointer; }
.ck input { width: auto; cursor: pointer; }

#login {
    position: fixed; top: 0; left: 0; width: 100vw; height: 100vh;
    display: grid; place-items: center; padding: 20px;
    background: linear-gradient(135deg, var(--sb) 0%, #1a4244 100%);
    z-index: 2147483647;
}
.lc {
    background: var(--pn); border-radius: 24px; padding: 40px;
    width: min(420px, 100%);
    box-shadow: 0 20px 40px rgba(0,0,0,0.3);
    text-align: center;
}
.lc h1 { margin: 0 0 10px; font-size: 28px; }
.lc .mu { margin-bottom: 24px; }
.lc label { display: block; font-size: 14px; margin: 16px 0 6px; text-align: start; font-weight: 500; }

#app { display: grid; grid-template-columns: 260px 1fr; height: 100%; }
aside { background: var(--sb); color: #cfe3e1; padding: 24px 16px; overflow: auto; display: flex; flex-direction: column; gap: 4px; }
aside h2 { margin: 0 10px 24px; color: #fff; font-size: 22px; }
aside .gl { font-size: 12px; color: #7fa5a3; margin: 20px 10px 6px; letter-spacing: 0.5px; text-transform: uppercase; }
aside a { display: block; padding: 10px 14px; border-radius: 12px; cursor: pointer; transition: 0.2s; font-weight: 500; }
aside a:hover { background: rgba(255,255,255,0.08); color: #fff; }
aside a.on { background: var(--ac); color: #fff; box-shadow: 0 4px 12px rgba(0,0,0,0.1); }
aside .me { margin-top: auto; padding: 16px 14px 0; border-top: 1px solid rgba(255,255,255,0.1); font-size: 13px; line-height: 1.6; }

main { overflow: auto; padding: 32px 40px; scroll-behavior: smooth; }
.top { display: flex; gap: 16px; align-items: center; flex-wrap: wrap; margin-bottom: 24px; }
.top h1 { margin: 0; font-size: 28px; margin-inline-end: auto; }
.top input, .top select { width: auto; min-width: 180px; padding: 10px 16px; }

.card { background: var(--pn); border: 1px solid var(--ln); border-radius: 20px; box-shadow: var(--shadow); transition: 0.3s; }
.card:hover { box-shadow: 0 8px 24px rgba(0,0,0,0.06); }
.tw { overflow-x: auto; border-radius: 20px; }

table { width: 100%; border-collapse: collapse; }
th { text-align: start; font-size: 14px; color: var(--mu); font-weight: 500; padding: 16px; border-bottom: 2px solid var(--bg); background: #fafcfc; }
td { padding: 14px 16px; border-bottom: 1px solid var(--ln); font-size: 14px; }
tr:last-child td { border: 0; }
tr:hover td { background: #fafcfc; }
td.a { white-space: nowrap; text-align: end; }
td.a .btn { margin-inline-start: 8px; }

.tag { display: inline-block; background: var(--ac2); color: var(--ac); border-radius: 20px; padding: 3px 12px; font-size: 12px; margin: 2px; font-weight: 500; }
.tag.r { background: #c0463b15; color: var(--rd); }

.em { padding: 60px 20px; text-align: center; color: var(--mu); font-size: 16px; }
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 16px; margin-bottom: 24px; }
.st { padding: 24px; text-align: center; }
.st b { display: block; font-size: 40px; color: var(--ac); line-height: 1; margin-bottom: 8px; }
.st span { color: var(--mu); font-weight: 500; }

.bar { display: grid; grid-template-columns: 100px 1fr 40px; gap: 16px; align-items: center; margin: 12px 0; }
.bar i { display: block; height: 14px; border-radius: 8px; background: linear-gradient(90deg, var(--ac), #66aeb0); transition: width 0.8s cubic-bezier(0.4, 0, 0.2, 1); }

.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(360px, 1fr)); gap: 20px; }
.sc { padding: 24px; }
.sh { display: flex; align-items: center; gap: 12px; margin-bottom: 12px; }
.sh h3 { margin: 0; flex: 1; font-size: 18px; }

.pr { display: grid; grid-template-columns: 70px 1fr; gap: 12px; padding: 12px 0; border-top: 1px solid var(--ln); }
.pr>b { font-size: 15px; color: var(--mu); padding-top: 6px; }

.tm { display: inline-flex; flex-direction: column; align-items: center; border: 1px solid var(--ln); background: var(--pn); border-radius: 14px; padding: 6px 14px; margin: 3px; line-height: 1.3; transition: 0.2s; box-shadow: 0 2px 5px rgba(0,0,0,0.02); }
.tm:hover { border-color: var(--ac); background: var(--ac2); transform: translateY(-2px); box-shadow: 0 4px 8px rgba(77, 148, 150, 0.15); }
.tm b { font-size: 17px; direction: ltr; color: var(--ink); }
.tm small { font-size: 12px; color: var(--mu); }

dialog { border: 0; border-radius: 24px; padding: 0; width: min(500px, 95vw); background: var(--pn); color: var(--ink); box-shadow: 0 24px 80px rgba(0,0,0,0.3); overflow: hidden; }
dialog[open] { display: flex; flex-direction: column; max-height: 90vh; animation: pop 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275); }
dialog::backdrop { background: rgba(10, 26, 27, 0.7); backdrop-filter: blur(4px); animation: fade 0.3s ease-out; }

.mh { display: flex; justify-content: space-between; align-items: center; padding: 24px 32px; border-bottom: 1px solid var(--ln); background: #fafcfc; }
.mh h3 { margin: 0; font-size: 22px; }
.x { border: 0; background: none; font-size: 28px; color: var(--mu); line-height: 1; padding: 0; width: 32px; height: 32px; border-radius: 50%; display: grid; place-items: center; transition: 0.2s; }
.x:hover { background: var(--ln); color: var(--ink); }

.mb { padding: 12px 32px 24px; overflow: auto; }
.mf { display: flex; gap: 12px; padding: 20px 32px; background: #fafcfc; border-top: 1px solid var(--ln); }

pre { background: var(--sb); color: #d8f3ee; padding: 16px; border-radius: 16px; overflow: auto; direction: ltr; text-align: left; font-size: 13px; max-height: 420px; box-shadow: inset 0 2px 10px rgba(0,0,0,0.2); }

#toast { position: fixed; bottom: 24px; inset-inline-start: 24px; background: var(--ink); color: #fff; padding: 12px 20px; border-radius: 14px; opacity: 0; transition: .4s cubic-bezier(0.175, 0.885, 0.32, 1.275); transform: translateY(20px); pointer-events: none; z-index: 9999; box-shadow: 0 10px 30px rgba(0,0,0,0.2); font-weight: 500; }
#toast.on { opacity: 1; transform: translateY(0); }
#toast.e { background: var(--rd); }

.dot { display: inline-block; width: 10px; height: 10px; border-radius: 50%; margin-inline-end: 8px; background: #2fb07a; box-shadow: 0 0 10px rgba(47, 176, 122, 0.4); }
.dot.no { background: var(--rd); box-shadow: 0 0 10px rgba(192, 70, 59, 0.4); }

@keyframes fade { from { opacity: 0; } to { opacity: 1; } }
@keyframes pop { from { opacity: 0; transform: scale(0.95) translateY(10px); } to { opacity: 1; transform: scale(1) translateY(0); } }
.fade-in { animation: fade 0.4s ease-out; }

.spinner { display: inline-block; width: 20px; height: 20px; border: 2.5px solid rgba(255,255,255,0.3); border-radius: 50%; border-top-color: currentColor; animation: spin 0.8s linear infinite; margin-inline-end: 10px; }
.btn.g .spinner, .btn.r .spinner { border-color: rgba(0,0,0,0.1); border-top-color: currentColor; }
@keyframes spin { to { transform: rotate(360deg); } }

@media(max-width: 780px) {
    #app { grid-template-columns: 1fr; grid-template-rows: auto 1fr; }
    aside { flex-direction: row; flex-wrap: wrap; padding: 12px; gap: 8px; }
    aside .gl, aside .me, aside h2 { display: none; }
    aside a { padding: 8px 12px; font-size: 14px; }
    main { padding: 20px; }
    .top { flex-direction: column; align-items: stretch; }
    .top h1 { margin-bottom: 10px; }
}