/* الألوان: خلفية #f7f7f7، حبر #1a2b27، نحاسي #b0835e — Alexandria للعناوين وIBM Plex Sans Arabic للنص */
:root {
  --bg: #f7f7f7; --card: #fff; --sunk: #f2f3f2; --line: #e6e6e6; --line2: #d6dad8;
  --ink: #1a2b27; --ink2: #2b3d38; --muted: #5a6560; --faint: #9aa39f; --copper: #b0835e; --copper-l: #e9c9a8;
  --s1: #7b8a96; --s2: #b0835e; --s3: #d17a22; --s4: #c0392b; --ok: #2f8a57;
  --radius: 12px;
  --font: 'IBM Plex Sans Arabic', 'SF Arabic', 'Segoe UI', Tahoma, sans-serif;
  --display: 'Alexandria', 'IBM Plex Sans Arabic', 'SF Arabic', sans-serif;
  --shadow: 0 1px 2px rgba(26, 43, 39, .04), 0 6px 20px -12px rgba(26, 43, 39, .18);
}
* { box-sizing: border-box; }
html, body { margin: 0; }
body { background: var(--bg); color: var(--ink); font-family: var(--font); font-size: 14px; line-height: 1.6; -webkit-font-smoothing: antialiased; padding-bottom: 40px; }
[hidden] { display: none !important; }
button, input, select, textarea { font: inherit; color: inherit; }
h1, h2, h3, h4 { font-family: var(--display); font-weight: 600; margin: 0; letter-spacing: -.2px; }
.muted { color: var(--muted); }
.small { font-size: 12px; }
.num { font-variant-numeric: tabular-nums; direction: ltr; unicode-bidi: isolate; }
svg.i { width: 18px; height: 18px; stroke: currentColor; fill: none; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; flex: none; }

/* أزرار وحقول */
.btn { display: inline-flex; align-items: center; gap: 6px; border: 1px solid var(--line); background: var(--card); color: var(--ink); border-radius: 8px; padding: 7px 14px; cursor: pointer; white-space: nowrap; font-weight: 500; transition: background .15s, border-color .15s, transform .1s; }
.btn:hover { border-color: var(--line2); background: #fbfbfb; }
.btn:active { transform: scale(.97); }
.btn.primary { background: var(--ink); color: var(--bg); border-color: transparent; }
.btn.primary:hover { background: var(--ink2); }
.btn.ghost { background: transparent; border-color: transparent; }
.btn.ghost:hover { background: var(--sunk); }
.btn.danger { color: var(--s4); border-color: #ecd0cc; }
.btn.small { padding: 4px 10px; font-size: 12px; }
.btn.icon { padding: 7px 9px; }
.btn.wide { width: 100%; justify-content: center; padding: 11px; }
.btn.on { border-color: var(--copper); color: var(--copper); }
.btn:disabled { opacity: .5; cursor: default; }
input, select, textarea { width: 100%; background: var(--card); border: 1px solid var(--line); border-radius: 8px; padding: 9px 11px; outline: none; transition: border-color .15s, box-shadow .15s; }
input:focus, select:focus, textarea:focus { border-color: var(--ink); box-shadow: 0 0 0 3px rgba(26, 43, 39, .08); }
label { display: grid; gap: 5px; color: var(--muted); font-size: 13px; }
label > input, label > select, label > textarea { color: var(--ink); font-size: 14px; }
label.check { display: flex; align-items: center; gap: 8px; color: var(--ink); }
label.check input { width: auto; }
.form-error { color: var(--s4); min-height: 1.4em; font-size: 13px; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.grid4 { display: grid; grid-template-columns: repeat(4, 1fr); gap: 10px; }
@media (max-width: 640px) { .grid2, .grid4 { grid-template-columns: 1fr 1fr; } }

/* الشعار */
/* علامة اللوحة: ترس نحاسي يدور ببطء */
.mark { width: 26px; height: 26px; color: var(--copper); flex: none; animation: spin 24s linear infinite; }
.brand { display: flex; align-items: center; gap: 10px; font-family: var(--display); font-size: 17px; }
.brand .sep { width: 1px; height: 22px; background: var(--line2); }
.brand.big { font-size: 22px; justify-content: center; margin-bottom: 6px; }
.brand.big .mark { width: 40px; height: 40px; }

/* الدخول */
.auth { position: fixed; inset: 0; display: grid; place-items: center; padding: 20px; overflow: hidden; }
.auth-bg .g { position: absolute; color: var(--ink); opacity: .05; animation: spin 40s linear infinite; }
.auth-bg .g1 { width: 520px; height: 520px; top: -160px; right: -140px; }
.auth-bg .g2 { width: 320px; height: 320px; bottom: -110px; left: -80px; color: var(--copper); opacity: .1; animation-direction: reverse; animation-duration: 28s; }
.auth-card { position: relative; width: min(380px, 100%); background: var(--card); border: 1px solid var(--line); border-radius: 16px; padding: 28px; display: grid; gap: 12px; box-shadow: var(--shadow); }
.auth-card p { margin: 0; text-align: center; }

/* الرأس */
.top { position: sticky; top: 0; z-index: 30; display: flex; align-items: center; justify-content: space-between; padding: 10px 22px; background: rgba(247, 247, 247, .88); backdrop-filter: blur(10px); border-bottom: 1px solid var(--line); }
.top-actions { display: flex; gap: 6px; align-items: center; }
.banner { margin: 14px 22px 0; padding: 12px 16px; border-radius: 10px; background: #fff7ee; border: 1px solid #f0d8bd; color: #7a4e22; display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.wrap { padding: 16px 22px 24px; display: grid; gap: 16px; max-width: 1500px; margin: 0 auto; }

/* بطاقات */
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; box-shadow: var(--shadow); min-width: 0; }
.card-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 12px; flex-wrap: wrap; }
.card-head h3 { font-size: 15px; display: flex; align-items: center; gap: 8px; }

@keyframes spin { to { transform: rotate(360deg); } }
.pulse { width: 8px; height: 8px; border-radius: 50%; background: var(--ok); display: inline-block; position: relative; flex: none; }
.pulse::after { content: ''; position: absolute; inset: 0; border-radius: 50%; background: inherit; animation: ping 1.6s ease-out infinite; }
@keyframes ping { from { transform: scale(1); opacity: .7; } to { transform: scale(3); opacity: 0; } }
@keyframes flash { 0% { box-shadow: 0 0 0 2px var(--copper), 0 0 22px color-mix(in srgb, var(--copper) 45%, transparent); } 100% { box-shadow: var(--shadow); } }
.seg { display: inline-flex; background: var(--sunk); border-radius: 8px; padding: 3px; gap: 2px; }
.seg button { border: 0; background: transparent; padding: 4px 11px; border-radius: 6px; cursor: pointer; font-size: 12.5px; color: var(--muted); }
.seg button.on { background: var(--card); color: var(--ink); box-shadow: 0 1px 2px rgba(0, 0, 0, .08); }
.chip { display: inline-flex; align-items: center; gap: 4px; padding: 1px 8px; border-radius: 20px; background: var(--sunk); font-size: 11.5px; color: var(--muted); white-space: nowrap; }
.chip.sev { background: color-mix(in srgb, var(--sc) 14%, #fff); color: var(--sc); font-weight: 600; }
.chip.ai { background: #f3ece5; color: var(--copper); font-weight: 600; }
.chip.ref { background: #eef2f1; color: var(--ink); font-family: ui-monospace, Menlo, monospace; font-size: 11px; direction: ltr; cursor: pointer; }
.chip.ref:hover { background: #e2e9e7; }
.empty { text-align: center; color: var(--faint); padding: 40px 10px; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chips button { border: 1px dashed var(--line2); background: transparent; border-radius: 20px; padding: 3px 11px; font-size: 12px; cursor: pointer; color: var(--muted); }
.chips button:hover { border-color: var(--copper); color: var(--copper); }
.modal { position: fixed; inset: 0; z-index: 50; background: rgba(26, 43, 39, .35); backdrop-filter: blur(3px); display: grid; place-items: center; padding: 16px; animation: fade .2s; }
@keyframes fade { from { opacity: 0; } }
.modal-card { width: min(760px, 100%); max-height: 92vh; overflow: auto; background: var(--card); border-radius: 16px; padding: 22px; box-shadow: 0 30px 80px -20px rgba(0, 0, 0, .35); animation: rise .25s; }
.modal-card.narrow { width: min(420px, 100%); }
@keyframes rise { from { transform: translateY(14px); opacity: 0; } }
.modal-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 14px; }
.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--line); margin-bottom: 16px; flex-wrap: wrap; }
.tabs button { border: 0; background: none; padding: 8px 12px; cursor: pointer; color: var(--muted); border-bottom: 2px solid transparent; margin-bottom: -1px; }
.tabs button.on { color: var(--ink); border-color: var(--copper); font-weight: 600; }
.note { font-size: 12.5px; color: var(--muted); background: var(--sunk); border-radius: 8px; padding: 9px 12px; }
.result { font-size: 13px; padding: 9px 12px; border-radius: 8px; white-space: pre-wrap; }
.result.ok { background: #ecf7f0; color: #1d6b40; } .result.bad { background: #fdecea; color: #a23224; }
table.t { width: 100%; border-collapse: collapse; font-size: 13px; }
table.t th, table.t td { text-align: start; padding: 7px 6px; border-bottom: 1px solid var(--sunk); }
table.t th { color: var(--muted); font-weight: 500; font-size: 12px; }
.row-end { display: flex; gap: 8px; justify-content: flex-end; flex-wrap: wrap; }
.toasts { position: fixed; bottom: 50px; left: 50%; transform: translateX(-50%); z-index: 60; display: grid; gap: 8px; }
.toast { background: var(--ink); color: var(--bg); padding: 10px 16px; border-radius: 10px; box-shadow: var(--shadow); animation: rise .25s; max-width: 90vw; }
.toast.bad { background: var(--s4); }
