:root {
  --brand: #0b6bcb;
  --brand-dark: #084a8f;
  --brand-soft: #e8f1fb;
  --bg: #f4f6fb;
  --card: #ffffff;
  --text: #14213d;
  --muted: #6b7a99;
  --border: #e3e8f2;
  --green: #16a34a;
  --shadow: 0 6px 24px rgba(16, 34, 74, 0.08);
  --radius: 14px;
}

/* ===== v2: حقول صغيرة + بطاقات المورد ===== */
input.mini { width: 88px; padding: 4px 6px; font-size: 13px; border-radius: 8px; }
.badge.soft { background: var(--brand-soft); color: var(--brand-dark); }
.toolbar { display: flex; gap: 10px; flex-wrap: wrap; align-items: flex-end; }
code { background: #eef2f9; padding: 1px 6px; border-radius: 6px; font-size: 12px; }

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--text);
  font-family: "Segoe UI", Tahoma, "Noto Naskh Arabic", Arial, sans-serif;
  font-size: 15px;
}

button, input, select, textarea { font-family: inherit; font-size: inherit; }

a { color: var(--brand); }

.hidden { display: none !important; }

/* ============ تسجيل الدخول ============ */
.login-wrap {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(135deg, #062a52, #0b6bcb 60%, #17a2d6);
}
.login-card {
  background: #fff;
  padding: 34px 30px;
  border-radius: 18px;
  width: 360px;
  box-shadow: 0 20px 50px rgba(0, 0, 0, 0.28);
  text-align: center;
}
.login-card h1 { margin: 6px 0 2px; font-size: 22px; }
.login-card p { color: var(--muted); margin: 0 0 20px; font-size: 14px; }
.login-card .logo { font-size: 44px; }

/* ============ الهيكل العام ============ */
.layout { display: flex; min-height: 100vh; }

.sidebar {
  width: 232px;
  background: linear-gradient(180deg, #062a52, #083a6e);
  color: #cfe0f5;
  padding: 18px 12px;
  position: sticky;
  top: 0;
  height: 100vh;
  flex-shrink: 0;
}
.sidebar .brand {
  display: flex; align-items: center; gap: 10px;
  padding: 6px 10px 18px; color: #fff; font-weight: 700; font-size: 17px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.12);
  margin-bottom: 14px;
}
.sidebar .brand small { display: block; font-weight: 400; font-size: 11px; color: #9dc0e6; }
.nav-item {
  display: flex; align-items: center; gap: 10px; justify-content: space-between;
  padding: 11px 12px; border-radius: 10px; cursor: pointer; margin-bottom: 4px;
  color: #cfe0f5; transition: 0.15s;
}
.nav-item:hover { background: rgba(255, 255, 255, 0.08); color: #fff; }
.nav-item.active { background: #fff; color: var(--brand-dark); font-weight: 700; }
.nav-item .count {
  background: rgba(255, 255, 255, 0.16); border-radius: 20px; padding: 1px 8px; font-size: 12px;
}
.nav-item.active .count { background: var(--brand-soft); color: var(--brand-dark); }
.sidebar .foot { margin-top: auto; font-size: 11px; color: #7fa5cd; padding: 10px; }
.sidebar-inner { display: flex; flex-direction: column; height: 100%; }
.sidebar-scroll { flex: 1; overflow-y: auto; }

.main { flex: 1; min-width: 0; display: flex; flex-direction: column; }

.topbar {
  background: #fff; border-bottom: 1px solid var(--border);
  padding: 14px 22px; display: flex; align-items: center; gap: 14px; flex-wrap: wrap;
  position: sticky; top: 0; z-index: 20;
}
.topbar h2 { margin: 0; font-size: 19px; }
.topbar .spacer { flex: 1; }
.pill {
  border-radius: 20px; padding: 4px 12px; font-size: 12.5px; font-weight: 600;
  background: var(--brand-soft); color: var(--brand-dark); white-space: nowrap;
}
.pill.ok { background: #e6f7ec; color: #146c37; }
.pill.warn { background: #fff4e5; color: #a35b00; }

.content { padding: 22px; }

/* ============ كروت ============ */
.card {
  background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow);
  padding: 18px; margin-bottom: 18px;
}
.card h3 { margin: 0 0 14px; font-size: 16px; }
.grid { display: grid; gap: 14px; }
.grid.cards { grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); }
.grid.two { grid-template-columns: 1fr 1fr; }
@media (max-width: 900px) { .grid.two { grid-template-columns: 1fr; } }

.stat { background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow); padding: 16px; }
.stat .label { color: var(--muted); font-size: 13px; }
.stat .value { font-size: 27px; font-weight: 800; margin-top: 6px; }
.stat .sub { font-size: 12px; color: var(--muted); margin-top: 4px; }

.bar-row { display: flex; align-items: center; gap: 10px; margin-bottom: 9px; font-size: 13.5px; }
.bar-row .name { width: 150px; flex-shrink: 0; }
.bar-row .track { flex: 1; background: #eef2f9; border-radius: 8px; height: 12px; overflow: hidden; }
.bar-row .fill { height: 100%; border-radius: 8px; }
.bar-row .num { width: 74px; text-align: left; color: var(--muted); }

/* ============ الجداول ============ */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
th, td { padding: 10px 10px; text-align: right; border-bottom: 1px solid var(--border); font-size: 13.5px; vertical-align: middle; }
th { color: var(--muted); font-weight: 600; background: #fafbfe; position: sticky; top: 0; }
tbody tr:hover { background: #f7faff; }
tbody tr { cursor: pointer; }
.code { font-family: Consolas, monospace; font-weight: 700; direction: ltr; display: inline-block; }

.badge {
  display: inline-block; padding: 3px 10px; border-radius: 20px; font-size: 12px; font-weight: 700;
  white-space: nowrap;
}
.badge.soft { background: #eef2f9; color: var(--muted); }

/* ============ عناصر الإدخال ============ */
input[type="text"], input[type="password"], input[type="date"], input[type="search"], select, textarea {
  width: 100%; padding: 9px 11px; border: 1px solid var(--border); border-radius: 10px;
  background: #fff; color: var(--text); outline: none;
}
input:focus, select:focus, textarea:focus { border-color: var(--brand); box-shadow: 0 0 0 3px rgba(11, 107, 203, 0.12); }
label.field { display: block; }
label.field span { display: block; font-size: 12.5px; color: var(--muted); margin-bottom: 5px; }

.btn {
  border: 0; border-radius: 10px; padding: 9px 16px; cursor: pointer; font-weight: 700;
  background: var(--brand); color: #fff; transition: 0.15s;
}
.btn:hover { background: var(--brand-dark); }
.btn:disabled { opacity: 0.55; cursor: not-allowed; }
.btn.ghost { background: #eef2f9; color: var(--text); }
.btn.ghost:hover { background: #e2e9f5; }
.btn.sm { padding: 6px 11px; font-size: 12.5px; }
.btn.danger { background: #ef4444; }
.btn.danger:hover { background: #c02626; }
.btn.green { background: var(--green); }
.btn.green:hover { background: #146c37; }

.toolbar { display: flex; gap: 10px; flex-wrap: wrap; align-items: flex-end; margin-bottom: 14px; }
.toolbar .field { min-width: 150px; }

.tabs { display: flex; gap: 6px; flex-wrap: wrap; margin-bottom: 14px; }
.tab {
  padding: 7px 14px; border-radius: 20px; background: #fff; border: 1px solid var(--border);
  cursor: pointer; font-size: 13.5px; font-weight: 600;
}
.tab.active { background: var(--brand); color: #fff; border-color: var(--brand); }

/* ============ الـ Drawer ============ */
.drawer-backdrop {
  position: fixed; inset: 0; background: rgba(6, 20, 45, 0.45); z-index: 40;
}
.drawer {
  position: fixed; top: 0; left: 0; height: 100vh; width: 520px; max-width: 95vw;
  background: #fff; z-index: 41; box-shadow: -12px 0 40px rgba(0, 0, 0, 0.25);
  display: flex; flex-direction: column;
}
.drawer header {
  padding: 16px 18px; border-bottom: 1px solid var(--border);
  display: flex; align-items: center; gap: 10px;
}
.drawer header h3 { margin: 0; font-size: 17px; }
.drawer .body { padding: 18px; overflow-y: auto; flex: 1; }
.drawer .row { display: flex; justify-content: space-between; gap: 10px; padding: 8px 0; border-bottom: 1px dashed var(--border); font-size: 13.5px; }
.drawer .row .k { color: var(--muted); }
.drawer .row .v { font-weight: 600; text-align: left; }
.drawer .actions { display: flex; gap: 8px; flex-wrap: wrap; margin: 14px 0; }
.drawer img.proof { width: 100%; border-radius: 12px; border: 1px solid var(--border); margin-top: 10px; }

.timeline { border-right: 2px solid var(--border); margin-top: 8px; padding-right: 14px; }
.timeline .ev { position: relative; padding-bottom: 12px; font-size: 13px; }
.timeline .ev::before {
  content: ""; position: absolute; right: -21px; top: 5px; width: 9px; height: 9px;
  border-radius: 50%; background: var(--brand);
}
.timeline .ev .when { color: var(--muted); font-size: 11.5px; }

/* ============ التنبيهات ============ */
.toasts { position: fixed; bottom: 20px; left: 20px; z-index: 60; display: flex; flex-direction: column; gap: 8px; }
.toast {
  background: #0f2d52; color: #fff; padding: 11px 16px; border-radius: 10px;
  box-shadow: 0 10px 26px rgba(0, 0, 0, 0.3); font-size: 13.5px; max-width: 380px;
}
.toast.err { background: #b91c1c; }
.toast.ok { background: #146c37; }

.empty { text-align: center; color: var(--muted); padding: 34px 10px; }
.muted { color: var(--muted); }
.small { font-size: 12.5px; }
.nowrap { white-space: nowrap; }

/* ============ المحاكي (شات) ============ */
.chat-page { display: flex; justify-content: center; padding: 22px; min-height: 100vh; background: #eef1f6; }
.phone {
  width: 430px; max-width: 100%; height: calc(100vh - 44px); background: #fff;
  border-radius: 20px; box-shadow: var(--shadow); display: flex; flex-direction: column; overflow: hidden;
}
.phone .head {
  background: #075e54; color: #fff; padding: 12px 16px; display: flex; align-items: center; gap: 10px;
}
.phone .head .avatar {
  width: 38px; height: 38px; border-radius: 50%; background: #25d366; display: grid; place-items: center; font-size: 19px;
}
.phone .head .who { flex: 1; }
.phone .head .who b { display: block; font-size: 15px; }
.phone .head .who span { font-size: 11.5px; opacity: 0.8; }
.chat-body { flex: 1; overflow-y: auto; padding: 14px; background: #e5ddd5; }
.msg { max-width: 85%; margin-bottom: 10px; padding: 9px 12px; border-radius: 12px; font-size: 13.8px; white-space: pre-wrap; line-height: 1.55; }
.msg.bot { background: #fff; border-top-right-radius: 3px; }
.msg.user { background: #dcf8c6; margin-right: auto; border-top-left-radius: 3px; }
.msg .chips { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 9px; }
.chip {
  border: 1px solid #b8d4ef; background: #f2f8ff; color: #0b4f96; border-radius: 16px;
  padding: 5px 11px; font-size: 12.5px; cursor: pointer; font-weight: 600;
}
.chip:hover { background: #dcecff; }
.msg img { max-width: 100%; border-radius: 10px; margin-top: 6px; }
.msg .meta { font-size: 10.5px; color: #8a8a8a; text-align: left; margin-top: 5px; }
.chat-foot { padding: 10px; background: #f0f2f5; border-top: 1px solid #ddd; display: flex; gap: 8px; align-items: center; }
.chat-foot input[type="text"] { flex: 1; border-radius: 20px; }
.chat-foot .icon-btn {
  width: 40px; height: 40px; border-radius: 50%; border: 0; background: #fff; cursor: pointer; font-size: 18px;
  box-shadow: 0 2px 6px rgba(0,0,0,0.12);
}
.chat-foot .icon-btn.send { background: #25d366; color: #fff; }
.chat-side { width: 300px; margin-right: 18px; }
.side-note { background: #fff; border-radius: 12px; padding: 14px; box-shadow: var(--shadow); font-size: 13px; }
.side-note h4 { margin: 0 0 8px; }
.side-note ul { padding-right: 18px; margin: 8px 0; }
@media (max-width: 800px) { .chat-side { display: none; } }

/* ============ الهوية البصرية (اللوجو + بنرات الشبكات) ============ */
.login-card .login-logo {
  width: 92px; height: 92px; border-radius: 50%; object-fit: cover;
  box-shadow: 0 8px 22px rgba(6, 20, 45, 0.28);
}
.sidebar .brand-logo {
  width: 38px; height: 38px; border-radius: 50%; object-fit: cover; flex-shrink: 0;
  box-shadow: 0 0 0 2px rgba(255, 255, 255, 0.18);
}
.brand-card { display: flex; gap: 18px; align-items: flex-start; flex-wrap: wrap; }
.brand-card .net-banner {
  width: 230px; max-width: 100%; border-radius: 14px; box-shadow: var(--shadow);
  border: 1px solid var(--border);
}
.brand-card .terms { margin-top: 10px; color: var(--muted); line-height: 1.7; }

.switch { display: inline-flex; align-items: center; gap: 7px; cursor: pointer; font-weight: 600; white-space: nowrap; }
.switch input[type="checkbox"] { width: auto; margin: 0; }
#packages-table select { min-width: 190px; }
#packages-table input[data-f="note"] { min-width: 150px; }
