/* ===========================================================================
   Motel Ard El Fananeen — Engineering Report
   Infinity A.I Division
   =========================================================================== */
:root {
  --navy:    #1F4E79;
  --navy-2:  #163a5c;
  --blue:    #2E75B6;
  --blue-lt: #5B9BD5;
  --accent:  #E2EFDA;   /* totals (light green) */
  --accent-b:#70AD47;
  --warn:    #FFF2CC;   /* amendments (yellow) */
  --warn-b:  #E6B800;
  --gold:    #C9A34E;   /* Hakeem Pacha brand accent */
  --gold-2:  #E6CD86;
  --gold-dp: #A67C2E;
  --bg:      #F4F6F9;
  --card:    #FFFFFF;
  --ink:     #1f2937;
  --muted:   #6b7785;
  --line:    #e3e8ef;
  --radius:  14px;
  --shadow:  0 2px 10px rgba(31,78,121,.06), 0 1px 3px rgba(0,0,0,.04);
}

* { box-sizing: border-box; }

body {
  font-family: 'Cairo', 'Segoe UI', Tahoma, sans-serif;
  background: var(--bg);
  color: var(--ink);
  margin: 0;
  font-size: 15px;
}

/* ----------------------------- NAVBAR ----------------------------------- */
.app-navbar {
  background: linear-gradient(110deg, var(--navy) 0%, var(--navy-2) 60%, var(--blue) 140%);
  display: flex;
  justify-content: space-between;
  align-items: center;
  min-height: 62px;
  box-shadow: 0 2px 14px rgba(22,58,92,.25);
  z-index: 1030;
}
.brand-badge {
  width: 40px; height: 40px;
  display: inline-flex; align-items: center; justify-content: center;
  background: linear-gradient(140deg, var(--gold-2), var(--gold) 55%, var(--gold-dp));
  border: 1px solid rgba(255,255,255,.45);
  border-radius: 11px;
  font-size: 1.2rem; color: #2a2208;
  box-shadow: 0 2px 8px rgba(166,124,46,.45);
}
.brand-title {
  font-weight: 800; font-size: 1.12rem; color: #fff; letter-spacing: .01em;
}
.brand-sub   { font-size: .71rem; color: #d7e4f2; font-weight: 600; }
.brand-org {
  color: var(--gold-2); font-weight: 800; font-size: .82rem; letter-spacing: .12em;
  background: rgba(201,163,78,.12);
  padding: .35rem .9rem; border-radius: 30px;
  border: 1px solid rgba(201,163,78,.45);
}
.brand-org i { color: var(--gold-2); }

/* ----------------------------- LAYOUT ----------------------------------- */
.layout { display: flex; align-items: flex-start; }
.sidebar {
  width: 260px; flex: 0 0 260px;
  background: var(--card);
  border-inline-start: 1px solid var(--line);
  min-height: calc(100vh - 62px);
  position: sticky; top: 62px;
}
.sidebar-label {
  font-size: .72rem; font-weight: 700; letter-spacing: .04em;
  color: var(--muted); text-transform: uppercase;
  padding: 1rem 1.25rem .5rem;
}
.sidebar-nav .nav-link {
  display: flex; align-items: center; gap: .65rem;
  color: var(--ink); font-weight: 600; font-size: .92rem;
  padding: .7rem 1.25rem;
  border-inline-start: 3px solid transparent;
  transition: all .15s ease;
}
.sidebar-nav .nav-link i { font-size: 1.05rem; color: var(--blue); width: 20px; text-align: center; }
.sidebar-nav .nav-link:hover { background: #f1f6fb; color: var(--navy); }
.sidebar-nav .nav-link.active {
  background: linear-gradient(90deg, rgba(46,117,182,.12), transparent);
  color: var(--navy); border-inline-start-color: var(--blue);
}
.sidebar-nav .nav-link.active i { color: var(--navy); }
.sidebar-foot { padding: 1rem 1.25rem; border-top: 1px solid var(--line); margin-top: .5rem; }

.content {
  flex: 1 1 auto; min-width: 0;
  padding: 1.6rem 2rem 2.5rem;
  max-width: 1200px;
}

/* ----------------------------- PAGE HEADER ------------------------------ */
.page-header {
  border-bottom: 2px solid var(--line);
  padding-bottom: 1rem; margin-bottom: 1.5rem;
}
.page-title {
  font-size: 1.7rem; font-weight: 800; color: var(--navy);
  margin: 0; position: relative; padding-inline-start: .9rem;
}
.page-title::before {
  content: ""; position: absolute; inset-inline-start: 0; top: 6px; bottom: 6px;
  width: 5px; border-radius: 4px;
  background: linear-gradient(var(--blue), var(--navy));
}
.page-subtitle { color: var(--muted); font-size: .92rem; margin-top: .35rem; }

/* ----------------------------- BUTTONS ---------------------------------- */
.toolbar { display: flex; gap: .5rem; flex-wrap: wrap; }
.btn-export, .btn-print {
  font-weight: 700; font-size: .85rem; border-radius: 9px;
  padding: .5rem .9rem; border: none; display: inline-flex; align-items: center; gap: .4rem;
}
.btn-export { background: var(--accent-b); color: #fff; }
.btn-export:hover { background: #5e9a3c; color: #fff; }
.btn-print  { background: #eef2f7; color: var(--navy); border: 1px solid var(--line); }
.btn-print:hover { background: #e2e9f1; }

/* ----------------------------- CARDS ------------------------------------ */
.card-r {
  background: var(--card); border: 1px solid var(--line);
  border-radius: var(--radius); box-shadow: var(--shadow);
  margin-bottom: 1.5rem; overflow: hidden;
}
.card-r-head {
  display: flex; align-items: center; gap: .55rem;
  padding: .85rem 1.2rem; font-weight: 700; color: var(--navy);
  background: linear-gradient(90deg, #f3f7fc, #fbfdff);
  border-bottom: 1px solid var(--line);
}
.card-r-head i { color: var(--blue); font-size: 1.1rem; }
.card-r-head .badge-soft {
  margin-inline-start: auto; background: var(--accent); color: #486c2a;
  font-size: .72rem; font-weight: 700; padding: .25rem .6rem; border-radius: 20px;
}
.card-r-body { padding: 1.1rem 1.2rem; }
.card-r-body.p0 { padding: 0; }

/* ----------------------------- KPI CARDS -------------------------------- */
.kpi-grid {
  display: grid; gap: 1rem;
  grid-template-columns: repeat(auto-fit, minmax(190px, 1fr));
  margin-bottom: 1.5rem;
}
.kpi {
  background: var(--card); border: 1px solid var(--line);
  border-radius: var(--radius); box-shadow: var(--shadow);
  padding: 1.1rem 1.2rem; position: relative; overflow: hidden;
}
.kpi::after {
  content: ""; position: absolute; inset-inline-end: -18px; top: -18px;
  width: 80px; height: 80px; border-radius: 50%;
  background: radial-gradient(circle, rgba(46,117,182,.10), transparent 70%);
}
.kpi-icon {
  width: 42px; height: 42px; border-radius: 11px;
  display: inline-flex; align-items: center; justify-content: center;
  font-size: 1.3rem; color: #fff; margin-bottom: .7rem;
  background: linear-gradient(135deg, var(--blue), var(--navy));
}
.kpi-icon.green { background: linear-gradient(135deg, #8bc34a, var(--accent-b)); }
.kpi-icon.amber { background: linear-gradient(135deg, #f5c451, var(--warn-b)); }
.kpi-icon.slate { background: linear-gradient(135deg, #7d93ab, #4a5b6e); }
.kpi-value { font-size: 1.75rem; font-weight: 800; color: var(--navy); line-height: 1.1; }
.kpi-label { color: var(--muted); font-size: .85rem; font-weight: 600; margin-top: .15rem; }
.kpi-unit  { font-size: .9rem; color: var(--muted); font-weight: 700; }

/* ----------------------------- TABLES ----------------------------------- */
.table-r { width: 100%; border-collapse: collapse; font-size: .9rem; }
.table-r thead th {
  background: var(--navy); color: #fff; font-weight: 700;
  padding: .7rem .8rem; text-align: center; font-size: .85rem;
  border: 1px solid var(--navy-2); white-space: nowrap;
}
.table-r tbody td {
  padding: .6rem .8rem; border: 1px solid var(--line);
  text-align: center; vertical-align: middle;
}
.table-r tbody tr:nth-child(even) { background: #f7fafd; }
.table-r tbody tr:hover { background: #eef5fc; }
.table-r td.text-start { text-align: start; }
.table-r .row-total {
  background: var(--accent) !important; font-weight: 800; color: #2f4f1c;
}
.table-r .row-total td { border-color: var(--accent-b); }
.cat-row td {
  background: linear-gradient(90deg, #e8eef6, #f4f8fc);
  font-weight: 800; color: var(--navy); text-align: start;
  border-top: 2px solid var(--blue-lt);
}
.cat-row td i { color: var(--blue); }
.subtotal-row td {
  background: #eef3f9; font-weight: 700; color: var(--navy-2); font-size: .85rem;
}
.table-wrap { overflow-x: auto; }
.unit-pill {
  display: inline-block; background: #eaf1f9; color: var(--navy);
  font-weight: 700; border-radius: 6px; padding: .1rem .5rem; font-size: .82rem;
}
.tag-num { font-variant-numeric: tabular-nums; font-weight: 700; }

/* ----------------------------- ALERT / AMENDMENT ------------------------ */
.amendment {
  background: var(--warn); border: 1px solid var(--warn-b);
  border-inline-start: 6px solid var(--warn-b);
  border-radius: var(--radius); padding: 1.1rem 1.3rem; margin-bottom: 1.5rem;
  box-shadow: var(--shadow);
}
.amendment-head {
  display: flex; align-items: center; gap: .6rem;
  font-weight: 800; color: #8a6d00; font-size: 1.05rem; margin-bottom: .3rem;
}
.amendment-head i { font-size: 1.3rem; }
.amendment-meta { font-size: .82rem; color: #97791a; font-weight: 700; margin-bottom: .8rem; }
.amendment-meta code {
  background: rgba(230,184,0,.18); color: #7a6200; padding: .1rem .45rem;
  border-radius: 5px; font-weight: 700;
}
.amendment-list { margin: 0; padding: 0; list-style: none; }
.amendment-list li {
  display: flex; gap: .6rem; padding: .45rem 0; border-top: 1px dashed rgba(230,184,0,.5);
}
.amendment-list li:first-child { border-top: none; }
.amendment-list .k { font-weight: 800; color: #6f5800; flex: 0 0 150px; }
.amendment-list .v { color: #5d4d11; }

/* ----------------------------- SCOPE BANNER (cost page) ----------------- */
.scope-banner {
  background: linear-gradient(120deg, #fbf6ea, #fffdf8);
  border: 1px solid var(--gold);
  border-inline-start: 6px solid var(--gold);
  border-radius: var(--radius); padding: 1.1rem 1.3rem; margin-bottom: 1.5rem;
  box-shadow: var(--shadow); color: #5a4a25;
}
.scope-head {
  display: flex; align-items: center; gap: .55rem;
  font-weight: 800; color: var(--gold-dp); font-size: 1.05rem; margin-bottom: .5rem;
}
.scope-head i { font-size: 1.25rem; }
.scope-banner code {
  background: rgba(201,163,78,.16); color: #7a5c1e; padding: .1rem .45rem;
  border-radius: 5px; font-weight: 700;
}
.scope-banner strong { color: var(--gold-dp); }
.scope-banner u { text-underline-offset: 3px; }

/* ----------------------------- REC LIST --------------------------------- */
.rec-list { list-style: none; margin: 0; padding: 0; }
.rec-list li {
  display: flex; gap: .7rem; align-items: flex-start;
  padding: .7rem .2rem; border-bottom: 1px solid var(--line);
}
.rec-list li:last-child { border-bottom: none; }
.rec-list .num {
  flex: 0 0 26px; height: 26px; border-radius: 50%;
  background: var(--blue); color: #fff; font-weight: 700; font-size: .8rem;
  display: inline-flex; align-items: center; justify-content: center;
}
.rec-list .rec-text { flex: 1; }
.rec-list .rec-ref {
  font-size: .72rem; color: var(--muted); background: #f1f5fa;
  padding: .1rem .5rem; border-radius: 20px; white-space: nowrap; font-weight: 700;
}

/* ----------------------------- BOQ TOOLBAR ------------------------------ */
.boq-toolbar {
  display: flex; flex-wrap: wrap; gap: .8rem; align-items: center;
  margin-bottom: 1rem;
}
.boq-search {
  position: relative; flex: 0 0 260px; max-width: 100%;
}
.boq-search i {
  position: absolute; inset-inline-start: .7rem; top: 50%; transform: translateY(-50%);
  color: var(--muted);
}
.boq-search input {
  width: 100%; padding: .5rem .7rem .5rem 2.1rem;
  border: 1px solid var(--line); border-radius: 9px; font-family: inherit; font-size: .9rem;
}
.boq-search input:focus { outline: none; border-color: var(--blue); box-shadow: 0 0 0 3px rgba(46,117,182,.12); }
.boq-chips { display: flex; flex-wrap: wrap; gap: .4rem; }
.chip {
  border: 1px solid var(--line); background: #fff; color: var(--navy);
  font-family: inherit; font-weight: 700; font-size: .78rem;
  padding: .35rem .8rem; border-radius: 30px; cursor: pointer; transition: all .15s;
}
.chip:hover { background: #f1f6fb; border-color: var(--blue-lt); }
.chip.active { background: var(--blue); color: #fff; border-color: var(--blue); }

/* ----------------------------- CHART ------------------------------------ */
.chart-box { position: relative; height: 340px; width: 100%; }

/* ----------------------------- FOOTER ----------------------------------- */
.app-footer {
  margin-top: 2.5rem; padding-top: 1.2rem; border-top: 1px solid var(--line);
  color: var(--muted); font-size: .82rem; text-align: center;
}
.app-footer .sep { margin: 0 .55rem; color: var(--line); }
.app-footer strong { color: var(--navy); }

/* ----------------------------- DATATABLES TWEAKS ------------------------ */
.dataTables_wrapper .dataTables_filter input,
.dataTables_wrapper .dataTables_length select {
  border: 1px solid var(--line); border-radius: 7px; padding: .25rem .5rem;
}
.dataTables_wrapper .dataTables_paginate .paginate_button.current {
  background: var(--blue) !important; border-color: var(--blue) !important; color: #fff !important;
}
table.dataTable thead .sorting:after, table.dataTable thead .sorting_asc:after,
table.dataTable thead .sorting_desc:after { color: #cfe0f2; }

/* ----------------------------- RESPONSIVE ------------------------------- */
@media (max-width: 991.98px) {
  .content { padding: 1.2rem 1rem 2rem; }
  .sidebar { position: fixed; }
}

/* ----------------------------- PRINT ------------------------------------ */
@media print {
  @page { margin: 1.2cm; }
  body { background: #fff; font-size: 11.5px; }
  .app-navbar, .sidebar, .toolbar, .d-print-none { display: none !important; }
  .layout { display: block; }
  .content { max-width: 100%; padding: 0; }
  .card-r, .kpi, .amendment { box-shadow: none; break-inside: avoid; }
  .card-r, .table-wrap { page-break-inside: avoid; }
  .table-r thead th { -webkit-print-color-adjust: exact; print-color-adjust: exact; }
  .page-title { color: #000; }
  a[href]:after { content: ""; }
}
