/* GoFix — أحمر وأسود */
:root {
  --red: #d71920;
  --red-dark: #a8121a;
  --red-soft: #fdecec;
  --ink: #141414;
  --ink-2: #2a2a2a;
  --muted: #6b6b6b;
  --line: #e4e4e4;
  --bg: #f5f5f5;
  --card: #fff;
  --ok: #1f8a4c;
  --ok-soft: #e7f5ec;
  --radius: 10px;
  --shadow: 0 1px 2px rgba(0,0,0,.06), 0 4px 16px rgba(0,0,0,.05);
  font-family: "Segoe UI", Tahoma, "Noto Sans Arabic", system-ui, sans-serif;
  color: var(--ink);
  background: var(--bg);
  font-size: 15px;
  line-height: 1.5;
}
* { box-sizing: border-box; }
body { margin: 0; min-height: 100vh; }
.hidden { display: none !important; }
.muted { color: var(--muted); font-size: .92em; }
a { color: var(--red-dark); }
h1, h2, h3 { margin: 0 0 .5em; line-height: 1.3; }

/* ---------- أزرار ---------- */
.btn {
  font: inherit; border: 1px solid var(--line); background: #fff; color: var(--ink);
  padding: .5em 1em; border-radius: 8px; cursor: pointer; white-space: nowrap; min-height: 40px;
}
.btn:hover:not(:disabled) { border-color: #bdbdbd; background: #fafafa; }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn-primary { background: var(--red); border-color: var(--red); color: #fff; font-weight: 600; }
.btn-primary:hover:not(:disabled) { background: var(--red-dark); border-color: var(--red-dark); }
.btn-danger { background: var(--ink); border-color: var(--ink); color: #fff; }
.btn-danger-ghost { color: var(--red-dark); }
.btn-sm { padding: .3em .75em; min-height: 34px; font-size: .92em; }
.btn-block { width: 100%; }
.btn-on { border-color: var(--red); color: var(--red-dark); background: var(--red-soft); }
.btn.loading { position: relative; color: transparent !important; }
.btn.loading::after {
  content: ""; position: absolute; inset: 0; margin: auto; width: 1.1em; height: 1.1em;
  border: 2px solid #fff; border-top-color: transparent; border-radius: 50%; animation: spin .7s linear infinite;
}
.icon-btn { font: inherit; background: none; border: 0; cursor: pointer; padding: .25em .5em; border-radius: 6px; color: inherit; min-width: 32px; min-height: 32px; }
.icon-btn:hover:not(:disabled) { background: #eee; }
.icon-btn:disabled { opacity: .3; }
.link-btn { background: none; border: 0; color: var(--muted); text-decoration: underline; cursor: pointer; font: inherit; margin-top: .75em; }
:focus-visible { outline: 2px solid var(--red); outline-offset: 2px; }

/* ---------- كروت ---------- */
.card { background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow); padding: 1.25em; margin-bottom: 1em; }
.card.narrow { max-width: 520px; }
.hero h2 { font-size: 1.35em; }
.tiles { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 12px; }
.tile { display: flex; flex-direction: column; gap: .3em; padding: 1em; background: #fff; border-radius: var(--radius); box-shadow: var(--shadow);
  text-decoration: none; color: var(--ink); border-inline-start: 4px solid var(--red); }
.tile:hover { background: #fffafa; }

/* ---------- البراند ---------- */
.brand { display: flex; align-items: center; gap: .5em; }
.brand img { max-height: 36px; max-width: 140px; object-fit: contain; }
.brand-text { font-weight: 800; font-size: 1.35em; letter-spacing: .5px; direction: ltr; }
.brand-text b { color: var(--red); }
.brand-big { justify-content: center; margin-bottom: 1em; }
.brand-big img { max-height: 72px; max-width: 220px; }
.brand-big .brand-text { font-size: 2.2em; }
.brand-name { font-weight: 600; }

/* ---------- الدخول ---------- */
.auth-wrap { min-height: 100vh; display: grid; place-items: center; padding: 1em;
  background: linear-gradient(160deg, #141414 0%, #141414 45%, #2a0b0d 100%); }
.auth-card { width: 100%; max-width: 380px; padding: 2em 1.5em; }
.auth-card h2 { text-align: center; }

/* ---------- الهيكل ---------- */
.layout { display: flex; min-height: 100vh; }
.side { width: 240px; background: var(--ink); color: #eee; display: flex; flex-direction: column; position: sticky; top: 0; height: 100vh; flex-shrink: 0; }
.side-brand { padding: 1em 1.1em; border-bottom: 1px solid #2c2c2c; }
.side-brand .brand-text { color: #fff; }
.nav { display: flex; flex-direction: column; padding: .5em; gap: 2px; flex: 1; overflow-y: auto; }
.nav a { display: flex; align-items: center; gap: .7em; padding: .65em .8em; color: #ddd; text-decoration: none; border-radius: 8px; }
.nav a:hover { background: #222; color: #fff; }
.nav a.active { background: var(--red); color: #fff; font-weight: 600; }
.nav-ic { width: 1.4em; text-align: center; }
.side-user { padding: 1em; border-top: 1px solid #2c2c2c; display: flex; align-items: center; justify-content: space-between; gap: .5em; }
.side-user .muted { color: #9a9a9a; }
.side-user .btn { background: transparent; color: #eee; border-color: #444; }
.main { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.topbar { display: flex; align-items: center; gap: .75em; padding: .75em 1.25em; background: #fff; border-bottom: 1px solid var(--line); position: sticky; top: 0; z-index: 5; }
.topbar h1 { font-size: 1.2em; margin: 0; }
.topbar .brand { display: none; }
.menu-btn { display: none; font-size: 1.3em; }
.page { padding: 1.25em; max-width: 1300px; width: 100%; }
.scrim { display: none; }

@media (max-width: 860px) {
  .side { position: fixed; inset-block: 0; inset-inline-start: 0; z-index: 30; transform: translateX(100%); transition: transform .2s; }
  body.nav-open .side { transform: none; }
  body.nav-open .scrim { display: block; position: fixed; inset: 0; background: rgba(0,0,0,.4); z-index: 20; }
  .menu-btn { display: inline-block; }
  .topbar .brand { display: flex; }
  .page { padding: .75em; }
}

/* ---------- جداول ---------- */
.dt { background: #fff; border-radius: var(--radius); box-shadow: var(--shadow); }
.dt-toolbar { display: flex; flex-wrap: wrap; gap: .5em; align-items: center; padding: .75em; border-bottom: 1px solid var(--line); }
.dt-search { flex: 1 1 200px; max-width: 320px; }
.dt-spacer { flex: 1; }
.dt-scroll { overflow-x: auto; }
.dt-table { width: 100%; border-collapse: collapse; }
.dt-table th, .dt-table td { padding: .6em .75em; text-align: start; border-bottom: 1px solid #efefef; vertical-align: middle; }
.dt-table thead th { background: #fafafa; font-weight: 600; font-size: .92em; color: #333; position: sticky; top: 0; white-space: nowrap; }
.dt-table th.sortable { cursor: pointer; user-select: none; }
.dt-table th.sortable:hover { color: var(--red-dark); }
.sort-ind { color: var(--red); font-size: .8em; }
.dt-filter-row th { padding: .35em .5em; background: #fff; }
.dt-filter { width: 100%; min-width: 80px; padding: .3em .5em !important; min-height: 32px !important; font-size: .9em; }
.dt-table tbody tr.clickable { cursor: pointer; }
.dt-table tbody tr:hover { background: #fff7f7; }
.dt-table tr.row-off td { color: #9a9a9a; }
.dt-empty { text-align: center !important; color: var(--muted); padding: 2em !important; }
.dt-actions { white-space: nowrap; text-align: end !important; }
.dt-actions > * { margin-inline-start: .25em; }
.al-num { text-align: end !important; font-variant-numeric: tabular-nums; }
.al-center { text-align: center !important; }
.dt-pager { display: flex; align-items: center; gap: .5em; padding: .6em .75em; }

/* على الموبايل: كل صف كارت */
@media (max-width: 640px) {
  .dt-table thead tr:first-child { display: none; }
  .dt-table, .dt-table tbody, .dt-table tr, .dt-table td { display: block; width: 100%; }
  .dt-filter-row { display: grid !important; grid-template-columns: 1fr 1fr; }
  .dt-table tbody tr { border-bottom: 6px solid var(--bg); padding: .4em 0; }
  .dt-table td { border: 0; display: flex; justify-content: space-between; gap: 1em; padding: .3em .9em; text-align: end !important; }
  .dt-table td::before { content: attr(data-label); color: var(--muted); font-size: .9em; text-align: start; }
  .dt-table td.dt-actions::before, .dt-table td.dt-empty::before { content: none; }
  .dt-search { max-width: none; flex-basis: 100%; }
}

.pill { display: inline-block; padding: .1em .65em; border-radius: 999px; background: #eee; font-size: .85em; white-space: nowrap; }
.pill-ok { background: var(--ok-soft); color: var(--ok); }
.pill-off { background: #f0f0f0; color: #888; }
.pill-brand { background: var(--red-soft); color: var(--red-dark); font-weight: 600; }

/* ---------- نماذج ---------- */
input, select, textarea { font: inherit; border: 1px solid #cfcfcf; border-radius: 8px; padding: .5em .7em; background: #fff; color: inherit; min-height: 40px; width: 100%; }
input:focus, select:focus, textarea:focus { border-color: var(--red); outline: none; box-shadow: 0 0 0 3px rgba(215,25,32,.12); }
input:disabled, select:disabled, textarea:disabled { background: #f3f3f3; color: #777; }
input[type=checkbox] { width: 18px; height: 18px; min-height: 0; accent-color: var(--red); margin: 0; }
input[type=file] { padding: .35em; }
.form { display: grid; grid-template-columns: 1fr; gap: .9em; }
.modal-wide .form { grid-template-columns: 1fr 1fr; }
.modal-wide .form .full, .modal-wide .form .form-error, .modal-wide .form .form-intro { grid-column: 1 / -1; }
.field { display: flex; flex-direction: column; gap: .3em; }
.field label { font-weight: 600; font-size: .93em; }
.req { color: var(--red); }
.hint { font-size: .85em; color: var(--muted); }
.field-error { color: var(--red-dark); font-size: .87em; min-height: 0; }
.field-error:empty { display: none; }
.field.has-error input, .field.has-error select, .field.has-error textarea { border-color: var(--red); background: #fff8f8; }
.form-error { background: var(--red-soft); color: var(--red-dark); border-radius: 8px; padding: .6em .8em; font-size: .93em; }
.form-intro { background: #f6f6f6; border-radius: 8px; padding: .6em .8em; font-size: .93em; }
.check { display: inline-flex; align-items: center; gap: .5em; cursor: pointer; font-weight: normal !important; }
.check.disabled { opacity: .5; cursor: not-allowed; }
.field-check { justify-content: center; }
.img-field { display: flex; flex-wrap: wrap; align-items: center; gap: .5em; }
.img-preview { max-height: 64px; max-width: 180px; object-fit: contain; border: 1px solid var(--line); border-radius: 6px; padding: 4px; background: #fff; }
.inline-input { width: 7em; min-height: 32px; padding: .2em .5em; display: inline-block; }
.fee-preview { background: #f7f7f7; border-radius: 8px; padding: .6em .8em; display: flex; flex-wrap: wrap; align-items: center; gap: .3em; }

/* ---------- الصلاحيات ---------- */
.perm-groups { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: .75em; }
.perm-groups > p { grid-column: 1 / -1; margin: 0; }
.perm-group { border: 1px solid var(--line); border-radius: 8px; padding: .5em .8em .8em; margin: 0; display: flex; flex-direction: column; gap: .45em; }
.perm-group legend { font-weight: 700; padding: 0 .3em; color: var(--red-dark); }
.ov-row { display: grid; grid-template-columns: auto 1fr; gap: .2em .5em; align-items: center; padding: .25em; border-radius: 6px; }
.ov-row .ov-sel { grid-column: 1 / -1; min-height: 34px; padding: .25em .5em; font-size: .9em; }
.ov-row.ov-set { background: #fff4f4; }
.dot { width: 10px; height: 10px; border-radius: 50%; display: inline-block; }
.dot-on { background: var(--ok); }
.dot-off { background: #c9c9c9; }

/* ---------- نوافذ ---------- */
.overlay { position: fixed; inset: 0; background: rgba(0,0,0,.45); display: grid; place-items: center; z-index: 50; padding: 1em; overflow-y: auto; }
.modal { background: #fff; border-radius: 12px; width: 100%; max-width: 460px; max-height: calc(100vh - 2em); display: flex; flex-direction: column; box-shadow: 0 10px 40px rgba(0,0,0,.25); }
.modal-wide { max-width: 820px; }
.modal-head { display: flex; align-items: center; justify-content: space-between; padding: .9em 1.1em; border-bottom: 1px solid var(--line); }
.modal-head h3 { margin: 0; font-size: 1.1em; }
.modal-body { padding: 1.1em; overflow-y: auto; }
.modal-foot { display: flex; gap: .5em; padding: .8em 1.1em; border-top: 1px solid var(--line); }
@media (max-width: 640px) {
  .overlay { padding: 0; place-items: end stretch; }
  .modal, .modal-wide { max-width: none; border-radius: 14px 14px 0 0; max-height: 92vh; }
  .modal-wide .form { grid-template-columns: 1fr; }
}
.col-list { list-style: none; padding: 0; margin: 0 0 1em; border: 1px solid var(--line); border-radius: 8px; }
.col-list li { display: flex; align-items: center; gap: .5em; padding: .35em .6em; border-bottom: 1px solid #f0f0f0; }
.col-list li:last-child { border-bottom: 0; }

/* ---------- تبويبات وشرايح ---------- */
.tabs { display: flex; gap: .25em; border-bottom: 2px solid var(--line); margin-bottom: 1em; overflow-x: auto; }
.tab { font: inherit; background: none; border: 0; padding: .6em 1em; cursor: pointer; border-bottom: 3px solid transparent; margin-bottom: -2px; white-space: nowrap; }
.tab.active { border-color: var(--red); color: var(--red-dark); font-weight: 700; }
.chips { display: flex; flex-wrap: wrap; gap: .4em; margin-bottom: .9em; }
.chip { font: inherit; border: 1px solid var(--line); background: #fff; border-radius: 999px; padding: .3em .9em; cursor: pointer; display: inline-flex; gap: .5em; align-items: center; }
.chip.active { background: var(--ink); color: #fff; border-color: var(--ink); }
.chip-n { background: rgba(0,0,0,.08); border-radius: 999px; padding: 0 .5em; font-size: .85em; }
.chip.active .chip-n { background: var(--red); }

/* ---------- عرض البيانات ---------- */
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: .25em 2em; margin-bottom: 1em; }
.grid2 .full { grid-column: 1 / -1; }
@media (max-width: 640px) { .grid2 { grid-template-columns: 1fr; } }
.kv-row { display: flex; justify-content: space-between; gap: 1em; padding: .55em 0; border-bottom: 1px dashed #eee; align-items: center; }
.kv-row b { font-weight: 600; text-align: end; white-space: pre-line; }
.kv { display: grid; grid-template-columns: max-content 1fr; gap: .5em 1.5em; margin: 0 0 1.25em; }
.kv dt { color: var(--muted); }
.kv dd { margin: 0; font-weight: 600; }

/* ---------- تحميل ورسايل ---------- */
.splash { display: grid; place-items: center; padding: 3em; }
.spinner { width: 34px; height: 34px; border: 3px solid #ddd; border-top-color: var(--red); border-radius: 50%; animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
#toasts { position: fixed; bottom: 1em; inset-inline-start: 50%; transform: translateX(50%); display: flex; flex-direction: column; gap: .5em; z-index: 100; align-items: center; }
.toast { background: var(--ink); color: #fff; padding: .65em 1.1em; border-radius: 8px; box-shadow: var(--shadow); transition: opacity .3s; border-inline-start: 4px solid var(--ok); }
.toast-err { border-color: var(--red); }
.toast-info { border-color: #999; }
.toast.out { opacity: 0; }
