@import url('https://fonts.googleapis.com/css2?family=Cairo:wght@400;500;600;700;800&family=IBM+Plex+Mono:wght@500&display=swap');

:root {
  --ink: #0f172a;
  --sidebar: #10172a;
  --sidebar-hover: #1b2440;
  --paper: #f6f7fb;
  --card: #ffffff;
  --line: #e6e8f0;
  --muted: #6b7280;
  --accent: #0d9488;
  --accent-dark: #0b7c72;
  --accent-soft: #e6f6f4;
  --danger: #dc2626;
  --danger-soft: #fdecec;
  --warn: #b45309;
  --warn-soft: #fef3e0;
  --radius: 12px;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: 'Cairo', 'Segoe UI', Tahoma, sans-serif;
  background: var(--paper);
  color: var(--ink);
  direction: rtl;
}

.layout { display: flex; min-height: 100vh; }

/* ---------- Sidebar ---------- */
.sidebar {
  width: 240px;
  flex-shrink: 0;
  background: var(--sidebar);
  color: #cbd5e1;
  display: flex;
  flex-direction: column;
  padding: 22px 14px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 6px 10px 26px;
  color: #fff;
}
.brand-mark {
  width: 34px; height: 34px; border-radius: 9px;
  background: linear-gradient(135deg, var(--accent), #14b8a6);
  display: flex; align-items: center; justify-content: center;
  font-weight: 800; font-size: 15px; color: #04211d;
}
.brand-name { font-weight: 700; font-size: 17px; }
.brand-sub { font-size: 11px; color: #94a3b8; margin-top: -2px; }

.nav-group { margin-top: 8px; display: flex; flex-direction: column; gap: 3px; }
.nav-item {
  display: flex; align-items: center; gap: 12px;
  padding: 11px 14px; border-radius: 10px;
  color: #cbd5e1; text-decoration: none; font-size: 14.5px; font-weight: 500;
  transition: background .15s ease;
}
.nav-item:hover { background: var(--sidebar-hover); color: #fff; }
.nav-item.active { background: var(--accent); color: #04211d; font-weight: 700; }
.nav-icon { width: 20px; text-align: center; font-size: 16px; }

.sidebar-footer { margin-top: auto; padding: 10px; }
.sidebar-footer a {
  color: #94a3b8; text-decoration: none; font-size: 13px;
  display: flex; align-items: center; gap: 8px;
}
.sidebar-footer a:hover { color: #fff; }

/* ---------- Main ---------- */
.main { flex: 1; min-width: 0; padding: 30px 36px; }
.page-header { margin-bottom: 24px; }
.page-title { font-size: 22px; font-weight: 800; margin: 0 0 4px; }
.page-desc { color: var(--muted); font-size: 14px; margin: 0; }

.card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 22px;
  margin-bottom: 20px;
}
.card-title { font-size: 15.5px; font-weight: 700; margin: 0 0 16px; display: flex; align-items: center; gap: 8px; }
.card-hint { color: var(--muted); font-size: 12.5px; margin: -10px 0 16px; line-height: 1.7; }

/* ---------- Forms ---------- */
label { font-size: 13.5px; font-weight: 600; color: #334155; display: block; margin-bottom: 6px; }
.field { margin-bottom: 14px; }
input[type=text], input[type=password], input[type=email], input[type=number],
select, textarea {
  width: 100%; padding: 10px 12px; border: 1px solid var(--line); border-radius: 9px;
  font-family: inherit; font-size: 14px; background: #fbfbfe; color: var(--ink);
}
input:focus, select:focus, textarea:focus {
  outline: none; border-color: var(--accent); background: #fff;
  box-shadow: 0 0 0 3px var(--accent-soft);
}
textarea { resize: vertical; }
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.grid-3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 14px; }
.check-row { display: flex; align-items: center; gap: 8px; font-size: 13.5px; color: #334155; margin: 10px 0; }
.check-row input { width: auto; }

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex; align-items: center; gap: 7px;
  padding: 10px 18px; border-radius: 9px; border: none;
  font-family: inherit; font-size: 14px; font-weight: 700; cursor: pointer;
  transition: transform .05s ease, opacity .15s ease;
}
.btn:active { transform: scale(.98); }
.btn-primary { background: var(--accent); color: #fff; }
.btn-primary:hover { background: var(--accent-dark); }
.btn-outline { background: #fff; color: var(--ink); border: 1px solid var(--line); }
.btn-outline:hover { border-color: #cbd5e1; }
.btn-danger { background: var(--danger-soft); color: var(--danger); }
.btn-danger:hover { opacity: .85; }
.btn-sm { padding: 6px 12px; font-size: 12.5px; }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn-block { width: 100%; justify-content: center; }

/* ---------- Table ---------- */
table { width: 100%; border-collapse: collapse; font-size: 13.5px; }
th { text-align: right; color: var(--muted); font-weight: 700; font-size: 12px;
     text-transform: uppercase; letter-spacing: .03em; padding: 10px 12px; border-bottom: 1px solid var(--line); }
td { padding: 11px 12px; border-bottom: 1px solid #f1f2f6; vertical-align: middle; }
tr:last-child td { border-bottom: none; }
.table-wrap { overflow-x: auto; }
.empty-row { text-align: center; color: var(--muted); padding: 34px 0; }

/* ---------- Badges ---------- */
.badge { display: inline-flex; align-items: center; gap: 5px; padding: 3px 10px;
         border-radius: 100px; font-size: 12px; font-weight: 700; }
.badge-ok { background: var(--accent-soft); color: var(--accent-dark); }
.badge-off { background: #f1f2f6; color: #64748b; }
.badge-err { background: var(--danger-soft); color: var(--danger); }

/* ---------- Upload dropzone ---------- */
.dropzone {
  border: 2px dashed var(--line); border-radius: var(--radius);
  padding: 30px; text-align: center; color: var(--muted); cursor: pointer;
  transition: border-color .15s ease, background .15s ease;
}
.dropzone:hover, .dropzone.dragover { border-color: var(--accent); background: var(--accent-soft); }
.dropzone-icon { font-size: 26px; margin-bottom: 8px; }

/* ---------- Toast / alerts ---------- */
.alert { padding: 12px 16px; border-radius: 9px; font-size: 13.5px; margin-bottom: 16px; }
.alert-error { background: var(--danger-soft); color: var(--danger); }
.alert-ok { background: var(--accent-soft); color: var(--accent-dark); }
#toast {
  position: fixed; bottom: 24px; left: 24px; z-index: 999;
  padding: 13px 20px; border-radius: 10px; font-size: 13.5px; font-weight: 600;
  box-shadow: 0 8px 24px rgba(0,0,0,.15); display: none;
}
#toast.ok { background: #0f2c28; color: #6ee7db; }
#toast.err { background: #3b0d0d; color: #fca5a5; }

/* ---------- Log console ---------- */
.console {
  background: #0b1220; color: #a3e6d3; font-family: 'IBM Plex Mono', monospace;
  font-size: 12.5px; padding: 16px; border-radius: var(--radius); height: 280px;
  overflow-y: auto; direction: ltr; text-align: left; line-height: 1.7;
}
.progress-bar { height: 8px; background: #eef0f5; border-radius: 100px; overflow: hidden; }
.progress-fill { height: 100%; background: var(--accent); transition: width .3s ease; width: 0%; }

.stat-row { display: grid; grid-template-columns: repeat(4, 1fr); gap: 14px; margin-bottom: 20px; }
.stat-box { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; }
.stat-num { font-size: 24px; font-weight: 800; }
.stat-label { font-size: 12px; color: var(--muted); margin-top: 2px; }

/* ---------- Login ---------- */
.login-wrap { min-height: 100vh; display: flex; align-items: center; justify-content: center; background: var(--sidebar); }
.login-card { background: #fff; border-radius: 18px; padding: 40px 36px; width: 380px; box-shadow: 0 20px 60px rgba(0,0,0,.35); }
.login-brand { text-align: center; margin-bottom: 24px; }
.login-brand .brand-mark { margin: 0 auto 10px; }

@media (max-width: 900px) {
  .layout { flex-direction: column; }
  .sidebar { width: 100%; flex-direction: row; overflow-x: auto; padding: 12px; }
  .nav-group { flex-direction: row; }
  .brand { display: none; }
  .main { padding: 18px; }
  .grid-2, .grid-3, .stat-row { grid-template-columns: 1fr; }
}
