/* ===== الخطوط ===== */
@font-face { font-family: "Lama Sans"; src: url("/static/fonts/LamaSans-Regular.ttf") format("truetype"); font-weight: 400; font-display: swap; }
@font-face { font-family: "Lama Sans"; src: url("/static/fonts/LamaSans-Medium.ttf") format("truetype"); font-weight: 500; font-display: swap; }
@font-face { font-family: "Lama Sans"; src: url("/static/fonts/LamaSans-Bold.ttf") format("truetype"); font-weight: 700; font-display: swap; }

/* ===== المتغيرات ===== */
:root {
  --brand-blue: #0F4995; --brand-teal: #26B49F; --brand-gray: #D1CED5; --brand-white: #FFFFFF; --brand-black: #000000;
  --g-900: #0F4995; --g-800: #0F4995; --g-700: #0F4995; --g-600: #0F4995; --g-500: #0F4995; --g-400: #3f74b2;
  --g-100: #e8f0fa; --g-50: #f5f8fc;
  --lime: #D1CED5; --lime-2: #e6e4e9; --lime-3: #f5f4f7;
  --bg: #f7f7f9; --card: #FFFFFF; --text: #000000; --muted: #62616a; --line: #D1CED5;
  --red: #c93838; --orange: #c97a18; --blue: #0F4995; --teal: #26B49F; --teal-ink: #053c35; --pink: #d788ad; --gray: #6d6c73; --yellow: #b88412;
  --shadow: 0 2px 10px rgba(15, 73, 149, .10);
  --radius: 10px;
  --topbar-h: 64px;
  --nav-w: 76px;
}
[data-theme="dark"] {
  --bg: #071a38; --card: #0b2854; --text: #FFFFFF; --muted: #c6c7cc; --line: #365889;
  --lime: #334a69; --lime-2: #1e3d69; --lime-3: #102e59; --g-100: #173d70; --g-50: #0c2a56;
  --shadow: 0 2px 10px rgba(0, 0, 0, .35);
}

/* ===== الأساسيات ===== */
* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; height: 100%; }
body { font-family: "Lama Sans", "Tajawal", "Segoe UI", Tahoma, Arial, sans-serif; background: var(--bg); color: var(--text); font-size: 15px; line-height: 1.5; }
a { color: inherit; text-decoration: none; }
button, input, select, textarea { font-family: inherit; font-size: inherit; color: inherit; }
.hidden { display: none !important; }
.ic { width: 22px; height: 22px; fill: none; stroke: currentColor; vertical-align: middle; }
.ic-sm { width: 17px; height: 17px; }
h1, h2, h3 { margin: 0; font-weight: 700; }
.muted { color: var(--muted); }
.center { text-align: center; }
.mt { margin-top: 16px; } .mb { margin-bottom: 16px; }
.row { display: flex; gap: 12px; align-items: center; flex-wrap: wrap; }
.grow { flex: 1; }
.between { justify-content: space-between; }
.nowrap { white-space: nowrap; }
.num { font-family: "Segoe UI", Tahoma, Arial, sans-serif; direction: ltr; unicode-bidi: embed; }

/* ===== الهيكل ===== */
.shell { display: flex; flex-direction: column; min-height: 100vh; }
.topbar { min-height: var(--topbar-h); background: var(--brand-blue); color: var(--brand-white); display: flex; align-items: center; justify-content: space-between; padding: 0 14px; box-shadow: 0 2px 8px rgba(0,0,0,.18); position: sticky; top: 0; z-index: 50; }
.tb-right, .tb-left { display: flex; align-items: center; gap: 6px; }
.tb-center { flex: 1; display: flex; justify-content: center; }
.icon-btn { background: transparent; border: 0; color: #fff; width: 40px; height: 40px; border-radius: 50%; display: inline-flex; align-items: center; justify-content: center; cursor: pointer; position: relative; }
.icon-btn:hover { background: rgba(255,255,255,.18); }
.icon-btn .badge { position: absolute; top: 2px; left: 2px; background: var(--red); color: #fff; border-radius: 10px; font-size: 11px; padding: 0 5px; line-height: 16px; min-width: 16px; text-align: center; }
.brand { display: flex; align-items: center; gap: 10px; margin: 0 8px; }
.brand img { width: 40px; height: 40px; background: #fff; border-radius: 10px; padding: 3px; }
.brand-text { display: flex; flex-direction: column; line-height: 1.15; }
.brand-text b { font-size: 16px; }
.brand-text span { font-size: 11.5px; opacity: .9; }
.tb-search { display: flex; background: #fff; border-radius: 8px; overflow: hidden; margin-right: 8px; height: 36px; }
.tb-search input { border: 0; padding: 0 12px; width: 220px; outline: none; color: #333; }
.tb-search button { border: 0; background: var(--brand-teal); color: var(--brand-black); width: 40px; cursor: pointer; }
.pill { background: var(--brand-gray); color: var(--brand-blue); border: 0; border-radius: 30px; padding: 6px 30px; font-weight: 700; font-size: 16px; cursor: pointer; box-shadow: inset 0 -2px 0 rgba(0,0,0,.08); }
.pill.dept { background: #fff3c4; }
.user-chip { display: flex; align-items: center; gap: 8px; margin-left: 8px; font-weight: 500; }
.user-chip img { width: 40px; height: 40px; border-radius: 50%; border: 2px solid #fff; object-fit: cover; background: #fff; }

.body { display: flex; flex: 1; min-height: 0; }
.view { flex: 1; min-width: 0; padding: 18px 20px 40px; }

.drawer-open { overflow: hidden; }
.mainmenu { position: fixed; inset: 0; background: rgba(0,0,0,.48); z-index: 120; backdrop-filter: blur(2px); }
.mm-inner { background: var(--card); width: min(360px, 90vw); height: 100%; box-shadow: -12px 0 34px rgba(0,0,0,.25); overflow: auto; animation: drawer-in .24s cubic-bezier(.23,1,.32,1); display: flex; flex-direction: column; }
.mm-head { min-height: 82px; padding: 14px 16px; background: var(--brand-blue); color: var(--brand-white); display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.mm-brand { display: flex; align-items: center; gap: 10px; min-width: 0; }
.mm-brand img { width: 48px; height: 48px; background: #fff; border-radius: 12px; padding: 4px; flex: 0 0 auto; }
.mm-brand div { display: flex; flex-direction: column; min-width: 0; }
.mm-brand b { font-size: 17px; }
.mm-brand span { font-size: 12px; opacity: .9; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.mm-group { padding: 12px 10px 4px; }
.mm-group > span { display: block; padding: 0 10px 7px; color: var(--muted); font-size: 12px; font-weight: 700; }
.mm-inner a { display: flex; align-items: center; gap: 12px; min-height: 48px; padding: 10px 14px; margin-bottom: 3px; font-size: 15px; border-radius: 9px; border-inline-start: 3px solid transparent; }
.mm-inner a:hover { background: var(--g-50); color: var(--g-800); }
.mm-inner a.active { background: var(--g-100); color: var(--g-900); border-inline-start-color: var(--g-600); font-weight: 700; }
.mm-version { margin-top: auto; padding: 16px 20px; color: var(--muted); font-size: 12px; border-top: 1px solid var(--line); }
@keyframes drawer-in { from { transform: translateX(28px); opacity: 0; } to { transform: none; opacity: 1; } }

.settings-panel { position: fixed; top: calc(var(--topbar-h) - 4px); left: 56px; width: min(320px, calc(100vw - 24px)); background: var(--card); border: 1px solid var(--line); border-radius: 12px; box-shadow: 0 12px 36px rgba(0,0,0,.24); padding: 8px; z-index: 90; transform-origin: top left; animation: pop-in .18s cubic-bezier(.23,1,.32,1); }
.settings-panel a { display: flex; align-items: center; gap: 12px; padding: 11px 12px; border-radius: 8px; }
.settings-panel a:hover { background: var(--g-50); }
.settings-panel a .ic { color: var(--g-700); }
.settings-panel a span { display: flex; flex-direction: column; }
.settings-panel a b { font-size: 14px; }
.settings-panel a small { color: var(--muted); font-size: 12px; }
@keyframes pop-in { from { transform: translateY(-6px) scale(.98); opacity: 0; } to { transform: none; opacity: 1; } }

.notif-panel { position: fixed; top: var(--topbar-h); left: 60px; width: 360px; max-height: 70vh; overflow: auto; background: var(--card); box-shadow: 0 8px 30px rgba(0,0,0,.25); border-radius: 0 0 10px 10px; z-index: 60; }
.notif-panel .np-head { display: flex; justify-content: space-between; align-items: center; padding: 10px 14px; background: var(--g-600); color: #fff; font-weight: 700; }
.notif-panel .np-head button { background: transparent; border: 0; color: #fff; cursor: pointer; font-size: 13px; text-decoration: underline; }
.notif { padding: 10px 14px; border-bottom: 1px solid var(--line); cursor: pointer; }
.notif.unread { background: var(--g-50); }
.notif b { display: block; font-size: 14px; }
.notif span { font-size: 13px; color: var(--muted); }
.notif small { display: block; font-size: 11.5px; color: var(--muted); margin-top: 2px; }

/* ===== البطاقات والعناوين ===== */
.card { background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow); padding: 18px 20px; margin-bottom: 18px; }
.card.tight { padding: 0; overflow: hidden; }
.section-bar { background: var(--g-500); color: #fff; padding: 12px 16px; border-radius: var(--radius) var(--radius) 0 0; display: flex; align-items: center; gap: 12px; flex-wrap: wrap; min-height: 60px; }
.section-bar .title { background: #fff; color: var(--g-900); font-weight: 700; padding: 8px 22px; border-radius: 8px; font-size: 16px; }
.section-bar .tabs { display: flex; gap: 6px; flex-wrap: wrap; }
.section-bar .tab { color: #fff; font-weight: 700; padding: 8px 20px; border-radius: 8px; font-size: 16px; cursor: pointer; border: 0; background: transparent; }
.section-bar .tab.active { background: #fff; color: var(--g-900); }
.section-bar .tab:hover:not(.active) { background: rgba(255,255,255,.18); }
.page-title { font-size: 30px; color: var(--g-600); text-align: center; margin: 6px 0 18px; font-weight: 700; }
.page-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 14px; flex-wrap: wrap; }
.page-head h1 { font-size: 22px; color: var(--g-800); }
.ptag { background: var(--teal); color: var(--teal-ink); font-weight: 700; padding: 6px 14px; border-radius: 6px; font-size: 18px; display: inline-flex; align-items: center; gap: 8px; }
.ptag img { width: 42px; height: 42px; background: #fff; border-radius: 4px; }

/* ===== الأزرار ===== */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; border: 0; border-radius: 8px; padding: 9px 20px; font-weight: 700; font-size: 15px; cursor: pointer; background: var(--g-600); color: #fff; transition: filter .15s; white-space: nowrap; }
.btn:hover { filter: brightness(1.08); }
.btn:disabled { opacity: .55; cursor: not-allowed; }
.btn.secondary { background: #8d9a92; }
.btn.light { background: var(--brand-teal); color: var(--teal-ink); }
.btn.outline { background: transparent; border: 2px solid var(--g-600); color: var(--g-700); }
.btn.danger { background: var(--red); }
.btn.blue { background: #4f8ac9; }
.btn.orange { background: var(--orange); }
.btn.sm { padding: 6px 12px; font-size: 13.5px; }
.btn.lg { padding: 12px 34px; font-size: 17px; }
.btn.ghost { background: transparent; color: var(--g-800); }
.btn.ghost:hover { background: var(--g-50); }
.btn-icon { width: 36px; height: 36px; border-radius: 8px; border: 0; background: transparent; color: var(--g-800); cursor: pointer; display: inline-flex; align-items: center; justify-content: center; }
.btn-icon:hover { background: var(--g-100); }
.btn-icon.danger { color: var(--red); }
.actions-row { display: flex; gap: 6px; background: var(--g-50); border-radius: 8px; padding: 4px 8px; }
.tab-btns { display: flex; justify-content: center; gap: 10px; margin: 10px 0 18px; flex-wrap: wrap; }
.tab-btns .btn { min-width: 170px; font-size: 18px; padding: 10px 26px; }
.tab-btns .btn.off { background: #8d9a92; }

/* ===== النماذج ===== */
.form-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 14px 28px; }
.form-grid .full { grid-column: 1 / -1; }
.field { display: flex; flex-direction: column; gap: 6px; margin-bottom: 12px; }
.field label { font-weight: 700; font-size: 14.5px; }
.field label .req { color: var(--red); }
.field label .help { color: var(--blue); font-size: 12px; margin-right: 6px; }
.input, textarea.input, select.input { width: 100%; border: 1px solid var(--line); border-radius: 8px; padding: 10px 12px; background: var(--card); outline: none; transition: border .15s, box-shadow .15s; }
.input:focus, textarea.input:focus, select.input:focus { border-color: var(--brand-teal); box-shadow: 0 0 0 3px rgba(38,180,159,.20); }
textarea.input { min-height: 110px; resize: vertical; }
.input.error { border-color: var(--red); }
.chips { display: flex; gap: 8px; flex-wrap: wrap; }
.chip { border: 0; background: var(--lime-3); color: var(--g-900); border-radius: 30px; padding: 6px 16px; cursor: pointer; font-weight: 700; }
.chip.active { background: var(--g-600); color: #fff; }
.chip.sm { padding: 3px 12px; font-size: 13px; }
.check { display: inline-flex; align-items: center; gap: 8px; cursor: pointer; }
.check input { width: 18px; height: 18px; accent-color: var(--g-600); }
.radio-row { display: flex; gap: 22px; }
.toggle { display: inline-flex; border-radius: 30px; overflow: hidden; border: 1px solid var(--line); }
.toggle button { border: 0; background: transparent; padding: 5px 14px; cursor: pointer; font-weight: 700; }
.toggle button.on { background: var(--g-600); color: #fff; }

/* select قابل للبحث */
.sel { position: relative; }
.sel .sel-input { width: 100%; border: 1px solid var(--line); border-radius: 8px; padding: 10px 36px 10px 12px; background: var(--card); outline: none; cursor: pointer; }
.sel .sel-input:focus { border-color: var(--brand-teal); box-shadow: 0 0 0 3px rgba(38,180,159,.20); }
.sel .sel-arrow { position: absolute; left: 10px; top: 50%; transform: translateY(-50%); color: var(--muted); pointer-events: none; }
.sel .sel-clear { position: absolute; left: 30px; top: 50%; transform: translateY(-50%); background: transparent; border: 0; color: var(--muted); cursor: pointer; padding: 2px; }
.sel .sel-list { position: absolute; top: 100%; right: 0; left: 0; background: var(--card); border: 1px solid var(--line); border-radius: 8px; box-shadow: 0 8px 24px rgba(0,0,0,.15); max-height: 260px; overflow: auto; z-index: 30; margin-top: 4px; }
.sel .sel-opt { padding: 9px 12px; cursor: pointer; border-bottom: 1px solid var(--line); }
.sel .sel-opt small { display: block; color: var(--muted); font-size: 12px; }
.sel .sel-opt:hover, .sel .sel-opt.hl { background: var(--g-50); }
.sel .sel-opt.selected { background: var(--brand-blue); color: #fff; }
.sel .sel-opt.selected small { color: #e8f0fa; }
.sel .sel-empty { padding: 10px; color: var(--muted); text-align: center; }

/* ===== الجداول ===== */
.table-wrap { max-width: 100%; overflow-x: auto; overscroll-behavior-inline: contain; }
table.grid { width: 100%; border-collapse: collapse; }
table.grid th { background: var(--lime); color: var(--g-900); font-weight: 700; padding: 11px 10px; text-align: right; font-size: 14.5px; white-space: nowrap; }
table.grid td { padding: 10px; border-bottom: 1px solid var(--line); vertical-align: middle; font-size: 14px; }
table.grid tr:hover td { background: var(--g-50); }
table.grid .empty td { text-align: center; padding: 26px; color: var(--muted); font-size: 16px; }
table.grid.compact th, table.grid.compact td { padding: 7px 8px; font-size: 13px; }
.tn { background: var(--teal); color: #fff; font-weight: 700; padding: 4px 12px; border-radius: 6px; display: inline-block; font-size: 14px; letter-spacing: .5px; }
.tn.draft { background: #7fa9d0; } .tn.late { background: var(--orange); }
.status { display: inline-block; padding: 3px 10px; border-radius: 20px; font-size: 12.5px; font-weight: 700; background: var(--g-100); color: var(--g-800); }
.status.pending { background: #fff1d6; color: #9a5b00; }
.status.received { background: #dff5f0; color: var(--teal-ink); }
.status.late { background: #fde2e2; color: #a12020; }
.status.completed { background: #dff5f0; color: var(--teal-ink); }
.status.saved { background: #e6e9e7; color: #444; }
.status.withdrawn { background: #fde2e2; color: #a12020; }
.status.forwarded { background: #dbe8fb; color: #234f8a; }
.status.draft { background: #e6e9e7; color: #555; }
.tag { display: inline-block; background: var(--lime-2); color: var(--g-900); font-size: 12px; padding: 2px 10px; border-radius: 12px; margin: 2px; }
.dot { display: inline-block; width: 18px; height: 18px; border-radius: 50%; vertical-align: middle; }
.dot.red { background: #c93838; } .dot.green { background: var(--teal); } .dot.pink { background: #d788ad; } .dot.gray { background: var(--brand-gray); } .dot.lightpink { background: #f3d4e1; }
.legend { display: flex; gap: 10px; align-items: center; font-size: 13px; flex-wrap: wrap; }
.legend .dot { margin-left: 4px; }
.toolbar { display: flex; align-items: center; gap: 10px; padding: 12px 14px; flex-wrap: wrap; border-bottom: 1px solid var(--line); }
.toolbar .search { display: flex; flex: 1; min-width: 220px; }
.toolbar .search input { flex: 1; border: 1px solid var(--line); border-radius: 8px; padding: 8px 12px; }
.pager { display: flex; align-items: center; gap: 8px; }
.pager button { border: 1px solid var(--line); background: var(--card); border-radius: 6px; width: 32px; height: 32px; cursor: pointer; }
.pager button:disabled { opacity: .4; cursor: default; }
.pager select { border: 1px solid var(--line); border-radius: 6px; padding: 5px 8px; }
.row-actions { display: inline-flex; gap: 2px; background: var(--g-50); border-radius: 8px; padding: 2px 6px; }
.row-actions .btn-icon { width: 32px; height: 32px; }
.row-actions .btn-icon .ic { width: 19px; height: 19px; }
.subject-cell { max-width: 420px; }
.subject-cell .s { font-weight: 500; }
.subject-cell .m { font-size: 12.5px; color: var(--muted); }

/* ===== المعالج ===== */
.stepper { display: flex; align-items: center; justify-content: space-between; margin: 10px 40px 26px; position: relative; }
.stepper .step { display: flex; flex-direction: column; align-items: center; gap: 8px; z-index: 1; min-width: 110px; }
.stepper .step .c { width: 30px; height: 30px; border-radius: 50%; border: 2px solid var(--brand-gray); background: var(--card); display: flex; align-items: center; justify-content: center; font-weight: 700; color: var(--g-700); }
.stepper .step.done .c { border-color: var(--teal); color: var(--teal); }
.stepper .step.active .c { border-color: var(--teal); background: var(--teal); color: #fff; }
.stepper .step span { font-size: 15px; color: var(--muted); }
.stepper .step.active span, .stepper .step.done span { color: var(--text); font-weight: 700; }
.stepper .line { flex: 1; height: 3px; background: #dbe3de; margin: 0 -40px; margin-bottom: 30px; }
.stepper .line.done { background: var(--teal); }
.wizard-form { max-width: 760px; margin-right: auto; }
.wizard-nav { display: flex; justify-content: flex-end; gap: 12px; margin-top: 24px; }

/* ===== المرفقات والعارض ===== */
.viewer { display: grid; grid-template-columns: 270px 1fr 250px; gap: 14px; min-height: 620px; }
.viewer-list { background: var(--bg); border-radius: 8px; padding: 8px; }
.viewer-list .all { background: var(--brand-blue); color: #fff; padding: 10px 12px; border-radius: 6px; font-weight: 700; margin-bottom: 8px; font-size: 14px; }
.att-group { margin-bottom: 8px; }
.att-group .g-head { background: var(--g-500); color: #fff; padding: 8px 12px; border-radius: 6px 6px 0 0; font-weight: 700; display: flex; justify-content: space-between; align-items: center; cursor: pointer; }
.att-group .g-body { background: var(--card); border-radius: 0 0 6px 6px; padding: 6px; }
.att-card { border: 2px solid transparent; border-radius: 6px; padding: 6px; cursor: pointer; margin-bottom: 4px; }
.att-card.active { border-color: var(--g-500); background: var(--g-50); }
.att-card .a-actions { display: flex; gap: 4px; justify-content: center; background: var(--lime); border-radius: 4px; margin-bottom: 4px; }
.att-card .a-actions .btn-icon { width: 30px; height: 30px; }
.att-card .thumb { width: 100px; height: 130px; background: #fff; border: 1px solid var(--line); margin: 6px auto; display: block; object-fit: contain; box-shadow: 0 1px 4px rgba(0,0,0,.15); }
.att-card .a-name { font-weight: 700; font-size: 13px; text-align: center; }
.att-card .a-meta { font-size: 11.5px; color: var(--muted); text-align: center; }
.viewer-main { background: #eef2f7; border-radius: 8px; display: flex; flex-direction: column; min-height: 600px; overflow: hidden; }
.v-toolbar { display: flex; justify-content: center; gap: 2px; padding: 6px; background: var(--g-50); border-bottom: 1px solid var(--line); flex-wrap: wrap; }
.v-tool { display: flex; flex-direction: column; align-items: center; gap: 2px; border: 0; background: transparent; padding: 4px 8px; min-width: 62px; cursor: pointer; border-radius: 6px; color: #333; font-size: 11.5px; }
.v-tool .ic { width: 24px; height: 24px; }
.v-tool:hover { background: var(--g-100); }
.v-tool.active { background: var(--g-600); color: #fff; }
.v-tool:disabled { opacity: .35; cursor: default; }
.v-pages { flex: 1; overflow: auto; padding: 18px; position: relative; }
.v-page { position: relative; margin: 0 auto 16px; background: #fff; box-shadow: 0 2px 8px rgba(0,0,0,.2); }
.v-page canvas { display: block; }
.v-page .overlay { position: absolute; inset: 0; }
.v-page .pnum { position: absolute; bottom: -18px; left: 0; right: 0; text-align: center; font-size: 12px; color: var(--muted); }
.v-page .wm { position: absolute; inset: 0; pointer-events: none; overflow: hidden; opacity: .13; font-family: Arial, sans-serif; font-size: 18px; color: #333; line-height: 90px; white-space: nowrap; }
.mark { position: absolute; border: 1px dashed transparent; cursor: move; user-select: none; }
.mark:hover, .mark.sel { border-color: var(--blue); }
.mark img { width: 100%; height: 100%; display: block; pointer-events: none; }
.mark .m-del { position: absolute; top: -12px; left: -12px; width: 22px; height: 22px; border-radius: 50%; background: var(--red); color: #fff; border: 0; cursor: pointer; display: none; font-size: 12px; line-height: 22px; text-align: center; padding: 0; }
.mark .m-res { position: absolute; bottom: -6px; right: -6px; width: 14px; height: 14px; background: var(--blue); border-radius: 2px; cursor: nwse-resize; display: none; }
.mark:hover .m-del, .mark.sel .m-del, .mark:hover .m-res, .mark.sel .m-res { display: block; }
.mark.text { background: transparent; padding: 2px 6px; font-family: "Lama Sans", "Tajawal", sans-serif; color: var(--brand-blue); font-weight: 700; font-size: 16px; min-width: 40px; white-space: pre-wrap; outline: none; }
.mark.highlight { background: rgba(255, 235, 59, .45); }
.mark.marker { border: 3px solid #d32f2f; border-radius: 50%; }
.viewer-side { display: flex; flex-direction: column; gap: 10px; }
.viewer-side .btn.outline { justify-content: space-between; padding: 12px 16px; font-size: 16px; }
.side-box { background: var(--bg); border-radius: 8px; padding: 12px; }
.side-box h4 { margin: 0 0 6px; font-size: 15px; }
.side-box .field { margin-bottom: 8px; }
.side-box .opts label { display: flex; align-items: center; gap: 8px; padding: 3px 0; }
.v-empty { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; color: #555; gap: 16px; }
.v-empty svg { width: 150px; height: 150px; }
.v-empty div { font-size: 26px; font-weight: 700; }
.v-frame { flex: 1; border: 0; width: 100%; min-height: 1200px; background: #eef2f7; }
.v-loading { padding: 40px; text-align: center; color: var(--muted); }
.no-att { background: #dff5f0; color: var(--teal-ink); text-align: center; padding: 10px; border-radius: 6px; font-weight: 700; }

/* ===== التفاصيل ===== */
.dtabs { display: flex; gap: 4px; border-bottom: 1px solid var(--line); flex-wrap: wrap; }
.dtab { display: inline-flex; align-items: center; gap: 8px; padding: 12px 18px; font-weight: 700; font-size: 16px; cursor: pointer; border: 0; background: transparent; color: var(--text); border-bottom: 3px solid transparent; }
.dtab.active { background: var(--g-600); color: #fff; border-radius: 6px 6px 0 0; }
.dtab .cnt { background: var(--teal); color: #fff; border-radius: 50%; min-width: 24px; height: 24px; display: inline-flex; align-items: center; justify-content: center; font-size: 13px; }
.dtab.active .cnt { background: #fff; color: var(--g-800); }
.action-bar { background: var(--g-100); padding: 8px 12px; display: flex; gap: 4px; flex-wrap: wrap; align-items: center; }
.action-bar .act { display: inline-flex; align-items: center; gap: 6px; border: 0; background: transparent; padding: 6px 12px; border-radius: 6px; cursor: pointer; font-weight: 500; border-left: 1px solid var(--brand-gray); }
.action-bar .act:last-child { border-left: 0; }
.action-bar .act:hover { background: #fff; }
.action-bar .act.primary { background: var(--g-600); color: #fff; }
.action-bar .act.warn { color: #a12020; }
.dnum { text-align: center; font-size: 26px; font-weight: 700; margin: 16px 0; }
.dgrid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 20px 24px; }
.dgrid .k { font-weight: 700; font-size: 15.5px; margin-bottom: 4px; }
.dgrid .v { color: #333; }
[data-theme="dark"] .dgrid .v { color: var(--text); }
.dgrid .k.red { color: var(--red); }
.dgrid .span2 { grid-column: span 2; }
.dgrid .span4 { grid-column: 1 / -1; }
.detail-workspace { display: grid; grid-template-columns: minmax(300px, .72fr) minmax(520px, 1.45fr); gap: 18px; align-items: start; }
.detail-workspace > section { min-width: 0; }
.detail-workspace h3 { color: var(--g-800); margin-bottom: 12px; padding-bottom: 9px; border-bottom: 1px solid var(--line); }
.detail-metadata .dgrid { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px 18px; }
.detail-metadata .dgrid .span4 { grid-column: 1 / -1; }
.detail-document { border-inline-start: 1px solid var(--line); padding-inline-start: 18px; }
.viewer-compact .viewer { grid-template-columns: minmax(0, 1fr) 180px; min-height: 640px; }
.viewer-compact .viewer-side { display: none; }
.viewer-compact .viewer-main { min-width: 0; }
.viewer-compact .viewer-list { min-width: 0; }
.viewer-compact .tab-btns .btn { min-width: 0; font-size: 14px; padding: 8px 14px; }
.mv-legend { display: flex; justify-content: center; gap: 22px; margin: 10px 0 16px; align-items: center; }
.mv-legend span { display: inline-flex; align-items: center; gap: 8px; font-size: 15px; }
.mv-legend i { width: 36px; height: 18px; display: inline-block; }
.flow { display: flex; flex-direction: column; gap: 0; padding: 10px 20px; }
.flow .node { display: flex; gap: 14px; align-items: flex-start; }
.flow .node .bul { width: 34px; height: 34px; border-radius: 50%; background: var(--g-600); color: #fff; display: flex; align-items: center; justify-content: center; font-weight: 700; flex-shrink: 0; }
.flow .node.copy .bul { background: #8d9a92; }
.flow .node .box { background: var(--card); border: 1px solid var(--line); border-radius: 8px; padding: 10px 14px; flex: 1; }
.flow .edge { width: 3px; height: 26px; background: var(--brand-gray); margin-right: 15px; }
.ref-card { border-top: 4px solid #c9a75b; background: var(--card); box-shadow: var(--shadow); border-radius: 8px; padding: 12px 14px; margin-bottom: 12px; }
.ref-card h4 { margin: 0 0 6px; }
.ref-pick { display: grid; grid-template-columns: 200px 1fr 44px; gap: 10px 14px; align-items: center; margin-bottom: 8px; }
.ref-pick label { font-size: 16px; }
.ref-pick .req { font-size: 12px; color: var(--muted); }
.orgtree { max-height: 360px; overflow: auto; }
.orgtree ul { list-style: none; margin: 0; padding-right: 18px; }
.orgtree > ul { padding-right: 0; }
.orgtree li > div { padding: 6px 8px; border-radius: 6px; cursor: pointer; display: flex; align-items: center; gap: 8px; }
.orgtree li > div:hover { background: var(--g-50); }
.orgtree li > div.sel { background: var(--g-600); color: #fff; }
.orgtree .emp { color: var(--muted); font-size: 13px; }
.annotations-panel { max-width: 980px; margin: 0 auto; }
.annotations-heading { display: flex; align-items: center; justify-content: space-between; gap: 16px; margin: 4px 0 16px; }
.annotations-heading h3 { display: flex; align-items: center; gap: 8px; margin: 0; color: var(--g-800); }
.annotations-heading h3 .ic { width: 21px; height: 21px; }
.annotations-heading p { margin: 4px 0 0; color: var(--muted); font-size: 13px; }
.annotation-compose { padding: 16px; background: var(--g-50); border: 1px solid var(--g-100); border-radius: 10px; margin-bottom: 16px; }
.annotation-compose h4 { display: flex; align-items: center; gap: 8px; margin: 0 0 12px; color: var(--g-800); }
.annotation-compose h4 .ic { width: 19px; height: 19px; }
.annotation-form { display: grid; grid-template-columns: minmax(0, 1fr) minmax(230px, .45fr); gap: 12px 16px; align-items: end; }
.annotation-form > .field:first-child { grid-row: span 2; }
.annotation-form > .btn { justify-self: start; min-height: 40px; }
.annotation-rule { grid-column: 1 / -1; display: flex; align-items: flex-start; gap: 7px; margin: 0; color: var(--muted); font-size: 12.5px; line-height: 1.6; }
.annotation-rule .ic { width: 17px; height: 17px; flex: 0 0 auto; color: var(--g-700); margin-top: 2px; }
.annotations-list { display: grid; gap: 10px; }
.annotation-card { background: var(--card); border: 1px solid var(--line); border-inline-start: 4px solid var(--g-500); border-radius: 10px; padding: 14px 16px; box-shadow: 0 1px 4px rgba(15,73,149,.08); }
.annotation-card.private { border-inline-start-color: #7c729d; background: #faf9fe; }
.annotation-meta { display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; }
.annotation-author { display: flex; align-items: center; gap: 9px; }
.annotation-avatar { width: 32px; height: 32px; display: inline-flex; align-items: center; justify-content: center; border-radius: 50%; background: var(--g-100); color: var(--g-800); font-weight: 700; }
.annotation-author b, .annotation-author small { display: block; }
.annotation-author small { color: var(--muted); font-size: 12px; margin-top: 2px; }
.annotation-status { display: flex; align-items: center; gap: 6px; }
.annotation-visibility { display: inline-flex; align-items: center; gap: 5px; padding: 3px 8px; border-radius: 999px; background: var(--g-50); color: var(--g-800); font-size: 12px; font-weight: 700; white-space: nowrap; }
.annotation-visibility.private { color: #574d7a; background: #eeeafd; }
.annotation-visibility .ic { width: 14px; height: 14px; }
.annotation-actions { display: flex; gap: 2px; }
.annotation-body { margin: 12px 0 8px; white-space: pre-wrap; line-height: 1.8; }
.annotation-time { color: var(--muted); font-size: 12px; }
.annotations-empty { min-height: 150px; display: flex; flex-direction: column; justify-content: center; align-items: center; gap: 6px; padding: 18px; background: var(--bg); border: 1px dashed var(--line); border-radius: 10px; color: var(--muted); text-align: center; }
.annotations-empty .ic { width: 34px; height: 34px; color: var(--g-700); }
.classification-badge { display: inline-flex; align-items: center; padding: 3px 8px; border-radius: 999px; background: var(--g-50); color: var(--g-800); font-size: 12px; font-weight: 700; white-space: nowrap; }
.classification-badge.sensitive { background: #fff1f1; color: #9a3030; }

/* ===== لوحة التحكم ===== */
.dashboard-context { display: flex; justify-content: space-between; align-items: end; gap: 16px; padding-bottom: 14px; margin-bottom: 14px; border-bottom: 1px solid var(--line); }
.dashboard-context b { display: block; color: var(--g-800); font-size: 19px; margin-top: 2px; }
.dashboard-period-control { display: flex; align-items: center; gap: 8px; }
.dashboard-period-control label { color: var(--muted); font-size: 13px; white-space: nowrap; }
.dashboard-period { min-width: 190px; }
.dash-top { display: grid; grid-template-columns: 1.1fr 1fr 1.2fr; gap: 16px; align-items: center; }
.stat-list { display: flex; flex-direction: column; gap: 10px; }
.stat { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.stat b { font-size: 15px; }
.stat .n { min-width: 56px; text-align: center; color: #fff; font-weight: 700; border-radius: 6px; padding: 4px 10px; }
.stat .n.c1 { background: var(--brand-teal); color: var(--teal-ink); } .stat .n.c2 { background: var(--brand-gray); color: var(--brand-black); } .stat .n.c3 { background: #dff5f0; color: var(--teal-ink); } .stat .n.c4 { background: var(--g-800); }
.donut-wrap { display: flex; align-items: center; gap: 16px; justify-content: center; }
.donut { width: 200px; height: 200px; }
.dlegend { display: flex; flex-direction: column; gap: 8px; }
.dlegend div { display: flex; align-items: center; gap: 8px; font-size: 13.5px; font-weight: 700; }
.dlegend .n { min-width: 48px; text-align: center; color: #fff; border-radius: 6px; padding: 2px 8px; }
.dash-bottom { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 16px; }
.widget { background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow); overflow: hidden; }
.widget .w-head { padding: 10px 14px; color: #fff; font-weight: 700; display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.widget .w-head.orange { background: var(--orange); }
.widget .w-head.blue { background: var(--brand-blue); }
.widget .w-head.green { background: var(--brand-teal); color: var(--teal-ink); }
.widget .w-head.green .mini-tabs { background: rgba(0,0,0,.12); }
.widget .w-head.green .mini-tabs button { color: var(--teal-ink); }
.widget .w-body { padding: 10px 14px; min-height: 220px; }
.widget .mini-tabs { display: flex; gap: 4px; background: rgba(255,255,255,.25); border-radius: 20px; padding: 2px; }
.widget .mini-tabs button { border: 0; background: transparent; color: #fff; padding: 3px 12px; border-radius: 20px; cursor: pointer; font-weight: 700; font-size: 13px; }
.widget .mini-tabs button.on { background: #fff; color: #333; }
.wl { list-style: none; margin: 0; padding: 0; }
.wl li { padding: 7px 0; border-bottom: 1px solid var(--line); font-size: 13.5px; display: flex; justify-content: space-between; gap: 8px; }
.wl li a { color: var(--g-800); font-weight: 700; }
.cal { width: 100%; border-collapse: collapse; text-align: center; font-size: 13.5px; }
.cal th { color: var(--muted); font-weight: 500; padding: 4px; }
.cal td { padding: 4px; }
.cal td span { display: inline-flex; width: 32px; height: 32px; align-items: center; justify-content: center; border-radius: 50%; position: relative; }
.cal td span.today { background: var(--g-600); color: #fff; font-weight: 700; }
.cal td span.due:after { content: ""; position: absolute; bottom: 1px; width: 6px; height: 6px; border-radius: 50%; background: var(--orange); }
.bars { display: flex; align-items: flex-end; gap: 14px; height: 170px; padding: 10px 6px 0; }
.bars .bar { flex: 1; display: flex; flex-direction: column; align-items: center; gap: 4px; height: 100%; justify-content: flex-end; }
.bars .bar .cols { display: flex; gap: 3px; align-items: flex-end; height: 100%; width: 100%; justify-content: center; }
.bars .bar .cols i { display: block; width: 14px; border-radius: 3px 3px 0 0; }
.bars .bar small { font-size: 11px; color: var(--muted); white-space: nowrap; }

/* ===== الدخول ===== */
.login { position: fixed; inset: 0; background: linear-gradient(135deg, var(--brand-blue), #174f9a); display: flex; align-items: center; justify-content: center; z-index: 100; }
.login-box { background: #fff; color: var(--brand-black); width: 420px; max-width: 94vw; border-radius: 16px; padding: 34px 32px; box-shadow: 0 20px 60px rgba(0,0,0,.35); }
.login-box .logo { text-align: center; margin-bottom: 14px; }
.login-box .logo img { width: 84px; height: 84px; }
.login-box h2 { text-align: center; color: var(--g-800); font-size: 22px; }
.login-box p { text-align: center; color: #667; margin: 4px 0 20px; }
.login-box .hint { font-size: 12.5px; color: #667; background: var(--g-50); border-radius: 8px; padding: 10px; margin-top: 14px; line-height: 1.7; }
.login-box .err { color: var(--red); text-align: center; font-weight: 700; min-height: 22px; }

/* ===== التنبيهات والنوافذ ===== */
.toasts { position: fixed; bottom: 20px; left: 20px; display: flex; flex-direction: column; gap: 10px; z-index: 200; }
.toast { background: var(--card); color: var(--text); border-radius: 8px; box-shadow: 0 6px 24px rgba(0,0,0,.25); padding: 12px 16px; min-width: 300px; max-width: 420px; display: flex; align-items: center; gap: 12px; border-right: 6px solid var(--g-600); animation: toastin .25s ease; }
.toast.error { border-right-color: var(--red); } .toast.info { border-right-color: var(--blue); } .toast.warn { border-right-color: var(--orange); }
.toast .t-ic { width: 30px; height: 30px; border-radius: 50%; display: flex; align-items: center; justify-content: center; color: #fff; background: var(--g-600); flex-shrink: 0; }
.toast.error .t-ic { background: var(--red); } .toast.info .t-ic { background: var(--blue); } .toast.warn .t-ic { background: var(--orange); }
.toast b { display: block; font-size: 14px; } .toast span { font-size: 13px; }
.toast .t-x { margin-right: auto; background: transparent; border: 0; cursor: pointer; color: var(--muted); }
@keyframes toastin { from { transform: translateY(20px); opacity: 0; } to { transform: none; opacity: 1; } }
.modal-bg { position: fixed; inset: 0; background: rgba(0,0,0,.45); display: flex; align-items: center; justify-content: center; z-index: 150; padding: 20px; }
.modal { background: var(--card); border-radius: 12px; width: 560px; max-width: 100%; max-height: 92vh; overflow: auto; box-shadow: 0 20px 60px rgba(0,0,0,.4); animation: modalin .2s ease; }
.modal.lg { width: 860px; } .modal.xl { width: 1100px; }
.modal .m-head { display: flex; align-items: center; justify-content: space-between; padding: 14px 18px; border-bottom: 1px solid var(--line); font-size: 20px; font-weight: 700; color: var(--g-800); }
.modal .m-head .x { width: 34px; height: 34px; border-radius: 50%; border: 0; background: var(--brand-blue); color: #fff; cursor: pointer; font-size: 18px; }
.modal .m-body { padding: 18px; }
.modal .m-foot { display: flex; justify-content: center; gap: 12px; padding: 14px 18px 18px; }
@keyframes modalin { from { transform: translateY(-16px); opacity: 0; } to { transform: none; opacity: 1; } }
.loader { position: fixed; inset: 0; background: rgba(255,255,255,.6); display: flex; flex-direction: column; align-items: center; justify-content: center; z-index: 300; gap: 12px; color: var(--g-800); font-weight: 700; }
.spinner { width: 46px; height: 46px; border: 5px solid var(--g-100); border-top-color: var(--g-600); border-radius: 50%; animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.loading-row { text-align: center; padding: 24px; color: var(--muted); }
.done-box { text-align: center; padding: 10px 0 20px; }
.done-box h2 { color: var(--g-600); font-size: 30px; }
.done-panels { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; margin-top: 20px; }
.done-panels .p { border-left: 1px solid var(--line); padding: 10px 30px; }
.done-panels .p:last-child { border-left: 0; }
.done-panels h3 { color: var(--g-700); font-size: 22px; margin-bottom: 14px; }
.done-panels .bignum { font-size: 22px; font-weight: 700; }
.done-panels img.qr { width: 150px; height: 150px; display: block; margin: 10px auto; }
.profile-head { display: flex; align-items: center; gap: 18px; }
.profile-head img { width: 96px; height: 96px; border-radius: 50%; object-fit: cover; border: 3px solid var(--g-100); }
.profile-head .name { font-size: 22px; font-weight: 700; color: var(--g-800); }
.acc { border-bottom: 1px solid var(--line); }
.acc .acc-h { display: flex; justify-content: space-between; align-items: center; padding: 14px 16px; font-size: 20px; font-weight: 700; cursor: pointer; background: var(--bg); }
.acc .acc-b { padding: 16px; }
.sigpad { border: 1px solid var(--line); background: #fff; border-radius: 8px; touch-action: none; display: block; width: 100%; max-width: 560px; height: 220px; }
.signature-summary { display: grid; grid-template-columns: auto 1fr auto; align-items: center; gap: 16px; background: var(--g-50); border: 1px solid var(--g-100); border-radius: 10px; padding: 16px; }
.signature-summary-icon { width: 46px; height: 46px; border-radius: 50%; display: inline-flex; align-items: center; justify-content: center; color: #fff; background: var(--g-600); }
.signature-summary-icon .ic { width: 24px; height: 24px; }
.signature-summary b { color: var(--g-900); font-size: 16px; }
.signature-summary p { margin: 3px 0 0; font-size: 13px; }
.signature-note { margin: 12px 0 0; font-size: 13px; }
.library-intro { margin: 0 0 14px; }
.signature-library { min-height: 142px; }
.signature-filters { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 12px; }
.signature-cards { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 12px; }
.signature-card { border: 1px solid var(--line); border-radius: 10px; overflow: hidden; background: var(--card); box-shadow: 0 1px 3px rgba(15,73,149,.08); }
.signature-preview { height: 118px; display: flex; align-items: center; justify-content: center; padding: 12px; background: linear-gradient(135deg, #fff, var(--g-50)); border-bottom: 1px solid var(--line); }
.signature-preview img { max-width: 100%; max-height: 94px; object-fit: contain; }
.signature-card-body { padding: 11px; display: flex; flex-direction: column; gap: 5px; }
.signature-card-title { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.signature-card-title b { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.signature-card-actions { display: flex; gap: 4px; flex-wrap: wrap; margin-top: 4px; }
.signature-card-actions .btn { padding: 5px 8px; font-size: 12px; }
.signature-card-actions .signature-delete { color: var(--red); }
.library-empty { min-height: 142px; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 7px; background: var(--g-50); border: 1px dashed var(--line); border-radius: 10px; }
.library-empty .ic { color: var(--g-700); width: 34px; height: 34px; }
.library-rule { border: 0; border-top: 1px solid var(--line); margin: 22px 0; }
.signature-create-head h3 { margin: 0; color: var(--g-800); font-size: 18px; }
.signature-create-head p { margin: 3px 0 10px; font-size: 13px; }
.signature-form { background: var(--bg); padding: 14px; border-radius: 10px; }
.signature-form .field { margin-bottom: 0; }
.signature-pad-wrap { padding: 10px 0 4px; }
.signature-pad-wrap .sigpad { max-width: none; }
.signature-form-actions { margin-top: 10px; }
.letter-composer { background: var(--card); padding: 18px; }
.letter-composer-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 16px; padding-bottom: 16px; margin-bottom: 18px; border-bottom: 1px solid var(--line); }
.letter-composer-head h2 { color: var(--g-800); font-size: 22px; margin: 2px 0; }
.letter-composer-head p { margin: 4px 0 0; font-size: 13px; }
.eyebrow { color: var(--g-700); font-size: 12px; font-weight: 700; }
.letter-reference { white-space: nowrap; color: var(--muted); font-size: 13px; background: var(--g-50); border-radius: 7px; padding: 7px 10px; }
.letter-fields { max-width: 980px; }
.letter-body-field { gap: 0; }
.letter-body-field > label { margin-bottom: 6px; }
.editor-toolbar { display: flex; gap: 3px; flex-wrap: wrap; padding: 6px; background: var(--g-50); border: 1px solid var(--line); border-bottom: 0; border-radius: 8px 8px 0 0; }
.editor-tool { width: 34px; height: 34px; display: inline-flex; justify-content: center; align-items: center; color: var(--g-800); background: transparent; border: 0; border-radius: 6px; cursor: pointer; }
.editor-tool:hover, .editor-tool:focus-visible { background: var(--g-100); outline: none; }
.letter-editor { min-height: 220px; width: 100%; padding: 12px; border: 1px solid var(--line); border-radius: 0 0 8px 8px; background: var(--card); outline: none; line-height: 1.85; }
.letter-editor:focus { border-color: var(--brand-teal); box-shadow: 0 0 0 3px rgba(38,180,159,.20); }
.letter-editor p { margin: 0 0 10px; }
.letter-composer-actions { display: flex; gap: 10px; justify-content: flex-end; margin-top: 20px; }
.kv-list { display: grid; grid-template-columns: repeat(4, 1fr); gap: 14px 18px; }
.kv-list .k { color: var(--muted); font-size: 13px; }
.kv-list .v { font-weight: 700; }
.admin-tabs { display: flex; gap: 6px; margin-bottom: 14px; flex-wrap: wrap; }
.search-bar { background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow); padding: 12px 16px; display: flex; gap: 10px; flex-wrap: wrap; align-items: center; margin-bottom: 14px; }
.search-bar .input { width: auto; min-width: 160px; }
.empty-big { text-align: center; padding: 40px; font-size: 24px; font-weight: 700; color: #444; }
[data-theme="dark"] .empty-big { color: var(--muted); }
.scan-video { width: 100%; max-height: 360px; background: #000; border-radius: 8px; }
.scan-thumbs { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 10px; }
.scan-thumbs img { width: 80px; height: 106px; object-fit: cover; border: 2px solid var(--line); border-radius: 4px; }
.qr-inline { width: 48px; height: 48px; vertical-align: middle; }
.print-frame { width: 100%; height: 75vh; border: 0; }
.hint-box { background: #fff8e1; border: 1px solid #ffe08a; border-radius: 8px; padding: 10px 14px; font-size: 13.5px; }
.badge-count { background: var(--teal); color: #fff; border-radius: 12px; padding: 0 8px; font-size: 12px; }

@media (max-width: 1100px) {
  .viewer { grid-template-columns: 1fr; }
  .detail-workspace { grid-template-columns: 1fr; }
  .detail-document { border-inline-start: 0; border-top: 1px solid var(--line); padding-inline-start: 0; padding-top: 16px; }
  .viewer-compact .viewer { grid-template-columns: 1fr; }
  .dash-top, .dash-bottom { grid-template-columns: 1fr; }
  .dgrid { grid-template-columns: repeat(2, 1fr); }
  .form-grid { grid-template-columns: 1fr; }
  .tb-search input { width: 130px; }
  .brand-text span { display: none; }
  .side-label { display: none; }
}
@media (max-width: 720px) {
  .topbar { position: sticky; min-height: 0; padding: 8px 10px; flex-wrap: wrap; gap: 7px 8px; }
  .tb-right { width: 100%; display: grid; grid-template-columns: 42px auto minmax(0, 1fr); gap: 5px; }
  .tb-right .brand { margin: 0; }
  .tb-right .brand-text { display: none; }
  .tb-right .tb-search { margin: 0; min-width: 0; width: 100%; }
  .tb-right .tb-search input { width: 100%; min-width: 0; }
  .tb-left { width: 100%; justify-content: center; gap: 2px; padding-top: 5px; border-top: 1px solid rgba(255,255,255,.2); }
  .tb-left .user-chip { margin: 0; }
  .tb-left .user-chip span { display: none; }
  .tb-left .icon-btn { width: 38px; height: 38px; }
  .view { padding: 12px; }
  .dgrid, .kv-list { grid-template-columns: 1fr; }
  .tb-center { display: none; }
  .done-panels { grid-template-columns: 1fr; }
  .stepper { margin: 10px 0 20px; }
  .stepper .step { min-width: 70px; }
  .stepper .step span { font-size: 12px; }
  .toolbar .search { min-width: 100%; }
  .search-bar { align-items: stretch; }
  .search-bar > .input, .search-bar > .sel, .search-bar > .btn { width: 100% !important; min-width: 0 !important; }
  .settings-panel { top: 116px; left: 12px; }
  .notif-panel { top: 116px; left: 12px; right: 12px; width: auto; }
  .dtabs, .action-bar { flex-wrap: nowrap; overflow-x: auto; overscroll-behavior-inline: contain; scrollbar-width: thin; }
  .dtab, .action-bar .act { flex: 0 0 auto; }
  .annotation-form { grid-template-columns: 1fr; }
  .annotation-form > .field:first-child { grid-row: auto; }
  .annotation-form > .btn { width: 100%; justify-content: center; }
  .annotation-meta { align-items: flex-start; }
  .annotation-status { flex-wrap: wrap; justify-content: flex-end; }
  .dashboard-context { align-items: stretch; flex-direction: column; }
  .dashboard-period-control { align-items: stretch; flex-direction: column; }
  .dashboard-period { width: 100%; }
  .modal-bg { align-items: flex-end; padding: 0; }
  .modal, .modal.lg, .modal.xl { width: 100%; max-height: 92vh; border-radius: 16px 16px 0 0; }
  .signature-summary { grid-template-columns: auto 1fr; }
  .signature-summary .btn { grid-column: 1 / -1; width: 100%; }
  .signature-cards { grid-template-columns: 1fr; }
  .signature-preview { height: 108px; }
  .signature-form { padding: 12px; }
  .sigpad { height: 170px; }
  .letter-composer { padding: 14px 0; }
  .letter-composer-head { padding: 0 14px 14px; flex-direction: column; gap: 8px; }
  .letter-fields { padding: 0 14px; }
  .letter-composer-actions { padding: 0 14px; flex-direction: column; }
  .letter-composer-actions .btn { width: 100%; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: 1ms !important; animation-iteration-count: 1 !important; transition-duration: 1ms !important; scroll-behavior: auto !important; }
}
@media print { .topbar, .sidenav, .toasts, .side-label { display: none !important; } .view { padding: 0; } }

/* ===== تحسينات الوضع الليلي ===== */
[data-theme="dark"] .status.received, [data-theme="dark"] .status.completed { background: #2f6b46; color: #e6f5ea; }
[data-theme="dark"] .status.pending { background: #6b4e12; color: #ffe9b8; }
[data-theme="dark"] .status.saved, [data-theme="dark"] .status.draft { background: #3b4a41; color: #e0e6e2; }
[data-theme="dark"] .status.late, [data-theme="dark"] .status.withdrawn { background: #6b2323; color: #ffd9d9; }
[data-theme="dark"] .status.forwarded { background: #23446b; color: #d9e6ff; }
[data-theme="dark"] .tag, [data-theme="dark"] .chip { color: #e6efe9; }
[data-theme="dark"] .chip.active { color: #fff; }
[data-theme="dark"] table.grid th { color: #e6efe9; }
[data-theme="dark"] .v-toolbar { background: #1f2d25; border-color: var(--line); }
[data-theme="dark"] .v-tool { color: #dfe7e2; }
[data-theme="dark"] .viewer-main { background: #101a14; }
[data-theme="dark"] .action-bar { background: #1e3140; color: #dfe7e2; }
[data-theme="dark"] .action-bar .act { border-left-color: #2f4a5e; }
[data-theme="dark"] .action-bar .act:hover { background: #2a4356; }
[data-theme="dark"] .sel .sel-input, [data-theme="dark"] .input { color: var(--text); }
[data-theme="dark"] .dtab { color: var(--text); }
[data-theme="dark"] .hint-box { background: #4a3f16; border-color: #7a6a2a; color: #fff3c4; }
[data-theme="dark"] .no-att { background: #244a34; color: #e6f5ea; }
[data-theme="dark"] .stat .n.c1, [data-theme="dark"] .stat .n.c3 { color: #1b2a20; }
