/* LWYRUP Theme — هوية Better Call Saul بألوان مريحة للعين
   يُحمّل بعد app.css فيعلو فوقه بدون تعديله.

   الفاتح (افتراضي): ورق عاجي دافئ + ذهبي معتّم.
   الداكن: مبني على قياسات شاشات الداكن الحقيقية في دراسة tasteskill
   (أرضية شبه سوداء #161514 — لا رمادي مزرق، فصل الأسطح بدرجة إضاءة فقط،
   رماديان متباعدان يجتازان 4.5:1، الذهبي للبيانات والحالة المختارة فقط).
   التبديل عبر data-theme الجاهز في التطبيق. */

/* ---------- الوجه الفاتح: ورق دافئ ---------- */
:root {
  --ground: #f3f0e9;
  --surface: #fbf9f4;
  --raised: #ebe7dc;
  --active: #e2ddd0;
  --border: #ddd8ca;
  --rule: #e8e3d6;
  --control: #d7d1c1;
  --text: #383d42;
  --muted: #62666c;
  --faint: #6d685f;
  --accent: #856a12;
  --accent-ink: #fdfbee;
  --primary: #3a3f45;
  --primary-ink: #f4f1ea;
  --positive: #587550;
  --negative: #b54339;
  --warning: #8a6d1f;
  --chart-1: #9c7c1c;
  --chart-2: #587550;
  --chart-3: #b54339;
  --chart-muted: #c9c3b4;
  --grid: var(--rule);
  --axis-ink: var(--muted);
  --ink: var(--text);
  --pill-positive-bg: #e0e8d8; --pill-positive-ink: #3b5233;
  --pill-negative-bg: #f4e0dd; --pill-negative-ink: #8a2f27;
  --pill-warning-bg: #efe8d2;  --pill-warning-ink: #6f5a1b;
  --pill-neutral-bg: #e7e2d5;  --pill-neutral-ink: #4a4a43;
}

/* ---------- الوجه الداكن: عميق ومريح ----------
   أرضية شبه سوداء دافئة؛ الأسطح تعلو بدرجة إضاءة واحدة؛
   الخطوط الهيكلية ٢٢-٣١ مستوى فوق الأرض؛ النص عاجي وليس أبيض ساطع؛
   الرماديان: #b8b4ab للثانوي و #98948c للميتا — متباعدان ومقروءان. */
:root[data-theme="dark"] {
  color-scheme: dark;
  --ground: #161514;
  --surface: #1d1c1a;
  --raised: #262422;
  --active: #2c2a27;
  --border: #2b2927;
  --rule: #232120;
  --control: #3d3a37;
  --text: #f2f1ed;
  --muted: #b8b4ab;
  --faint: #98948c;
  --accent: #E9CB72;
  --accent-ink: #1c1708;
  --primary: #f4f3f0;
  --primary-ink: #161514;
  --positive: #3fc07a;
  --negative: #e5566f;
  --warning: #d9b45c;
  --chart-1: #E9CB72;
  --chart-2: #b8b4ab;
  --chart-3: #e5566f;
  --chart-muted: #3d3a37;
  --grid: #232120;
  --axis-ink: var(--muted);
  --ink: var(--text);
  --pill-positive-bg: #172a1d; --pill-positive-ink: #3fc07a;
  --pill-negative-bg: #2c1a20; --pill-negative-ink: #e5566f;
  --pill-warning-bg: #2a2416;  --pill-warning-ink: #d9b45c;
  --pill-neutral-bg: #262422;  --pill-neutral-ink: #f1efe9;
}

/* إصلاح هيكلي: عرض .app كان يلغي إخفاء [hidden] الافتراضي،
   فيبقى التطبيق مرسوماً (ومقروءاً لقارئات الشاشة) خلف شاشة الدخول. */
[hidden] { display: none !important; }

/* ---------- 3 نقاط (قائمة خيارات المستند في الأرشيف) ---------- */
.row-menu {
  width: 26px; height: 26px;
  display: inline-grid; place-items: center;
  border: 1px solid var(--control); border-radius: 6px;
  background: transparent; color: var(--muted);
  cursor: pointer; font-size: 16px; line-height: 1;
  transition: color var(--t-hover) ease, border-color var(--t-hover) ease, background-color var(--t-hover) ease;
}
.row-menu:hover { color: var(--text); border-color: var(--accent); background: var(--raised); }
.row-menu-pop {
  position: fixed; z-index: 50;
  min-width: 120px;
  background: var(--surface); border: 1px solid var(--border);
  border-radius: 8px; box-shadow: 0 8px 24px rgba(0,0,0,.18);
  padding: 4px; display: grid; gap: 2px;
}
/* td containing the menu must be relative */
td:has(.row-menu) { position: relative; }
.row-menu-pop button {
  border: 0; background: none; font: inherit; font-size: 13px;
  text-align: right; padding: 8px 12px; border-radius: 6px;
  color: var(--text); cursor: pointer; width: 100%;
}
.row-menu-pop button:hover { background: var(--raised); }
.row-menu-pop button.danger { color: var(--negative); }
.row-menu-pop button.danger:hover { background: rgba(217,100,92,.10); }
/* الحاوية relative للـpop */
tr { position: relative; }
.lw-lockup {
  display: inline-flex;
  align-items: center;
  line-height: 1;
}
.lw-word {
  font-family: 'Bodoni Moda', 'Times New Roman', serif;
  font-weight: 800;
  font-size: 16px;
  letter-spacing: -0.01em;
  color: var(--text);
  direction: ltr;
  white-space: nowrap;
}
.lw-ymark {
  display: inline-block;
  height: 0.73em;
  width: 0.70em;
  vertical-align: baseline;
  margin: 0 -0.02em;
  color: var(--accent);
}

/* الشعار في الشريط الجانبي: LWYRUP (لحاله، بدون نص) */
.sidebar .brand {
  flex-direction: column;
  align-items: flex-start;
  gap: 4px;
  padding-bottom: 12px;
}
.sidebar .brand .lw-scales { width: 34px; height: 35px; }
.sidebar .brand .lw-word { font-size: 24px; letter-spacing: -0.01em; }

/* mark الترويسة (م) — محذوف: الشعار يُضاف من قبل المستخدم.
   الترويسة: عنوان + بيانات (بدون عمود mark) */
.letter-doc .doc-head { grid-template-columns: 1fr auto; }

/* علامة مائية (watermark) — شفافية متحكّم بها */
.letter-doc { position: relative; }
.letter-doc::before {
  content: '';
  position: absolute; inset: 0;
  background-image: var(--wmk-url, none);
  background-repeat: no-repeat;
  background-position: center;
  background-size: contain;
  opacity: var(--wmk-opacity, 0);
  pointer-events: none;
  z-index: 0;
}
.letter-doc > * { position: relative; z-index: 1; }

/* تذييل المستند (عنوان، موقع، إلخ) — يُحدّث من الإعدادات */
.letter-doc::after {
  content: var(--doc-footer, "");
  display: block;
  margin-top: auto;
  padding-top: 8px;
  border-top: 0.5px solid #c9c3b6;
  font-size: 9pt;
  color: #7a746a;
  text-align: center;
  white-space: pre-wrap;
  position: relative;
  z-index: 1;
}

:root {
  --doc-accent: #7a5f18;
  --wmk-url: none;
  --wmk-opacity: 0.12;
}

/* بطاقة الدخول أعرض تملأ عمودها أكثر (تقلل فراغ الدرز بين العمودين) */
.login-card { max-width: 460px; }

/* زر خطر (حذف) */
.btn.danger { background: var(--negative); color: #fff; border-color: transparent; }
.btn.danger:hover { filter: brightness(0.92); }

/* حذف صف محفوظ من الأرشيف — زر نصّي (بدلاً من ✕) */
.row-del {
  margin-inline-start: 6px; height: 20px; padding: 0 7px;
  display: inline-flex; align-items: center; vertical-align: middle;
  border: 1px solid var(--control); border-radius: 5px;
  background: transparent; color: var(--faint);
  cursor: pointer; font-size: 11px; font-family: inherit; font-weight: 500;
  line-height: 1;
  transition: color var(--t-hover) ease, border-color var(--t-hover) ease, background-color var(--t-hover) ease;
}
.row-del:hover { color: var(--negative); border-color: var(--negative); background: rgba(217,100,92,.06); }

/* نصوص الدخول الحاملة لمحتوى تُقرأ في 13px — 12px تبقى للأسطر الفرعية فقط */
.login-lockup .sc { font-size: 13px; }
.login-hint { font-size: 13px; }

/* ---------- تبويبات شاشة الدخول: الدخول / إنشاء حساب ---------- */
.auth-tabs {
  display: flex; gap: 4px;
  background: var(--raised); padding: 4px; border-radius: 8px;
  margin-bottom: 22px;
}
.auth-tab {
  flex: 1; border: 0; background: none; font: inherit;
  font-size: 13px; height: 34px; border-radius: 6px;
  color: var(--muted); cursor: pointer;
  transition: background-color var(--t-hover) ease, color var(--t-hover) ease;
}
.auth-tab.active { background: var(--surface); color: var(--text); font-weight: 500; }

/* ---------- شريط تبويبات الإعدادات (خط سفلي كقواعد شاشات التطبيقات) ---------- */
.tabbar {
  display: flex; gap: 2px;
  border-bottom: 1px solid var(--border);
  margin: 18px 0 22px;
}
.tabbar .tab {
  border: 0; background: none; font: inherit;
  padding: 10px 14px; font-size: 13px;
  color: var(--muted); cursor: pointer;
  border-bottom: 2px solid transparent;
  margin-bottom: -1px;
}
.tabbar .tab:hover { color: var(--text); }
.tabbar .tab.active { color: var(--text); border-bottom-color: var(--accent); font-weight: 500; }

/* ---------- المستندات: هوية LWYRUP على الورق الرسمي ----------
   التنسيق والهيكل يبقيان كما هما (عرف المستندات القانونية، والورقة
   بيضاء دائماً كما صمّم الأصل). الذهب مقتصد وهادئ: يظهر فقط في مواضع
   الهوية (الترويسة، الغلاف، عنوان العقد، مربعات الأقسام) بدرجة برونزية
   عميقة #7a5f18 (6:1 على الأبيض) — والترقيم المتكرر (بنود الجداول
   والقوائم) بالحبر نفسه، فلا يصير الذهب نقشاً على كل سطر. */
.letter-doc .doc-head .mk { background: var(--doc-accent, #7a5f18); }
.letter-doc.cover .cov-kicker { color: var(--doc-accent, #7a5f18); }
.letter-doc.cover .cov-party .lab { color: var(--doc-accent, #7a5f18); }
.letter-doc.cover .cov-amount { background: #f8f4e9; border-inline-start-color: var(--doc-accent, #7a5f18); }
.letter-doc .sec.cont .sec-head .meta { color: var(--doc-accent, #7a5f18); }
.letter-doc .sec-head .no { background: var(--doc-accent, #7a5f18); }
.letter-doc .ct-cover .ct-title { color: var(--doc-accent, #7a5f18); }
/* الترقيم المتكرر: حبر — أهدأ وأرسمي */
.letter-doc ol.numList > li::marker { color: #1a1a1a; }
.letter-doc ul.dotList > li::marker { color: #1a1a1a; }
.letter-doc .req-table .no { color: #1a1a1a; }
.letter-doc .ct-table .no { color: #1a1a1a; }

/* ---------- تناسب: sidebar + sheet + delete button + ملء الصفحة ---------- */
:root {
  --sidebar-width: 240px;
  --sheet-inset: 4px;
  --nav-row: 36px;
}
.canvas { padding: 20px; }

/* ---------- حذف صف محفوظ من الأرشيف — زر نصّي (بدلاً من ✕) ---------- */
