/* MVP 3.3.0 — Light Design System
   Visual direction: clean enterprise UI + GIS workspace, RTL-first.
   Font files are intentionally not bundled; Vazirmatn is used when installed,
   with system fallbacks for fully offline/on-prem deployments. */

:root{
  --ui-font:"Vazirmatn","IRANSansX","Segoe UI",Tahoma,Arial,sans-serif;
  --bg:#f6f8fb;
  --surface:#ffffff;
  --surface-soft:#f9fafb;
  --surface-muted:#f2f5f9;
  --text:#172033;
  --text-2:#344054;
  --muted:#667085;
  --muted-2:#98a2b3;
  --border:#e4e9f0;
  --border-strong:#d6dee8;
  --brand:#315efb;
  --brand-strong:#2448d8;
  --brand-soft:#eef2ff;
  --teal:#0f8a7a;
  --teal-soft:#e8f8f5;
  --success:#16803b;
  --success-soft:#eaf8ef;
  --warning:#b7791f;
  --warning-soft:#fff7e6;
  --danger:#b42318;
  --danger-soft:#fff0ef;
  --sidebar:238px;
  --header-h:78px;
  --radius-sm:10px;
  --radius:14px;
  --radius-lg:20px;
  --shadow-xs:0 1px 2px rgba(16,24,40,.04);
  --shadow-sm:0 8px 24px rgba(16,24,40,.06);
  --shadow-md:0 18px 45px rgba(16,24,40,.10);
}

html{background:var(--bg);scrollbar-gutter:stable}
body{margin:0;background:var(--bg);color:var(--text);font-family:var(--ui-font);font-size:14px;line-height:1.65;font-variant-numeric:tabular-nums;-webkit-font-smoothing:antialiased}
button,input,select,textarea{font-family:inherit}
::selection{background:#cfd9ff;color:#182150}

.password-input{position:relative;display:flex;align-items:center}
.password-input input{width:100%;padding-left:48px}
.password-eye{position:absolute;left:8px;top:50%;transform:translateY(-50%);width:36px;height:36px;min-width:36px;padding:0;border:1px solid var(--border);border-radius:10px;background:#fff;color:var(--text-2);font-size:18px;line-height:1;box-shadow:none}
.password-eye:hover{background:var(--brand-soft);border-color:#cfd8ff;color:var(--brand-strong)}
.password-help{font-size:10.5px;color:var(--muted)}

/* ---------- Application shell ---------- */
.topbar{
  position:fixed;z-index:60;top:0;right:var(--sidebar);left:0;height:var(--header-h);
  padding:0 28px;display:flex;align-items:center;justify-content:space-between;gap:24px;
  background:rgba(255,255,255,.94);color:var(--text);border-bottom:1px solid var(--border);
  box-shadow:none;backdrop-filter:blur(14px)
}
.topbar h1{font-size:18px;line-height:1.4;margin:0;color:var(--text);font-weight:800;letter-spacing:-.25px}
.topbar p{display:inline-flex;margin:5px 0 0;color:var(--muted);font-size:11px;line-height:1.2}
.topbar p::before{content:'نسخه 3.4.1';display:inline-flex;align-items:center;margin-left:8px;padding:3px 8px;border:1px solid #d8e0ff;border-radius:999px;background:var(--brand-soft);color:var(--brand-strong);font-weight:700}
.top-actions{display:flex;align-items:center;gap:10px;min-width:0}
.project-picker{display:flex;grid-auto-flow:column;align-items:center;gap:8px;color:var(--muted);font-size:11px;font-weight:600}
.project-picker select{min-width:210px;height:42px;border-radius:12px;background:#fbfcfe}
.badge{display:inline-flex;align-items:center;gap:7px;min-height:34px;padding:6px 11px;background:#f4f6f9;border:1px solid var(--border);color:var(--text-2);font-size:11px;font-weight:700}
.badge::before{content:'';width:8px;height:8px;border-radius:50%;background:#24a148;box-shadow:0 0 0 3px #e6f6eb}
#logoutBtn{height:38px;padding-inline:12px}

.tabs{
  position:fixed;z-index:70;top:0;right:0;bottom:0;width:var(--sidebar);
  display:flex;flex-direction:column;gap:4px;overflow-y:auto;overflow-x:hidden;
  padding:96px 14px 72px;background:var(--surface);border-left:1px solid var(--border);border-bottom:0;box-shadow:none
}
.tabs::before{
  content:'مدیریت شبکه آب\A WATER CONNECTIONS';white-space:pre;
  position:absolute;top:20px;right:18px;left:18px;height:56px;padding-right:48px;
  display:flex;align-items:center;color:var(--text);font-weight:800;font-size:14px;line-height:1.25;
  background:radial-gradient(circle at calc(100% - 18px) 50%,#69d3c5 0 7px,#315efb 8px 14px,transparent 15px)
}
.tabs::after{content:'MVP 3.4.1 · Internet Ready';position:absolute;right:18px;bottom:18px;color:var(--muted-2);font-size:10px;letter-spacing:.1px}
.tab{
  position:relative;width:100%;min-height:42px;display:flex;align-items:center;gap:10px;text-align:right;
  padding:9px 12px 9px 10px;border:1px solid transparent;border-radius:12px;background:transparent;color:#4a5568;
  font-size:12.5px;font-weight:600;white-space:normal;transition:.16s ease;box-shadow:none
}
.tab::before{display:grid;place-items:center;width:24px;height:24px;flex:0 0 24px;border-radius:8px;background:#f4f6f9;color:#667085;font-size:14px;font-weight:500}
.tab[data-view="dashboard"]::before{content:'⌂'}
.tab[data-view="projects"]::before{content:'▦'}
.tab[data-view="people"]::before{content:'♙'}
.tab[data-view="cad"]::before{content:'⌖'}
.tab[data-view="connections"]::before{content:'◇'}
.nav-group{display:grid;gap:4px;border-radius:12px}.nav-group-toggle{width:100%;min-height:42px;display:flex;align-items:center;justify-content:space-between;padding:9px 12px;border:1px solid transparent;border-radius:12px;background:transparent;color:#4a5568;box-shadow:none;font-size:12.5px;font-weight:700}.nav-group-toggle::before{content:'▤';display:grid;place-items:center;width:24px;height:24px;margin-left:10px;flex:0 0 24px;border-radius:8px;background:#f4f6f9;color:#667085}.nav-group-toggle:hover{background:#f7f9fc;color:var(--text);border-color:#edf0f5;box-shadow:none;transform:none}.nav-group.active-group>.nav-group-toggle{color:var(--brand-strong);background:#f8f9ff}.nav-group-items{display:none;gap:3px;padding:2px 11px 4px 0}.nav-group.open .nav-group-items{display:grid}.nav-chevron{margin-right:auto;transition:.15s ease}.nav-group.open .nav-chevron{transform:rotate(180deg)}.nav-subtab{min-height:36px;padding:7px 10px 7px 8px;font-size:11.5px}.nav-subtab::before{width:20px;height:20px;flex-basis:20px;font-size:11px}
.tab[data-view="documents"]::before{content:'⇄'}
.tab[data-view="warehouse"]::before{content:'≋'}
.tab[data-view="contractors"]::before{content:'◉'}
.tab[data-view="users"]::before{content:'⚙'}
.tab:hover{background:#f7f9fc;color:var(--text);border-color:#edf0f5;box-shadow:none}
.tab.active{background:var(--brand-soft);color:var(--brand-strong);font-weight:800;border-color:#dfe5ff;box-shadow:none}
.tab.active::before{background:var(--brand);color:white;box-shadow:0 4px 10px rgba(49,94,251,.22)}

main{max-width:none;margin:0 0 0 0;margin-right:var(--sidebar);padding:calc(var(--header-h) + 24px) 28px 36px;min-height:100vh}
.view{animation:viewIn .18s ease both}
@keyframes viewIn{from{opacity:0;transform:translateY(3px)}to{opacity:1;transform:none}}

/* ---------- Typography / page headers ---------- */
.toolbar{margin:0 0 18px;min-height:56px;align-items:flex-end}
.toolbar h2{margin:0 0 5px;font-size:22px;line-height:1.45;color:var(--text);font-weight:850;letter-spacing:-.35px}
.toolbar p,.panel-head p,.panel p{color:var(--muted);font-size:11.5px;line-height:1.7;margin:0}
.panel h3,.panel-head h3{font-size:14px;line-height:1.5;font-weight:800;color:var(--text);margin:0 0 3px}
.muted{color:var(--muted);font-size:11px}

/* ---------- Surfaces ---------- */
.panel{
  background:var(--surface);border:1px solid var(--border);border-radius:var(--radius-lg);padding:18px;
  box-shadow:var(--shadow-xs);margin-bottom:16px
}
.panel:hover{border-color:#dce2ea}
.panel-head{min-height:38px;margin-bottom:10px}
.callout{border-right:0;border-top:3px solid var(--brand);background:linear-gradient(180deg,#fff,#fafbff)}
.detail-box{background:#fafbfc;border:1px solid var(--border);border-radius:14px}
.card-list{gap:9px}
.card{border:1px solid var(--border);border-radius:14px;padding:12px 13px;background:#fff;transition:.14s ease;box-shadow:none}
.card:hover{border-color:#bcc9dc;background:#fbfcfe;transform:translateY(-1px)}
.card.active{outline:none;border-color:#9db0ff;background:#f5f7ff;box-shadow:0 0 0 3px #eef2ff}
.card b{color:var(--text);font-size:12px}.card small{color:var(--muted);font-size:10px}

/* ---------- Buttons & controls ---------- */
button,.file-btn{
  min-height:40px;border:1px solid transparent;border-radius:11px;padding:8px 14px;background:var(--brand);color:white;
  font:600 12px/1.4 var(--ui-font);box-shadow:0 1px 2px rgba(49,94,251,.16);transition:.14s ease
}
button:hover:not(:disabled),.file-btn:hover{background:var(--brand-strong);box-shadow:0 6px 14px rgba(49,94,251,.16);transform:translateY(-1px)}
button:active:not(:disabled){transform:translateY(0)}
.secondary{background:#f0f3f7;color:var(--text-2);border-color:#e4e9f0;box-shadow:none}
.secondary:hover:not(:disabled),.file-btn.secondary:hover{background:#e9eef5;color:var(--text);box-shadow:none}
.ghost{background:#fff;color:var(--text-2);border-color:var(--border);box-shadow:none}
.ghost:hover:not(:disabled){background:#f8fafc;box-shadow:none}
.success{background:var(--success)}.danger{background:var(--danger)}
.small{min-height:32px;padding:5px 10px;border-radius:9px;font-size:10.5px}
.icon-btn{min-height:34px;background:transparent;color:#475467;border:0;box-shadow:none;font-size:24px;padding:0 8px}
.toolbar-actions{gap:8px}

input,select,textarea{
  min-height:42px;width:100%;border:1px solid var(--border-strong);border-radius:11px;padding:9px 11px;background:#fff;
  color:var(--text);font:500 12px/1.5 var(--ui-font);box-shadow:inset 0 1px 1px rgba(16,24,40,.02);transition:.14s ease
}
textarea{min-height:88px;resize:vertical}
input::placeholder,textarea::placeholder{color:#a3acb9}
input:hover,select:hover,textarea:hover{border-color:#bcc7d5}
input:focus,select:focus,textarea:focus{outline:0;border-color:#7d94ff;box-shadow:0 0 0 4px rgba(49,94,251,.09)}
label{font-size:11px;color:#596579;font-weight:650;gap:6px}
.check-line{font-weight:600}
.check-line input{min-height:0}

/* ---------- KPI / dashboard ---------- */
.stats{gap:14px;margin-bottom:18px}
.stat{position:relative;overflow:hidden;min-height:108px;padding:17px 18px;border:1px solid var(--border);border-radius:18px;background:#fff;box-shadow:var(--shadow-xs)}
.stat::after{content:'';position:absolute;left:0;right:0;bottom:0;height:3px;background:linear-gradient(90deg,#315efb,#68c8c0);opacity:.85}
.stat span{color:var(--muted);font-size:11px;font-weight:650}
.stat b{display:block;margin-top:10px;font-size:28px;line-height:1.15;color:var(--text);font-weight:850;letter-spacing:-.5px}
.compact-stats .stat{min-height:86px;padding:13px 15px}.compact-stats .stat b{font-size:21px}

/* ---------- Tables ---------- */
.table-scroll{border:1px solid var(--border);border-radius:14px;background:#fff;scrollbar-width:thin;scrollbar-color:#c7d0dd transparent}
table{font-size:11.5px;border-collapse:separate;border-spacing:0;width:100%}
th,td{height:44px;padding:9px 11px;border-bottom:1px solid #edf0f4;text-align:right;white-space:nowrap}
th{top:0;background:#f8fafc;color:#667085;font-size:10.5px;font-weight:800;letter-spacing:.02em;z-index:3}
tbody tr{transition:.12s ease}tbody tr:hover{background:#fafcff}
tbody tr:last-child td{border-bottom:0}
.status{padding:4px 8px;border-radius:999px;font-size:10px;font-weight:750;border:1px solid transparent}
.status.posted,.status.complete,.status.approved{background:var(--success-soft);color:#146c35;border-color:#d8f0df}
.status.draft,.status.pending{background:var(--warning-soft);color:#8a5d10;border-color:#f5e4b9}
.status.submitted,.status.technical_approved,.status.printed,.status.executed{background:#edf3ff;color:#3154b8;border-color:#dce6ff}
.status.rejected,.status.cancelled{background:var(--danger-soft);color:var(--danger);border-color:#f7d8d4}

/* ---------- Login ---------- */
.auth-gate{
  position:fixed;inset:0;z-index:999;display:grid;place-items:center;overflow:hidden;
  background:
    radial-gradient(circle at 12% 18%,rgba(76,201,190,.24),transparent 24%),
    radial-gradient(circle at 88% 84%,rgba(49,94,251,.18),transparent 28%),
    linear-gradient(135deg,#f8fafc,#eef2f8)
}
.auth-gate::before{content:'';position:absolute;width:520px;height:520px;border-radius:50%;border:1px solid rgba(49,94,251,.08);box-shadow:0 0 0 70px rgba(49,94,251,.025),0 0 0 150px rgba(15,138,122,.018);top:-220px;left:-140px}
.auth-card{
  position:relative;z-index:1;width:min(450px,92vw);padding:34px 34px 28px;border:1px solid rgba(255,255,255,.92);
  border-radius:24px;background:rgba(255,255,255,.96);box-shadow:0 30px 80px rgba(32,48,74,.16);display:grid;gap:13px
}
.auth-card::before{content:'WC';display:grid;place-items:center;width:46px;height:46px;border-radius:14px;background:linear-gradient(135deg,#315efb,#0f8a7a);color:white;font-weight:900;letter-spacing:.5px;box-shadow:0 10px 24px rgba(49,94,251,.20)}
.auth-card h1{font-size:22px;margin:2px 0 0;color:var(--text);font-weight:850}
.auth-card>p{color:var(--muted);font-size:12px}
.auth-card form{gap:13px}
.auth-options{margin-top:2px}
.primary-wide{min-height:45px;font-weight:800}
.auth-link{border:0;background:transparent;color:var(--brand);min-height:32px;box-shadow:none}
.auth-link:hover{background:var(--brand-soft)!important;box-shadow:none!important}
#authNote{min-height:18px;color:var(--muted);line-height:1.65}

/* ---------- Modal ---------- */
dialog{border:1px solid rgba(255,255,255,.8);border-radius:22px;background:#fff;box-shadow:0 28px 90px rgba(15,23,42,.25);overflow:hidden}
dialog::backdrop{background:rgba(18,27,42,.52);backdrop-filter:blur(3px)}
#modalForm{padding:20px 22px 22px}.modal-head{padding-bottom:12px;border-bottom:1px solid var(--border)}
#modalTitle{font-size:16px;margin:0;color:var(--text)}
#modalBody{gap:14px;padding:16px 1px 8px}.modal-actions{padding-top:14px;border-top:1px solid var(--border)}

/* ---------- Map / GIS workspace ---------- */
#view-cad .map-page-head{margin-bottom:14px}
#view-cad .map-page-head .toolbar-actions{background:#fff;border:1px solid var(--border);border-radius:14px;padding:6px;box-shadow:var(--shadow-xs)}
#view-cad .map-page-head select{min-width:180px;min-height:36px;height:36px;border:0;background:#f6f8fb}
#view-cad .map-page-head button{min-height:36px}
.cad-layout{grid-template-columns:minmax(0,2.65fr) minmax(310px,.8fr);gap:16px}
.map-panel{padding:10px;border-radius:20px;background:#101827;border-color:#1e293b;box-shadow:0 16px 40px rgba(15,23,42,.16)}
.map-tools{min-height:34px;padding:0 5px 7px;color:#c8d2e0;font-size:10px}
.map-tools span:first-child{color:#fff;font-weight:700}
.map-basket-bar{margin:0 0 9px;padding:8px 10px;background:rgba(255,255,255,.075);border:1px solid rgba(255,255,255,.10);border-radius:13px;color:#fff}
.map-basket-bar b{font-size:11px}.map-basket-codes{color:#b7c3d4}.count-badge{background:#4d76ff;color:#fff}
.map-basket-bar .secondary{background:rgba(255,255,255,.10);border-color:rgba(255,255,255,.12);color:#e8edf5}.map-basket-bar .secondary:hover{background:rgba(255,255,255,.16)}
.map-viewport{height:690px;border:1px solid #243348;border-radius:15px;background:radial-gradient(circle at 48% 42%,#223249,#121b28 72%);box-shadow:inset 0 0 70px rgba(0,0,0,.18)}
.map-viewport.delivery-select-mode{box-shadow:inset 0 0 0 2px #4ad6c7,inset 0 0 70px rgba(0,0,0,.18)}
.legend-box{padding:9px 5px 1px;color:#cbd5e1}
.legend-item.pipe-toggle{background:rgba(255,255,255,.08);color:#dfe7f2;border-color:rgba(255,255,255,.10)}
.cad-side{top:calc(var(--header-h) + 18px);max-height:calc(100vh - var(--header-h) - 36px);padding:16px}
.map-layer-list{gap:7px;max-height:340px;padding-left:3px}
.map-layer-item{grid-template-columns:auto auto minmax(0,1fr);gap:8px;border:1px solid var(--border);border-radius:12px;padding:8px 9px;background:#fff}
.map-layer-item:hover{border-color:#b9c7dc;background:#fbfcff}.map-layer-item.off{opacity:.58;background:#f7f8fa}
.map-layer-item input{appearance:none;-webkit-appearance:none;position:relative;width:31px;height:18px;min-height:18px;border:0;border-radius:999px;background:#ccd5e1;box-shadow:none;padding:0;cursor:pointer;transition:.16s ease}
.map-layer-item input::after{content:'';position:absolute;top:2px;right:2px;width:14px;height:14px;border-radius:50%;background:#fff;box-shadow:0 1px 3px rgba(0,0,0,.18);transition:.16s ease}
.map-layer-item input:checked{background:var(--brand)}
.map-layer-item input:checked::after{transform:translateX(-13px)}
.map-layer-name b{font-size:11px;color:var(--text);font-weight:750}.map-layer-name small{font-size:9.5px;color:var(--muted)}
.map-feature-detail{border-color:var(--border);border-radius:13px;background:#fafbfc;padding:12px}.map-feature-detail dl{font-size:10.5px}
.map-hover-tooltip{border-radius:10px;background:rgba(10,16,27,.91);border-color:rgba(255,255,255,.14);font-size:10px;box-shadow:0 12px 28px rgba(0,0,0,.3)}
.map-node-label{font-family:var(--ui-font);font-weight:750;letter-spacing:.05px}
.cad-admin-panel,.cad-review-collapse{border-radius:16px;box-shadow:none}
.cad-admin-panel>summary,.cad-review-collapse>summary,.side-details>summary{padding:13px 15px}
.cad-admin-panel[open]>summary,.cad-review-collapse[open]>summary{background:#f8f9fc}

/* ---------- Reports / library ---------- */
.library-grid{gap:16px}.library-grid>.panel{min-height:500px}
#itemSearch,#templateSearch,#stockSearch{margin-bottom:12px;background:#fbfcfe}
.report-filter-panel{background:linear-gradient(180deg,#fff,#fbfcff)}
.report-filters{gap:12px}.report-apply{height:42px}
#view-contractors #contractorReportBody>.panel{border-radius:18px}
.positive-number{color:#147d42;font-weight:800}.negative-number{color:#b42318;font-weight:800}

/* ---------- Details / misc ---------- */
hr{border-top:1px solid var(--border)}
.toast{left:24px;bottom:24px;min-width:220px;border-radius:13px;background:#172033;color:#fff;box-shadow:0 16px 40px rgba(16,24,40,.22);font-size:11px}
.filters{gap:10px}.filters>*{max-width:360px}
.line-builder,.template-line-builder{border-color:var(--border);border-radius:14px;background:#fbfcfe}
.basket{background:#f2f6ff;border-color:#dbe5ff;border-radius:13px}

/* ---------- Responsive ---------- */
@media(max-width:1180px){
  :root{--sidebar:208px}
  .topbar{padding-inline:20px}.project-picker select{min-width:160px}
  main{padding-inline:20px}.cad-layout{grid-template-columns:minmax(0,2.2fr) minmax(280px,.8fr)}
}
@media(max-width:980px){
  :root{--header-h:auto}
  .topbar{position:relative;right:auto;left:auto;height:auto;padding:14px 16px;align-items:flex-start;flex-direction:column;background:#fff}
  .top-actions{width:100%;flex-wrap:wrap}.project-picker{flex:1}.project-picker select{min-width:180px}
  .tabs{position:sticky;top:0;right:auto;bottom:auto;width:auto;height:auto;padding:8px 10px;flex-direction:row;overflow:auto;border-left:0;border-bottom:1px solid var(--border);z-index:80}
  .tabs::before,.tabs::after{display:none}.tab{width:auto;min-width:max-content;min-height:38px;padding:7px 10px}.tab::before{width:21px;height:21px;flex-basis:21px}
  main{margin-right:0;padding:20px 14px 30px}.cad-side{position:static;max-height:none}.cad-layout{grid-template-columns:1fr}.map-viewport{height:540px}
}
@media(max-width:650px){
  body{font-size:13px}.topbar h1{font-size:16px}.topbar p{display:none}.project-picker{width:100%;grid-auto-flow:row;display:grid}.project-picker select{width:100%}
  #logoutBtn{margin-right:auto}.toolbar{align-items:flex-start;flex-direction:column}.toolbar-actions{width:100%}.toolbar-actions>*{flex:1}
  .panel{padding:13px;border-radius:16px}.stats{grid-template-columns:1fr 1fr}.stat{min-height:88px;padding:13px}.stat b{font-size:21px}
  .map-viewport{height:440px}.map-panel{padding:7px}.cad-layout{gap:10px}
  .auth-card{padding:27px 22px;border-radius:21px}.report-filters{grid-template-columns:1fr}.two-col{grid-template-columns:1fr}
}
@media(max-width:430px){.stats{grid-template-columns:1fr}.top-actions{gap:6px}.badge{order:3}.map-viewport{height:390px}}

@media print{
  .topbar,.tabs{display:none!important}main{margin:0!important;padding:0!important}.panel{box-shadow:none!important}
}

/* 3.4 team access */
.row-actions{display:flex;gap:6px;align-items:center}.role-help{padding:10px 12px;border:1px solid #dfe5ff;border-radius:12px;background:#f6f8ff;color:#52617a;font-size:11px}.role-grid{display:grid;grid-template-columns:repeat(2,minmax(0,1fr));gap:8px}.role-option{display:flex;align-items:center;gap:10px;padding:10px 11px;border:1px solid var(--border);border-radius:12px;background:#fff}.role-option input{width:auto;min-height:0}.role-option span{display:grid;gap:1px}.role-option b{font-size:11.5px;color:var(--text)}.role-option small{font-size:9px;color:var(--muted)}
@media(max-width:980px){.nav-group{min-width:max-content}.nav-group-items{position:absolute;z-index:95;margin-top:43px;padding:7px;min-width:190px;background:#fff;border:1px solid var(--border);border-radius:12px;box-shadow:var(--shadow-md)}.nav-group-toggle{min-width:max-content}.nav-group-toggle::before{display:none}.nav-subtab{width:100%}}
@media(max-width:650px){.role-grid{grid-template-columns:1fr}}
