/* الواجهات بالعربي ومن اليمين للشمال. مفيش CSS أو JS جوه الصفحات (CSP صارم). */
:root {
    --bg: #f5f6f8;
    --panel: #fff;
    --text: #1d2330;
    --muted: #667085;
    --line: #e3e6eb;
    --accent: #1f5eff;
    --ok: #127a3a;
    --warn: #9a6200;
    --err: #b42318;
    --radius: 10px;
    font-family: "Segoe UI", Tahoma, "Noto Sans Arabic", Arial, sans-serif;
}

* { box-sizing: border-box; }

body { margin: 0; background: var(--bg); color: var(--text); line-height: 1.6; }

h1 { font-size: 1.4rem; margin: 0 0 .5rem; }
h2 { font-size: 1.1rem; margin: 1.5rem 0 .5rem; }

a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }

.topbar {
    display: flex; align-items: center; justify-content: space-between; gap: 1rem;
    padding: .75rem 1.25rem; background: var(--panel); border-bottom: 1px solid var(--line);
}
.topbar nav { display: flex; align-items: center; gap: 1rem; }

.page { max-width: 1100px; margin: 0 auto; padding: 1.5rem 1rem; }
.auth { min-height: 100vh; display: grid; place-items: center; padding: 1rem; }

.card {
    width: 100%; max-width: 420px; background: var(--panel); border: 1px solid var(--line);
    border-radius: var(--radius); padding: 1.5rem;
}
.page .card { max-width: 520px; }

label { display: block; margin: .9rem 0 .3rem; font-weight: 600; }
input {
    width: 100%; padding: .6rem .7rem; border: 1px solid var(--line); border-radius: 8px;
    font: inherit; background: #fff;
}
input:focus { outline: 2px solid var(--accent); outline-offset: 1px; }

button {
    margin-top: 1.2rem; width: 100%; padding: .65rem; border: 0; border-radius: 8px;
    background: var(--accent); color: #fff; font: inherit; font-weight: 600; cursor: pointer;
}
button.link { margin: 0; width: auto; padding: 0; background: none; color: var(--accent); font-weight: 400; }
form.inline { display: inline; }

.muted { color: var(--muted); }
.small { font-size: .85rem; }

.notice { padding: .6rem .8rem; border-radius: 8px; background: #eef3ff; margin: .75rem 0; }
.notice ul { margin: 0; padding-inline-start: 1.1rem; }
.notice-ok { background: #e8f6ee; color: var(--ok); }
.notice-warn { background: #fff5e0; color: var(--warn); }
.notice-error { background: #fdecea; color: var(--err); }

.secret {
    font-family: ui-monospace, Consolas, monospace; font-size: 1.1rem; letter-spacing: .08em;
    background: var(--bg); padding: .6rem; border-radius: 8px; text-align: center; word-break: break-all;
}
code { word-break: break-all; }

.facts { display: grid; grid-template-columns: max-content 1fr; gap: .3rem 1rem; }
.facts dt { color: var(--muted); }
.facts dd { margin: 0; }

.grid { width: 100%; border-collapse: collapse; background: var(--panel); border: 1px solid var(--line); }
.grid th, .grid td { padding: .55rem .7rem; border-bottom: 1px solid var(--line); text-align: start; }
.grid th { background: #fafbfc; font-weight: 600; }

.chips { display: flex; flex-wrap: wrap; gap: .5rem; list-style: none; padding: 0; }
.chips li { background: var(--panel); border: 1px solid var(--line); border-radius: 999px; padding: .2rem .8rem; }

.status { font-size: .85rem; padding: .1rem .5rem; border-radius: 6px; background: var(--bg); }
.status-active { color: var(--ok); }
.status-trial, .status-grace { color: var(--warn); }
.status-suspended, .status-trial_expired, .status-cancelled { color: var(--err); }

@media (max-width: 640px) {
    .topbar { flex-direction: column; align-items: flex-start; }
    .grid { display: block; overflow-x: auto; }
}

.card.wide { max-width: 760px; }
textarea, select {
    width: 100%; padding: .6rem .7rem; border: 1px solid var(--line); border-radius: 8px;
    font: inherit; background: #fff;
}
.actions { display: flex; gap: .75rem; align-items: center; margin-top: 1.2rem; }
.actions button { margin-top: 0; width: auto; padding: .6rem 1.4rem; }
.button {
    display: inline-block; padding: .55rem 1.2rem; border-radius: 8px; background: var(--accent);
    color: #fff; font-weight: 600;
}
.button:hover { text-decoration: none; opacity: .92; }
.button.secondary { background: var(--bg); color: var(--text); border: 1px solid var(--line); }
.toolbar { display: flex; flex-wrap: wrap; gap: .75rem; align-items: center; justify-content: space-between; margin-bottom: 1rem; }
.row-actions { display: flex; flex-wrap: wrap; gap: .6rem; font-size: .9rem; }
.grid td.value { max-width: 280px; overflow-wrap: anywhere; font-size: .9rem; }
.thumb { width: 40px; height: 40px; object-fit: cover; border-radius: 6px; background: var(--bg); }
.check { display: flex; gap: .5rem; align-items: center; font-weight: 400; }
.check input { width: auto; }
.status-disabled { color: var(--warn); }
.status-archived { color: var(--muted); }
fieldset.cost { border: 1px solid var(--line); border-radius: var(--radius); padding: 1rem; margin-top: 1rem; }
fieldset.cost legend { font-weight: 600; padding: 0 .4rem; }
.cost-block { border-top: 1px dashed var(--line); margin-top: .8rem; padding-top: .4rem; }
.cost-block h3 { font-size: 1rem; margin: .4rem 0; }
button.secondary-button { background: var(--bg); color: var(--text); border: 1px solid var(--line); width: auto; padding: .55rem 1.2rem; }
fieldset.settings { border: 0; padding: 0; margin: 0; min-width: 0; }
.page .card.wide { margin-bottom: 1.25rem; }
.cols { display: grid; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); gap: 0 1rem; }
input[type="color"] { height: 2.5rem; padding: .2rem; }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }
form.toolbar select { width: auto; min-width: 180px; }
form.toolbar button { margin-top: 0; }
fieldset.checks { border: 1px solid var(--line); border-radius: var(--radius); padding: .6rem 1rem; margin-top: 1rem; max-height: 360px; overflow-y: auto; }
fieldset.checks legend { font-weight: 600; padding: 0 .4rem; }
select[multiple] { min-height: 4rem; }
.pager { display: flex; gap: 1rem; align-items: center; justify-content: center; margin: 1rem 0; }
del { text-decoration: line-through; }
.labels { display: grid; grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); gap: .5rem; }
.label { border: 1px dashed var(--line); border-radius: 6px; padding: .5rem; display: flex; flex-direction: column; gap: .15rem; background: var(--panel); font-size: .85rem; }
.label strong { font-family: ui-monospace, Consolas, monospace; font-size: 1rem; letter-spacing: .05em; }
@media print {
    .topbar, .no-print, .notice { display: none !important; }
    body { background: #fff; }
    .page { padding: 0; max-width: none; }
    .label { break-inside: avoid; border-color: #999; }
}
.tabs { display: flex; gap: .25rem; border-bottom: 1px solid var(--line); margin-bottom: 1rem; }
.tabs a { padding: .5rem 1rem; border: 1px solid transparent; border-bottom: 0; border-radius: 8px 8px 0 0; color: var(--muted); }
.tabs a.active { background: var(--panel); border-color: var(--line); color: var(--text); font-weight: 600; }
form.toolbar input { width: auto; }
pre.sample { background: var(--bg); padding: .6rem; border-radius: 8px; overflow-x: auto; font-size: .85rem; }
.split { display: grid; grid-template-columns: 1fr 1fr; gap: 1.25rem; align-items: start; }
@media (max-width: 900px) { .split { grid-template-columns: 1fr; } }

/* جداول عريضة (تقرير المعاملات) بتتسحب أفقي بدل ما تكسر الصفحة */
.table-scroll { overflow-x: auto; }
