:root {
  --bg: #0f1c1a;
  --bg-2: #152825;
  --panel: #1a322e;
  --panel-2: #21403b;
  --line: rgba(232, 220, 190, 0.12);
  --text: #f3eee3;
  --muted: #a8b5b0;
  --accent: #e2b45a;
  --accent-2: #f0c97a;
  --teal: #2f9e8c;
  --danger: #e07a6a;
  --ok: #5cbc8a;
  --warn: #d4a017;
  --shadow: 0 18px 50px rgba(0, 0, 0, 0.35);
  --radius: 16px;
  --font: "IBM Plex Sans Arabic", Tahoma, sans-serif;
  --en: "Outfit", "IBM Plex Sans Arabic", sans-serif;
}

* { box-sizing: border-box; }
html, body { height: 100%; }

/* display:grid/flex overrides the native [hidden] behavior — force hide */
[hidden] { display: none !important; }
body {
  margin: 0;
  font-family: var(--font);
  background:
    radial-gradient(1200px 600px at 100% -10%, rgba(226, 180, 90, 0.12), transparent 55%),
    radial-gradient(900px 500px at -10% 100%, rgba(47, 158, 140, 0.16), transparent 50%),
    linear-gradient(160deg, #0c1715, #132420 45%, #0f1c1a);
  color: var(--text);
}

button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
a { color: var(--accent); }

.login-screen {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
}

.login-panel {
  width: min(440px, 100%);
  background: linear-gradient(180deg, rgba(33, 64, 59, 0.95), rgba(21, 40, 37, 0.98));
  border: 1px solid var(--line);
  border-radius: 24px;
  box-shadow: var(--shadow);
  overflow: hidden;
}

.login-brand {
  padding: 36px 32px 18px;
  text-align: center;
  background:
    linear-gradient(135deg, rgba(226, 180, 90, 0.14), transparent 45%),
    linear-gradient(180deg, rgba(47, 158, 140, 0.12), transparent);
}

.brand-logo {
  width: 120px;
  height: 120px;
  margin: 0 auto 14px;
  display: block;
  object-fit: contain;
  border-radius: 28px;
  box-shadow: 0 14px 40px rgba(40, 120, 220, 0.28);
  background: rgba(0, 0, 0, 0.25);
}
.brand-logo.sm {
  width: 48px;
  height: 48px;
  margin: 0;
  border-radius: 14px;
  box-shadow: 0 8px 20px rgba(40, 120, 220, 0.22);
  flex-shrink: 0;
}

.login-brand h1 { margin: 0; font-size: 1.8rem; }
.brand-en {
  margin: 4px 0 0;
  font-family: var(--en);
  color: var(--accent-2);
  letter-spacing: 0.04em;
}
.brand-sub { margin: 10px 0 0; color: var(--muted); font-size: 0.92rem; }

.login-form { padding: 18px 32px 32px; display: grid; gap: 14px; }
.login-form label, .form-grid label {
  display: grid;
  gap: 6px;
  color: var(--muted);
  font-size: 0.92rem;
}
input, select, textarea {
  width: 100%;
  border: 1px solid var(--line);
  background: rgba(8, 16, 14, 0.45);
  border-radius: 12px;
  padding: 11px 12px;
  outline: none;
}
input:focus, select:focus, textarea:focus {
  border-color: rgba(226, 180, 90, 0.55);
  box-shadow: 0 0 0 3px rgba(226, 180, 90, 0.12);
}
textarea { min-height: 90px; resize: vertical; }

.btn {
  border: 1px solid transparent;
  border-radius: 12px;
  padding: 10px 16px;
  background: var(--panel-2);
  color: var(--text);
  transition: 0.15s ease;
}
.btn:hover { filter: brightness(1.08); }
.btn-primary {
  background: linear-gradient(135deg, var(--accent), #c8963a);
  color: #1a1508;
  font-weight: 600;
}
.btn-teal { background: linear-gradient(135deg, var(--teal), #217868); color: #fff; }
.btn-whatsapp {
  background: linear-gradient(135deg, #25d366, #128c7e);
  color: #fff;
  border-color: transparent;
  font-weight: 600;
}
.btn-whatsapp:hover { filter: brightness(1.06); }
.btn-waze {
  background: linear-gradient(135deg, #33ccff, #1c7aa8);
  color: #07202b;
  border-color: transparent;
  font-weight: 600;
}
.btn-waze:hover { filter: brightness(1.06); }
.btn-waze:disabled { opacity: 0.45; cursor: not-allowed; }
.btn-ghost { background: transparent; border-color: var(--line); }
.btn-danger { background: rgba(224, 122, 106, 0.18); color: #ffc2b8; border-color: rgba(224, 122, 106, 0.35); }
.btn-block { width: 100%; }
.btn-sm { padding: 7px 10px; font-size: 0.86rem; border-radius: 10px; }

.form-error { color: #ffb4a8; margin: 0; }
.login-alt { margin: 4px 0 0; text-align: center; }
.login-alt a { color: var(--accent); text-decoration: none; font-weight: 600; }

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

.sidebar {
  background: rgba(15, 28, 26, 0.92);
  border-left: 1px solid var(--line);
  display: flex;
  flex-direction: column;
  padding: 18px 14px;
  position: sticky;
  top: 0;
  height: 100vh;
}

.sidebar-brand {
  display: flex;
  gap: 12px;
  align-items: center;
  padding: 8px 8px 18px;
}
.sidebar-brand strong { display: block; }
.sidebar-brand span {
  display: block;
  font-family: var(--en);
  font-size: 0.78rem;
  color: var(--accent-2);
}

.nav { display: grid; gap: 6px; flex: 1; }
.nav-item {
  text-align: right;
  border: 0;
  background: transparent;
  color: var(--muted);
  padding: 12px 14px;
  border-radius: 12px;
}
.nav-item:hover { background: rgba(255,255,255,0.04); color: var(--text); }
.nav-item.active {
  background: linear-gradient(90deg, rgba(226, 180, 90, 0.18), rgba(47, 158, 140, 0.08));
  color: var(--text);
  border: 1px solid rgba(226, 180, 90, 0.22);
}

.sidebar-foot { padding-top: 12px; border-top: 1px solid var(--line); }
.current-user { color: var(--muted); font-size: 0.88rem; margin-bottom: 10px; padding: 0 4px; }

.main { padding: 22px 26px 40px; min-width: 0; }
.topbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  margin-bottom: 18px;
}
.topbar h2 { margin: 0; font-size: 1.45rem; }
.topbar-end { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.topbar-actions { display: flex; gap: 8px; flex-wrap: wrap; }
.live-pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 10px;
  border-radius: 999px;
  font-size: 0.78rem;
  color: #9be4bc;
  border: 1px solid rgba(92,188,138,0.35);
  background: rgba(92,188,138,0.12);
}
.live-pill::before {
  content: "";
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--ok);
  box-shadow: 0 0 0 4px rgba(92,188,138,0.18);
}

.notif-wrap { position: relative; }
.notif-btn {
  position: relative;
  background: rgba(255,255,255,0.04);
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 6px 12px;
}
.notif-count {
  display: inline-flex;
  min-width: 18px;
  height: 18px;
  margin-inline-start: 6px;
  align-items: center;
  justify-content: center;
  border-radius: 999px;
  background: var(--danger);
  color: #fff;
  font-size: 0.72rem;
  padding: 0 5px;
}
.notif-panel {
  position: absolute;
  inset-inline-end: 0;
  top: calc(100% + 8px);
  width: min(380px, 86vw);
  max-height: 420px;
  overflow: auto;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 14px;
  box-shadow: var(--shadow);
  z-index: 40;
  padding: 10px;
}
.notif-item {
  border-bottom: 1px solid var(--line);
  padding: 10px 8px;
}
.notif-item:last-child { border-bottom: 0; }
.notif-item.unread { background: rgba(226,180,90,0.08); border-radius: 10px; }
.notif-item small { color: var(--muted); display: block; margin-top: 4px; }
.check-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
}
.check-grid label {
  display: flex;
  gap: 8px;
  align-items: center;
  background: rgba(0,0,0,0.16);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 8px 10px;
}
}
.presence {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  white-space: nowrap;
}
.presence-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--muted);
  flex-shrink: 0;
}
.presence-dot.online {
  background: var(--ok);
  box-shadow: 0 0 0 4px rgba(92,188,138,0.18);
}
.perm-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
}
.perm-item {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 0;
  padding: 8px 10px;
  background: rgba(0,0,0,0.2);
  border-radius: 10px;
  border: 1px solid var(--line);
  color: var(--text);
}
.perm-item input { width: auto; accent-color: var(--accent); }

.page-content { display: grid; gap: 16px; }

.stats {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 12px;
}
.stat-card {
  background: linear-gradient(180deg, rgba(33,64,59,0.9), rgba(21,40,37,0.95));
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 16px;
}
.stat-card span { color: var(--muted); font-size: 0.9rem; }
.stat-card strong { display: block; margin-top: 8px; font-size: 1.55rem; }

.panel {
  background: rgba(21, 40, 37, 0.88);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 16px;
}
.panel h3 { margin: 0 0 12px; font-size: 1.05rem; }

.toolbar {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  align-items: end;
}
.report-filters label {
  margin: 0;
  min-width: 160px;
}
.report-filters input,
.report-filters select {
  margin-top: 4px;
}
.toolbar input, .toolbar select { max-width: 280px; }

.table-wrap { overflow: auto; border-radius: 12px; border: 1px solid var(--line); }
table { width: 100%; border-collapse: collapse; min-width: 720px; }
th, td {
  padding: 11px 12px;
  border-bottom: 1px solid var(--line);
  text-align: right;
  vertical-align: top;
}
th {
  background: rgba(0,0,0,0.22);
  color: var(--muted);
  font-weight: 500;
  font-size: 0.88rem;
}
tr:hover td { background: rgba(255,255,255,0.02); }
tfoot td {
  background: rgba(0,0,0,0.18);
  border-bottom: 0;
}
.actions { display: flex; gap: 6px; flex-wrap: wrap; }

.badge {
  display: inline-flex;
  align-items: center;
  padding: 3px 9px;
  border-radius: 999px;
  font-size: 0.78rem;
  border: 1px solid transparent;
}
.badge-ok { background: rgba(92,188,138,0.15); color: #9be4bc; border-color: rgba(92,188,138,0.3); }
.badge-warn { background: rgba(212,160,23,0.15); color: #f0d27a; border-color: rgba(212,160,23,0.3); }
.badge-info { background: rgba(47,158,140,0.15); color: #8fd8cb; border-color: rgba(47,158,140,0.3); }
.badge-muted { background: rgba(255,255,255,0.06); color: var(--muted); border-color: var(--line); }
.badge-danger { background: rgba(224,122,106,0.15); color: #ffb4a8; border-color: rgba(224,122,106,0.3); }

.form-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
}
.form-grid .full { grid-column: 1 / -1; }
.form-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  margin-top: 8px;
}

.customer-picker {
  display: grid;
  gap: 6px;
  color: var(--muted);
  font-size: 0.92rem;
  min-width: 0;
}
.combo { position: relative; }
.combo [data-customer-q] { padding-left: 40px; }
.combo-clear {
  position: absolute;
  left: 6px;
  top: 50%;
  transform: translateY(-50%);
  width: 28px;
  height: 28px;
  border: 0;
  border-radius: 8px;
  background: transparent;
  color: var(--muted);
  font-size: 1.2rem;
  line-height: 1;
  cursor: pointer;
}
.combo-clear:hover { color: var(--text); background: rgba(255,255,255,0.06); }
.combo-list {
  position: absolute;
  z-index: 30;
  top: calc(100% + 4px);
  right: 0;
  left: 0;
  margin: 0;
  padding: 6px;
  list-style: none;
  max-height: 240px;
  overflow: auto;
  background: #142824;
  border: 1px solid var(--line);
  border-radius: 12px;
  box-shadow: var(--shadow);
}
.combo-item {
  display: grid;
  gap: 2px;
  width: 100%;
  text-align: right;
  background: transparent;
  border: 0;
  border-radius: 10px;
  padding: 8px 10px;
  color: inherit;
  cursor: pointer;
}
.combo-item span { color: var(--muted); font-size: 0.82rem; }
.combo-item.active, .combo-item:hover { background: rgba(226, 180, 90, 0.14); }
.combo-empty { padding: 10px; color: var(--muted); font-size: 0.88rem; }

.modal {
  position: fixed;
  inset: 0;
  z-index: 50;
  display: grid;
  place-items: center;
  padding: 18px;
}
.modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(0,0,0,0.55);
}
.modal-card {
  position: relative;
  width: min(760px, 100%);
  max-height: min(90vh, 900px);
  overflow: auto;
  background: linear-gradient(180deg, #1f3a35, #152825);
  border: 1px solid var(--line);
  border-radius: 18px;
  box-shadow: var(--shadow);
}
.modal-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 14px 16px;
  border-bottom: 1px solid var(--line);
  position: sticky;
  top: 0;
  background: #1a322e;
  z-index: 1;
}
.modal-head h3 { margin: 0; }
.modal-body { padding: 16px; }
.icon-btn {
  width: 36px;
  height: 36px;
  border-radius: 10px;
  border: 1px solid var(--line);
  background: transparent;
  font-size: 1.3rem;
  line-height: 1;
}

.empty {
  text-align: center;
  color: var(--muted);
  padding: 28px 12px;
}

@media (max-width: 980px) {
  .app { grid-template-columns: 1fr; }
  .sidebar { height: auto; position: relative; border-left: 0; border-bottom: 1px solid var(--line); }
  .nav { grid-template-columns: repeat(3, 1fr); }
  .stats { grid-template-columns: repeat(2, 1fr); }
}

@media (max-width: 640px) {
  .form-grid { grid-template-columns: 1fr; }
  .stats { grid-template-columns: 1fr; }
  .main { padding: 16px; }
  .nav { grid-template-columns: repeat(2, 1fr); }
  .perm-grid { grid-template-columns: 1fr; }
}
