/* =====================================================================
   Enigma Cleaning — app shell.  Follows the OneBloc App Shell (brand kit):
   white sidebar, white cards on a soft grey canvas, one accent per module.
   Everything themes off --ob-* / --acc so ob-ui.css and datagrid.css inherit it.
   ===================================================================== */
:root { --ob-font: "Plus Jakarta Sans", system-ui, -apple-system, sans-serif; --radius: 14px; --radius-control: 11px; }
* { box-sizing: border-box; }
html, body { height: 100%; }
body { margin: 0; font-family: var(--ob-font); font-size: 14px; color: var(--ob-ink); background: var(--ob-bg); -webkit-font-smoothing: antialiased; text-rendering: optimizeLegibility; }
.mono, .num { font-family: "JetBrains Mono", ui-monospace, monospace; font-variant-numeric: tabular-nums; }
a { color: var(--acc-deep); }
button, input, select, textarea { font-family: inherit; font-size: inherit; }
button { cursor: pointer; }

/* ------------------------------------------------------------ shell */
.app { display: flex; min-height: 100vh; }
/* Sizes follow the OneBloc ERP sidebar (the suite reference): 256px, 13.5px links, 10.5px group labels. */
.sidebar { width: 256px; flex: none; background: var(--ob-card); border-right: 1px solid var(--ob-line); padding: 16px 10px 14px; display: flex; flex-direction: column; gap: 1px; position: sticky; top: 0; height: 100vh; overflow-y: auto; }
.sidebar .brand { padding: 2px 8px 12px; display: block; text-decoration: none; }
.nav-group { margin: 12px 8px 4px; font-size: 10.5px; font-weight: 700; letter-spacing: .08em; text-transform: uppercase; color: var(--ob-faint); }
.nav-item { display: flex; align-items: center; gap: 11px; padding: 8px 10px; border-radius: 9px; font-size: 13.5px; font-weight: 500; color: var(--ob-slate); text-decoration: none; transition: background .14s, color .14s; }
.nav-item .ic { width: 18px; height: 18px; flex: none; color: var(--ob-muted); transition: color .14s; display: inline-block; }
.nav-item .ic svg, .btn .ic svg { width: 100%; height: 100%; display: block; }
.nav-item:hover { background: var(--ob-line-soft); color: var(--ob-ink); }
/* the suite's active pill: solid module colour, white text (white on --acc-deep is 5.0:1) */
.nav-item.active { background: var(--acc-deep); color: #fff; font-weight: 600; }
.nav-item.active .ic { color: #fff; }
/* folding groups (ERP): the label is the toggle; a folded group still shows that something lives in it */
.nav-fold { display: flex; flex-direction: column; gap: 1px; }
.nav-fold > summary.nav-group { display: flex; align-items: center; justify-content: space-between; gap: 6px; cursor: pointer; list-style: none; user-select: none; margin: 10px 0 2px; padding: 6px 8px; border-radius: 7px; }
.nav-fold > summary.nav-group::-webkit-details-marker { display: none; }
.nav-fold > summary.nav-group:hover { background: var(--ob-line-soft); color: var(--ob-slate); }
.nav-fold > summary.nav-group:focus-visible { outline: 2px solid var(--acc); outline-offset: 1px; }
.nav-fold .chev { width: 12px; height: 12px; display: inline-block; flex: none; transition: transform .16s ease; }
.nav-fold .chev svg { width: 100%; height: 100%; display: block; }
.nav-fold[open] .chev { transform: rotate(180deg); }
.nav-fold:not([open]) > summary.nav-group { color: var(--ob-muted); }
.nav-item .badge-count { margin-left: auto; font-size: 11.5px; font-weight: 700; background: var(--acc-soft); color: var(--acc-deep); padding: 2px 8px; border-radius: 999px; }
.sidebar .grow { flex: 1; min-height: 16px; }
.sidebar .foot { border-top: 1px solid var(--ob-line-soft); padding: 12px 6px 0; display: flex; align-items: center; gap: 10px; }
.sidebar .foot .logout { margin-left: auto; }
.sidebar .foot .logout .btn .ic { width: 16px; height: 16px; display: inline-block; }
.avatar { width: 34px; height: 34px; border-radius: 50%; flex: none; display: grid; place-items: center; background: var(--acc-soft); color: var(--acc-deep); font-weight: 800; font-size: 12.5px; letter-spacing: .02em; }
.who { font-size: 13px; font-weight: 600; color: var(--ob-slate); line-height: 1.35; min-width: 0; }
.who small { display: block; color: var(--ob-faint); font-weight: 500; font-size: 11.5px; }
.who span { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.content { flex: 1; min-width: 0; padding: 28px 34px 56px; }
.content-narrow { max-width: 720px; margin: 0 auto; }

/* ------------------------------------------------------------ page header */
.page-head { display: flex; align-items: flex-start; gap: 16px; margin-bottom: 22px; flex-wrap: wrap; }
.page-head h1 { font-size: 26px; font-weight: 800; letter-spacing: -.02em; margin: 0 0 3px; }
.page-head .sub { color: var(--ob-muted); font-size: 13.5px; }
.page-head .actions { margin-left: auto; display: flex; gap: 9px; align-items: center; flex-wrap: wrap; }

/* ------------------------------------------------------------ buttons */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; height: 42px; padding: 0 17px; border-radius: var(--radius-control); font-weight: 600; font-size: 14px; text-decoration: none; border: 1px solid var(--ob-line); background: var(--ob-card); color: var(--ob-slate); transition: background .15s, border-color .15s, color .15s, transform .1s; white-space: nowrap; }
.btn:hover { border-color: #D5D9E0; background: #FBFCFD; color: var(--ob-ink); }
.btn:active { transform: translateY(1px); }
.btn svg { width: 17px; height: 17px; flex: none; }
.btn .ic { width: 17px; height: 17px; flex: none; display: inline-block; line-height: 0; }
.btn.primary { background: var(--acc-deep); border-color: var(--acc-deep); color: #fff; box-shadow: var(--ob-shadow-btn); }
.btn.primary:hover { background: #0E6E30; border-color: #0E6E30; color: #fff; }
.btn.danger { background: var(--ob-danger); border-color: var(--ob-danger); color: #fff; }
.btn.danger:hover { background: #A9391F; border-color: #A9391F; color: #fff; }
.btn.ghost { border-color: transparent; background: transparent; }
.btn.ghost:hover { background: var(--ob-line-soft); }
.btn.sm { height: 34px; padding: 0 12px; font-size: 13px; border-radius: 9px; }
.btn.lg { height: 52px; padding: 0 24px; font-size: 16px; }
.btn.wide { width: 100%; }
.btn[disabled], .btn.disabled { opacity: .55; cursor: not-allowed; pointer-events: none; }
.btn.whatsapp { background: #128C4A; border-color: #128C4A; color: #fff; }

/* ------------------------------------------------------------ cards */
.card { background: var(--ob-card); border: 1px solid var(--ob-line); border-radius: 16px; padding: 20px 22px; margin-bottom: 18px; }
.card.flush { padding: 0; overflow: hidden; }
.card-head { display: flex; align-items: center; gap: 10px; font-size: 15px; font-weight: 700; margin-bottom: 16px; }
.card-head .sub { font-weight: 500; font-size: 12.5px; color: var(--ob-muted); margin-left: auto; }
.card-head svg { width: 18px; height: 18px; color: var(--acc-deep); }
.card-sec { padding: 16px 22px; border-top: 1px solid var(--ob-line-soft); }
.grid-2 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; }
.grid-3 { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 16px; }
.split { display: grid; grid-template-columns: minmax(0, 1.35fr) minmax(0, 1fr); gap: 18px; align-items: start; }

/* ------------------------------------------------------------ chips */
.chip { display: inline-flex; align-items: center; gap: 7px; font-size: 12.5px; font-weight: 600; padding: 5px 11px; border-radius: 999px; background: var(--ob-line-soft); color: var(--ob-slate); white-space: nowrap; }
.chip .d { width: 7px; height: 7px; border-radius: 50%; background: currentColor; flex: none; }
.chip.ok { background: var(--ob-success-soft); color: var(--ob-success); }
.chip.warn { background: var(--ob-warning-soft); color: var(--ob-warning); }
.chip.bad { background: var(--ob-danger-soft); color: var(--ob-danger); }
.chip.info { background: var(--acc-soft); color: var(--acc-deep); }
.chip.neutral { background: var(--ob-line-soft); color: var(--ob-muted); }
.chip.sm { font-size: 11px; padding: 3px 8px; }

/* status chips by job / expense / invoice state (data-status attribute) */
.chip[data-status="Scheduled"], .chip[data-status="Open"], .chip[data-status="Draft"] { background: var(--ob-line-soft); color: var(--ob-muted); }
.chip[data-status="Assigned"], .chip[data-status="Submitted"], .chip[data-status="VendorReview"], .chip[data-status="Quoted"] { background: #EAF1FF; color: #2563EB; }
.chip[data-status="InProgress"], .chip[data-status="PendingApproval"] { background: var(--ob-warning-soft); color: var(--ob-warning); }
.chip[data-status="Completed"], .chip[data-status="Generated"] { background: #EAF1FF; color: #1D4ED8; }
.chip[data-status="Verified"], .chip[data-status="Approved"], .chip[data-status="Accepted"], .chip[data-status="Posted"], .chip[data-status="Paid"], .chip[data-status="Invoiced"], .chip[data-status="Done"], .chip[data-status="Closed"], .chip[data-status="Returned"], .chip[data-status="Locked"] { background: var(--ob-success-soft); color: var(--ob-success); }
.chip[data-status="Cancelled"], .chip[data-status="Abandoned"], .chip[data-status="Rejected"], .chip[data-status="Void"], .chip[data-status="Disputed"], .chip[data-status="Failed"], .chip[data-status="Disposed"] { background: var(--ob-danger-soft); color: var(--ob-danger); }

/* ------------------------------------------------------------ fields */
.field { margin-bottom: 15px; }
.field > label { display: flex; align-items: center; gap: 6px; font-size: 12.5px; font-weight: 600; color: var(--ob-slate); margin-bottom: 6px; }
.input, select.input, textarea.input { width: 100%; height: 42px; padding: 0 12px; border: 1px solid var(--ob-line); border-radius: var(--radius-control); background: #fff; color: var(--ob-ink); outline: none; transition: border-color .15s, box-shadow .15s; }
textarea.input { height: auto; padding: 10px 12px; line-height: 1.55; resize: vertical; }
.input:focus, select.input:focus, textarea.input:focus { border-color: var(--acc); box-shadow: 0 0 0 3px rgba(27, 166, 74, .16); }
.input[readonly] { background: var(--ob-bg); color: var(--ob-slate); }
.input.code { font-family: "JetBrains Mono", monospace; font-size: 22px; letter-spacing: .3em; text-transform: uppercase; height: 54px; text-align: center; }
.hint { font-size: 12px; color: var(--ob-faint); margin: 5px 0 0; }
.field-row { display: flex; gap: 14px; flex-wrap: wrap; }
.field-row > .field { flex: 1 1 220px; margin-bottom: 15px; }
.input-money { text-align: right; font-family: "JetBrains Mono", monospace; }

/* ------------------------------------------------------------ tables */
.tbl { width: 100%; border-collapse: collapse; font-size: 13.5px; }
.tbl th { text-align: left; font-size: 11px; font-weight: 700; letter-spacing: .07em; text-transform: uppercase; color: var(--ob-faint); padding: 11px 14px; border-bottom: 1px solid var(--ob-line); white-space: nowrap; }
.tbl td { padding: 12px 14px; border-bottom: 1px solid var(--ob-line-soft); vertical-align: middle; }
.tbl tr:last-child td { border-bottom: 0; }
.tbl tbody tr:hover { background: #FAFCFB; }
.tbl td.num, .tbl th.num { text-align: right; font-family: "JetBrains Mono", monospace; font-variant-numeric: tabular-nums; }
.tbl .muted { color: var(--ob-muted); }
.tbl tfoot td { font-weight: 700; border-top: 1px solid var(--ob-line); }
.table-wrap { overflow-x: auto; }

/* ------------------------------------------------------------ alerts */
.alert { display: flex; gap: 10px; align-items: flex-start; padding: 12px 15px; border-radius: 12px; font-size: 13.5px; border: 1px solid var(--ob-line); background: var(--ob-line-soft); color: var(--ob-slate); margin-bottom: 16px; }
.alert.ok { background: var(--ob-success-soft); border-color: #C9E6D8; color: var(--ob-success); }
.alert.warn { background: var(--ob-warning-soft); border-color: #EEDCB6; color: var(--ob-warning); }
.alert.bad { background: var(--ob-danger-soft); border-color: #F0CFC7; color: var(--ob-danger); }
.alert svg { width: 18px; height: 18px; flex: none; margin-top: 1px; }

/* ------------------------------------------------------------ meta boxes / stats */
.meta-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: 12px; }
.meta-box { background: var(--ob-bg); border: 1px solid var(--ob-line); border-radius: 12px; padding: 12px 14px; min-width: 0; }
.meta-box .k { font-size: 10.5px; font-weight: 700; letter-spacing: .07em; text-transform: uppercase; color: var(--ob-faint); margin-bottom: 4px; }
.meta-box .v { font-size: 15px; font-weight: 700; color: var(--ob-ink); word-break: break-word; }
.meta-box .v.accent { color: var(--acc-deep); }
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(168px, 1fr)); gap: 14px; margin-bottom: 20px; }
.stat { background: var(--ob-card); border: 1px solid var(--ob-line); border-radius: 16px; padding: 16px 18px; text-decoration: none; color: inherit; display: block; }
.stat:hover { border-color: #D5D9E0; }
.stat .k { font-size: 11.5px; font-weight: 600; color: var(--ob-muted); margin-bottom: 7px; }
.stat .v { font-family: "JetBrains Mono", ui-monospace, monospace; font-variant-numeric: tabular-nums; font-size: 27px; font-weight: 600; letter-spacing: -.02em; color: var(--ob-ink); line-height: 1.1; }
.stat .foot { font-size: 12px; color: var(--ob-faint); margin-top: 6px; }
.stat.accent .v { color: var(--acc-deep); }
.stat.warn .v { color: var(--ob-warning); }
.stat.bad .v { color: var(--ob-danger); }

/* ------------------------------------------------------------ pills / tabs */
.pills { display: flex; flex-wrap: wrap; gap: 8px; }
.pill { display: inline-flex; align-items: center; gap: 7px; padding: 7px 14px; border-radius: 999px; font-size: 13px; font-weight: 600; border: 1px solid var(--ob-line); background: var(--ob-card); color: var(--ob-slate); text-decoration: none; cursor: pointer; }
.pill:hover { border-color: #CBD3DC; background: #FBFCFD; }
.pill.active { background: var(--acc-soft); border-color: var(--acc); color: var(--acc-deep); }

/* ------------------------------------------------------------ board (vendor dashboard) */
.board { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 14px; }
.board-col { background: var(--ob-card); border: 1px solid var(--ob-line); border-radius: 16px; padding: 14px; }
.board-col h3 { margin: 0 0 10px; font-size: 13px; font-weight: 800; letter-spacing: .06em; text-transform: uppercase; color: var(--ob-muted); display: flex; align-items: center; gap: 8px; }
.job-card { border: 1px solid var(--ob-line); border-radius: 12px; padding: 11px 12px; margin-bottom: 9px; background: #fff; display: grid; gap: 6px; }
.job-card.priority { border-left: 4px solid var(--ob-warning); }
.job-card .row { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.job-card .unit { font-weight: 800; font-size: 15px; font-family: "JetBrains Mono", monospace; }
.job-card .when { color: var(--ob-muted); font-size: 12.5px; margin-left: auto; }
.job-card .who { font-size: 12.5px; }

/* ------------------------------------------------------------ photos */
.photo-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(120px, 1fr)); gap: 8px; }
.photo-grid a { display: block; aspect-ratio: 1; border-radius: 10px; overflow: hidden; border: 1px solid var(--ob-line); background: var(--ob-line-soft); }
.photo-grid img { width: 100%; height: 100%; object-fit: cover; display: block; }
.photo-pair { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.photo-pair h4 { margin: 0 0 8px; font-size: 12px; text-transform: uppercase; letter-spacing: .06em; color: var(--ob-faint); }
.thumbs { display: flex; gap: 4px; }
.thumbs img { width: 40px; height: 40px; object-fit: cover; border-radius: 6px; border: 1px solid var(--ob-line); }

/* ------------------------------------------------------------ timeline */
.timeline { list-style: none; margin: 0; padding: 0; }
.timeline li { display: flex; gap: 12px; padding: 8px 0; border-bottom: 1px solid var(--ob-line-soft); font-size: 13px; }
.timeline li .t { width: 130px; flex: none; color: var(--ob-muted); font-family: "JetBrains Mono", monospace; font-size: 12px; }

/* ------------------------------------------------------------ WhatsApp team-group replies on a job (DECISIONS D8) */
.greply { flex: 1; min-width: 0; display: grid; gap: 6px; }
.greply .who { font-weight: 700; }
.greply .body { white-space: pre-wrap; overflow-wrap: anywhere; }
.greply .photo-grid { grid-template-columns: repeat(auto-fill, minmax(96px, 140px)); }
.group-id { font-family: "JetBrains Mono", ui-monospace, monospace; font-size: 12px; color: var(--ob-muted); overflow-wrap: anywhere; }

/* ------------------------------------------------------------ auth page */
.auth { min-height: 100vh; display: grid; grid-template-columns: minmax(0, 1.05fr) minmax(0, 1fr); }
.auth-side { background: linear-gradient(155deg, #F1FAF4 0%, #E3F4E9 55%, #D6EFDF 100%); padding: 46px 52px; display: flex; flex-direction: column; justify-content: space-between; border-right: 1px solid var(--ob-line); }
.auth-side h2 { font-size: 30px; font-weight: 800; letter-spacing: -.025em; margin: 0 0 12px; max-width: 15ch; }
.auth-side p { color: var(--ob-slate); font-size: 14.5px; line-height: 1.65; max-width: 44ch; margin: 0; }
.auth-points { list-style: none; padding: 0; margin: 26px 0 0; display: grid; gap: 12px; }
.auth-points li { display: flex; gap: 10px; align-items: flex-start; font-size: 13.5px; color: var(--ob-slate); }
.auth-points svg { width: 17px; height: 17px; color: var(--acc-deep); flex: none; margin-top: 2px; }
.auth-form { display: flex; align-items: center; justify-content: center; padding: 40px 32px; }
.auth-or { display: flex; align-items: center; gap: 12px; margin: 20px 0; color: var(--ob-faint); font-size: 12.5px; }
.auth-or::before, .auth-or::after { content: ""; flex: 1; height: 1px; background: var(--ob-line); }
.auth-form .inner { width: 100%; max-width: 400px; }
.auth-form h1 { font-size: 24px; font-weight: 800; letter-spacing: -.02em; margin: 22px 0 5px; }
.auth-form .sub { color: var(--ob-muted); font-size: 13.5px; margin: 0 0 24px; }
.join-vendor summary { cursor: pointer; font-weight: 600; color: var(--ob-slate); }

/* ------------------------------------------------------------ misc */
.muted { color: var(--ob-muted); }
.faint { color: var(--ob-faint); }
.small { font-size: 12.5px; }
.right { text-align: right; }
.nowrap { white-space: nowrap; }
.stack { display: flex; flex-direction: column; gap: 4px; }
.row-actions { display: flex; gap: 7px; align-items: center; flex-wrap: wrap; }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; border: 0; }
.divider { height: 1px; background: var(--ob-line-soft); margin: 18px 0; }
.money { font-family: "JetBrains Mono", monospace; font-variant-numeric: tabular-nums; }
.money.neg { color: var(--ob-success); }
.flag-list { display: flex; gap: 5px; flex-wrap: wrap; }
.kbd { font-family: "JetBrains Mono", monospace; font-size: 11px; border: 1px solid var(--ob-line); border-bottom-width: 2px; border-radius: 5px; padding: 1px 6px; color: var(--ob-muted); background: #fff; }
.sticky-bar { position: sticky; bottom: 0; background: rgba(246,247,249,.92); backdrop-filter: blur(8px); padding: 12px 0; margin-top: 16px; border-top: 1px solid var(--ob-line); display: flex; gap: 10px; flex-wrap: wrap; }

/* ------------------------------------------------------------ responsive */
@media (max-width: 1080px) { .split, .grid-2, .grid-3 { grid-template-columns: minmax(0, 1fr); } }
@media (max-width: 900px) {
  .app { flex-direction: column; }
  .sidebar { width: 100%; height: auto; position: static; border-right: 0; border-bottom: 1px solid var(--ob-line); flex-direction: row; flex-wrap: wrap; align-items: center; gap: 6px; padding: 12px 16px; }
  .sidebar .brand { padding: 0 12px 0 0; }
  .sidebar .grow, .nav-group { display: none; }
  .nav-fold { display: contents; }   /* the wrap row takes the links straight; app.js opens every group at this width */
  .nav-fold > summary.nav-group { display: none; }   /* no fold toggle in the one-row menu (out-ranks the desktop rule) */
  .nav-item { padding: 8px 11px; font-size: 13.5px; }
  .nav-item .ic { display: none; }
  .sidebar .foot { border: 0; padding: 0; margin-left: auto; }
  .sidebar .foot .who { display: none; }
  .content { padding: 18px 14px 40px; }
  .auth { grid-template-columns: 1fr; }
  .auth-side { display: none; }
  .photo-pair { grid-template-columns: 1fr; }
}
