*, *::before, *::after { box-sizing: border-box; }
/* ---------- NESAM brand palette (from logo: teal + charcoal + off-white) ---------- */
:root {
  --primary: #00838a; --primary-dark: #00575c; --primary-light: #17a2a8; --accent: #00a5ad;
  --bg: #f2f5f5; --card: #ffffff; --text: #253030; --muted: #64807e;
  --danger: #c0392b; --ok: #1e8e3e; --warn: #b7791f; --border: #d9e3e2;
  --topbar: #00838a; --topbar-text: #f4f3ee;
  --radius: 10px;
  --shadow: 0 1px 4px rgba(0, 60, 63, .08);
}
html[data-theme="dark"] {
  --primary: #19b3ba; --primary-dark: #0e8a90; --primary-light: #2fd0d7; --accent: #19b3ba;
  --bg: #0d1717; --card: #142021; --text: #e4eceb; --muted: #8fa9a7;
  --danger: #e06553; --ok: #4cc06d; --warn: #d9a144; --border: #24393a;
  --topbar: #0b2f31; --topbar-text: #e9f2f1;
  --shadow: 0 1px 6px rgba(0, 0, 0, .35);
}
html, body { overflow-x: hidden; max-width: 100%; }
body { margin: 0; font-family: "Segoe UI", Tahoma, Arial, sans-serif; background: var(--bg); color: var(--text); }
[lang="ar"] body, html[dir="rtl"] body { font-family: Tahoma, "Segoe UI", Arial, sans-serif; }

/* Layout */
#topbar { background: var(--topbar); color: var(--topbar-text); display: flex; align-items: center; gap: 12px; padding: 10px 16px; position: sticky; top: 0; z-index: 50; flex-wrap: wrap; }
#topbar .brand { font-weight: 700; font-size: 17px; display: flex; align-items: center; gap: 10px; }
#topbar .brand small { display: block; font-weight: 400; font-size: 11px; opacity: .8; }
.brand-logo { height: 38px; border-radius: 8px; }
#topbar .right { display: flex; align-items: center; gap: 8px; }

/* ---------- Side navigation (left in English, right in Arabic) ---------- */
.layout { display: flex; align-items: flex-start; }
#sidebar { width: 205px; flex-shrink: 0; background: var(--card); border-inline-end: 1px solid var(--border);
  position: sticky; top: 58px; height: calc(100vh - 58px); overflow-y: auto; padding: 14px 10px; }
#nav { display: flex; flex-direction: column; gap: 3px; }
#nav a { color: var(--text); text-decoration: none; padding: 10px 13px; border-radius: 9px; font-size: 14.5px; display: block; }
#nav a:hover { background: color-mix(in srgb, var(--primary) 10%, var(--card)); }
#nav a.active { background: var(--primary); color: #fff; font-weight: 600; }
/* Bottom navigation (mobile app style) */
#bottomnav { display: none; }
@media (max-width: 760px) {
  .layout { flex-direction: column; }
  #sidebar { display: none; }
  #bottomnav { display: flex; position: fixed; bottom: 0; left: 0; right: 0; z-index: 60;
    background: var(--card); border-top: 1px solid var(--border);
    overflow-x: auto; -webkit-overflow-scrolling: touch; scrollbar-width: none;
    padding: 5px 4px calc(5px + env(safe-area-inset-bottom));
    box-shadow: 0 -3px 14px rgba(0, 0, 0, .14); }
  #bottomnav::-webkit-scrollbar { display: none; }
  #bottomnav a { flex: 1 0 auto; min-width: 62px; max-width: 96px; display: flex; flex-direction: column; align-items: center; gap: 2px;
    text-decoration: none; color: var(--muted); padding: 5px 4px; border-radius: 9px; }
  #bottomnav a.active { color: var(--primary); background: color-mix(in srgb, var(--primary) 13%, var(--card)); }
  .bn-ico { font-size: 19px; line-height: 1.15; }
  .bn-lbl { font-size: 10.5px; font-weight: 600; white-space: nowrap; max-width: 90px; overflow: hidden; text-overflow: ellipsis; }
  #main { padding-bottom: 92px; }
  .site-footer { padding-bottom: 86px; }
  .act-drawer { padding-bottom: calc(60px + env(safe-area-inset-bottom)); }
}
.lang-btn { background: rgba(255,255,255,.9); color: #00575c; border: none; padding: 6px 12px; border-radius: 7px; cursor: pointer; font-weight: 700; }
html[data-theme="dark"] .lang-btn { background: rgba(255,255,255,.15); color: var(--topbar-text); }
.logout-btn { background: transparent; color: var(--topbar-text); border: 1px solid rgba(255,255,255,.4); padding: 6px 10px; border-radius: 7px; cursor: pointer; }
#main { flex: 1; min-width: 0; max-width: 1100px; margin: 20px auto; padding: 0 14px 60px; }

/* Activity side panel */
.act-btn { background: rgba(255,255,255,.14); color: var(--topbar-text); border: 1px solid rgba(255,255,255,.35); padding: 6px 11px; border-radius: 7px; cursor: pointer; font-size: 15px; }
.act-btn:hover { background: rgba(255,255,255,.25); }
.notify-btn { position: relative; }
#notif-badge { position: absolute; top: -7px; inset-inline-end: -7px; min-width: 17px; height: 17px; padding: 1px 4px; border-radius: 10px; background: var(--danger); color: #fff; font-size: 10px; font-weight: 800; line-height: 15px; border: 1px solid var(--topbar); }
.notif-item { text-decoration: none; color: var(--text); border-radius: 7px; }
.notif-item.unread { background: color-mix(in srgb, var(--primary) 10%, var(--card)); }
.act-drawer { position: fixed; top: 0; bottom: 0; inset-inline-end: 0; width: min(340px, 90vw); background: var(--card);
  border-inline-start: 1px solid var(--border); box-shadow: -6px 0 24px rgba(0,0,0,.18); z-index: 95;
  display: flex; flex-direction: column; transform: translateX(110%); transition: transform .25s; }
html[dir="rtl"] .act-drawer { transform: translateX(-110%); box-shadow: 6px 0 24px rgba(0,0,0,.18); }
.act-drawer.open { transform: translateX(0) !important; }
.act-head { display: flex; align-items: center; gap: 8px; padding: 12px 14px; border-bottom: 2px solid var(--primary); background: var(--bg); }
.act-list { overflow-y: auto; flex: 1; padding: 10px 12px; }
.act-item { display: flex; gap: 10px; padding: 9px 4px; border-bottom: 1px solid var(--border); font-size: 13.5px; }
.act-item:last-child { border-bottom: none; }
.act-ico { font-size: 17px; line-height: 1.3; }
.act-txt { line-height: 1.45; }
.act-time { color: var(--muted); font-size: 11.5px; margin-top: 2px; }
@media print { .act-drawer { display: none !important; } }

/* Modal */
.modal-bg { position: fixed; inset: 0; background: rgba(5,25,26,.55); display: flex; align-items: center; justify-content: center; z-index: 100; padding: 14px; }
.modal { background: var(--card); color: var(--text); border-radius: 12px; padding: 20px; width: 100%; max-width: 560px; max-height: 92vh; overflow-y: auto; border: 1px solid var(--border); }
.modal h3 { margin: 0 0 14px; }
.modal .btns { display: flex; gap: 10px; justify-content: flex-end; margin-top: 16px; }

/* Cards, tables, forms */
.card { background: var(--card); border: 1px solid var(--border); border-radius: var(--radius); padding: 18px; margin-bottom: 16px; box-shadow: var(--shadow); }
.card h2 { margin: 0 0 14px; font-size: 19px; }
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 12px; }
.stat { background: var(--card); border: 1px solid var(--border); border-radius: var(--radius); padding: 14px; text-align: center; box-shadow: var(--shadow); }
.stat .ico { font-size: 20px; margin-bottom: 2px; }
.stat .num { font-size: 28px; font-weight: 700; color: var(--primary); }
.stat .lbl { font-size: 13px; color: var(--muted); margin-top: 2px; }
.stat.warn { border-color: #f0d9a8; }
.stat.warn .num { color: var(--warn); }

table { width: 100%; border-collapse: collapse; font-size: 14px; }
th, td { padding: 9px 10px; border-bottom: 1px solid var(--border); text-align: start; }
th { background: color-mix(in srgb, var(--primary) 8%, var(--card)); font-size: 12.5px; text-transform: uppercase; letter-spacing: .4px; color: var(--muted); }
tr:hover td { background: color-mix(in srgb, var(--primary) 4%, var(--card)); }
tr.row-pending td { background: color-mix(in srgb, var(--warn) 9%, var(--card)); }
.table-wrap { overflow-x: auto; }

label { display: block; font-size: 13px; color: var(--muted); margin-bottom: 4px; }
input, select, textarea { width: 100%; padding: 9px 10px; border: 1px solid var(--border); border-radius: 8px; font-size: 14px; font-family: inherit; background: var(--card); color: var(--text); }
input:focus, select:focus, textarea:focus { outline: 2px solid var(--primary); border-color: var(--primary); }
input:disabled { background: var(--bg); color: var(--muted); }
.form-row { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 12px; margin-bottom: 12px; }
.form-row.single { grid-template-columns: 1fr; }

button, .btn { background: var(--primary); color: #fff; border: none; padding: 9px 16px; border-radius: 8px; font-size: 14px; cursor: pointer; font-family: inherit; text-decoration: none; display: inline-block; }
button:hover, .btn:hover { background: var(--primary-dark); }
.btn-sec { background: color-mix(in srgb, var(--primary) 10%, var(--card)); color: var(--text); }
.btn-sec:hover { background: color-mix(in srgb, var(--primary) 20%, var(--card)); }
.btn-danger { background: var(--danger); }
.btn-sm { padding: 5px 10px; font-size: 13px; }
.btn-lg { padding: 13px 22px; font-size: 16px; width: 100%; }
.toolbar { display: flex; gap: 10px; align-items: center; margin-bottom: 14px; flex-wrap: wrap; }
.toolbar input[type="search"], .toolbar select { max-width: 260px; }
.spacer { flex: 1; }

.badge { display: inline-block; padding: 3px 9px; border-radius: 20px; font-size: 12px; font-weight: 600; }
.badge.released { background: #fff3d6; color: #8a6210; }
.badge.installed { background: #ddf3e2; color: #14652c; }
.badge.returned { background: #e3e8e6; color: #55655f; }
.badge.active { background: #ddf3e2; color: #14652c; }
.badge.closed { background: #e3e8e6; color: #55655f; }
.badge.low { background: #fde3df; color: #93261a; }
.badge.pending { background: #fff3d6; color: #8a6210; }
html[data-theme="dark"] .badge.released, html[data-theme="dark"] .badge.pending { background: #4a3a10; color: #f5d489; }
html[data-theme="dark"] .badge.installed, html[data-theme="dark"] .badge.active { background: #143d22; color: #8fe3ab; }
html[data-theme="dark"] .badge.returned, html[data-theme="dark"] .badge.closed { background: #2b3936; color: #b9c9c5; }
html[data-theme="dark"] .badge.low { background: #4c1d16; color: #f4a496; }

.muted { color: var(--muted); font-size: 13px; }
.error-msg { background: #fde3df; color: #93261a; padding: 10px 12px; border-radius: 8px; margin-bottom: 12px; }
.ok-msg { background: #ddf3e2; color: #14652c; padding: 10px 12px; border-radius: 8px; margin-bottom: 12px; }
html[data-theme="dark"] .error-msg { background: #4c1d16; color: #f4a496; }
html[data-theme="dark"] .ok-msg { background: #143d22; color: #8fe3ab; }
.empty { text-align: center; color: var(--muted); padding: 30px 10px; }

/* Login */
.login-wrap { min-height: 100vh; display: flex; align-items: center; justify-content: center; background: linear-gradient(135deg, #00838a 0%, #00474b 100%); padding: 16px; }
.login-box { background: var(--card); border-radius: 14px; padding: 30px; width: 100%; max-width: 380px; }
.login-logo { text-align: center; margin-bottom: 8px; }
.login-logo .brand-logo { height: 84px; border-radius: 12px; }
.login-box h1 { margin: 0 0 4px; font-size: 22px; color: var(--primary); text-align: center; }
.login-box .sub { text-align: center; color: var(--muted); font-size: 13px; margin-bottom: 20px; }
.login-box .lang-row { text-align: center; margin-top: 14px; display: flex; gap: 8px; justify-content: center; }
.login-box .lang-btn { background: var(--primary); color: #fff; }

/* Key-value blocks */
.kv { display: grid; grid-template-columns: auto 1fr; gap: 6px 16px; font-size: 14px; margin-top: 8px; }
.kv .k { color: var(--muted); }

/* Progress bar */
.progress { position: relative; background: color-mix(in srgb, var(--primary) 12%, var(--bg)); border-radius: 20px; height: 20px; overflow: hidden; }
.progress-fill { background: linear-gradient(90deg, var(--primary-dark), var(--primary-light)); height: 100%; border-radius: 20px; transition: width .3s; }
.progress-lbl { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; font-size: 11.5px; font-weight: 700; color: var(--text); }
.progress-fill.slow { background: linear-gradient(90deg, #c98f1b, #e0b04a); }
.progress-fill.done { background: linear-gradient(90deg, #1e8e3e, #34b45a); }

/* Alerts */
.alert { display: flex; align-items: center; gap: 12px; padding: 11px 14px; border-radius: 10px; margin-bottom: 8px; font-size: 14px; }
.alert > div { flex: 1; }
.alert-ico { font-size: 20px; }
.alert.warn { background: #fff8e6; border: 1px solid #f0d9a8; color: #4d3a08; }
.alert.danger { background: #fdeeec; border: 1px solid #f3c1ba; color: #5a1c12; }
html[data-theme="dark"] .alert.warn { background: #3a2f10; border-color: #6b5619; color: #f2dfae; }
html[data-theme="dark"] .alert.danger { background: #43201a; border-color: #7a382c; color: #f4c4bb; }

/* Project cards */
.proj-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: 14px; }
.proj-card { background: var(--card); border: 1px solid var(--border); border-radius: 14px; padding: 16px; display: flex; flex-direction: column; gap: 12px; box-shadow: var(--shadow); transition: box-shadow .15s, transform .15s; }
.proj-card:hover { box-shadow: 0 4px 16px rgba(0, 60, 63, .18); transform: translateY(-2px); }
.proj-card.closed { opacity: .65; }
.pc-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 10px; }
.pc-title { font-size: 16.5px; font-weight: 700; color: var(--primary); text-decoration: none; }
.pc-title:hover { text-decoration: underline; }
.pc-progress { display: flex; align-items: center; gap: 14px; }
.pc-pct { font-size: 34px; font-weight: 800; color: var(--primary); min-width: 74px; text-align: center; line-height: 1; }
.pc-pct small { font-size: 16px; font-weight: 700; }
.pc-pct.slow { color: var(--warn); }
.pc-pct.done { color: var(--ok); }
.pc-bar { flex: 1; }
.pc-nums { font-size: 12.5px; color: var(--muted); margin-top: 5px; }
.progress-lg { height: 14px; }
.progress-lg .progress-lbl { display: none; }
.pc-meta { display: flex; flex-direction: column; gap: 5px; font-size: 13px; border-top: 1px solid var(--border); padding-top: 10px; }
.pc-meta > div { display: flex; justify-content: space-between; gap: 10px; align-items: center; }
.pc-meta .k { color: var(--muted); }
.pc-view { text-align: center; margin-top: auto; }

/* Daily logs */
.log-entry { border: 1px solid var(--border); border-radius: 10px; padding: 12px 14px; margin-bottom: 10px; background: color-mix(in srgb, var(--primary) 2%, var(--card)); }
.log-entry.pending { border-color: #e5c576; background: color-mix(in srgb, #e5c576 8%, var(--card)); }
.log-entry.rejected { opacity: .6; }
.log-entry .log-head { display: flex; justify-content: space-between; gap: 10px; flex-wrap: wrap; margin-bottom: 6px; }
.log-entry .log-note { font-size: 14px; white-space: pre-wrap; margin-bottom: 6px; }
.log-entry .log-lines { display: flex; gap: 6px; flex-wrap: wrap; margin-bottom: 6px; }
.log-photo { max-height: 140px; max-width: 100%; border-radius: 8px; border: 1px solid var(--border); }

/* ---------- Receipt (always printed on white) ---------- */
.receipt-paper { background: #fff; color: #1c2b27; max-width: 800px; margin: 0 auto; padding: 34px 40px; border: 1px solid var(--border); border-radius: 8px; }
.receipt-paper.rc-disabled { opacity: .55; filter: grayscale(.4); pointer-events: none; }
.rc-head { display: flex; justify-content: space-between; align-items: flex-start; border-bottom: 3px solid #00838a; padding-bottom: 14px; }
.rc-head .co { font-size: 20px; font-weight: 800; color: #00838a; }
.rc-head .co-sub { font-size: 12px; color: #64807e; white-space: pre-line; }
.rc-title { text-align: center; margin: 16px 0 4px; }
.rc-title .en { font-size: 18px; font-weight: 700; letter-spacing: 1px; }
.rc-title .ar { font-size: 17px; font-weight: 700; }
.rc-meta { display: flex; justify-content: space-between; gap: 20px; margin: 14px 0; font-size: 13.5px; flex-wrap: wrap; }
.rc-meta div { line-height: 1.7; }
.receipt-paper table { margin: 10px 0 18px; }
.receipt-paper th { background: #00838a; color: #fff; }
.receipt-paper th, .receipt-paper td { border: 1px solid #c9d4d0; padding: 7px 9px; font-size: 13px; }
.receipt-paper tr:hover td { background: transparent; }
.rc-sign { display: flex; justify-content: space-between; gap: 30px; margin-top: 44px; }
.rc-sign > div { flex: 1; text-align: center; font-size: 13px; }
.rc-sign .line { border-top: 1.5px solid #444; margin-top: 42px; padding-top: 6px; }
.rc-notes { font-size: 13px; margin-top: 8px; min-height: 20px; }
.edit-hint { background: #fff8e6; border: 1px dashed #d4a537; padding: 8px 12px; border-radius: 8px; font-size: 13px; margin-bottom: 12px; color: #4d3a08; }
html[data-theme="dark"] .edit-hint { background: #3a2f10; border-color: #6b5619; color: #f2dfae; }
[contenteditable="true"]:hover { outline: 1.5px dashed #d4a537; }
[contenteditable="true"]:focus { outline: 2px solid #d4a537; background: #fffdf4; }

@media print {
  #topbar, #sidebar, .no-print { display: none !important; }
  #main { margin: 0; max-width: none; padding: 0; }
  body { background: #fff; }
  .receipt-paper { border: none; border-radius: 0; padding: 10px 0; max-width: none; }
  .card { border: none; padding: 0; }
  [contenteditable="true"]:hover, [contenteditable="true"]:focus { outline: none; background: none; }
}
/* ---------- Mobile (phones) ---------- */
@media (max-width: 640px) {
  #topbar { padding: 7px 10px; gap: 8px; position: static; }
  #topbar .brand { font-size: 15px; }
  #topbar .brand small { display: none; }
  .brand-logo { height: 30px; }
  #topbar .right { gap: 5px; }
  .act-btn { padding: 5px 8px; font-size: 14px; }
  .lang-btn, .logout-btn { padding: 5px 9px; font-size: 13px; }

  #main { padding: 0 8px 40px; margin: 12px auto; }
  .card { padding: 13px 12px; margin-bottom: 12px; border-radius: 9px; }
  .card h2 { font-size: 16.5px; margin-bottom: 10px; }
  .toolbar { gap: 7px; margin-bottom: 10px; }
  .toolbar input[type="search"], .toolbar select { max-width: none; flex: 1; min-width: 130px; }
  button, .btn { padding: 8px 13px; font-size: 13.5px; }

  /* forms stack vertically */
  .form-row { grid-template-columns: 1fr; gap: 9px; }

  /* tables become stacked cards — no horizontal scrolling on phones */
  .card .table-wrap { margin: 0; overflow: visible; }
  .card .table-wrap thead { display: none; }
  .card .table-wrap table, .card .table-wrap tbody, .card .table-wrap tr, .card .table-wrap td { display: block; width: 100%; }
  .card .table-wrap tr { border: 1px solid var(--border); border-radius: 10px; margin-bottom: 9px; padding: 3px 11px; background: color-mix(in srgb, var(--primary) 2%, var(--card)); }
  .card .table-wrap tr:hover td, .card .table-wrap tr.row-pending td { background: transparent; }
  .card .table-wrap tr.row-pending { border-color: #e5c576; }
  .card .table-wrap td { display: flex; justify-content: space-between; align-items: center; gap: 12px; border-bottom: 1px dashed var(--border); padding: 7px 0; text-align: end; font-size: 13.5px; }
  .card .table-wrap td:last-child { border-bottom: none; }
  .card .table-wrap td[data-label]::before { content: attr(data-label); font-weight: 700; color: var(--muted); font-size: 10.5px; text-transform: uppercase; letter-spacing: .4px; text-align: start; flex-shrink: 0; }
  .card .table-wrap td .progress { flex: 1; max-width: 58%; }
  .card .table-wrap td input, .card .table-wrap td select { max-width: 56%; }
  .card .table-wrap td:empty { display: none; }
  .btn-sm { padding: 6px 9px; font-size: 12.5px; }

  /* dashboard */
  .stats { grid-template-columns: repeat(auto-fit, minmax(105px, 1fr)); gap: 8px; }
  .stat { padding: 10px 6px; }
  .stat .num { font-size: 21px; }
  .stat .lbl { font-size: 11px; }
  .proj-grid { grid-template-columns: 1fr; gap: 10px; }
  .pc-pct { font-size: 27px; min-width: 58px; }
  .alert { padding: 9px 10px; font-size: 13px; gap: 8px; flex-wrap: wrap; }

  /* modal */
  .modal { padding: 14px 12px; max-height: 94vh; }
  .modal-bg { padding: 8px; align-items: flex-start; padding-top: 20px; }

  /* activity drawer full width */
  .act-drawer { width: 100vw; }

  /* printable papers on screen */
  .receipt-paper { padding: 16px 12px; }
  .rc-head { flex-direction: column; gap: 10px; }
  .rc-head > div[style] { text-align: start !important; }
  .rc-meta { flex-direction: column; gap: 6px; }
  .rc-sign { flex-direction: column; gap: 8px; }
  .rc-sign .line { margin-top: 26px; }

  /* profile / kv blocks */
  .kv { grid-template-columns: 1fr; gap: 2px 0; }
  .kv .k { margin-top: 7px; font-size: 12px; }
  .checkin-btn { width: 100%; }
  .site-header { font-size: 12.5px; padding: 6px 10px; }
  .log-photo { max-height: 110px; }
}
@media (max-width: 380px) {
  #topbar .brand { display: none; }
}
/* ===== Additions: avatars, check-in, site header/footer, hidden cards, disabled rows ===== */
.avatar { border-radius: 50%; object-fit: cover; display: inline-block; vertical-align: middle; border: 2px solid var(--border); }
.avatar-ph { background: var(--primary); color: #fff; display: inline-flex; align-items: center; justify-content: center; font-weight: 700; }
.checkin-btn { padding: 12px 22px; font-size: 15px; border-radius: 10px; font-weight: 700; }
.checkin-btn.in { background: var(--ok); }
.checkin-btn.out { background: var(--danger); }
.site-header { background: color-mix(in srgb, var(--primary) 14%, var(--bg)); color: var(--text); text-align: center; padding: 7px 14px; font-size: 13.5px; border-bottom: 1px solid var(--border); }
.site-footer { text-align: center; color: var(--muted); font-size: 12.5px; padding: 16px 14px 22px; border-top: 1px solid var(--border); margin-top: 30px; }
.hidden-card { border: 1.5px dashed var(--warn); }
tr.row-disabled td { opacity: .55; }
.rc-print-footer { text-align: center; font-size: 11px; color: #667; border-top: 1px solid #ccc; margin-top: 26px; padding-top: 8px; }

/* ============================================================
   ZOHO-STYLE THEME (NESAM teal) — clean white workspace look
   ============================================================ */
:root {
  --bg: #f7f8f8; --card: #ffffff; --border: #e6e9e8; --text: #212b2a; --muted: #6b7876;
  --topbar: #ffffff; --topbar-text: #212b2a;
  --shadow: 0 1px 2px rgba(20, 40, 38, .06);
}
html[data-theme="dark"] {
  --topbar: #142021; --topbar-text: #e4eceb;
}
#topbar { border-bottom: 1px solid var(--border); padding: 8px 16px; }
#topbar .brand { color: var(--primary); }
#topbar .brand small { color: var(--muted); }
.lang-btn { background: color-mix(in srgb, var(--primary) 10%, var(--card)); color: var(--primary); border: 1px solid var(--border); }
.logout-btn { color: var(--muted); border: 1px solid var(--border); }
.act-btn { background: transparent; color: var(--muted); border: 1px solid var(--border); position: relative; }
.act-btn:hover { background: color-mix(in srgb, var(--primary) 8%, var(--card)); color: var(--primary); }
#notif-badge { position: absolute; top: -6px; inset-inline-end: -6px; background: var(--danger); color: #fff;
  border-radius: 10px; min-width: 16px; height: 16px; line-height: 16px; font-size: 10px; font-weight: 700; padding: 0 3px; }

/* + New button & quick-create menu (Zoho center) */
.top-center { display: flex; align-items: center; gap: 10px; flex: 1; justify-content: center; }
.newmenu-wrap { position: relative; }
.new-btn { background: var(--primary); color: #fff; font-weight: 700; border-radius: 8px; padding: 8px 16px; white-space: nowrap; }
.newmenu-panel { display: none; position: absolute; top: 40px; inset-inline-start: 0; min-width: 230px; z-index: 120;
  background: var(--card); border: 1px solid var(--border); border-radius: 10px; box-shadow: 0 8px 26px rgba(0,0,0,.16); padding: 6px; }
.newmenu-panel.open { display: flex; flex-direction: column; }
.newmenu-panel a { padding: 9px 12px; border-radius: 7px; color: var(--text); text-decoration: none; font-size: 14px; }
.newmenu-panel a:hover { background: color-mix(in srgb, var(--primary) 9%, var(--card)); }
#global-search { max-width: 340px; border-radius: 8px; background: var(--bg); }

/* Sidebar: Zoho-like */
#sidebar { background: var(--card); padding: 10px 8px; }
#nav a { color: var(--text); font-size: 14px; border-inline-start: 3px solid transparent; border-radius: 0 8px 8px 0; }
html[dir="rtl"] #nav a { border-radius: 8px 0 0 8px; }
#nav a.active { background: color-mix(in srgb, var(--primary) 10%, var(--card)); color: var(--primary); border-inline-start-color: var(--primary); font-weight: 700; }
#nav a:hover:not(.active) { background: color-mix(in srgb, var(--primary) 5%, var(--card)); }

/* Tables: Zoho list style */
th { background: var(--bg); color: var(--muted); font-size: 11.5px; letter-spacing: .6px; border-bottom: 1px solid var(--border); }
tr:hover td { background: color-mix(in srgb, var(--primary) 3%, var(--card)); }
.card { border-radius: 8px; }

/* Invoice totals block */
.inv-totals { max-width: 340px; margin-inline-start: auto; margin-top: 14px; font-size: 14px; }
.inv-totals > div { display: flex; justify-content: space-between; padding: 7px 10px; border-bottom: 1px solid var(--border); }
.inv-totals > div.grand { background: color-mix(in srgb, var(--primary) 8%, var(--card)); font-size: 16px; border-radius: 8px; border-bottom: none; margin-top: 4px; }

/* Receivables aging (Zoho dashboard) */
.aging { display: grid; grid-template-columns: repeat(auto-fit, minmax(120px, 1fr)); gap: 10px; }
.aging > div { border: 1px solid var(--border); border-radius: 10px; padding: 10px 12px; display: flex; flex-direction: column; gap: 4px; }
.aging .a-lbl { font-size: 12px; font-weight: 700; }

/* Sales vs expenses mini chart */
.fchart { display: flex; gap: 6px; align-items: flex-end; overflow-x: auto; padding-top: 8px; }
.fchart-col { display: flex; flex-direction: column; align-items: center; gap: 4px; min-width: 44px; }
.fchart-bars { display: flex; gap: 3px; align-items: flex-end; height: 74px; }
.fchart-bar { width: 12px; border-radius: 3px 3px 0 0; min-height: 2px; }
.fchart-bar.sales { background: var(--primary); }
.fchart-bar.exp { background: var(--danger); opacity: .8; }
.fchart-col span { font-size: 10.5px; color: var(--muted); }
.dot { display: inline-block; width: 10px; height: 10px; border-radius: 50%; vertical-align: middle; }

@media (max-width: 900px) { .top-center { display: none; } }

/* ============================================================
   ZOHO DOCUMENT TEMPLATE — quotations, invoices, receipts,
   delivery certificates (matches the approved PDF layout)
   ============================================================ */
.receipt-paper { padding: 46px 44px; color: #222; }
.doc-top { display: flex; justify-content: space-between; align-items: flex-start; gap: 24px; margin-bottom: 26px; }
.doc-co .doc-logo { display: block; height: 120px; width: auto; border-radius: 0; margin-bottom: 12px; }
.doc-co .co-name { font-weight: 700; font-size: 15px; color: #1c1c1c; }
.doc-co .co-lines { font-size: 12.5px; color: #555; line-height: 1.6; white-space: pre-line; }
.doc-title { text-align: end; flex-shrink: 0; }
.doc-title h1 { font-size: 44px; font-weight: 300; color: #1c1c1c; margin: 0 0 4px; letter-spacing: 1px; line-height: 1; }
.doc-title .doc-ar { font-size: 17px; color: #444; margin-bottom: 6px; }
.doc-title .doc-no { font-weight: 700; font-size: 14px; color: #222; }
.doc-billto { display: flex; justify-content: space-between; align-items: flex-end; gap: 20px; margin: 22px 0 16px; }
.doc-billto .bt-label { font-size: 13px; color: #444; margin-bottom: 4px; }
.doc-billto .bt-name { font-weight: 700; font-size: 14px; color: #1c1c1c; }
.doc-billto .bt-lines { font-size: 12.5px; color: #555; line-height: 1.6; white-space: pre-line; }
.doc-date { font-size: 13px; color: #222; text-align: end; line-height: 1.8; flex-shrink: 0; }
.receipt-paper table { margin: 12px 0 6px; }
.receipt-paper thead th { background: #3d3f42 !important; color: #fff !important; border: none !important;
  font-size: 11.5px; font-weight: 600; padding: 9px 10px; text-transform: none; letter-spacing: .2px; }
.receipt-paper tbody td { border: none !important; border-bottom: 1px solid #e9e9e9 !important; padding: 11px 10px; font-size: 13px; background: transparent !important; color: #222; }
.receipt-paper td .sub, .receipt-paper .sub { color: #888; font-size: 12px; }
.receipt-paper .num { text-align: end; }
.doc-totals { max-width: 340px; margin-inline-start: auto; margin-top: 4px; font-size: 13.5px; color: #222; }
.doc-totals > div { display: flex; justify-content: space-between; gap: 20px; padding: 9px 14px; }
.doc-totals .grand { background: #f4f4f4; font-weight: 700; font-size: 14.5px; }
.doc-section-title { font-size: 14.5px; color: #333; margin: 30px 0 6px; font-weight: 400; }
.doc-notes { margin-top: 28px; font-size: 12.5px; color: #444; }
.doc-notes b { display: block; color: #222; margin-bottom: 4px; font-size: 13.5px; font-weight: 400; }
.doc-hr { border-top: 1px solid #ddd; margin-top: 40px; padding-top: 12px; text-align: center; font-size: 11.5px; color: #777; }
.doc-band { display: block; width: 100%; height: auto; margin: 0 0 18px; }
.doc-band-footer { margin: 22px 0 0; }

/* Sidebar menu groups */
.nav-grp { margin-top: 6px; }
.nav-grp-title { display: flex; justify-content: space-between; align-items: center; gap: 8px;
  padding: 7px 11px 4px; font-size: 10px; font-weight: 700; letter-spacing: .9px; text-transform: uppercase;
  color: var(--muted); cursor: pointer; user-select: none; }
.nav-grp-title:hover { color: var(--primary); }
.nav-grp .chev { font-size: 9px; transition: transform .15s; }
.nav-grp:not(.open) .chev { transform: rotate(-90deg); }
.nav-grp .nav-grp-items { display: none; }
.nav-grp.open .nav-grp-items { display: block; }

/* ============================================================
   COMPACT DENSITY: narrower pages & documents, smaller fonts
   ============================================================ */
body { font-size: 13.5px; }
#main { max-width: 960px; }
#sidebar { width: 182px; }
#nav a { font-size: 13px; padding: 8px 11px; }
#topbar .brand { font-size: 15px; }
#topbar .brand small { font-size: 10px; }
.brand-logo { height: 32px; }
.card { padding: 14px 15px; margin-bottom: 12px; }
.card h2 { font-size: 16px; margin-bottom: 10px; }
h3 { font-size: 15px; }
table { font-size: 12.5px; }
th { font-size: 10.5px; padding: 7px 8px; }
td { padding: 7px 8px; }
button, .btn { padding: 7px 13px; font-size: 13px; }
.btn-sm { padding: 4px 8px; font-size: 12px; }
.btn-lg { padding: 11px 18px; font-size: 14.5px; }
input, select, textarea { padding: 7px 9px; font-size: 13px; }
label { font-size: 12px; }
.badge { font-size: 11px; padding: 2px 8px; }
.muted { font-size: 12px; }
.stat { padding: 10px 8px; }
.stat .num { font-size: 22px; }
.stat .lbl { font-size: 11.5px; }
.stat .ico { font-size: 16px; }
.pc-title { font-size: 15px; }
.pc-pct { font-size: 28px; min-width: 62px; }
.alert { font-size: 13px; padding: 9px 12px; }
.kv { font-size: 13px; }
.new-btn { padding: 7px 14px; font-size: 13.5px; }
#global-search { max-width: 300px; }
.toolbar { gap: 8px; margin-bottom: 11px; }
.inv-totals { font-size: 13px; max-width: 300px; }

/* Documents: narrower paper, tighter type */
.receipt-paper { max-width: 700px; padding: 32px 34px; }
.doc-co .doc-logo { height: 92px; }
.doc-co .co-name { font-size: 13.5px; }
.doc-co .co-lines { font-size: 11px; line-height: 1.5; }
.doc-title h1 { font-size: 32px; }
.doc-title .doc-ar { font-size: 14px; }
.doc-title .doc-no { font-size: 12.5px; }
.doc-billto { margin: 16px 0 12px; }
.doc-billto .bt-label { font-size: 11.5px; }
.doc-billto .bt-name { font-size: 12.5px; }
.doc-billto .bt-lines { font-size: 11px; }
.doc-date { font-size: 11.5px; }
.receipt-paper thead th { font-size: 10px; padding: 7px 8px; }
.receipt-paper tbody td { font-size: 11.5px; padding: 8px; }
.receipt-paper td .sub, .receipt-paper .sub { font-size: 10.5px; }
.doc-totals { font-size: 12px; max-width: 300px; }
.doc-totals > div { padding: 7px 12px; }
.doc-totals .grand { font-size: 13px; }
.doc-section-title { font-size: 13px; margin: 22px 0 4px; }
.doc-notes { font-size: 11.5px; margin-top: 20px; }
.doc-notes b { font-size: 12px; }
.doc-hr { font-size: 10.5px; margin-top: 30px; }
.rc-sign { font-size: 11.5px; margin-top: 30px; }
.rc-sign .line { margin-top: 30px; }
.receipt-paper .rc-sign { margin-top: 40px; }
html[data-theme="dark"] .receipt-paper { color: #222; } /* documents always print-white */
@media (max-width: 640px) {
  .doc-top, .doc-billto { flex-direction: column; align-items: flex-start; }
  .doc-title { text-align: start; }
  .doc-title h1 { font-size: 30px; }
}
