/*
  Workdesk: the whole stylesheet. Same look as apto (Arya's palette, Manrope headings, Inter body,
  gold buttons, white cards on cream), so the firm's two screens feel like one product.
  The CSP forbids inline styles: the progress bar width is set through the CSSOM.
*/

@font-face {
  font-family: "Inter";
  src: url("/static/fonts/inter.woff2") format("woff2");
  font-weight: 100 900;
  font-display: swap;
}
@font-face {
  font-family: "Manrope";
  src: url("/static/fonts/manrope.woff2") format("woff2");
  font-weight: 200 800;
  font-display: swap;
}

:root {
  --gold: #c99a3b;
  --gold-dark: #a97f2c;
  --gold-pale: #f6eedc;
  --gold-line: #ead9b4;
  --cream: #f5f3ea;
  --ink: #1a1a1a;
  --night: #1c1c1a;
  --body: #5a5a57;
  --white: #ffffff;
  --line: #e4e1d6;
  --muted: #8a877f;
  --ok: #2f7a4b;
  --ok-bg: #e5f2e9;
  --warn: #9a6a12;
  --warn-bg: #fbf0d8;
  --danger: #c0352a;
  --danger-bg: #fbe7e4;
  --neutral-bg: #eeece5;
  --font-head: "Manrope", system-ui, sans-serif;
  --font-body: "Inter", system-ui, sans-serif;
  --radius: 10px;
  --shadow: 0 1px 2px rgba(26, 26, 26, 0.04), 0 4px 16px rgba(26, 26, 26, 0.04);
}

* {
  box-sizing: border-box;
}
html,
body {
  margin: 0;
}
body {
  font-family: var(--font-body);
  font-size: 14px;
  line-height: 1.5;
  color: var(--body);
  background: var(--cream);
  -webkit-font-smoothing: antialiased;
}
h1,
h2,
h3 {
  font-family: var(--font-head);
  color: var(--ink);
  margin: 0;
  letter-spacing: -0.01em;
}
h1 {
  font-size: 28px;
  font-weight: 800;
}
h2 {
  font-size: 16px;
  font-weight: 700;
}
h3 {
  font-size: 14px;
  font-weight: 700;
  margin-bottom: 8px;
}
p {
  margin: 0;
}
a {
  color: var(--gold-dark);
}
[hidden] {
  display: none !important;
}
.muted {
  color: var(--muted);
}
.small {
  font-size: 12px;
}
.hl {
  color: var(--gold);
}
.loading {
  padding: 40px;
  text-align: center;
}

/* ---------- buttons and forms */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  border: 1px solid var(--line);
  background: var(--white);
  color: var(--ink);
  font: 600 13px var(--font-body);
  padding: 9px 16px;
  border-radius: var(--radius);
  cursor: pointer;
}
.btn:hover {
  border-color: var(--gold-line);
}
.btn:disabled {
  opacity: 0.6;
  cursor: default;
}
.btn-gold {
  background: var(--gold);
  border-color: var(--gold);
  color: var(--white);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  font-weight: 700;
}
.btn-gold:hover {
  background: var(--gold-dark);
}
.btn-sm {
  padding: 6px 12px;
  font-size: 12px;
}
.btn-ghost {
  background: transparent;
  border-color: transparent;
}
label {
  display: grid;
  gap: 6px;
  font-weight: 600;
  color: var(--ink);
  font-size: 13px;
}
.opt {
  color: var(--muted);
  font-weight: 400;
}
input,
select,
textarea {
  font: 14px var(--font-body);
  padding: 9px 11px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--white);
  color: var(--ink);
  width: 100%;
  min-width: 0;
}
input:focus,
select:focus,
textarea:focus {
  outline: 2px solid var(--gold-line);
  border-color: var(--gold);
}
.form,
.login {
  display: grid;
  gap: 14px;
}
.form-error {
  background: var(--danger-bg);
  color: var(--danger);
  padding: 8px 12px;
  border-radius: 8px;
}
.actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}
.card {
  background: var(--white);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 20px;
}
.card.empty {
  text-align: center;
  display: grid;
  gap: 6px;
  padding: 40px 20px;
}
.notice {
  background: var(--warn-bg);
  color: var(--warn);
  padding: 8px 12px;
  border-radius: 8px;
}
.notice-ok {
  background: var(--ok-bg);
  color: var(--ok);
}

/* ---------- sign in */
.login-page {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 16px;
}
.login {
  width: 100%;
  max-width: 380px;
}
.brand {
  display: flex;
  align-items: center;
  gap: 8px;
  font: 800 16px var(--font-head);
  color: var(--ink);
}
.mark {
  display: grid;
  place-items: center;
  width: 28px;
  height: 28px;
  border-radius: 8px;
  background: var(--gold);
  color: var(--white);
}

/* ---------- top bar and board */
.top {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  padding: 12px 24px;
  background: var(--night);
}
.top .brand {
  color: var(--white);
}
.top .btn-ghost {
  color: var(--white);
}
.who {
  display: flex;
  align-items: center;
  gap: 8px;
}
.who .muted {
  color: #b9b6ac;
}
.page {
  padding: 24px;
  max-width: 1400px;
  margin: 0 auto;
}
.page-head {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 18px;
}
.board {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 14px;
  align-items: start;
}
.col {
  background: var(--neutral-bg);
  border-radius: var(--radius);
  padding: 12px;
  display: grid;
  gap: 10px;
  min-width: 0;
}
.col h2 {
  font-size: 13px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  display: flex;
  justify-content: space-between;
}
.count {
  color: var(--muted);
}
.empty {
  padding: 8px 2px;
}
.ticket {
  display: grid;
  gap: 4px;
  text-align: left;
  background: var(--white);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 12px;
  cursor: pointer;
  font: inherit;
  color: inherit;
  min-width: 0;
}
.ticket:hover {
  border-color: var(--gold);
}
.ticket-top {
  display: flex;
  justify-content: space-between;
  gap: 6px;
}
.ticket-title {
  font-weight: 700;
  color: var(--ink);
  overflow-wrap: anywhere;
}
.order-no {
  font: 700 12px var(--font-head);
  color: var(--gold-dark);
  letter-spacing: 0.03em;
}
.ticket-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  margin: 4px 0 2px;
}
.tag {
  font-size: 11px;
  font-weight: 600;
  padding: 2px 8px;
  border-radius: 99px;
  background: var(--neutral-bg);
  color: var(--body);
}
.tag-gold {
  background: var(--gold-pale);
  color: var(--gold-dark);
}
.bar {
  height: 5px;
  background: var(--neutral-bg);
  border-radius: 99px;
  overflow: hidden;
}
.bar span {
  display: block;
  height: 100%;
  background: var(--gold);
}

/* ---------- one order (side panel) */
.panel-wrap {
  position: fixed;
  inset: 0;
  background: rgba(26, 26, 26, 0.35);
  display: flex;
  justify-content: flex-end;
  z-index: 10;
}
.panel {
  width: min(560px, 100%);
  height: 100%;
  overflow-y: auto;
  background: var(--white);
  padding: 22px;
  display: grid;
  align-content: start;
  gap: 18px;
}
.panel-head {
  display: flex;
  justify-content: space-between;
  gap: 12px;
}
.steps {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
}
.steps .ps {
  border-top: 3px solid var(--line);
  padding-top: 6px;
  font-size: 12px;
  font-weight: 600;
  color: var(--muted);
}
.steps .ps.done {
  border-color: var(--ink);
  color: var(--ink);
}
.steps .ps.current {
  border-color: var(--gold);
  color: var(--gold-dark);
}
.fields {
  display: grid;
  grid-template-columns: max-content minmax(0, 1fr);
  gap: 8px 16px;
  margin: 0;
}
.fields dt {
  color: var(--muted);
}
.fields dd {
  margin: 0;
  color: var(--ink);
  min-width: 0;
  overflow-wrap: anywhere;
  white-space: pre-wrap;
}
.files {
  display: grid;
  gap: 6px;
  margin-top: 16px;
}
.file {
  padding: 8px 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  text-decoration: none;
  overflow-wrap: anywhere;
}
.receive {
  display: grid;
  gap: 10px;
  background: var(--gold-pale);
  padding: 14px;
  border-radius: var(--radius);
  color: var(--ink);
}
.amounts {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
}

/* ---------- refinements: header, summary, search, cards, panel */
.tiny {
  font-size: 11px;
}
.firm {
  margin-left: 10px;
  padding-left: 12px;
  border-left: 1px solid #3a3a36;
  font: 600 13px var(--font-body);
  color: #b9b6ac;
}
.avatar,
.initials {
  display: inline-grid;
  place-items: center;
  border-radius: 50%;
  background: var(--gold-pale);
  color: var(--gold-dark);
  font: 700 11px var(--font-head);
  flex: none;
}
.avatar {
  width: 28px;
  height: 28px;
}
.initials {
  width: 20px;
  height: 20px;
  font-size: 9px;
}
.who-name {
  color: #b9b6ac;
  font-size: 12px;
}
.sync {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  color: var(--muted);
  margin-top: 4px;
}
.sync .dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--ok);
}
.sync-bad .dot {
  background: var(--danger);
}
.search {
  width: min(320px, 100%);
}
.stats {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 12px;
  margin-bottom: 18px;
}
.stat {
  background: var(--white);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 12px 16px;
  display: grid;
}
.stat-num {
  font: 800 24px var(--font-head);
  color: var(--ink);
}
.stat-label {
  font-size: 12px;
  color: var(--muted);
}
.stat-gold {
  border-color: var(--gold-line);
  background: var(--gold-pale);
}
.stat-late .stat-num {
  color: var(--danger);
}
.ticket-late {
  border-left: 3px solid var(--danger);
}
.ticket-client {
  display: flex;
  align-items: center;
  gap: 6px;
  min-width: 0;
}
.ticket-amount {
  display: grid;
  gap: 4px;
}
.tag-new {
  background: var(--ink);
  color: var(--white);
}
.due {
  font-size: 11px;
  font-weight: 600;
  color: var(--muted);
  white-space: nowrap;
}
.due-late {
  color: var(--danger);
}
.due-soon {
  color: var(--warn);
}
.panel-head .due {
  margin-left: 8px;
}
.more {
  justify-self: center;
}

/* panel */
.panel {
  width: min(680px, 100%);
}
.panel-grid {
  display: grid;
  grid-template-columns: minmax(0, 200px) minmax(0, 1fr);
  gap: 20px;
}
.panel section h3 {
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--muted);
}
.vsteps {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  gap: 2px;
}
.vsteps li {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 5px 0;
  color: var(--muted);
  font-size: 13px;
  font-weight: 600;
}
.vdot {
  display: inline-grid;
  place-items: center;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  border: 2px solid var(--line);
  font-size: 11px;
  flex: none;
}
.vlabel {
  display: grid;
}
.vsteps li.done {
  color: var(--ink);
}
.vsteps li.done .vdot {
  background: var(--ink);
  border-color: var(--ink);
  color: var(--white);
}
.vsteps li.current {
  color: var(--gold-dark);
}
.vsteps li.current .vdot {
  border-color: var(--gold);
  background: var(--gold);
  color: var(--white);
}
.receive {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
}
.report-box {
  border: 1px solid var(--gold-line);
  border-radius: var(--radius);
  padding: 16px;
  background: #fffdf8;
}
.form-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}
.form-head h3 {
  margin: 0;
}
label.inline {
  display: flex;
  align-items: center;
  gap: 8px;
}
label.inline select {
  width: auto;
}
.with-of {
  display: flex;
  align-items: center;
  gap: 8px;
}
.of {
  white-space: nowrap;
  font-weight: 400;
}
input.over {
  border-color: var(--danger);
  outline-color: var(--danger-bg);
}
.spacer {
  flex: 1;
}
.btn-danger-ghost {
  color: var(--danger);
  border-color: transparent;
  background: transparent;
}
.btn-danger-ghost:hover {
  border-color: var(--danger-bg);
  background: var(--danger-bg);
}
.history {
  list-style: none;
  margin: 0;
  padding: 0 0 0 14px;
  border-left: 2px solid var(--line);
  display: grid;
  gap: 12px;
}
.history li {
  position: relative;
}
.history li::before {
  content: "";
  position: absolute;
  left: -20px;
  top: 6px;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--gold);
}
.h-what {
  font-weight: 600;
  color: var(--ink);
}

/* ---------- toast */
.toast {
  position: fixed;
  bottom: 20px;
  left: 50%;
  transform: translateX(-50%);
  max-width: calc(100% - 32px);
  background: var(--night);
  color: var(--white);
  padding: 10px 16px;
  border-radius: var(--radius);
  z-index: 20;
}
.toast-error {
  background: var(--danger);
}
.toast-warn {
  background: var(--warn);
}

/* ---------- small screens: the board becomes one column per row */
@media (max-width: 900px) {
  .board {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
  .stats {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}
@media (max-width: 560px) {
  .page,
  .top {
    padding-left: 16px;
    padding-right: 16px;
  }
  .board {
    grid-template-columns: minmax(0, 1fr);
  }
  .amounts {
    grid-template-columns: minmax(0, 1fr);
  }
  .who-name,
  .firm {
    display: none;
  }
  .panel-grid {
    grid-template-columns: minmax(0, 1fr);
  }
  .search {
    width: 100%;
  }
}

/* ---------- QuickBooks (through apto): status box and the bill form */
.qb-box {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 14px 16px;
  background: var(--white);
}
.qb-box p {
  margin: 8px 0 0;
}
.qb-head {
  display: flex;
  align-items: center;
  gap: 10px;
}
.qb-head h3 {
  margin: 0;
}
.qb-logo {
  display: inline-grid;
  place-items: center;
  width: 26px;
  height: 26px;
  border-radius: 50%;
  background: #2ca01c;
  color: var(--white);
  font: 800 11px var(--font-head);
  flex: none;
}
.ok-dot {
  display: inline-block;
  width: 8px;
  height: 8px;
  margin-right: 6px;
  border-radius: 50%;
  background: var(--ok);
}
.danger {
  color: var(--danger);
}
.report-box-qb {
  border-color: #b9dcb2;
  background: #fbfdf9;
}
.bill-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
}
.bill-lines {
  display: grid;
  gap: 8px;
}
.bill-line {
  display: grid;
  grid-template-columns: minmax(0, 2fr) minmax(0, 3fr) minmax(0, 1fr) minmax(0, 1fr);
  gap: 8px;
  padding-top: 8px;
  border-top: 1px dashed var(--line);
}
@media (max-width: 560px) {
  .bill-grid,
  .bill-line {
    grid-template-columns: minmax(0, 1fr);
  }
}

/* ---------- month-end close: bank transactions and journal entries */
.tx-filters {
  display: flex;
  flex-wrap: wrap;
  align-items: end;
  gap: 10px;
}
.tx-filters label {
  min-width: 130px;
}
.tx-filters .tx-bank {
  flex: 1 1 200px;
}
.tx-list {
  display: grid;
  max-height: 420px;
  overflow-y: auto;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--white);
}
.tx {
  display: grid;
  grid-template-columns: 56px minmax(0, 2fr) minmax(0, 1.6fr) auto;
  align-items: center;
  gap: 4px 10px;
  padding: 8px 12px;
  border-bottom: 1px solid var(--line);
  font-weight: 400;
}
.tx:last-child {
  border-bottom: 0;
}
.tx-off {
  cursor: default;
  opacity: 0.6;
}
.tx-who {
  display: grid;
  min-width: 0;
}
.tx-who b {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.tx-date {
  color: var(--muted);
  font-size: 13px;
}
.tx-amt {
  font-variant-numeric: tabular-nums;
  text-align: right;
  white-space: nowrap;
}
.tx-in {
  color: var(--ok);
}
.tx-cat {
  display: grid;
  gap: 2px;
  min-width: 0;
}
.tx-cat select {
  width: 100%;
  padding: 4px 6px;
  font-size: 13px;
}
.tx-note:empty {
  display: none;
}
.tx-note.ok {
  color: var(--ok);
}
.tx-pager,
.je-head {
  display: flex;
  align-items: center;
  gap: 8px;
}
.je-head h3 {
  margin: 0;
}
.je-list {
  display: grid;
  gap: 8px;
}
.je {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr)) repeat(2, minmax(0, 1.5fr));
  align-items: end;
  gap: 8px;
  padding-top: 8px;
  border-top: 1px dashed var(--line);
}
.je .je-wide {
  grid-column: span 3;
}
.je-remove {
  justify-self: end;
}
@media (max-width: 560px) {
  .tx {
    grid-template-columns: minmax(0, 1fr) auto;
  }
  .tx-date,
  .tx-who {
    grid-column: 1;
  }
  .tx-cat {
    grid-column: 1 / -1;
  }
  .tx-amt {
    grid-column: 2;
    grid-row: 1;
  }
  .je {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
  .je .je-wide {
    grid-column: 1 / -1;
  }
}
