:root {
  --bg: #0b0d12;
  --bg-soft: #11141b;
  --surface: #161a23;
  --surface-2: #1d2230;
  --border: #262c3a;
  --text: #e7ecf3;
  --text-dim: #8b94a7;
  --primary: #6c8cff;
  --primary-2: #8aa5ff;
  --primary-soft: rgba(108,140,255,0.15);
  --success: #3fd193;
  --danger: #ff6b78;
  --warn: #ffb454;
  --radius: 14px;
  --radius-sm: 10px;
  --shadow: 0 8px 24px rgba(0,0,0,0.35);
  --shadow-lg: 0 20px 48px rgba(0,0,0,0.55);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "Heebo", "Assistant", Roboto, sans-serif;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; background: var(--bg); color: var(--text); min-height: 100vh; -webkit-font-smoothing: antialiased; }

body {
  background:
    radial-gradient(1200px 600px at 100% -10%, rgba(108,140,255,0.12), transparent 60%),
    radial-gradient(900px 500px at -10% 110%, rgba(63,209,147,0.07), transparent 60%),
    var(--bg);
}

.screen { display: none; min-height: 100vh; }
.screen.active { display: block; }

#login-screen.active { display: flex; align-items: center; justify-content: center; padding: 24px; }
.card {
  width: 100%; max-width: 380px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 28px 24px;
  box-shadow: var(--shadow-lg);
}
.brand { text-align: center; margin-bottom: 22px; }
.brand .logo {
  width: 54px; height: 54px; border-radius: 16px;
  display: inline-flex; align-items: center; justify-content: center;
  background: linear-gradient(135deg, var(--primary), #4f6dd6);
  color: white; font-size: 26px; margin-bottom: 12px;
  box-shadow: 0 8px 20px rgba(108,140,255,0.4);
}
.brand h1 { margin: 0; font-size: 22px; font-weight: 700; }
.brand .subtitle { color: var(--text-dim); margin: 6px 0 0; font-size: 14px; }

label { display: block; font-size: 13px; color: var(--text-dim); margin-bottom: 14px; }
label.full { grid-column: 1 / -1; }

input[type="text"], input[type="password"], input[type="number"], input[type="date"], select {
  width: 100%;
  margin-top: 6px;
  background: var(--surface-2);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 12px 14px;
  font-size: 16px;
  outline: none;
  transition: border-color .15s, box-shadow .15s, background .15s;
}
input:focus, select:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px var(--primary-soft);
  background: #1f2533;
}
select { appearance: none; }

.btn {
  display: inline-flex; align-items: center; justify-content: center;
  border: none; border-radius: var(--radius-sm); padding: 13px 18px;
  font-size: 15px; font-weight: 600; cursor: pointer;
  transition: transform .05s, background .15s, opacity .15s;
}
.btn:active { transform: translateY(1px); }
.btn-primary { background: linear-gradient(135deg, var(--primary), #4f6dd6); color: white; box-shadow: 0 6px 16px rgba(108,140,255,0.35); width: 100%; }
.btn-primary:hover { filter: brightness(1.05); }
.btn-ghost { background: transparent; color: var(--text-dim); border: 1px solid var(--border); }
.btn-ghost:hover { color: var(--text); border-color: var(--text-dim); }
.btn-danger { background: rgba(255,107,120,0.12); color: var(--danger); border: 1px solid rgba(255,107,120,0.3); }
.btn-success {
  background: linear-gradient(135deg, var(--success), #28b078);
  color: #062417; border: none; font-weight: 600;
  box-shadow: 0 6px 16px rgba(63,209,147,0.3);
}
.btn-success:hover { filter: brightness(1.05); }

.btn-icon {
  background: var(--surface-2);
  border: 1px solid var(--border);
  color: var(--text);
  width: 40px; height: 40px;
  border-radius: 12px;
  display: inline-flex; align-items: center; justify-content: center;
  font-size: 18px; cursor: pointer;
}
.btn-icon:hover { background: #232a3a; }

.error { color: var(--danger); margin-top: 12px; font-size: 13px; min-height: 18px; text-align: center; }
.msg { font-size: 13px; min-height: 18px; }
.msg.ok { color: var(--success); }
.msg.err { color: var(--danger); }

.topbar {
  position: sticky; top: 0; z-index: 5;
  display: flex; align-items: center; justify-content: space-between;
  padding: 14px 16px;
  background: rgba(11,13,18,0.85);
  backdrop-filter: saturate(140%) blur(10px);
  border-bottom: 1px solid var(--border);
}
.topbar-actions { display: flex; gap: 8px; }
.user-info { display: flex; align-items: center; gap: 10px; font-weight: 600; }
.dot { width: 10px; height: 10px; border-radius: 50%; background: var(--success); box-shadow: 0 0 0 4px rgba(63,209,147,0.15); }
.dot.manager { background: var(--primary); box-shadow: 0 0 0 4px var(--primary-soft); }

.content { max-width: 720px; margin: 0 auto; padding: 20px 16px 60px; }
.content h2 { font-size: 18px; margin: 6px 0 16px; font-weight: 700; }
.content h3 { font-size: 15px; margin: 18px 0 10px; color: var(--text-dim); font-weight: 600; }

.form-grid {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  box-shadow: var(--shadow);
}
.form-grid label { margin-bottom: 0; }
.form-actions { display: flex; gap: 10px; }
.form-actions .btn { flex: 1; }

@media (max-width: 520px) {
  .form-grid { grid-template-columns: 1fr; }
}

.entries { display: flex; flex-direction: column; gap: 10px; margin-top: 12px; }
.entry {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px 16px;
  box-shadow: var(--shadow);
}
.entry-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 8px; }
.entry-type {
  font-weight: 700; font-size: 14px;
  padding: 4px 10px; border-radius: 999px;
  background: var(--primary-soft); color: var(--primary-2);
}
.entry-type.dep { background: rgba(63,209,147,0.12); color: var(--success); }
.entry-type.wd { background: rgba(255,107,120,0.12); color: var(--danger); }
.entry-type.note { background: rgba(255,180,84,0.12); color: var(--warn); }
.entry-time { font-size: 12px; color: var(--text-dim); }
.entry-body { display: grid; grid-template-columns: repeat(2, 1fr); gap: 6px 12px; font-size: 14px; }
.entry-body .row { display: flex; gap: 6px; }
.entry-body .k { color: var(--text-dim); }
.entry-body .v { font-weight: 600; }
.entry-body .amount-pos { font-weight: 700; color: var(--success); }
.entry-body .amount-neg { font-weight: 700; color: var(--danger); }
.entry-worker { font-size: 12px; color: var(--text-dim); margin-bottom: 6px; }
.entry-actions { margin-top: 10px; display: flex; justify-content: flex-start; }
.btn-edit { padding: 6px 14px; font-size: 13px; width: auto; }
.manager-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 14px; flex-wrap: wrap; gap: 10px; }
.manager-header h2 { margin: 0; }
#reconcile-btn { width: auto; padding: 10px 18px; font-size: 14px; }
.manager-actions { display: flex; gap: 8px; flex-wrap: wrap; }
#undo-reconcile-btn { width: auto; padding: 10px 14px; font-size: 13px; }

.entry.settled { opacity: 0.55; }
.entry.settled::after { content: 'סגור'; position: absolute; top: 8px; left: 10px; font-size: 11px; padding: 2px 8px; border-radius: 999px; background: rgba(139,148,167,0.18); color: var(--text-dim); }
.entry { position: relative; }



.filters {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px;
  display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; align-items: end;
  margin-bottom: 14px;
  box-shadow: var(--shadow);
}
.filters label { margin: 0; }
.filter-actions {
  grid-column: 1/-1;
  display: flex; gap: 8px; justify-content: flex-end; flex-wrap: wrap;
  padding-top: 4px;
}
.filter-actions .btn { width: auto; padding: 11px 18px; }

@media (max-width: 640px) {
  .filters { grid-template-columns: 1fr 1fr; }
  .filter-actions .btn { flex: 1; }
}

.stats {
  display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px;
  margin-bottom: 14px;
}
.stat .value.neg { color: var(--danger); }
.stat .value.pos { color: var(--success); }
.stat {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 12px;
  text-align: center;
}
.stat .label { font-size: 12px; color: var(--text-dim); }
.stat .value { font-size: 18px; font-weight: 700; margin-top: 4px; }

@media (max-width: 520px) {
  .stats { grid-template-columns: repeat(2, 1fr); }
}

.modal {
  position: fixed; inset: 0; background: rgba(0,0,0,0.55);
  display: flex; align-items: center; justify-content: center;
  z-index: 50; padding: 16px;
}
.modal.hidden { display: none; }
.modal-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  width: 100%; max-width: 520px;
  max-height: 88vh; overflow: auto;
  box-shadow: var(--shadow-lg);
}
.modal-head {
  display: flex; justify-content: space-between; align-items: center;
  padding: 16px 18px; border-bottom: 1px solid var(--border);
  position: sticky; top: 0; background: var(--surface); z-index: 1;
}
.modal-head h2 { margin: 0; font-size: 16px; }
.modal-body { padding: 16px 18px; }

.hidden { display: none !important; }

.worker-row {
  display: flex; justify-content: space-between; align-items: center;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 10px 14px;
}
.worker-row .name { font-weight: 600; }
.worker-row .username { color: var(--text-dim); font-size: 12px; }
.worker-row .actions { display: flex; gap: 6px; }

input, select { font-size: 16px; }

.pager { display: flex; justify-content: center; align-items: center; gap: 12px; margin-top: 16px; flex-wrap: wrap; }
.pager .btn { width: auto; padding: 8px 14px; font-size: 13px; }
.pager-info { color: var(--text-dim); font-size: 13px; }
