/* لوحة منصات أجواد — Ajwwad purple, calm surfaces, RTL. */
:root {
    --p: #4A148C;
    --p-dark: #3A0F70;
    --p-soft: #F3EFFA;
    --p-line: #DDD6FE;
    --page: #F5F3FB;
    --card: #FFFFFF;
    --line: #ECE9F2;
    --text: #1F1B2D;
    --muted: #6B7280;
    --ok-bg: #D1FAE5; --ok: #065F46;
    --warn-bg: #FEF3C7; --warn: #92400E;
    --bad-bg: #FFE4E6; --bad: #BE123C;
    --info-bg: #E0F2FE; --info: #0369A1;
    --grey-bg: #F3F4F6; --grey: #4B5563;
    --radius: 14px;
    --shadow: 0 1px 2px rgba(31, 27, 45, .04), 0 4px 16px rgba(74, 20, 140, .05);
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
    margin: 0;
    font-family: 'IBM Plex Sans Arabic', system-ui, -apple-system, 'Segoe UI', Tahoma, sans-serif;
    font-size: 16px; line-height: 1.7; color: var(--text); background: var(--page);
}
a { color: var(--p); text-decoration: none; }
a:hover { color: var(--p-dark); text-decoration: underline; }
h1 { font-size: 26px; font-weight: 600; margin: 0; line-height: 1.4; }
h2 { font-size: 20px; font-weight: 600; margin: 0 0 14px; }
h3 { font-size: 17px; font-weight: 600; margin: 0 0 10px; }
p { margin: 0 0 12px; }
small, .muted { color: var(--muted); font-size: 14px; }
code, .ltr { direction: ltr; unicode-bidi: isolate; }
code { font-family: ui-monospace, Consolas, monospace; font-size: 13px; background: var(--grey-bg); padding: 1px 6px; border-radius: 6px; }

/* ---- Header ---- */
.top {
    background: linear-gradient(135deg, #4A148C 0%, #5B1FA6 60%, #6D28D9 100%);
    color: #fff;
}
.top-in { max-width: 1180px; margin: 0 auto; padding: 0 16px; height: 66px; display: flex; align-items: center; gap: 22px; }
.top .brand { display: flex; align-items: center; gap: 12px; color: #fff; font-weight: 600; font-size: 16px; white-space: nowrap; }
.top .brand:hover { text-decoration: none; }
.top .brand img { height: 30px; width: auto; }
.top .brand span { opacity: .9; border-inline-start: 1px solid rgba(255,255,255,.35); padding-inline-start: 12px; }
.top nav { display: flex; gap: 4px; flex: 1; }
.top nav a { color: rgba(255,255,255,.85); font-size: 15px; font-weight: 500; padding: 8px 14px; border-radius: 10px; }
.top nav a:hover, .top nav a.on { color: #fff; background: rgba(255,255,255,.14); text-decoration: none; }
.top form { margin: 0; }
.top .out { background: none; border: 0; color: rgba(255,255,255,.85); font: inherit; font-size: 14px; cursor: pointer; padding: 8px 10px; border-radius: 10px; }
.top .out:hover { background: rgba(255,255,255,.14); color: #fff; }

.wrap { max-width: 1180px; margin: 0 auto; padding: 26px 16px 60px; }
.head { display: flex; align-items: center; justify-content: space-between; gap: 14px; flex-wrap: wrap; margin-bottom: 20px; }
.head p { margin: 4px 0 0; color: var(--muted); }
.actions { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.actions form { margin: 0; }

/* ---- Cards ---- */
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); padding: 22px; margin-bottom: 18px; }
.card.flush { padding: 0; overflow: hidden; }
.card.flush > h2 { padding: 18px 22px 0; }
.grid { display: grid; gap: 16px; }
.grid-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.grid-3 { grid-template-columns: 2fr 1fr; }

.stats { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 14px; margin-bottom: 18px; }
.stat { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px 18px; box-shadow: var(--shadow); color: var(--text); display: block; }
.stat:hover { text-decoration: none; border-color: var(--p-line); }
.stat.on { border-color: var(--p); box-shadow: 0 0 0 2px var(--p-soft); }
.stat b { display: block; font-size: 28px; font-weight: 600; line-height: 1.2; }
.stat span { color: var(--muted); font-size: 14px; }
.stat i { display: inline-block; width: 8px; height: 8px; border-radius: 50%; margin-inline-end: 6px; vertical-align: middle; }

/* ---- Buttons ---- */
.btn {
    display: inline-flex; align-items: center; justify-content: center; gap: 6px;
    font: inherit; font-size: 15px; font-weight: 500; line-height: 1.4;
    padding: 9px 18px; border-radius: 10px; border: 1px solid transparent; cursor: pointer;
    background: var(--p); color: #fff; white-space: nowrap;
}
.btn:hover { background: var(--p-dark); color: #fff; text-decoration: none; }
.btn.light { background: var(--p-soft); color: var(--p); }
.btn.light:hover { background: #E9E1F7; }
.btn.ghost { background: #fff; color: var(--text); border-color: var(--line); }
.btn.ghost:hover { border-color: var(--p-line); color: var(--p); }
.btn.danger { background: #fff; color: var(--bad); border-color: #FBCFE8; }
.btn.danger:hover { background: var(--bad-bg); }
.btn.sm { font-size: 14px; padding: 6px 12px; }
.btn[disabled] { opacity: .55; cursor: wait; }

/* ---- Pills ---- */
.pill { display: inline-flex; align-items: center; gap: 5px; font-size: 13px; font-weight: 500; padding: 2px 10px; border-radius: 999px; white-space: nowrap; }
.pill.ok { background: var(--ok-bg); color: var(--ok); }
.pill.outdated, .pill.warning { background: var(--warn-bg); color: var(--warn); }
.pill.attention, .pill.silent, .pill.failed { background: var(--bad-bg); color: var(--bad); }
.pill.pending, .pill.running, .pill.new_order { background: var(--info-bg); color: var(--info); }
.pill.manual, .pill.rolled_back { background: var(--grey-bg); color: var(--grey); }
.pill.brand { background: var(--p-soft); color: var(--p); }

/* ---- Table ---- */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 15px; }
th { text-align: start; font-weight: 500; color: var(--muted); font-size: 14px; padding: 12px 16px; border-bottom: 1px solid var(--line); background: #FBFAFE; white-space: nowrap; }
td { padding: 13px 16px; border-bottom: 1px solid var(--line); vertical-align: middle; }
tr:last-child td { border-bottom: 0; }
td .name { font-weight: 600; color: var(--text); }
td .url { display: block; color: var(--muted); font-size: 13px; direction: ltr; text-align: end; unicode-bidi: isolate; }
.empty { padding: 40px 20px; text-align: center; color: var(--muted); }

/* ---- Forms ---- */
.field { margin-bottom: 16px; }
.field label { display: block; font-weight: 500; font-size: 15px; margin-bottom: 6px; }
.field .hint { display: block; color: var(--muted); font-size: 13px; margin-top: 5px; }
input[type=text], input[type=email], input[type=password], input[type=url], input[type=search], input[type=number], input[type=date], select, textarea {
    width: 100%; font: inherit; font-size: 16px; color: var(--text);
    padding: 10px 14px; border: 1px solid #DCD7E6; border-radius: 10px; background: #fff;
}
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--p); box-shadow: 0 0 0 3px var(--p-soft); }
input[type=file] { font: inherit; font-size: 15px; }
textarea { min-height: 90px; resize: vertical; }
.check { display: flex; align-items: center; gap: 8px; font-size: 15px; }
.search { display: flex; gap: 8px; }
.search input { max-width: 280px; }

/* ---- Alerts ---- */
.alert { border-radius: 12px; padding: 12px 16px; margin-bottom: 18px; font-size: 15px; }
.alert.ok { background: var(--ok-bg); color: var(--ok); }
.alert.bad { background: var(--bad-bg); color: var(--bad); }
.alert.info { background: var(--p-soft); color: var(--p); border: 1px solid var(--p-line); }
.alert ul { margin: 0; padding-inline-start: 18px; }

.token-box { display: flex; gap: 8px; align-items: stretch; margin-top: 10px; }
.token-box textarea { direction: ltr; text-align: left; font-family: ui-monospace, Consolas, monospace; font-size: 13px; min-height: 76px; word-break: break-all; }

/* ---- Facts / log ---- */
.facts { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 0; margin: 0; }
.facts div { padding: 12px 0; border-bottom: 1px dashed var(--line); }
.facts dt { color: var(--muted); font-size: 13px; }
.facts dd { margin: 2px 0 0; font-weight: 500; }
.log { list-style: none; margin: 0; padding: 0; }
.log li { display: flex; gap: 12px; padding: 10px 0; border-bottom: 1px dashed var(--line); }
.log li:last-child { border-bottom: 0; }
.log time { color: var(--muted); font-size: 13px; direction: ltr; min-width: 64px; padding-top: 2px; }
.log .dot { width: 10px; height: 10px; border-radius: 50%; margin-top: 8px; flex: none; background: var(--p-line); }
.log .success .dot { background: #10B981; }
.log .warning .dot { background: #F59E0B; }
.log .error .dot { background: #E11D48; }
.bar { display: flex; height: 10px; border-radius: 999px; overflow: hidden; background: var(--grey-bg); margin: 8px 0 12px; }
.bar span { display: block; height: 100%; }
.legend { display: flex; flex-direction: column; gap: 6px; font-size: 14px; }
.legend div { display: flex; justify-content: space-between; }

/* ---- Auth pages ---- */
.auth { min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 30px 16px;
    background: radial-gradient(1100px 500px at 90% -10%, #EDE4FB 0%, transparent 60%), var(--page); }
.auth .box { width: 100%; max-width: 460px; }
.auth .box.wide { max-width: 640px; }
.auth .logo { text-align: center; margin-bottom: 18px; }
.auth .logo img { height: 46px; }
.auth h1 { text-align: center; margin-bottom: 4px; }
.auth .sub { text-align: center; color: var(--muted); margin-bottom: 20px; }
.auth .btn { width: 100%; padding: 11px; font-size: 17px; }
.sep { border: 0; border-top: 1px dashed var(--line); margin: 20px 0; }

/* ---- Phones / tablets ---- */
@media (max-width: 991.98px) {
    .stats { grid-template-columns: repeat(3, minmax(0, 1fr)); }
    .grid-3 { grid-template-columns: 1fr; }
    .facts { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    /* Sites table becomes one card per row */
    table.stack thead { display: none; }
    table.stack, table.stack tbody, table.stack tr, table.stack td { display: block; width: 100%; }
    table.stack tr { padding: 12px 16px; border-bottom: 1px solid var(--line); }
    table.stack td { border: 0; padding: 4px 0; display: flex; justify-content: space-between; gap: 12px; align-items: center; }
    table.stack td::before { content: attr(data-label); color: var(--muted); font-size: 13px; flex: none; }
    table.stack td.main { display: block; }
    table.stack td.main::before { content: none; }
    table.stack td .url { text-align: start; }
}
@media (max-width: 767.98px) {
    .top-in { height: auto; flex-wrap: wrap; padding: 10px 16px; gap: 8px 14px; }
    .top .brand span { display: none; }
    .top nav { order: 3; flex-basis: 100%; overflow-x: auto; }
    .top nav a { padding: 6px 10px; font-size: 14px; }
    .top form { margin-inline-start: auto; }
    .stats { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .grid-2 { grid-template-columns: 1fr; }
    .facts { grid-template-columns: 1fr; }
    .card { padding: 18px 16px; }
    h1 { font-size: 22px; }
    .search { width: 100%; }
    .search input { max-width: none; }
    .head .actions { width: 100%; }
    .token-box { flex-direction: column; }
}

/* Subscriptions (2.3) */
.pill.sub-active { background: var(--ok-bg); color: var(--ok); }
.pill.sub-expiring, .pill.sub-grace { background: var(--warn-bg); color: var(--warn); }
.pill.sub-expired, .pill.sub-suspended { background: var(--bad-bg); color: var(--bad); }
.pill.sub-none { background: var(--grey-bg); color: var(--grey); }
.sub-head { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin-bottom: 6px; }
.sub-head b { font-size: 18px; }
.inline-fields { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 0 12px; }
details.box { border: 1px solid var(--line); border-radius: 10px; padding: 10px 14px; margin-top: 12px; }
details.box summary { cursor: pointer; font-weight: 500; }
details.box[open] summary { margin-bottom: 10px; }
.amount.neg { color: var(--bad); }
@media (max-width: 600px) { .inline-fields { grid-template-columns: 1fr; } }
dd.ltr { text-align: right; }
.pay-row { padding: 10px 0; border-bottom: 1px dashed var(--line); }
.pay-row:last-child { border-bottom: 0; }
.pay-row small { display: block; margin-top: 2px; }
.alert.warn { background: var(--warn-bg); color: var(--warn); }
