/* منظومة الإدارة المالية — نسخة الويب. نفس ألوان البرنامج المكتبي ومنظومة العهد (المظهر الزمردي والذهبي) */
@font-face { font-family: "Tajawal"; src: url("/fonts/Tajawal-Regular.ttf") format("truetype"); font-weight: 400; font-display: swap; }
@font-face { font-family: "Tajawal"; src: url("/fonts/Tajawal-Medium.ttf") format("truetype"); font-weight: 500; font-display: swap; }
@font-face { font-family: "Tajawal"; src: url("/fonts/Tajawal-Bold.ttf") format("truetype"); font-weight: 700; font-display: swap; }

:root {
  --primary: #0d4a36; --primary2: #17694c; --dark: #08301f; --accent: #b8902f; --accent-soft: #f6efdc;
  --bg: #f3f6f4; --surface: #ffffff; --surface2: #f7faf8; --text: #18241f; --muted: #5e6b65; --border: #dce5df;
  --ok: #1e8a4c; --ok-bg: #e5f5ec; --warn: #b26a00; --warn-bg: #fff3dc; --bad: #c0392b; --bad-bg: #fdecea;
  --info: #1d6b5c; --info-bg: #e5f2ee; --muted-bg: #eef1f0; --radius: 12px; --shadow: 0 3px 18px rgba(16, 40, 40, .08);
}
* { box-sizing: border-box; }
html, body { margin: 0; }
body { font-family: "Tajawal", "Segoe UI", Tahoma, sans-serif; background: var(--bg); color: var(--text); font-size: 15px; line-height: 1.6; }
a { color: var(--primary2); text-decoration: none; }
button, input, select, textarea { font: inherit; color: inherit; }
.boot { padding: 80px 16px; text-align: center; color: var(--muted); }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.hidden { display: none !important; }

/* ---------- الشريط العلوي */
.topbar { background: var(--primary); color: #fff; display: flex; align-items: center; gap: 14px; padding: 0 18px; height: 58px;
  position: sticky; top: 0; z-index: 20; box-shadow: 0 2px 10px rgba(0,0,0,.12); }
.brand { display: flex; align-items: center; gap: 10px; font-weight: 700; white-space: nowrap; color: #fff; }
.brand img { width: 30px; height: 30px; }
.brand small { display: block; font-weight: 400; color: #cfe0db; font-size: 12px; line-height: 1.2; }
.nav { display: flex; gap: 2px; overflow-x: auto; flex: 1; scrollbar-width: none; }
.nav a { color: #d6e4e2; padding: 8px 12px; border-radius: 9px; white-space: nowrap; font-weight: 500; }
.nav a:hover { background: rgba(255,255,255,.08); color: #fff; }
.nav a.on { background: rgba(255,255,255,.14); color: #fff; box-shadow: inset 0 -3px 0 var(--accent); }
.top-actions { display: flex; align-items: center; gap: 6px; }
.icon-btn { background: transparent; border: 0; color: #fff; width: 40px; height: 40px; border-radius: 10px; cursor: pointer; position: relative;
  display: inline-flex; align-items: center; justify-content: center; }
.icon-btn:hover { background: rgba(255,255,255,.1); }
.icon-btn svg { width: 21px; height: 21px; }
.badge-dot { position: absolute; top: 4px; left: 4px; background: var(--accent); color: #1d1a0d; border-radius: 10px; font-size: 11px;
  min-width: 18px; height: 18px; padding: 0 5px; display: flex; align-items: center; justify-content: center; font-weight: 700; }
.user-chip { color: #e6f0ed; font-size: 13px; padding: 0 6px; white-space: nowrap; }

/* ---------- الصفحة */
.page { max-width: 1240px; margin: 0 auto; padding: 22px 18px 60px; }
.page-head { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; margin-bottom: 16px; }
.page-head h1 { font-size: 22px; margin: 0; flex: 1; }
.crumb { color: var(--muted); font-size: 13px; }
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); }
.card-pad { padding: 18px; }
.card h3 { margin: 0 0 10px; font-size: 16px; }

/* ---------- أزرار */
.btn { border: 1px solid var(--border); background: var(--surface); padding: 8px 15px; border-radius: 10px; cursor: pointer; font-weight: 500;
  display: inline-flex; align-items: center; gap: 6px; white-space: nowrap; }
.btn:hover { border-color: var(--primary2); }
.btn.primary { background: var(--primary); border-color: var(--primary); color: #fff; }
.btn.primary:hover { background: var(--primary2); }
.btn.approve { background: var(--ok); border-color: var(--ok); color: #fff; }
.btn.danger { color: var(--bad); border-color: #f0c9c4; }
.btn.danger:hover { background: var(--bad-bg); }
.btn.accent { background: var(--accent); border-color: var(--accent); color: #1d1a0d; }
.btn:disabled { opacity: .55; cursor: default; }
.btn-row { display: flex; gap: 8px; flex-wrap: wrap; }

/* ---------- الرئيسية */
.tiles { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 14px; margin-bottom: 20px; }
.tile { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 16px 18px; box-shadow: var(--shadow);
  display: block; color: var(--text); border-inline-start: 5px solid var(--primary2); }
.tile:hover { border-color: var(--primary2); }
.tile b { display: block; font-size: 30px; color: var(--primary); line-height: 1.2; }
.tile.hot { border-inline-start-color: var(--accent); }
.tile.hot b { color: #8a6a17; }

/* ---------- القوائم */
.toolbar { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; margin-bottom: 12px; }
.search { flex: 1; min-width: 200px; }
.tabs { display: flex; gap: 6px; flex-wrap: wrap; margin-bottom: 12px; }
.tab { border: 1px solid var(--border); background: var(--surface); border-radius: 20px; padding: 5px 13px; cursor: pointer; font-size: 14px; }
.tab.on { background: var(--primary); color: #fff; border-color: var(--primary); }
.tab span { opacity: .75; margin-inline-start: 4px; }
table.list { width: 100%; border-collapse: collapse; }
table.list th { text-align: right; font-weight: 700; color: var(--muted); font-size: 13px; padding: 10px 12px; border-bottom: 1px solid var(--border);
  background: var(--surface2); white-space: nowrap; }
table.list td { padding: 10px 12px; border-bottom: 1px solid var(--border); vertical-align: top; }
table.list tr.row { cursor: pointer; }
table.list tr.row:hover td { background: #f0f6f3; }
table.list tr.late-open td:first-child { box-shadow: inset -4px 0 0 var(--bad); }
table.list tr.late-done td:first-child { box-shadow: inset -4px 0 0 var(--warn); }
.subject { font-weight: 500; }
.empty { padding: 40px; text-align: center; color: var(--muted); }
.pager { display: flex; gap: 6px; justify-content: center; align-items: center; padding: 12px; }
.table-wrap { overflow-x: auto; }

/* ---------- الشارات */
.pill { display: inline-block; padding: 2px 10px; border-radius: 20px; font-size: 12.5px; font-weight: 500; white-space: nowrap;
  background: var(--muted-bg); color: var(--muted); }
.pill.ok { background: var(--ok-bg); color: var(--ok); }
.pill.info { background: var(--info-bg); color: var(--info); }
.pill.warn { background: var(--warn-bg); color: var(--warn); }
.pill.bad { background: var(--bad-bg); color: var(--bad); }
.pill.gold { background: var(--accent-soft); color: #7a5c12; }

/* ---------- المراسلة */
.mail-layout { display: grid; grid-template-columns: minmax(0, 1fr) 360px; gap: 16px; align-items: start; }
.stages { display: flex; gap: 0; margin-bottom: 14px; overflow-x: auto; }
.stage { padding: 6px 14px; background: var(--surface2); border: 1px solid var(--border); font-size: 13px; color: var(--muted); white-space: nowrap; }
.stage:first-child { border-radius: 0 20px 20px 0; }
.stage:last-child { border-radius: 20px 0 0 20px; }
.stage.on { background: var(--primary); color: #fff; border-color: var(--primary); }
.stage.past { background: var(--info-bg); color: var(--info); }
.sheet-title { font-size: 20px; font-weight: 700; margin: 4px 0 12px; }
.grid2 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px 22px; }
.kv { display: flex; flex-direction: column; }
.kv span { color: var(--muted); font-size: 13px; }
.kv b { font-weight: 500; }
.notebox { background: var(--accent-soft); border: 1px solid #ecdcb2; border-radius: 10px; padding: 10px 14px; margin: 12px 0; }
.holdbox { background: var(--bad-bg); border: 1px solid #f3c7c1; border-radius: 10px; padding: 10px 14px; margin: 12px 0; color: #7d2117; }
.summary { white-space: pre-wrap; unicode-bidi: plaintext; margin: 10px 0; }
.section-title { font-weight: 700; margin: 18px 0 8px; color: var(--primary); }
.att { display: flex; align-items: center; gap: 10px; padding: 8px 10px; border: 1px solid var(--border); border-radius: 10px; margin-bottom: 6px; }
.att a { flex: 1; }
.chatter .mv { display: flex; gap: 10px; padding: 10px 0; border-bottom: 1px dashed var(--border); }
.avatar { width: 34px; height: 34px; border-radius: 50%; background: var(--primary2); color: #fff; display: flex; align-items: center;
  justify-content: center; font-weight: 700; flex: none; }
.mv .who { font-weight: 700; font-size: 14px; }
.mv .when { color: var(--muted); font-size: 12px; margin-inline-start: 6px; }
.mv .act { font-size: 14px; }
.mv .body { white-space: pre-wrap; unicode-bidi: plaintext; background: var(--surface2); border-radius: 8px; padding: 6px 10px; margin-top: 4px; font-size: 14px; }
.ref { border: 1px solid var(--border); border-radius: 10px; padding: 10px 12px; margin-bottom: 8px; }
.ref .head { display: flex; justify-content: space-between; gap: 8px; }

/* ---------- النماذج */
label.field { display: flex; flex-direction: column; gap: 5px; margin-bottom: 12px; font-size: 14px; font-weight: 500; }
label.field .req { color: var(--bad); }
input[type=text], input[type=password], input[type=date], input[type=number], input[type=search], select, textarea {
  border: 1px solid var(--border); border-radius: 9px; padding: 8px 11px; background: var(--surface); width: 100%; min-height: 40px; }
textarea { min-height: 90px; resize: vertical; unicode-bidi: plaintext; }
input[type=text], input[type=search] { unicode-bidi: plaintext; }
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--primary2); box-shadow: 0 0 0 3px rgba(23,105,76,.12); }
.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 0 18px; }
.form-grid .wide { grid-column: 1 / -1; }
.check { display: flex; align-items: center; gap: 8px; margin: 4px 0; font-weight: 400; }
.check input { width: 18px; height: 18px; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 6px; }
.chip { background: var(--info-bg); color: var(--info); border-radius: 16px; padding: 3px 10px; font-size: 13px; display: inline-flex; gap: 6px; align-items: center; }
.chip button { border: 0; background: none; color: inherit; cursor: pointer; padding: 0; font-size: 15px; line-height: 1; }
.warnline { color: var(--warn); font-size: 13px; }
.errline { color: var(--bad); font-size: 14px; min-height: 20px; }

/* ---------- النوافذ */
.modal-bg { position: fixed; inset: 0; background: rgba(8, 30, 22, .45); display: flex; align-items: flex-start; justify-content: center;
  padding: 40px 16px; z-index: 50; overflow-y: auto; }
.modal { background: var(--surface); border-radius: 14px; width: 100%; max-width: 560px; box-shadow: 0 20px 60px rgba(0,0,0,.25); }
.modal.wide { max-width: 860px; }
.modal-head { padding: 16px 20px; border-bottom: 1px solid var(--border); font-weight: 700; font-size: 17px; display: flex; justify-content: space-between; }
.modal-body { padding: 18px 20px; }
.modal-foot { padding: 12px 20px; border-top: 1px solid var(--border); display: flex; gap: 8px; }
.drop { position: absolute; top: 52px; left: 12px; width: min(420px, calc(100vw - 24px)); max-height: 70vh; overflow-y: auto; background: var(--surface);
  color: var(--text); border-radius: 12px; box-shadow: 0 16px 48px rgba(0,0,0,.2); z-index: 40; }
.drop .item { padding: 10px 14px; border-bottom: 1px solid var(--border); cursor: pointer; }
.drop .item.unread { background: #f4faf7; }
.drop .item.act { border-inline-start: 4px solid var(--accent); }
.drop .item:hover { background: var(--surface2); }
#toast { position: fixed; bottom: 22px; left: 50%; transform: translateX(-50%); z-index: 60; }
#toast div { background: var(--dark); color: #fff; padding: 10px 18px; border-radius: 10px; margin-top: 8px; box-shadow: var(--shadow); }
#toast div.err { background: var(--bad); }

/* ---------- الدخول */
.login-wrap { min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 20px;
  background: linear-gradient(160deg, var(--primary) 0%, var(--dark) 100%); }
.login { width: 100%; max-width: 400px; padding: 30px 28px; }
.login h1 { font-size: 21px; margin: 10px 0 2px; text-align: center; }
.login .org { text-align: center; color: var(--muted); margin-bottom: 20px; }
.login .logo { display: block; margin: 0 auto; width: 58px; height: 58px; }
.secret { font-family: Consolas, monospace; direction: ltr; text-align: center; font-size: 18px; letter-spacing: 2px; background: var(--surface2);
  border: 1px dashed var(--border); border-radius: 10px; padding: 10px; word-break: break-all; }
.codes { display: grid; grid-template-columns: repeat(2, 1fr); gap: 6px; direction: ltr; font-family: Consolas, monospace; }
.codes div { background: var(--surface2); border: 1px solid var(--border); border-radius: 8px; padding: 6px; text-align: center; }

@media (max-width: 900px) {
  .mail-layout { grid-template-columns: 1fr; }
  .grid2, .form-grid { grid-template-columns: 1fr; }
  .user-chip { display: none; }
  .topbar { padding: 0 10px; gap: 8px; }
  .brand span { display: none; }
  .page { padding: 16px 12px 50px; }
  table.list .opt { display: none; }
}
