/* Quiet Workspace — shared components and layouts. No legacy CSS. */
*, *::before, *::after { box-sizing: border-box; }
html { font-family: Arial, "Segoe UI", sans-serif; }
body { margin: 0; min-width: 320px; background: var(--canvas); color: var(--text); font-size: 15px; line-height: 1.5; }
button, input, select, textarea { font: inherit; }
button { cursor: pointer; }
button:disabled, input:disabled { cursor: not-allowed; opacity: .64; }
button:focus-visible, input:focus-visible, select:focus-visible, textarea:focus-visible { outline: 3px solid var(--focus); outline-offset: 2px; }
[hidden] { display: none !important; }
.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; }
.site-header { background: var(--header); border-bottom: 1px solid var(--line); }
.header-inner { width: 100%; margin: auto; padding: 12px 24px; min-height: 72px; display: flex; align-items: center; gap: 20px; }
.brand { flex-shrink: 0; display: flex; flex-direction: column; line-height: 1.2; }
.brand strong { font-size: 23px; letter-spacing: -.7px; }
.brand small { font-size: 11px; font-weight: 400; color: var(--muted); padding-top: 2px; }
.nav-button { min-height: 40px; border: 0; border-radius: 4px; padding: 8px 14px; font-size: 14px; font-weight: 600; background: transparent; color: var(--text); }
.nav-button:hover { background: var(--surface-raised); }
.nav-button.active { background: var(--accent-soft); color: var(--accent); }
html[data-theme="dark"] .nav-button.active { color: #fff; }
.header-actions { display: flex; align-items: center; gap: 8px; margin-left: auto; }
.settings-button { display: inline-flex; align-items: center; justify-content: center; padding: 7px; width: 42px; min-height: 42px; flex: 0 0 42px; }
.settings-button svg { width: 21px; height: 21px; }
.settings-button.active { background: var(--accent-soft); color: var(--accent); }
.shell { min-width: 0; width: 100%; max-width: 1540px; margin: 0 auto; padding: 26px 30px 58px; }
.preview-notice strong { font-weight: 700; }
.page-heading { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 14px; margin: 0 0 20px; }
h1 { font-size: 26px; line-height: 1.2; letter-spacing: -.5px; margin: 0; }
h2 { font-size: 17px; margin: 0; }
p { margin: 0; }
.page-heading p { font-size: 14px; color: var(--muted); margin-top: 5px; }
.btn { display: inline-flex; justify-content: center; align-items: center; min-height: 42px; padding: 9px 15px; background: var(--button); color: var(--text); border: 1px solid var(--field-border); border-radius: 5px; font-size: 14px; font-weight: 600; white-space: nowrap; }
.btn:hover:not(:disabled) { background: var(--button-hover); }
.btn.primary { background: #245c87; border-color: #245c87; color: #fff; }
.btn.primary:hover:not(:disabled) { background: #194869; border-color: #194869; }
html[data-theme="dark"] .btn.primary { background: #286a98; border-color: #78bdec; }
html[data-theme="dark"] .btn.primary:hover:not(:disabled) { background: #205878; }
.btn.small { padding: 5px 10px; min-height: 34px; font-size: 12px; }
.panel { background: var(--surface); border: 1px solid var(--line); border-radius: 6px; margin: 0 0 20px; overflow: hidden; }
.panel-heading { display: flex; gap: 14px; flex-wrap: wrap; justify-content: space-between; align-items: center; padding: 18px 22px; border-bottom: 1px solid var(--line); }
.panel-heading p { font-size: 13px; color: var(--muted); margin-top: 3px; }
.mini-badge { padding: 3px 8px; border: 1px solid var(--line); border-radius: 4px; color: var(--muted); font-size: 12px; }
.toolbar { padding: 15px 22px; display: flex; gap: 14px; justify-content: space-between; align-items: center; border-bottom: 1px solid var(--line); }
input, select, textarea { min-height: 41px; width: 100%; background: var(--field); color: var(--text); border: 1px solid var(--field-border); border-radius: 4px; padding: 9px 11px; }
input::placeholder, textarea::placeholder { color: var(--muted); opacity: 1; }
textarea { resize: vertical; }
.toolbar input { max-width: 410px; }
.count { color: var(--muted); font-size: 13px; white-space: nowrap; }
.table-scroll { overflow-x: auto; }
table { border-collapse: collapse; width: 100%; text-align: left; }
th { background: var(--surface-raised); color: var(--text); font-size: 12px; }
th, td { border-bottom: 1px solid var(--line); padding: 14px 16px; vertical-align: middle; }
tbody tr:last-child td { border-bottom: 0; }
tbody tr:hover { background: var(--accent-soft); }
.order-id { font-weight: 700; color: var(--accent); }
.status { font-size: 12px; font-weight: 600; display: inline-block; padding: 3px 9px; border: 1px solid var(--line); border-radius: 4px; }
.status.ready { background: var(--ready-bg); color: var(--ready-text); }
.status.draft { background: var(--draft-bg); color: var(--draft-text); }
.empty-results { padding: 25px; text-align: center; color: var(--muted); }
.placeholder { padding: 36px 25px; max-width: 700px; }
.placeholder h2 { margin-bottom: 8px; }
.placeholder p { color: var(--muted); }
.footer { color: var(--muted); font-size: 12px; text-align: center; padding-top: 15px; }


/* Application shell: a calm, familiar navigation rail with content at its side. */
.app-layout { display: grid; grid-template-columns: 208px minmax(0, 1fr); min-height: calc(100vh - 73px); }
.sidebar { background: var(--surface); border-right: 1px solid var(--line); padding: 26px 12px 16px; display: flex; flex-direction: column; gap: 8px; }
.sidebar-label { padding: 0 12px 8px; color: var(--muted); font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: .08em; }
.side-nav { display: flex; flex-direction: column; gap: 5px; }
.side-nav .nav-button { display: block; width: 100%; text-align: left; padding: 11px 14px; border-radius: 5px; min-height: 44px; }
.side-nav .nav-button.active { box-shadow: inset 3px 0 0 var(--accent); }
.sidebar-footnote { margin-top: auto; padding: 14px 12px 0; font-size: 11px; color: var(--muted); }
.header-actions { gap: 10px; }

/* Deliberately empty CTO canvas until its interface is designed. */
.cto-blank-canvas { min-height: 380px; display: grid; place-items: center; padding: 30px; }
.cto-blank-canvas p { max-width: 420px; text-align: center; color: var(--muted); font-size: 14px; }

@media (max-width: 1150px) {
  .shell { padding: 24px 22px 50px; }
}
@media (max-width: 850px) {
  .app-layout { grid-template-columns: 168px minmax(0, 1fr); }
}
@media (max-width: 650px) {
  .header-inner { padding: 12px 15px; }
  .app-layout { grid-template-columns: 1fr; }
  .sidebar { padding: 10px 14px; border-right: 0; border-bottom: 1px solid var(--line); gap: 0; }
  .sidebar-label, .sidebar-footnote { display: none; }
  .side-nav { flex-direction: row; gap: 6px; }
  .side-nav .nav-button { text-align: center; width: auto; flex: 1; padding: 9px 7px; }
  .side-nav .nav-button.active { box-shadow: inset 0 -3px 0 var(--accent); }
  .shell { padding: 18px 14px 40px; }
  .page-heading h1 { font-size: 23px; }
  .panel-heading, .toolbar { padding: 15px; }
  .count { display: none; }
  th, td { padding: 12px; }
}


/* Planning: understated calendar using the existing Quiet Workspace tokens. */
.planning-layout { display: grid; grid-template-columns: minmax(0, 1fr) 275px; gap: 18px; align-items: start; }
.calendar-panel { min-width: 0; }
.calendar-toolbar { display: flex; gap: 18px; flex-wrap: wrap; align-items: center; justify-content: space-between; padding: 18px 20px; border-bottom: 1px solid var(--line); }
.calendar-heading h2 { font-size: 19px; }
.calendar-range { color: var(--muted); font-size: 12px; margin-top: 3px; }
.calendar-controls { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.calendar-control-group { display: inline-flex; gap: 3px; border: 1px solid var(--line); border-radius: 5px; padding: 3px; }
.calendar-control-group .btn { border: 0; min-height: 33px; }
.calendar-view.active { background: var(--accent-soft); color: var(--accent); }
html[data-theme="dark"] .calendar-view.active { color: var(--text); }
.icon-button { min-width: 35px; font-size: 23px; line-height: 1; padding: 3px 9px; }
.calendar-weekdays, .calendar-grid { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); }
.calendar-weekdays { border-bottom: 1px solid var(--line); background: var(--surface-raised); }
.calendar-weekdays span { padding: 12px 5px; text-align: center; color: var(--muted); font-weight: 700; font-size: 12px; }
.calendar-grid { background: var(--line); gap: 1px; border-bottom: 1px solid var(--line); }
.calendar-day { position: relative; width: 100%; min-width: 0; min-height: 100px; display: flex; flex-direction: column; align-items: flex-start; gap: 5px; background: var(--surface); border: 0; border-radius: 0; color: var(--text); padding: 11px 10px; text-align: left; font-size: 14px; }
.calendar-day:hover { background: var(--accent-soft); }
.calendar-day.other-month { background: var(--surface-raised); color: var(--muted); }
.calendar-day.other-month:hover { background: var(--accent-soft); }
.calendar-day.selected { background: var(--accent-soft); box-shadow: inset 0 0 0 2px var(--accent); z-index: 1; }
.calendar-day-number { display: inline-flex; justify-content: center; align-items: center; height: 28px; min-width: 28px; border-radius: 50%; font-weight: 600; }
.calendar-day.today .calendar-day-number { background: var(--accent); color: var(--accent-text); }
html[data-theme="dark"] .calendar-day.today .calendar-day-number { background: #286a98; color: #fff; }
.calendar-day:focus-visible { outline-offset: -4px; z-index: 2; }
.calendar-footnote { display: flex; gap: 16px; justify-content: space-between; flex-wrap: wrap; align-items: center; font-size: 12px; color: var(--muted); padding: 12px 18px; }
.calendar-key { display: inline-flex; align-items: center; gap: 7px; }
.calendar-dot { width: 11px; height: 11px; border-radius: 50%; background: var(--accent); }
.planning-day-panel { position: sticky; top: 20px; }
.planning-day-head { padding: 19px 20px; border-bottom: 1px solid var(--line); }
.eyebrow { text-transform: uppercase; font-size: 11px; font-weight: 700; letter-spacing: .07em; color: var(--muted); }
.planning-day-head h2 { margin-top: 8px; font-size: 20px; line-height: 1.3; }
.planning-weekday { color: var(--muted); margin-top: 3px; font-size: 13px; }
.planning-day-body { padding: 19px 20px 22px; border-bottom: 1px solid var(--line); }
.planning-day-body h3 { margin: 0 0 13px; font-size: 14px; }
.planning-empty { padding: 17px 12px; border-radius: 5px; background: var(--surface-raised); color: var(--muted); font-size: 13px; text-align: center; }
.planning-explainer { margin-top: 14px; color: var(--muted); font-size: 12px; }
.planning-jump { padding: 18px 20px; }
.planning-jump label { display: block; font-size: 13px; font-weight: 700; margin-bottom: 8px; }
.planning-jump-controls { display: flex; align-items: center; gap: 7px; }
.planning-jump-controls input { min-width: 0; }
@media (max-width: 1140px) { .planning-layout { grid-template-columns: minmax(0, 1fr); } .planning-day-panel { position: static; } }
@media (max-width: 650px) {
  .calendar-toolbar { padding: 15px; }
  .calendar-controls { width: 100%; justify-content: space-between; }
  .calendar-day { padding: 5px 3px; align-items: center; min-height: 65px; }
  .calendar-day-number { height: 26px; min-width: 26px; font-size: 12px; }
  .calendar-weekdays span { padding: 9px 0; font-size: 11px; }
  .calendar-footnote { gap: 7px; }
}

/* CTO general details — field placement follows the approved two-column sketch.
   Separate stacks preserve reading order; the weight/tare pair shares one row. */
.cto-details-layout { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); column-gap: 34px; row-gap: 0; }
.cto-details-column { min-width: 0; display: flex; flex-direction: column; }
.cto-field-group { display: grid; align-content: start; gap: 15px; }
.cto-field-group-secondary { margin-top: 55px; }
.cto-weight-row { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 13px; }
.cto-instructions-field { grid-column: 1 / -1; margin-top: 55px; }
.cto-instructions-field textarea { min-height: 45px; }
@media (max-width: 1380px) { .cto-details-layout { column-gap: 22px; } }
@media (max-width: 900px) {
  .cto-details-layout { grid-template-columns: minmax(0, 1fr); gap: 20px; }
  .cto-details-column { gap: 20px; }
  .cto-field-group-secondary, .cto-instructions-field { margin-top: 0; }
}
@media (max-width: 420px) {
  .cto-weight-row { grid-template-columns: minmax(0, 1fr); }
}

/* CTO editor — two content cards and a sticky actions rail. */
.cto-layout { display: grid; grid-template-columns: minmax(0, 1fr) 224px; gap: 18px; align-items: start; }
.cto-form { min-width: 0; }
.cto-card { margin-bottom: 18px; }
.cto-card-body { padding: 22px; }
.cto-fields { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); column-gap: 20px; row-gap: 18px; }
.field { min-width: 0; display: flex; flex-direction: column; gap: 6px; }
.field-wide { grid-column: 1 / -1; }
.field label { font-weight: 600; font-size: 13px; color: var(--text); }
.field input, .field textarea { margin: 0; }
.field-hint { color: var(--muted); font-size: 12px; line-height: 1.35; }
.cto-container-heading { align-items: center; }
.cto-mode-control { display: inline-flex; gap: 3px; padding: 3px; background: var(--surface-raised); border: 1px solid var(--field-border); border-radius: 6px; }
.cto-mode { padding: 8px 18px; min-height: 36px; border: 1px solid transparent; border-radius: 4px; color: var(--text); background: transparent; font-size: 13px; font-weight: 700; }
.cto-mode:hover:not(.active) { background: var(--button-hover); }
.cto-mode.active { background: var(--surface); border-color: var(--field-border); box-shadow: 0 1px 2px rgba(0,0,0,.05); }
.cto-mode-summary { color: var(--muted); font-size: 13px; margin-bottom: 18px; }
.cto-container-rows { display: grid; gap: 18px; }
.cto-container-row { min-width: 0; }
.cto-container-row + .cto-container-row { border-top: 1px solid var(--line); padding-top: 18px; }
.cto-container-row-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 12px; gap: 10px; }
.cto-container-row-head h3 { font-size: 14px; margin: 0; }
.cto-batch-footer { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 12px; border-top: 1px solid var(--line); margin-top: 20px; padding-top: 18px; }
.cto-actions-panel { position: sticky; top: 18px; margin-bottom: 0; }
.cto-actions-header { padding: 18px 18px 14px; border-bottom: 1px solid var(--line); }
.cto-actions-header h2 { font-size: 16px; }
.cto-actions-header p { font-size: 12px; color: var(--muted); margin-top: 2px; }
.cto-action-list { display: grid; gap: 10px; padding: 16px 18px 14px; }
.cto-action-list .btn { width: 100%; }
@media (max-width: 1120px) {
  .cto-layout { grid-template-columns: minmax(0, 1fr); }
  .cto-actions-panel { position: static; }
  .cto-action-list { grid-template-columns: minmax(0, 1fr); }
}
@media (max-width: 650px) {
  .cto-card-body { padding: 16px; }
  .cto-fields { grid-template-columns: minmax(0, 1fr); gap: 14px; }
  .cto-container-heading { align-items: stretch; }
  .cto-mode-control { align-self: flex-start; }
  .cto-action-list { grid-template-columns: minmax(0, 1fr); }
}

/* CTO step 2 — separate container cards, shared right-hand actions panel. */
.step-label { color: var(--muted); text-transform: uppercase; letter-spacing: .08em; font-size: 11px !important; font-weight: 700; margin: 0 0 6px !important; }
.assignment-page-heading { align-items: center; }
.assignment-cards { display: grid; grid-template-columns: minmax(0, 1fr); gap: 16px; max-width: 880px; }
.assignment-card { margin-bottom: 0; }
.assignment-card-heading { padding: 18px 22px; }
.assignment-card-title { display: flex; flex-direction: column; gap: 3px; }
.assignment-container-ref { font-size: 13px; color: var(--muted); overflow-wrap: anywhere; }
.assignment-card-fields { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 18px; padding: 23px 22px 25px; }
.assignment-card-fields .field { min-width: 0; }
@media (max-width: 760px) {
  .assignment-card-fields { grid-template-columns: minmax(0, 1fr); padding: 17px; gap: 14px; }
  .assignment-card-heading { padding: 16px 17px; }
}

/* CTO creation refinements and browser-local save messaging. */
.cto-heading-actions { display: inline-flex; align-items: center; gap: 10px; }
.cto-clear-button { width: 42px; min-width: 42px; height: 42px; padding: 8px; }
.cto-clear-button svg { display: block; }
.assignment-layout .assignment-cards { max-width: none; }
.assignment-main { min-width: 0; }
.assignment-storage-note { margin: 10px 0 24px; }
.assignment-action-note { padding: 0 18px 15px; color: var(--muted); font-size: 12px; }
.assignment-error { margin: 0 18px 16px; color: var(--text); font-size: 13px; font-weight: 600; overflow-wrap: anywhere; }
.assignment-error:empty { display: none; }
.order-save-notice { margin: 16px 22px 0; border: 1px solid var(--line); background: var(--surface-raised); border-radius: 5px; padding: 12px 14px; font-size: 13px; }
@media (max-width: 650px) { .order-save-notice { margin: 14px 15px 0; } }

/* Home table: keep actual table cells in the table layout, including status. */
.table-scroll { width: 100%; }
.orders-table { min-width: 940px; width: 100%; table-layout: fixed; margin: 0 auto; }
.orders-table th, .orders-table td { text-align: left; vertical-align: middle; overflow-wrap: anywhere; }
.orders-table th:nth-child(1) { width: 12%; }
.orders-table th:nth-child(2) { width: 13%; }
.orders-table th:nth-child(3) { width: 19%; }
.orders-table th:nth-child(4) { width: 18%; }
.orders-table th:nth-child(5) { width: 16%; }
.orders-table th:nth-child(6) { width: 9%; }
.orders-table th:nth-child(7) { width: 13%; }
.orders-table th:nth-child(6), .orders-table th:nth-child(7),
.orders-table .order-status-cell, .orders-table .order-actions-cell { text-align: center; }
.orders-table .status { display: inline-flex; align-items: center; justify-content: center; line-height: 1.4; vertical-align: middle; }
.order-row-actions { display: flex; align-items: center; justify-content: center; flex-wrap: wrap; gap: 6px; }
.order-row-actions .btn { min-height: 32px; padding: 5px 9px; }
.order-row-actions .row-delete { color: #a83d34; }
.order-row-actions .row-delete:hover { background: var(--draft-bg); }
.cto-edit-notice { margin: 0 0 15px; padding: 12px 14px; border: 1px solid var(--line); background: var(--surface-raised); border-radius: 5px; color: var(--text); font-size: 13px; }

/* CTO dates and time slots shown directly on Planning calendar and selected day. */
.calendar-appointments { display: flex; flex-wrap: wrap; gap: 3px; margin-top: 3px; }
.calendar-appointment { display: block; width: 100%; min-width: 0; background: var(--accent-soft); border-radius: 3px; padding: 2px 4px; color: var(--accent); font-size: 10px; line-height: 1.3; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.calendar-appointment-count { font-size: 11px; color: var(--muted); }
.planning-ctos { list-style: none; padding: 0; margin: 0; display: grid; gap: 9px; }
.planning-cto { border: 1px solid var(--line); border-radius: 5px; background: var(--surface-raised); padding: 12px; font-size: 13px; }
.planning-cto strong { display: block; overflow-wrap: anywhere; font-size: 14px; }
.planning-cto-time { display: block; margin: 3px 0; font-weight: 700; color: var(--accent); }
.planning-cto-meta { color: var(--muted); overflow-wrap: anywhere; }
@media (max-width: 650px) {
  .orders-table { min-width: 850px; }
  .calendar-appointment { font-size: 9px; padding: 2px 3px; }
  .calendar-day { overflow: hidden; }
  .calendar-appointments { width: 100%; }
}
