/* =========================================================
   WN2WN — Accounting Office System
   Identity: off-white paper, navy ink, fine crimson rules
   ========================================================= */
:root {
  --paper:      #FAF8F3;   /* off-white page */
  --paper-2:    #F3EFE6;   /* slightly deeper paper */
  --card:       #FFFFFF;
  --navy:       #0B1F4B;   /* main text & headings */
  --navy-2:     #1B3270;
  --navy-soft:  #4A5878;   /* secondary text */
  --muted:      #8A93A8;
  --red:        #B3122E;   /* fine decorative rules */
  --red-soft:   #F6E3E6;
  --line:       #E6E0D3;   /* neutral hairlines */
  --ok:         #1F7A4D;
  --ok-soft:    #E3F2EA;
  --warn:       #9A6B00;
  --warn-soft:  #FBF1D9;
  --radius:     10px;
  --shadow:     0 1px 2px rgba(11,31,75,.05), 0 6px 20px rgba(11,31,75,.05);
  --font:       "IBM Plex Sans Arabic", "Segoe UI", Tahoma, Arial, sans-serif;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  font-family: var(--font);
  font-size: 15px;
  line-height: 1.65;
  color: var(--navy);
  background: var(--paper);
}
a { color: var(--navy-2); text-decoration: none; }
a:hover { color: var(--red); }
h1, h2, h3, h4 { color: var(--navy); margin: 0 0 .5em; line-height: 1.35; font-weight: 600; }
img { max-width: 100%; }
small, .muted { color: var(--navy-soft); }
code, .mono { font-family: Consolas, "Courier New", monospace; font-size: .92em; }

/* ---------- Decorative rules ---------- */
.rule        { height: 1px; background: var(--red); border: 0; margin: 18px 0; }
.rule-double { height: 4px; border-top: 1px solid var(--red); border-bottom: 1px solid var(--red); margin: 14px 0; }
.rule-short  { width: 56px; height: 2px; background: var(--red); margin: 8px 0 18px; }
.ornament {
  display: flex; align-items: center; gap: 12px; color: var(--red); font-size: 12px; margin: 22px 0;
}
.ornament::before, .ornament::after { content: ""; flex: 1; height: 1px; background: var(--red); opacity: .55; }

/* ---------- App shell ---------- */
.shell { display: flex; min-height: 100vh; }
.sidebar {
  width: 260px; flex: 0 0 260px;
  background: var(--card);
  border-inline-end: 1px solid var(--line);
  position: sticky; top: 0; height: 100vh; overflow-y: auto;
  display: flex; flex-direction: column;
  padding: 20px 16px;
}
.sidebar::before {               /* thin red line along the inner edge */
  content: ""; position: absolute; top: 0; bottom: 0; inset-inline-end: 3px; width: 1px; background: var(--red); opacity: .35;
}
.brand { display: flex; align-items: center; gap: 10px; color: var(--navy); }
.brand-logo { width: 42px; height: 42px; object-fit: contain; border-radius: 8px; }
.brand-name { font-weight: 700; font-size: 16px; line-height: 1.3; }
.nav { display: flex; flex-direction: column; gap: 2px; }
.nav-link {
  display: flex; align-items: center; gap: 10px;
  padding: 9px 12px; border-radius: 8px; color: var(--navy); font-weight: 500;
  border-inline-start: 2px solid transparent;
}
.nav-link:hover { background: var(--paper); color: var(--navy); }
.nav-link.active { background: var(--paper-2); border-inline-start-color: var(--red); font-weight: 600; }
.nav-link.disabled { color: var(--muted); cursor: default; }
.nav-link.disabled:hover { background: transparent; }
.nav-icon { width: 20px; text-align: center; color: var(--red); }
.nav-link.disabled .nav-icon { color: var(--muted); }
.nav-section { margin: 16px 12px 6px; font-size: 12px; color: var(--muted); letter-spacing: .3px; }
.badge-soon {
  margin-inline-start: auto; font-size: 10.5px; padding: 1px 7px; border-radius: 20px;
  border: 1px solid var(--red); color: var(--red); background: transparent;
}
.sidebar-foot { margin-top: auto; padding-top: 16px; font-size: 12px; color: var(--muted); text-align: center; }

.main { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.topbar {
  display: flex; align-items: center; gap: 14px;
  padding: 14px 28px; background: var(--paper);
}
.topbar-rule { height: 4px; border-top: 1px solid var(--red); border-bottom: 1px solid var(--line); margin: 0 28px; }
.page-title { font-size: 21px; margin: 0; flex: 1; }
.topbar-actions { display: flex; align-items: center; gap: 12px; }
.lang-switch { font-size: 13px; padding: 5px 12px; border: 1px solid var(--line); border-radius: 20px; background: var(--card); }
.user-chip { display: flex; align-items: center; gap: 8px; color: var(--navy); }
.avatar {
  width: 34px; height: 34px; border-radius: 50%;
  display: grid; place-items: center; background: var(--navy); color: #fff; font-weight: 600;
  box-shadow: 0 0 0 2px var(--paper), 0 0 0 3px var(--red);
}
.user-meta { display: flex; flex-direction: column; line-height: 1.2; }
.user-meta b { font-size: 13.5px; font-weight: 600; }
.user-meta small { font-size: 11.5px; }
.menu-btn { display: none; background: none; border: 1px solid var(--line); border-radius: 8px; padding: 4px 10px; font-size: 18px; color: var(--navy); cursor: pointer; }
.content { padding: 24px 28px 40px; flex: 1; }
.app-foot {
  display: flex; justify-content: space-between; gap: 10px; flex-wrap: wrap;
  padding: 14px 28px; font-size: 12.5px; color: var(--navy-soft);
  border-top: 1px solid var(--line);
}
.app-foot .powered b { color: var(--red); letter-spacing: 1px; }
.sidebar-backdrop { display: none; }

/* ---------- Cards & grids ---------- */
.card {
  background: var(--card); border: 1px solid var(--line); border-radius: var(--radius);
  box-shadow: var(--shadow); padding: 22px; margin-bottom: 20px; position: relative;
}
.card-title { font-size: 17px; margin-bottom: 4px; }
.card-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; margin-bottom: 14px; }
.card-head .card-title { margin: 0; }
.card.accent { border-top: 2px solid var(--red); }
.grid { display: grid; gap: 18px; }
.grid-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.grid-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.grid-4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }

.stat { padding: 18px 20px; }
.stat .stat-label { font-size: 13px; color: var(--navy-soft); }
.stat .stat-value { font-size: 28px; font-weight: 700; margin-top: 4px; line-height: 1.2; }
.stat .stat-note { font-size: 12px; color: var(--muted); }
.stat .stat-value.sm { font-size: 20px; line-height: 1.4; }
.stat::after { content: ""; position: absolute; inset-inline-start: 20px; bottom: 0; width: 40px; height: 2px; background: var(--red); }

.module {
  display: flex; gap: 14px; align-items: flex-start; padding: 18px; border: 1px dashed var(--line);
  border-radius: var(--radius); background: var(--card);
}
.module-icon {
  flex: 0 0 42px; width: 42px; height: 42px; border-radius: 10px; display: grid; place-items: center;
  border: 1px solid var(--red); color: var(--red); font-size: 18px;
}
.module h4 { margin: 0 0 2px; font-size: 15px; }
.module p { margin: 0; font-size: 13px; color: var(--navy-soft); }

/* ---------- Forms ---------- */
.form-row { margin-bottom: 16px; }
.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 0 18px; }
.form-grid .full { grid-column: 1 / -1; }
label { display: block; font-weight: 500; margin-bottom: 6px; font-size: 14px; }
label .req { color: var(--red); }
.hint { font-size: 12.5px; color: var(--navy-soft); margin-top: 4px; }
input[type=text], input[type=email], input[type=password], input[type=number], input[type=tel], input[type=url],
input[type=search], select, textarea {
  width: 100%; padding: 10px 12px; font: inherit; color: var(--navy);
  background: #fff; border: 1px solid var(--line); border-radius: 8px;
  transition: border-color .15s, box-shadow .15s;
}
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--navy-2); box-shadow: 0 0 0 3px rgba(27,50,112,.1); }
input[readonly] { background: var(--paper); }
textarea { min-height: 90px; resize: vertical; }
input[type=file] { font: inherit; font-size: 13px; }
.check { display: flex; align-items: center; gap: 8px; font-weight: 400; }
.check input { width: 17px; height: 17px; accent-color: var(--navy); }

/* Password eye toggle (added automatically by app.js to every password field) */
.pw-wrap { position: relative; }
.pw-wrap input { padding-inline-end: 46px; }
.pw-eye {
  position: absolute; top: 50%; transform: translateY(-50%); inset-inline-end: 6px;
  width: 36px; height: 32px; border: 0; background: transparent; cursor: pointer;
  color: var(--navy-soft); display: grid; place-items: center; border-radius: 6px;
}
.pw-eye:hover { color: var(--red); background: var(--paper); }
.pw-eye svg { width: 20px; height: 20px; }

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  padding: 10px 20px; font: inherit; font-weight: 600; font-size: 14px;
  border-radius: 8px; border: 1px solid var(--navy); cursor: pointer;
  background: var(--navy); color: #fff; transition: background .15s, color .15s, border-color .15s;
  text-decoration: none; white-space: nowrap;
}
.btn:hover { background: var(--navy-2); color: #fff; }
.btn-outline { background: transparent; color: var(--navy); }
.btn-outline:hover { background: var(--navy); color: #fff; }
.btn-red { background: var(--red); border-color: var(--red); }
.btn-red:hover { background: #8f0e24; border-color: #8f0e24; }
.btn-ghost { background: transparent; color: var(--navy); border-color: var(--line); }
.btn-ghost:hover { background: var(--card); color: var(--red); border-color: var(--red); }
.btn-sm { padding: 5px 12px; font-size: 13px; }
.btn-xs { padding: 2px 9px; font-size: 12px; font-weight: 500; }
.btn-block { width: 100%; }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.actions { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }

/* ---------- Alerts & badges ---------- */
.alert { padding: 12px 16px; border-radius: 8px; margin-bottom: 16px; border: 1px solid; border-inline-start-width: 3px; font-size: 14px; }
.alert-success { background: var(--ok-soft); border-color: var(--ok); color: var(--ok); }
.alert-error   { background: var(--red-soft); border-color: var(--red); color: var(--red); }
.alert-warning { background: var(--warn-soft); border-color: var(--warn); color: var(--warn); }
.alert-info    { background: #EEF1F8; border-color: var(--navy-2); color: var(--navy); }
.badge { display: inline-block; font-size: 12px; padding: 2px 9px; border-radius: 20px; border: 1px solid var(--line); background: var(--paper); color: var(--navy); }
.badge-ok { border-color: var(--ok); color: var(--ok); background: var(--ok-soft); }
.badge-off { border-color: var(--muted); color: var(--muted); }
.badge-red { border-color: var(--red); color: var(--red); background: var(--red-soft); }
.badge-level { font-size: 11px; padding: 0 7px; border-color: var(--red); color: var(--red); background: transparent; }

/* ---------- Tables ---------- */
.table-wrap { overflow-x: auto; }
table.table { width: 100%; border-collapse: collapse; font-size: 14px; }
.table th {
  text-align: start; font-weight: 600; color: var(--navy); background: var(--paper);
  padding: 10px 12px; border-bottom: 1px solid var(--red); white-space: nowrap;
}
.table td { padding: 10px 12px; border-bottom: 1px solid var(--line); vertical-align: middle; }
.table tr:hover td { background: #FDFCF9; }
.table .num { text-align: end; font-variant-numeric: tabular-nums; }

/* ---------- Category tree ---------- */
.tree { list-style: none; margin: 0; padding: 0; }
.tree ul { list-style: none; margin: 0; padding-inline-start: 22px; border-inline-start: 1px dashed rgba(179,18,46,.35); margin-inline-start: 10px; }
.tree-item { display: flex; align-items: center; gap: 8px; padding: 6px 8px; border-radius: 6px; flex-wrap: wrap; }
.tree-item:hover { background: var(--paper); }
.tree-toggle {
  width: 22px; height: 22px; border-radius: 5px; border: 1px solid var(--line); background: #fff; color: var(--navy);
  cursor: pointer; font-size: 13px; line-height: 1; display: grid; place-items: center; flex: 0 0 22px;
}
.tree-toggle.leaf { visibility: hidden; }
.tree-name { font-weight: 500; }
.tree-name .en { color: var(--navy-soft); font-weight: 400; font-size: 13px; }
.tree-item.inactive .tree-name { color: var(--muted); text-decoration: line-through; }
.tree-meta { font-size: 12px; color: var(--navy-soft); }
.tree-actions { margin-inline-start: auto; display: flex; gap: 4px; opacity: .25; transition: opacity .15s; }
.tree-item:hover .tree-actions, .tree-item:focus-within .tree-actions { opacity: 1; }
li.collapsed > ul { display: none; }
li.hidden-by-search { display: none; }
mark { background: var(--red-soft); color: var(--red); padding: 0 2px; border-radius: 3px; }

.picker { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 12px; }
.picker-path { margin-top: 12px; font-size: 14px; padding: 10px 14px; border: 1px dashed var(--red); border-radius: 8px; background: #fff; }

/* ---------- Modal ---------- */
.modal { position: fixed; inset: 0; background: rgba(11,31,75,.35); display: none; align-items: center; justify-content: center; padding: 16px; z-index: 100; }
.modal.open { display: flex; }
.modal-box { background: var(--card); border-radius: 12px; width: 100%; max-width: 560px; max-height: 90vh; overflow-y: auto; padding: 24px; border-top: 3px solid var(--red); }
.modal-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 10px; }
.modal-close { background: none; border: 0; font-size: 22px; cursor: pointer; color: var(--navy-soft); }

/* ---------- Auth (login / installer) ---------- */
body.auth {
  min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 24px;
  background:
    linear-gradient(var(--paper), var(--paper)) padding-box;
}
.auth-frame {
  width: 100%; max-width: 440px; background: var(--card); border-radius: 14px; padding: 34px 32px;
  box-shadow: var(--shadow); border: 1px solid var(--line); position: relative;
}
.auth-frame.wide { max-width: 720px; }
.auth-frame::before {        /* inner fine red frame */
  content: ""; position: absolute; inset: 7px; border: 1px solid var(--red); border-radius: 10px; opacity: .45; pointer-events: none;
}
.auth-logo { display: block; margin: 0 auto 10px; width: 72px; height: 72px; object-fit: contain; }
.auth-title { text-align: center; font-size: 22px; margin: 0; }
.auth-sub { text-align: center; color: var(--navy-soft); margin: 4px 0 0; font-size: 14px; }
.auth-foot { text-align: center; margin-top: 18px; font-size: 13px; color: var(--navy-soft); }
.auth-lang { position: absolute; top: 18px; inset-inline-end: 22px; font-size: 13px; z-index: 2; }

.steps { display: flex; justify-content: space-between; gap: 4px; margin: 20px 0 24px; counter-reset: st; }
.step { flex: 1; text-align: center; font-size: 12.5px; color: var(--muted); position: relative; padding-top: 34px; }
.step::before {
  counter-increment: st; content: counter(st);
  position: absolute; top: 0; left: 50%; transform: translateX(-50%);
  width: 28px; height: 28px; border-radius: 50%; display: grid; place-items: center;
  border: 1px solid var(--line); background: #fff; color: var(--muted); font-weight: 600;
}
.step::after { content: ""; position: absolute; top: 14px; inset-inline-start: calc(50% + 18px); width: calc(100% - 36px); height: 1px; background: var(--line); }
.step:last-child::after { display: none; }
.step.done::before { background: var(--navy); border-color: var(--navy); color: #fff; content: "✓"; }
.step.done::after { background: var(--red); }
.step.current { color: var(--navy); font-weight: 600; }
.step.current::before { border-color: var(--red); color: var(--red); box-shadow: 0 0 0 3px var(--red-soft); }

.req-list { list-style: none; padding: 0; margin: 0 0 16px; }
.req-list li { display: flex; justify-content: space-between; padding: 8px 0; border-bottom: 1px solid var(--line); font-size: 14px; }
.req-ok { color: var(--ok); font-weight: 600; }
.req-bad { color: var(--red); font-weight: 600; }

.country-pick { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.country-pick label {
  border: 1px solid var(--line); border-radius: 10px; padding: 14px; cursor: pointer; text-align: center; margin: 0;
  font-weight: 500; transition: border-color .15s, background .15s;
}
.country-pick input { position: absolute; opacity: 0; pointer-events: none; }
.country-pick .flag { font-size: 28px; display: block; }
.country-pick input:checked + span { color: var(--navy); }
.country-pick label:has(input:checked) { border-color: var(--red); background: #fff; box-shadow: 0 0 0 3px var(--red-soft); }

/* ---------- Public site ---------- */
body.public { background: var(--paper); }
.pub-top { max-width: 1120px; margin: 0 auto; padding: 18px 24px; display: flex; align-items: center; gap: 14px; }
.pub-top .brand-name { font-size: 18px; }
.pub-top nav { margin-inline-start: auto; display: flex; align-items: center; gap: 18px; font-size: 14.5px; }
.pub-rule { max-width: 1120px; margin: 0 auto; height: 4px; border-top: 1px solid var(--red); border-bottom: 1px solid var(--red); }
.hero { max-width: 1120px; margin: 0 auto; padding: 70px 24px 60px; text-align: center; }
.hero h1 { font-size: 40px; font-weight: 700; margin-bottom: 10px; }
.hero p { font-size: 18px; color: var(--navy-soft); max-width: 680px; margin: 0 auto 28px; }
.hero .eyebrow { color: var(--red); letter-spacing: 2px; font-size: 13px; font-weight: 600; margin-bottom: 14px; display: inline-block; border-bottom: 1px solid var(--red); padding-bottom: 4px; }
.section { max-width: 1120px; margin: 0 auto; padding: 40px 24px; }
.section-title { text-align: center; font-size: 26px; margin-bottom: 0; }
.section-title + .rule-short { margin: 10px auto 30px; }
.service { text-align: center; padding: 26px 20px; }
.service .module-icon { margin: 0 auto 12px; }
.service h3 { font-size: 17px; }
.service p { font-size: 14px; color: var(--navy-soft); margin: 0; }
.sectors { display: flex; flex-wrap: wrap; justify-content: center; gap: 10px; }
.sectors span { padding: 7px 16px; border: 1px solid var(--line); border-radius: 22px; background: #fff; font-size: 14px; }
.sectors span:hover { border-color: var(--red); color: var(--red); }
.contact-line { display: flex; flex-wrap: wrap; justify-content: center; gap: 26px; font-size: 15px; }
.pub-foot { border-top: 1px solid var(--red); max-width: 1120px; margin: 30px auto 0; padding: 18px 24px 30px; display: flex; justify-content: space-between; flex-wrap: wrap; gap: 10px; font-size: 13px; color: var(--navy-soft); }

/* ---------- Utilities ---------- */
.mt-0 { margin-top: 0; } .mb-0 { margin-bottom: 0; } .mt-2 { margin-top: 16px; } .mb-2 { margin-bottom: 16px; }
.text-center { text-align: center; } .text-red { color: var(--red); } .text-ok { color: var(--ok); }
.flex { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.spacer { flex: 1; }
.nowrap { white-space: nowrap; }
.empty { text-align: center; padding: 30px; color: var(--muted); }

/* ---------- Responsive ---------- */
@media (max-width: 1100px) {
  .grid-4 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .picker { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 860px) {
  .sidebar { position: fixed; inset-block: 0; inset-inline-start: 0; z-index: 60; transform: translateX(100%); transition: transform .2s; box-shadow: var(--shadow); }
  html[dir=ltr] .sidebar { transform: translateX(-100%); }
  body.sidebar-open .sidebar { transform: translateX(0); }
  body.sidebar-open .sidebar-backdrop { display: block; position: fixed; inset: 0; background: rgba(11,31,75,.3); z-index: 50; }
  .menu-btn { display: inline-block; }
  .grid-2, .grid-3, .form-grid { grid-template-columns: 1fr; }
  .topbar, .content, .app-foot { padding-inline: 16px; }
  .topbar-rule { margin: 0 16px; }
  .user-meta { display: none; }
  .page-title { font-size: 17px; }
  .hero h1 { font-size: 30px; }
  .pub-top nav .hide-sm { display: none; }
}
@media (max-width: 520px) {
  .grid-4, .picker, .country-pick { grid-template-columns: 1fr; }
  .auth-frame { padding: 28px 20px; }
  .steps .step { font-size: 0; }
}
@media print {
  .sidebar, .topbar, .topbar-rule, .app-foot, .btn { display: none !important; }
  body { background: #fff; }
}
