@font-face {
  font-family: "DM Sans";
  src: url("assets/dm-sans.woff2") format("woff2");
  font-weight: 400 700;
  font-display: swap;
}
@font-face {
  font-family: "Barlow Condensed";
  src: url("assets/barlow-condensed-700.woff2") format("woff2");
  font-weight: 700;
  font-display: swap;
}

:root {
  --ink: #1c2b27;
  --sidebar: #172724;
  --paper: #fffefa;
  --surface: #f3f2ec;
  --line: #dcded5;
  --muted: #59615a;
  --accent: #c65629;
  --action: #964020;
  --action-hover: #7a3117;
  --wash: #f7e8db;
  --green: #2c5546;
  --gold: #f3bc78;
  --radius: 16px;
  --sidebar-width: 218px;
  --display: "Barlow Condensed", "DM Sans", sans-serif;
  --body: "DM Sans", system-ui, sans-serif;
}
[dir="rtl"] {
  --display: var(--body);
  --body: "DM Sans", "Noto Sans Arabic", "Geeza Pro", Tahoma, system-ui, sans-serif;
}
*, *::before, *::after { box-sizing: border-box; }
[hidden] { display: none !important; }
body { margin: 0; background: var(--surface); color: var(--ink); font: 15px/1.55 var(--body); }
[dir="rtl"] body { line-height: 1.7; }
h1, h2, h3, p, dl, dd { margin: 0; }
h2 { font-size: 18px; line-height: 1.35; letter-spacing: -.025em; margin-bottom: 6px; }
h3 { font-size: 14px; margin: 14px 0 8px; }
[dir="rtl"] h2 { letter-spacing: normal; }
:focus-visible { outline: 2px solid #b8592c; outline-offset: 3px; }
.app :focus-visible, .sidebar :focus-visible { outline-color: var(--gold); }
.icon { display: block; width: 19px; height: 19px; flex: none; }
[data-icon] { display: inline-flex; align-items: center; flex: none; }
[dir="rtl"] .directional { transform: scaleX(-1); }

button, input, select, textarea { font: inherit; }
button {
  display: inline-flex; justify-content: center; align-items: center; gap: 8px;
  min-height: 44px; padding: 9px 13px; border: 1px solid var(--line);
  border-radius: 9px; background: var(--paper); color: var(--ink);
  font-weight: 650; cursor: pointer;
}
button:hover { background: #eeeee7; border-color: #b9c0b2; }
button:disabled { opacity: .5; cursor: default; }
button.main { color: #fff; background: var(--action); border-color: var(--action); }
button.main:hover { background: var(--action-hover); border-color: var(--action-hover); }
button.wide { width: 100%; }
button.x { min-width: 40px; padding-inline: 7px; color: var(--muted); }
button.danger { border-color: #dcaaa4; color: #982b21; }
button.danger:hover { background: #fcf0ed; }
input, select, textarea {
  width: 100%; min-width: 0; min-height: 44px; padding: 9px 10px;
  border: 1px solid #cfd4c9; border-radius: 8px; background: #fff;
  color: var(--ink); font-size: 16px;
}
input::placeholder, textarea::placeholder { color: #6a746a; }
textarea { min-height: 82px; resize: vertical; }
input[type="number"], input[type="tel"] { font-variant-numeric: tabular-nums; }
[dir="rtl"] input[type="number"], [dir="rtl"] input[type="tel"] { direction: ltr; text-align: end; }
input[type="color"] { padding: 4px; }
label { display: flex; flex-direction: column; gap: 5px; font-size: 13px; font-weight: 650; }
.chk { flex-direction: row; align-items: center; gap: 9px; margin-block: 8px; font-size: 14px; }
.chk input { flex: none; width: 18px; height: 18px; min-height: 18px; margin: 0; accent-color: var(--green); }
.row { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 135px), 1fr)); gap: 12px; }
.bar { display: flex; flex-wrap: wrap; gap: 8px; }
.mut { color: var(--muted); font-size: 14px; margin-block-end: 10px; }
details summary { cursor: pointer; color: var(--green); font-weight: 700; padding-block: 7px; }
details[open] > summary { margin-block-end: 4px; }

.app {
  min-height: 68px; padding: 10px clamp(16px, 2.4vw, 34px);
  display: flex; justify-content: space-between; align-items: center; gap: 10px;
  color: white; background: var(--sidebar); border-bottom: 1px solid #344740;
}
.wordmark { display: flex; align-items: center; gap: 10px; font: 700 31px/1 "Barlow Condensed", sans-serif; white-space: nowrap; }
.wordmark-icon { display: grid; width: 34px; height: 34px; place-content: center; border-radius: 9px; background: var(--gold); color: var(--sidebar); }
.wordmark-icon .icon { width: 21px; height: 21px; }
.top-actions { flex-wrap: nowrap; align-items: center; }
.top-actions button, .sidebar-new { border-color: #496056; color: #f6f7ef; background: #263a32; }
.top-actions button:hover, .sidebar-new:hover { border-color: #778b7b; background: #354e43; }
.top-actions button { min-height: 40px; }
#gear, #installbtn { width: 40px; padding: 0; }
#qcount { border-radius: 10px; background: #435b51; padding: 0 6px; font-size: 12px; }
#v_niche { width: min(100% - 32px, 720px); margin: 28px auto; }

#v_app { display: grid; grid-template-columns: var(--sidebar-width) minmax(0, 1fr); min-height: calc(100dvh - 68px); }
.sidebar {
  position: sticky; top: 0; z-index: 4; align-self: start;
  height: max(540px, calc(100dvh - 68px)); display: flex; flex-direction: column;
  gap: 18px; padding: 29px 17px 18px; color: #e6eee8; background: var(--sidebar);
}
.sidebar-label { padding-inline: 11px; color: #b3c5ba; font-size: 11px; font-weight: 700; letter-spacing: .13em; text-transform: uppercase; }
[dir="rtl"] .sidebar-label { letter-spacing: 0; }
.steps { display: grid; align-content: start; gap: 7px; position: relative; }
.steps::before { content: ""; position: absolute; inset-block: 24px; inset-inline-start: 24px; width: 1px; background: #4a6156; }
.steps button {
  position: relative; justify-content: flex-start; min-width: 0; gap: 10px;
  padding: 9px; color: #d2dfd6; border-color: transparent; background: transparent;
  font-size: 14px; white-space: nowrap;
}
.steps button:hover { background: #2b4036; }
.steps b {
  position: relative; display: grid; place-items: center; flex: none; width: 29px; height: 29px;
  border-radius: 50%; background: #263c34; border: 1px solid #61796b;
  font-size: 12px; line-height: 1; font-variant-numeric: tabular-nums;
}
.steps button.on { color: #fff; border-color: #566b60; background: #2b4036; }
.steps .on b { background: var(--gold); border-color: var(--gold); color: #35251d; }
.steps .done b { color: #e1ece3; background: #3c5a4b; border-color: #73927c; }
.steps .done b::before { content: "✓"; position: absolute; inset: 0; display: grid; place-items: center; background: inherit; border-radius: inherit; }
.sidebar-new { justify-content: flex-start; padding-inline: 12px; }
.sidebar-profile {
  display: flex; gap: 9px; align-items: center; min-width: 0; padding: 15px 4px 3px;
  margin-top: auto; border-top: 1px solid #3a4d44;
}
.sidebar-profile > span { padding: 5px; background: #293e36; border-radius: 7px; color: var(--gold); }
.sidebar-profile div { min-width: 0; }
.sidebar-profile strong, .sidebar-profile small { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sidebar-profile small { color: #b3c5ba; }

.workspace {
  display: grid; grid-template-columns: minmax(0, 1fr) minmax(238px, 29%);
  grid-template-rows: 1fr auto; grid-template-areas: "stage estimate" "nav estimate";
  gap: 15px 23px; align-content: start; width: 100%; max-width: 1510px;
  margin-inline: auto; padding: 24px clamp(18px, 2.35vw, 34px) 16px;
}
.stage { grid-area: stage; min-width: 0; }
[data-step]:not(.on) { display: none; }
section, .line {
  background: var(--paper); border: 1px solid var(--line); border-radius: var(--radius);
  padding: clamp(14px, 1.7vw, 23px); margin-block-end: 13px; min-width: 0;
}
.page-heading { margin: 0 0 18px; }
.page-heading h1 { font: 700 clamp(38px, 5vw, 58px)/1.05 var(--display); }
.page-heading p { color: var(--muted); margin-top: 5px; }

.work-hero {
  position: relative; isolation: isolate; display: flex; align-items: center; overflow: hidden;
  padding: clamp(18px, 2.7vw, 39px); min-height: clamp(174px, 16vw, 244px); margin-bottom: 16px;
  border-radius: 19px; color: #fffdf5; background: #22362d;
}
.work-hero::before {
  content: ""; position: absolute; z-index: -1; inset-block: 0; inset-inline-end: 0; width: 71%;
  background: linear-gradient(90deg, #22362d, #22362d00 63%), url("assets/placo-workshop.webp") 50% 45% / cover;
  opacity: .62;
}
[dir="rtl"] .work-hero::before { background-image: linear-gradient(270deg, #22362d, #22362d00 63%), url("assets/placo-workshop.webp"); }
.work-hero > div { max-width: 430px; }
.hero-tag {
  display: inline-block; padding: 3px 8px; border: 1px solid #b69668; border-radius: 5px;
  color: #ffe0ad; background: #263a2e; font-size: 11px; font-weight: 700; letter-spacing: .1em;
}
[dir="rtl"] .hero-tag { letter-spacing: 0; }
.work-hero h1 { font: 700 clamp(35px, 4.45vw, 66px)/.94 var(--display); margin-block: 9px 11px; text-wrap: balance; }
.work-hero p { max-width: 38ch; color: #f2f4ed; font-size: 14px; }
[dir="rtl"] .work-hero h1 { font-size: clamp(27px, 3.3vw, 49px); line-height: 1.3; }

.tiles { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 128px), 1fr)); gap: 8px; }
.tiles button { flex-direction: column; align-items: flex-start; justify-content: center; text-align: start; padding: 10px; min-width: 0; }
.tiles button small { color: var(--muted); }
#tiles { grid-template-columns: repeat(4, minmax(0, 1fr)); }
#tiles button {
  position: relative; display: grid; justify-items: start; justify-content: stretch;
  align-content: start; gap: 7px; min-height: 95px; padding: 9px; background: #f5f4ed;
  line-height: 1.25; font-size: 13px;
}
#tiles button:hover { background: #eaf0e7; border-color: #91a293; }
#tiles .tile-icon {
  display: grid; place-items: center; width: 33px; height: 33px; border-radius: 8px;
  background: #e5eae1; color: #345746;
}
#tiles .tile-plus { position: absolute; inset-inline-end: 10px; inset-block-start: 13px; color: #536b5c; }
#tiles .tile-plus .icon { width: 14px; height: 14px; }
.work-heading { display: flex; gap: 9px; align-items: center; margin: 15px 0 8px; }
.work-heading h2 { margin: 0; }
.count { background: #e5e9df; padding: 2px 9px; border-radius: 15px; font-size: 12px; font-weight: 700; }
.line { padding-block: 12px; }
.head { display: flex; align-items: center; gap: 9px; margin-bottom: 8px; }
.head b { flex: 1; }
.head .tile-icon { color: var(--green); }
.head .m2 { color: #31533e; background: #eaf0e6; border-radius: 5px; padding: 3px 7px; font-size: 13px; font-weight: 700; white-space: nowrap; }
.room { margin-bottom: 8px; }
.warn, .banner { color: #694012; background: #f9eddb; border-radius: 8px; padding: 8px 10px; margin-block: 8px; font-size: 14px; }
.banner .bar { margin-top: 8px; justify-content: space-between; }
.empty-state { padding: 15px; background: var(--paper); border: 1px dashed #b7c2b3; border-radius: 10px; }

.mrow {
  display: grid; grid-template-columns: minmax(0, 1.55fr) minmax(52px, .7fr) minmax(65px, .8fr) minmax(56px, .65fr);
  gap: 6px 11px; align-items: center; padding: 10px 0; border-bottom: 1px solid var(--line);
}
.mrow:first-child { padding-block-start: 0; }
.mrow .mlab { overflow-wrap: anywhere; font-weight: 650; }
.mrow .mlab small { display: block; color: var(--muted); font-size: 12px; font-weight: 400; }
.mrow .mlab button { min-height: 34px; }
.mrow .mtot { text-align: end; font-weight: 700; font-variant-numeric: tabular-nums; }
.mrow.ed input.q { border-color: #a75436; background: #fff9f3; }
#labour .mrow { grid-template-columns: minmax(0, 1fr) repeat(2, minmax(62px, .7fr)) auto; }
.sumline { display: flex; justify-content: space-between; padding-top: 13px; font-weight: 700; }
.per, .suppbox { background: #f1f3ed; border-radius: 8px; padding: 4px 10px; margin-block: 10px; }

.estimate { grid-area: estimate; min-width: 0; align-self: stretch; }
.estimate-card {
  position: sticky; top: 20px; padding: 19px; background: var(--paper);
  border: 1px solid var(--line); border-radius: var(--radius);
  box-shadow: 0 3px 9px #17272409;
}
.estimate-icon { width: 39px; height: 39px; border-radius: 10px; background: var(--wash); color: var(--action); justify-content: center; margin-bottom: 10px; }
.estimate-card h2 { margin-bottom: 2px; }
.quote-ref { color: var(--muted); font-size: 12px; }
.estimate-total {
  display: grid; padding: 12px 13px 14px; margin: 15px 0 7px;
  background: #e9efe7; color: #233b2e; border: 1px solid #e1e7df; border-radius: 10px;
}
.estimate-total > span { font-weight: 650; font-size: 13px; }
.estimate-total b { font: 700 clamp(29px, 3.05vw, 46px)/1.1 var(--display); overflow-wrap: anywhere; }
.estimate-total small { font: 700 13px var(--body); white-space: nowrap; }
.estimate-lines > div { display: flex; justify-content: space-between; align-items: baseline; gap: 9px; padding: 9px 0; border-bottom: 1px solid #e7e9df; font-size: 13px; }
.estimate-lines dd { text-align: end; font-weight: 700; font-variant-numeric: tabular-nums; }
.estimate-note { display: flex; gap: 8px; align-items: flex-start; color: var(--muted); margin-top: 13px; font-size: 12px; }
.estimate-note .icon { width: 15px; height: 15px; margin-top: 2px; }

.nav {
  position: sticky; z-index: 3; bottom: 0; grid-area: nav;
  display: flex; align-items: center; gap: 9px; padding: 8px 0;
  background: var(--surface); border-top: 1px solid var(--line);
}
.navtot { margin-inline-start: auto; text-align: end; color: var(--muted); font-size: 11px; line-height: 1.25; }
.navtot b { display: block; color: var(--ink); font-size: 17px; }
.nav button { min-height: 47px; }
#next { min-width: 108px; }
#next[hidden] { display: inline-flex !important; visibility: hidden; pointer-events: none; }
.mobile-new { display: none; }

body:has(dialog[open]) { overflow: hidden; }
dialog.sheet {
  position: fixed; inset: 0; width: 100%; max-width: none; height: 100%; max-height: none;
  margin: 0; padding: 0; border: 0; color: var(--ink); background: transparent;
}
dialog.sheet[open] { display: flex; justify-content: flex-end; align-items: stretch; }
dialog.sheet::backdrop { background: #14251f85; }
.sheet > div {
  width: min(100%, 545px); overflow: auto; overscroll-behavior: contain;
  padding: 0 19px max(20px, env(safe-area-inset-bottom));
  background: var(--paper); border-inline-start: 1px solid var(--line);
  box-shadow: 0 0 48px #17272436;
}
.sheet .sh {
  display: flex; position: sticky; top: 0; z-index: 1; justify-content: space-between;
  align-items: center; gap: 12px; background: var(--paper); padding: 14px 0;
  border-bottom: 1px solid var(--line); margin-bottom: 14px;
}
.sheet .sh h2 { margin-bottom: 0; }
.sheet .sh button { flex: none; }
#qlist, .plist { list-style: none; padding: 0; margin: 8px 0 15px; }
#qlist li, .plist li {
  display: flex; justify-content: space-between; flex-wrap: wrap; align-items: center; gap: 7px 10px;
  border-bottom: 1px solid var(--line); padding-block: 10px; overflow-wrap: anywhere;
}
#qlist li > span:first-child { flex: 1 1 135px; min-width: 0; }
#qlist li > span:last-child { display: flex; gap: 6px; flex-wrap: wrap; }
#qlist li small { display: block; color: var(--muted); }
#qlist .due { color: #87411b; font-weight: 700; }
#qlist .ok { color: #286243; font-weight: 700; }
#logo_prev { display: flex; gap: 8px; align-items: center; margin-top: 7px; }
#logo_prev img { max-height: 56px; max-width: 140px; background: white; border-radius: 5px; }
.ledger { padding: 12px; margin-bottom: 13px; background: #e9efe7; border-radius: 10px; }
.ledger div { display: flex; justify-content: space-between; padding: 4px 0; gap: 7px; }
.ledger .big { font-size: 17px; border-top: 1px solid #c1cebf; margin-top: 3px; }
.payrow { display: flex; align-items: end; gap: 8px; }
.payrow label { flex: 1; min-width: 0; }
.plist li span { flex: 1; }
.plist li.refused span, .plist li.refused b { text-decoration: line-through; color: var(--muted); }
.chip.ok { background: #e2efe5; color: #24583e; }
.chip.no { background: #fceae6; color: #922d26; }
#toast {
  position: fixed; z-index: 15; inset-block-end: 76px; inset-inline-start: 50%; transform: translateX(-50%);
  border-radius: 8px; padding: 10px 14px; background: var(--sidebar); color: white; max-width: calc(100% - 24px);
}
[dir="rtl"] #toast { transform: translateX(50%); }

#docwrap { overflow: hidden; }
#docscale { width: max-content; margin: 0 auto 12px; }
#rwrap { position: fixed; left: -10000px; top: 0; width: 720px; }
.docbar .bar button { flex: 1 1 auto; }

@media (min-width: 926px) {
  .navtot { display: none; }
  #next { margin-inline-start: auto; }
}
@media (max-width: 1060px) {
  :root { --sidebar-width: 184px; }
  .workspace { gap: 12px 14px; }
}
@media (max-width: 925px) {
  #v_app { display: block; }
  .sidebar { height: auto; display: block; padding: 6px max(11px, calc((100% - 740px) / 2)); top: 0; }
  .sidebar-label, .sidebar-new, .sidebar-profile { display: none; }
  .steps { grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 2px; }
  .steps::before { inset-block: 14px auto; inset-inline: 13%; width: auto; height: 1px; }
  .steps button { flex-direction: column; gap: 3px; padding: 0 2px 4px; min-height: 46px; font-size: 12px; }
  .steps b { width: 27px; height: 27px; }
  .steps button.on, .steps button:hover { background: transparent; border-color: transparent; }
  .workspace { display: block; max-width: 775px; padding: 15px 15px calc(91px + env(safe-area-inset-bottom)); }
  .estimate { display: none; }
  .nav {
    position: fixed; inset-inline: 0; bottom: 0; padding: 8px max(15px, calc((100% - 745px) / 2)) calc(8px + env(safe-area-inset-bottom));
    background: var(--paper); box-shadow: 0 -6px 22px #1727240c;
  }
  .mobile-new { display: inline-flex; }
  #next[hidden] { display: none !important; }
  #prev:not([hidden]) ~ .mobile-new { display: none; }
}
@media (max-width: 600px) {
  .app { min-height: 59px; padding-inline: 12px; }
  .wordmark { gap: 7px; font-size: 26px; }
  .wordmark-icon { width: 28px; height: 28px; border-radius: 6px; }
  .wordmark-icon .icon { width: 17px; height: 17px; }
  .top-actions { gap: 5px; }
  .top-actions button { font-size: 12px; min-height: 36px; padding: 5px 7px; gap: 3px; }
  #gear, #installbtn { width: 36px; }
  .top-actions .icon { width: 15px; height: 15px; }
  #archive_btn > [data-icon], .lang > [data-icon] { display: none; }
  .work-hero { min-height: 159px; margin-bottom: 12px; border-radius: 13px; }
  .work-hero h1 { font-size: clamp(33px, 8vw, 46px); }
  .work-hero p { max-width: 33ch; font-size: 13px; }
  #tiles { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  #tiles button { min-height: 70px; gap: 5px; padding-block: 7px; }
  #tiles .tile-icon { width: 24px; height: 24px; }
  #tiles .tile-icon .icon { width: 16px; height: 16px; }
  .mrow, #labour .mrow { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr) minmax(40px, auto); align-items: end; }
  .mrow .mlab { grid-column: 1 / -1; }
  .mrow .mtot { padding-bottom: 10px; }
  dialog.sheet[open] { align-items: flex-end; justify-content: center; }
  .sheet > div { max-height: min(90%, 740px); border-inline-start: 0; border-radius: 17px 17px 0 0; }
}
@media (max-width: 365px) {
  .top-actions button { padding-inline: 5px; }
  .wordmark { font-size: 23px; }
  #archive_btn { width: 36px; padding: 0; }
  #archive_btn > [data-icon] { display: inline-flex; }
  #archive_btn > [data-i], #qcount { display: none; }
  .steps button { font-size: 11px; }
  .nav button { min-width: 0; padding-inline: 8px; }
}
@media print {
  @page { size: A4; margin: 12mm; }
  body { background: #fff; }
  header.app, .sidebar, .estimate, .nav, .docbar, #toast, .sheet, #rwrap, #v_niche, [data-step]:not(#docwrap) { display: none !important; }
  #v_app, #docwrap, .workspace { display: block !important; }
  .workspace { max-width: none; padding: 0; }
  #docwrap { overflow: visible; }
  #docscale { zoom: 1 !important; margin: 0; width: auto; }
  #doc { width: auto; margin: 0; padding: 0; box-shadow: none; }
  .dt th, .dh, .dtitle { -webkit-print-color-adjust: exact; print-color-adjust: exact; }
}
