@charset "utf-8";

/* ============================================================
   نظام المحاسبة السحابي — erp.supeer.net
   واجهة عربية RTL بلغة تصميم دفتر الأستاذ
   ============================================================ */

:root {
  --paper:      #E7EDE4;
  --paper-deep: #DCE4D8;
  --sheet:      #FCFBF7;
  --ink:        #14313A;
  --ink-soft:   #4A6670;
  --ink-faint:  #7E949B;
  --rule:       #C4D0C6;
  --rule-firm:  #9EB1A3;
  --debit:      #1D6B55;
  --debit-wash: #E2EDE7;
  --credit:     #9E3D2C;
  --credit-wash:#F4E5E0;
  --brass:      #B8902F;
  --brass-wash: #F6EEDA;

  --radius: 3px;
  --radius-lg: 6px;
  --gutter: clamp(1rem, 3vw, 2rem);
  --ease: cubic-bezier(0.33, 0.9, 0.35, 1);

  --font: "IBM Plex Sans Arabic", "Segoe UI", Tahoma, sans-serif;
  --font-fig: "IBM Plex Mono", Consolas, monospace;

  --side-w: 208px;
  --top-h: 58px;
}

*, *::before, *::after { box-sizing: border-box; }

html { font-size: 16px; -webkit-text-size-adjust: 100%; }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { transition-duration: 0.001ms !important; animation-duration: 0.001ms !important; }
}

body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font-family: var(--font);
  line-height: 1.65;
  -webkit-font-smoothing: antialiased;
}

h1, h2, h3, h4 { margin: 0; font-weight: 600; line-height: 1.25; }
p { margin: 0; }
ul, ol { margin: 0; padding: 0; list-style: none; }
a { color: var(--debit); text-underline-offset: 3px; }
a:hover { color: var(--ink); }
button { font: inherit; color: inherit; }
svg { display: block; }

:where(a, button, input, select, textarea, summary, [tabindex]):focus-visible {
  outline: 2px solid var(--debit);
  outline-offset: 2px;
  border-radius: 2px;
}

.fig, .amt, .num {
  font-family: var(--font-fig);
  font-variant-numeric: tabular-nums;
  font-feature-settings: "tnum" 1;
  letter-spacing: -0.02em;
}

.skip {
  position: absolute; inset-block-start: -100px; inset-inline-start: 1rem;
  z-index: 200; background: var(--ink); color: var(--sheet);
  padding: 0.6rem 1rem; border-radius: var(--radius);
}
.skip:focus { inset-block-start: 0.5rem; color: var(--sheet); }

/* ---------- الشريط العلوي ---------- */

.topbar {
  position: sticky; inset-block-start: 0; z-index: 60;
  display: flex; align-items: center; gap: 1rem;
  min-height: var(--top-h);
  padding: 0 var(--gutter);
  padding-block-start: env(safe-area-inset-top, 0px);
  background: var(--sheet);
  border-block-end: 1px solid var(--rule-firm);
}

.brand {
  display: inline-flex; align-items: center; gap: 0.55rem;
  color: var(--ink); text-decoration: none;
  font-weight: 600; font-size: 1.02rem;
  margin-inline-end: auto;
}
.brand svg { width: 26px; height: 26px; flex: none; }

.topbar__user { display: flex; align-items: center; gap: 0.5rem; }
.who { display: flex; flex-direction: column; line-height: 1.25; margin-inline-end: 0.5rem; text-align: start; }
.who b { font-size: 0.85rem; font-weight: 500; }
.who em { font-style: normal; font-size: 0.7rem; color: var(--ink-faint); }

@media (max-width: 640px) { .who { display: none; } }

.burger {
  display: none; background: transparent;
  border: 1px solid var(--rule-firm); border-radius: var(--radius);
  padding: 0.4rem 0.55rem; cursor: pointer;
}
.burger span { display: block; width: 16px; height: 1.5px; background: var(--ink); margin: 3.5px 0; }

/* ---------- الهيكل ---------- */

.shell { display: grid; grid-template-columns: var(--side-w) minmax(0, 1fr); align-items: start; }

.side {
  position: sticky;
  inset-block-start: calc(var(--top-h) + env(safe-area-inset-top, 0px));
  padding: 1.2rem 0.8rem;
  border-inline-end: 1px solid var(--rule);
  min-height: calc(100vh - var(--top-h));
}
.side a {
  display: block; padding: 0.55rem 0.75rem;
  color: var(--ink-soft); text-decoration: none;
  font-size: 0.9rem; border-radius: var(--radius);
  border-inline-start: 2px solid transparent;
  transition: background 0.15s var(--ease), color 0.15s var(--ease);
}
.side a:hover { background: var(--paper-deep); color: var(--ink); }
.side a[aria-current="page"] {
  background: var(--sheet); color: var(--ink); font-weight: 500;
  border-inline-start-color: var(--debit);
}

.main { padding: var(--gutter); min-width: 0; }
.main--plain { max-width: 520px; margin-inline: auto; padding-block: clamp(2rem, 8vh, 5rem); }
body.plain .main--plain { min-height: 70vh; }

@media (max-width: 860px) {
  .burger { display: block; }
  .shell { grid-template-columns: 1fr; }
  .side {
    position: fixed; inset-block-start: calc(var(--top-h) + env(safe-area-inset-top, 0px));
    inset-inline-start: 0; width: min(80vw, var(--side-w));
    background: var(--sheet); z-index: 55; min-height: auto;
    max-height: calc(100vh - var(--top-h)); overflow-y: auto;
    transform: translateX(110%); transition: transform 0.25s var(--ease);
    box-shadow: -12px 0 30px -22px rgba(20,49,58,.6);
  }
  html[dir="rtl"] .side { transform: translateX(110%); }
  .side[data-open="true"] { transform: none; }
}

/* ---------- البطاقات والعناوين ---------- */

.card {
  background: var(--sheet);
  border: 1px solid var(--rule-firm);
  border-radius: var(--radius-lg);
  padding: 1.3rem 1.25rem;
}
.card + .card { margin-block-start: 1.2rem; }

.pagehead {
  display: flex; flex-wrap: wrap; gap: 0.8rem 1.2rem;
  align-items: center; justify-content: space-between;
  margin-block-end: 1.3rem;
}
.pagehead h1 { font-size: 1.45rem; }
.pagehead p { color: var(--ink-soft); font-size: 0.88rem; margin-block-start: 0.3rem; }

.h2 { font-size: 1.15rem; }
.h3 { font-size: 1rem; }
.muted { color: var(--ink-soft); font-size: 0.88rem; }
.tiny { font-size: 0.78rem; color: var(--ink-faint); }
.mt-1 { margin-block-start: 1rem; }
.mt-2 { margin-block-start: 1.6rem; }
.right { text-align: end; }
.center { text-align: center; }

/* ---------- الأزرار ---------- */

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 0.4rem;
  padding: 0.6rem 1.1rem; border-radius: var(--radius);
  border: 1px solid var(--ink); background: var(--ink); color: var(--sheet);
  font-size: 0.87rem; font-weight: 500; text-decoration: none; cursor: pointer;
  transition: background 0.15s var(--ease), border-color 0.15s var(--ease);
}
.btn:hover { background: var(--debit); border-color: var(--debit); color: var(--sheet); }
.btn--ghost { background: transparent; color: var(--ink); border-color: var(--rule-firm); }
.btn--ghost:hover { background: var(--paper-deep); color: var(--ink); border-color: var(--rule-firm); }
.btn--danger { background: var(--credit); border-color: var(--credit); }
.btn--danger:hover { background: #86321f; border-color: #86321f; }
.btn--sm { padding: 0.36rem 0.7rem; font-size: 0.78rem; }
.btn--wide { width: 100%; }
.btn[disabled] { opacity: 0.5; cursor: not-allowed; }

.btn-row { display: flex; flex-wrap: wrap; gap: 0.6rem; }

/* ---------- الرسائل ---------- */

.flash {
  border-radius: var(--radius); padding: 0.8rem 1rem;
  margin-block-end: 1.1rem; font-size: 0.88rem;
  border: 1px solid var(--rule-firm); background: var(--sheet);
}
.flash--ok    { border-color: var(--debit);  background: var(--debit-wash); }
.flash--error { border-color: var(--credit); background: var(--credit-wash); }
.flash--warn  { border-color: var(--brass);  background: var(--brass-wash); }

/* ---------- النماذج ---------- */

.form { display: grid; gap: 1rem; }
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 1rem; }
.grid-3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 1rem; }
@media (max-width: 720px) { .grid-2, .grid-3 { grid-template-columns: 1fr; } }

.field label { display: block; font-size: 0.84rem; color: var(--ink-soft); margin-block-end: 0.35rem; }
.field label span.req { color: var(--credit); }

.field input, .field select, .field textarea, .inp {
  width: 100%; font: inherit; font-size: 0.9rem;
  padding: 0.6rem 0.7rem;
  border: 1px solid var(--rule-firm); border-radius: var(--radius);
  background: var(--sheet); color: var(--ink);
  transition: border-color 0.15s var(--ease);
}
.field input:focus, .field select:focus, .field textarea:focus { border-color: var(--debit); }
.field textarea { min-height: 90px; resize: vertical; }
.field input[type="number"], .field input.amt { font-family: var(--font-fig); text-align: end; }
.hint { font-size: 0.76rem; color: var(--ink-faint); margin-block-start: 0.3rem; }
.err  { font-size: 0.78rem; color: var(--credit); margin-block-start: 0.3rem; }

.errors { border: 1px solid var(--credit); background: var(--credit-wash);
  border-radius: var(--radius); padding: 0.8rem 1rem; font-size: 0.85rem; }
.errors li { padding-block: 0.15rem; }

/* ---------- الجداول ---------- */

.table-wrap { overflow-x: auto; border: 1px solid var(--rule-firm); border-radius: var(--radius-lg); background: var(--sheet); }

table.tbl { width: 100%; border-collapse: collapse; font-size: 0.87rem; }
table.tbl th, table.tbl td { padding: 0.62rem 0.8rem; border-block-end: 1px solid var(--rule); text-align: start; }
table.tbl thead th {
  background: var(--paper-deep); font-size: 0.76rem; font-weight: 600;
  color: var(--ink-soft); border-block-end: 1px solid var(--rule-firm);
  position: sticky; inset-block-start: 0;
}
table.tbl tbody tr:last-child td { border-block-end: 0; }
table.tbl tbody tr:hover { background: color-mix(in srgb, var(--paper) 45%, var(--sheet)); }
table.tbl td.amt, table.tbl th.amt { text-align: end; }
table.tbl tfoot td { background: var(--paper-deep); font-weight: 600; border-block-start: 1px solid var(--rule-firm); }

.debit  { color: var(--debit); }
.credit { color: var(--credit); }

.empty { padding: 2.2rem 1rem; text-align: center; color: var(--ink-faint); font-size: 0.88rem; }
.empty b { display: block; color: var(--ink-soft); font-weight: 500; margin-block-end: 0.3rem; }

/* ---------- الشارات ---------- */

.pill {
  display: inline-block; font-size: 0.72rem; font-weight: 500;
  padding: 0.12rem 0.5rem; border-radius: 2px; border: 1px solid var(--rule-firm);
  color: var(--ink-soft); background: var(--paper);
}
.pill--ok    { color: var(--debit);  border-color: var(--debit);  background: var(--debit-wash); }
.pill--warn  { color: var(--brass);  border-color: var(--brass);  background: var(--brass-wash); }
.pill--off   { color: var(--credit); border-color: var(--credit); background: var(--credit-wash); }

/* ---------- بطاقات الأرقام ---------- */

.kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 1rem; }
.kpi { background: var(--sheet); border: 1px solid var(--rule-firm); border-radius: var(--radius-lg); padding: 1.1rem 1.1rem 1.2rem; }
.kpi h3 { font-size: 0.78rem; font-weight: 500; color: var(--ink-faint); }
.kpi .num { font-size: 1.5rem; font-weight: 500; margin-block-start: 0.4rem; line-height: 1.1; }
.kpi .tiny { margin-block-start: 0.3rem; }

/* ---------- محرر القيد ---------- */

.jrow td { padding: 0.4rem 0.5rem; }
.jrow input, .jrow select { padding: 0.45rem 0.55rem; font-size: 0.85rem; }
.balance-bar {
  display: flex; flex-wrap: wrap; gap: 0.6rem 1.6rem; align-items: center;
  margin-block-start: 1rem; padding: 0.8rem 1rem;
  border: 1px solid var(--rule-firm); border-radius: var(--radius);
  background: var(--paper-deep); font-size: 0.88rem;
}
.balance-bar b { font-family: var(--font-fig); }
.balance-bar[data-balanced="true"]  { border-color: var(--debit);  background: var(--debit-wash); }
.balance-bar[data-balanced="false"] { border-color: var(--credit); background: var(--credit-wash); }

.linkbtn {
  background: none; border: 0; padding: 0.2rem 0.4rem; cursor: pointer;
  color: var(--credit); font-size: 0.8rem; text-decoration: underline;
}

/* ---------- تسجيل الدخول ---------- */

.auth-card {
  background: var(--sheet); border: 1px solid var(--rule-firm);
  border-radius: var(--radius-lg); padding: 1.8rem 1.6rem;
  box-shadow: 0 18px 34px -28px rgba(20,49,58,.55);
}
.auth-brand { display: flex; align-items: center; gap: 0.6rem; margin-block-end: 1.4rem; }
.auth-brand svg { width: 34px; height: 34px; }
.auth-brand b { font-size: 1.08rem; font-weight: 600; }

/* ---------- تذييل ---------- */

.pagefoot {
  display: flex; justify-content: space-between; gap: 1rem;
  padding: 1rem var(--gutter);
  padding-block-end: calc(1rem + env(safe-area-inset-bottom, 0px));
  border-block-start: 1px solid var(--rule);
  color: var(--ink-faint); font-size: 0.76rem;
}

/* ---------- طباعة ---------- */

@media print {
  .topbar, .side, .pagefoot, .btn, .btn-row, .skip { display: none !important; }
  .shell { display: block; }
  body { background: #fff; }
  .card, .table-wrap { border: 0; }
  table.tbl thead th { background: #eee; position: static; }
}
