/* لوحة Chefo Server */
:root {
  --bg: #f4f6f8; --card: #fff; --text: #17202a; --muted: #5d6b79; --line: #dfe4ea; --soft: #eef2f5;
  --pri: #0f766e; --pri-2: #0d5f59; --pri-soft: #e0f2ef; --ok: #15803d; --ok-soft: #e3f5e8; --warn: #b45309; --warn-soft: #fdf1df;
  --bad: #b91c1c; --bad-soft: #fde8e8; --code: #0f172a; --code-text: #e2e8f0; --shadow: 0 1px 2px rgba(16,24,40,.06), 0 1px 3px rgba(16,24,40,.08);
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0f1418; --card: #171e24; --text: #e6ebef; --muted: #9aa8b4; --line: #2a343d; --soft: #1e272e;
    --pri: #2dd4bf; --pri-2: #5eead4; --pri-soft: #12342f; --ok: #4ade80; --ok-soft: #14301f; --warn: #fbbf24; --warn-soft: #33270f;
    --bad: #f87171; --bad-soft: #3a1717; --code: #0a0e11; --code-text: #d7dee4; --shadow: none;
    color-scheme: dark;
  }
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { margin: 0; }
body { background: var(--bg); color: var(--text); font: 15px/1.6 "Segoe UI", Tahoma, "Noto Sans Arabic", system-ui, sans-serif; }
a { color: var(--pri); text-decoration: none; }
a:hover { text-decoration: underline; }
code, pre, .mono { font-family: Consolas, "Cascadia Mono", Menlo, monospace; font-size: 13px; }
code { background: var(--soft); padding: 1px 6px; border-radius: 4px; direction: ltr; unicode-bidi: isolate; }
pre { background: var(--code); color: var(--code-text); padding: 12px 14px; border-radius: 8px; overflow: auto; direction: ltr; text-align: left; white-space: pre-wrap; word-break: break-word; margin: 8px 0; }
pre.log { max-height: 60vh; min-height: 200px; }
h1 { font-size: 22px; margin: 0 0 14px; }
h2 { font-size: 17px; margin: 0 0 10px; }
h3 { font-size: 15px; margin: 14px 0 8px; }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.ltr { direction: ltr; unicode-bidi: isolate; display: inline-block; }
.sp { flex: 1; }
.inline { display: inline; margin: 0; }

/* الهيكل */
.top { position: sticky; top: 0; z-index: 20; display: flex; align-items: center; gap: 10px; height: 54px; padding: 0 16px; background: var(--card); border-bottom: 1px solid var(--line); }
.brand { display: flex; align-items: center; gap: 8px; font-weight: 700; color: var(--text); font-size: 17px; }
.brand:hover { text-decoration: none; }
.brand.big { font-size: 20px; justify-content: center; margin-bottom: 8px; }
.logo { display: inline-grid; place-items: center; width: 28px; height: 28px; border-radius: 7px; background: var(--pri); color: #fff; font-size: 15px; }
.who { color: var(--muted); font-size: 14px; }
.menu { display: none; background: none; border: 0; font-size: 22px; color: var(--text); cursor: pointer; padding: 4px 8px; }
.shell { display: flex; min-height: calc(100vh - 54px); }
.side { width: 220px; flex: none; background: var(--card); border-inline-end: 1px solid var(--line); padding: 10px 8px; position: sticky; top: 54px; height: calc(100vh - 54px); overflow: auto; }
.side a { display: flex; align-items: center; gap: 10px; padding: 9px 12px; border-radius: 8px; color: var(--text); margin-bottom: 2px; }
.side a:hover { background: var(--soft); text-decoration: none; }
.side a.on { background: var(--pri-soft); color: var(--pri); font-weight: 600; }
.side .ic { width: 20px; text-align: center; opacity: .85; }
.side .sep { height: 1px; background: var(--line); margin: 8px 6px; }
.page { flex: 1; min-width: 0; padding: 22px 24px 60px; max-width: 1280px; }
@media (max-width: 860px) {
  .menu { display: block; }
  .side { position: fixed; top: 54px; right: 0; z-index: 30; transform: translateX(110%); transition: transform .2s; box-shadow: var(--shadow); }
  .side.open { transform: none; }
  .page { padding: 16px 16px 60px; }
}

/* البطاقات */
.card { background: var(--card); border: 1px solid var(--line); border-radius: 12px; padding: 18px; box-shadow: var(--shadow); margin-bottom: 16px; }
.card > h2:first-child { display: flex; align-items: center; gap: 8px; }
.grid { display: grid; gap: 14px; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); margin-bottom: 16px; }
.stat { background: var(--card); border: 1px solid var(--line); border-radius: 12px; padding: 14px 16px; box-shadow: var(--shadow); }
.stat .k { color: var(--muted); font-size: 13px; }
.stat .v { font-size: 22px; font-weight: 700; margin-top: 2px; }
.stat .s { color: var(--muted); font-size: 13px; }
.bar { height: 7px; background: var(--soft); border-radius: 9px; overflow: hidden; margin-top: 8px; }
.bar > i { display: block; height: 100%; background: var(--pri); border-radius: 9px; }
.bar.warn > i { background: var(--warn); }
.bar.bad > i { background: var(--bad); }
.head { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin-bottom: 14px; }
.head h1 { margin: 0; }
.row { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.cols { display: grid; gap: 16px; grid-template-columns: 1fr 1fr; }
@media (max-width: 1000px) { .cols { grid-template-columns: 1fr; } }

/* الأزرار والحقول */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; border: 1px solid var(--line); background: var(--card); color: var(--text); border-radius: 8px; padding: 7px 14px; font: inherit; font-size: 14px; cursor: pointer; white-space: nowrap; }
.btn:hover { background: var(--soft); text-decoration: none; }
.btn:disabled { opacity: .5; cursor: default; }
.btn.pri { background: var(--pri); border-color: var(--pri); color: #fff; }
.btn.pri:hover { background: var(--pri-2); }
@media (prefers-color-scheme: dark) { .btn.pri { color: #04201d; } }
.btn.danger { color: var(--bad); border-color: color-mix(in srgb, var(--bad) 40%, var(--line)); }
.btn.danger:hover { background: var(--bad-soft); }
.btn.sm { padding: 3px 10px; font-size: 13px; }
.btn.ghost { background: none; }
.btn.link { border: 0; background: none; color: var(--pri); padding: 4px; }
.btn.wide { width: 100%; padding: 10px; margin-top: 6px; }
label { display: block; margin-bottom: 12px; font-size: 14px; color: var(--muted); }
label > input, label > select, label > textarea { display: block; width: 100%; margin-top: 4px; }
input, select, textarea { font: inherit; color: var(--text); background: var(--card); border: 1px solid var(--line); border-radius: 8px; padding: 8px 10px; }
input:focus, select:focus, textarea:focus { outline: 2px solid color-mix(in srgb, var(--pri) 45%, transparent); border-color: var(--pri); }
input[type=checkbox], input[type=radio] { width: auto; display: inline-block; margin: 0 0 0 6px; accent-color: var(--pri); }
label.chk { display: flex; align-items: center; gap: 4px; color: var(--text); margin-bottom: 8px; }
textarea.editor { width: 100%; min-height: 60vh; font-family: Consolas, Menlo, monospace; font-size: 13px; direction: ltr; text-align: left; white-space: pre; tab-size: 4; }
input.code { font-size: 26px; letter-spacing: 6px; text-align: center; }
.fields { display: grid; gap: 0 12px; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); }

/* الجداول */
.tbl-wrap { overflow-x: auto; margin: 0 -4px; }
table { width: 100%; border-collapse: collapse; font-size: 14px; }
th, td { text-align: right; padding: 9px 8px; border-bottom: 1px solid var(--line); vertical-align: middle; }
th { color: var(--muted); font-weight: 600; font-size: 13px; background: var(--soft); }
tr:hover td { background: color-mix(in srgb, var(--soft) 50%, transparent); }
td.act { white-space: nowrap; text-align: left; }
td.num, th.num { text-align: left; direction: ltr; white-space: nowrap; }
.fname { display: inline-flex; align-items: center; gap: 8px; cursor: pointer; color: var(--text); }
.fname .ic { width: 18px; text-align: center; }
.empty { color: var(--muted); text-align: center; padding: 24px; }

/* الشارات */
.badge { display: inline-block; padding: 1px 9px; border-radius: 99px; font-size: 12px; font-weight: 600; background: var(--soft); color: var(--muted); white-space: nowrap; }
.badge.ok { background: var(--ok-soft); color: var(--ok); }
.badge.warn { background: var(--warn-soft); color: var(--warn); }
.badge.bad { background: var(--bad-soft); color: var(--bad); }
.badge.pri { background: var(--pri-soft); color: var(--pri); }
.dot { display: inline-block; width: 9px; height: 9px; border-radius: 50%; background: var(--muted); margin-inline-end: 6px; }
.dot.ok { background: var(--ok); } .dot.bad { background: var(--bad); } .dot.warn { background: var(--warn); }
.note { border-radius: 10px; padding: 10px 14px; margin: 0 0 14px; background: var(--pri-soft); border: 1px solid color-mix(in srgb, var(--pri) 25%, transparent); }
.note.warn { background: var(--warn-soft); border-color: color-mix(in srgb, var(--warn) 30%, transparent); }
.note.bad { background: var(--bad-soft); border-color: color-mix(in srgb, var(--bad) 30%, transparent); }
.err { background: var(--bad-soft); color: var(--bad); border-radius: 8px; padding: 9px 12px; margin-bottom: 12px; }

/* مدير الملفّات */
.crumbs { display: flex; flex-wrap: wrap; gap: 2px; align-items: center; direction: ltr; justify-content: flex-end; font-family: Consolas, Menlo, monospace; font-size: 13px; }
.crumbs a { padding: 2px 6px; border-radius: 5px; }
.crumbs a:hover { background: var(--soft); text-decoration: none; }
.drop { outline: 2px dashed var(--pri); outline-offset: -6px; background: var(--pri-soft); }
.uploads { margin: 0 0 12px; }
.up { display: grid; grid-template-columns: 1fr 120px; gap: 4px 10px; align-items: center; font-size: 13px; margin-bottom: 6px; }
.up .bar { margin: 0; }

/* النوافذ والتنبيهات */
.modal { position: fixed; inset: 0; z-index: 50; background: rgba(10,15,20,.5); display: grid; place-items: center; padding: 16px; }
.modal[hidden] { display: none; }
.dlg { background: var(--card); border-radius: 14px; width: min(560px, 100%); max-height: calc(100vh - 32px); overflow: auto; padding: 20px; box-shadow: 0 20px 50px rgba(0,0,0,.3); }
.dlg.wide { width: min(1100px, 100%); }
.dlg h2 { margin-bottom: 14px; }
.dlg .foot { display: flex; gap: 8px; justify-content: flex-start; margin-top: 16px; flex-wrap: wrap; }
.toast { position: fixed; bottom: 20px; left: 50%; transform: translateX(-50%); z-index: 60; background: var(--text); color: var(--bg); padding: 10px 18px; border-radius: 10px; box-shadow: var(--shadow); max-width: calc(100vw - 32px); }
.toast.bad { background: var(--bad); color: #fff; }
.secret { font-family: Consolas, Menlo, monospace; font-size: 16px; letter-spacing: 2px; background: var(--soft); padding: 8px 12px; border-radius: 8px; direction: ltr; text-align: center; word-break: break-all; user-select: all; }
.copy { cursor: pointer; }
.qr { display: grid; place-items: center; padding: 12px; background: #fff; border-radius: 10px; width: max-content; margin: 8px auto; }
.spin { display: inline-block; width: 14px; height: 14px; border: 2px solid currentColor; border-top-color: transparent; border-radius: 50%; animation: sp .8s linear infinite; vertical-align: -2px; }
@keyframes sp { to { transform: rotate(360deg); } }

/* صفحات الدخول */
body.auth { display: grid; place-items: center; min-height: 100vh; padding: 16px; }
.authcard { width: min(420px, 100%); padding: 26px; }
.authcard h1 { text-align: center; font-size: 18px; color: var(--muted); font-weight: 600; }
