:root {
  color-scheme: light;
  --bg: #eef2f6;
  --sheet: #ffffff;
  --ink: #17212f;
  --muted: #667085;
  --line: #cfd7e3;
  --line-dark: #aeb8c7;
  --green-dark: #c7e6d0;
  --green-mid: #dff3e5;
  --green-light: #eef9f0;
  --green-ink: #14532d;
  --red-dark: #ffd0c7;
  --red-mid: #ffe1dc;
  --red-light: #fff0ed;
  --red-ink: #9f1239;
  --amber-soft: #fff86a;
  --yellow-soft: #fff7d6;
  --blue-soft: #e8f1ff;
  --shadow: 0 10px 24px rgba(17, 24, 39, 0.08);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-width: 360px;
  height: 100vh;
  overflow: hidden;
  background: var(--bg);
  color: var(--ink);
  font-family:
    Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI",
    sans-serif;
}

button,
input,
select {
  font: inherit;
}

.login-view {
  display: grid;
  min-height: 100vh;
  place-items: center;
  padding: 16px;
}

.login-view[hidden] {
  display: none;
}

.login-card {
  display: grid;
  width: min(380px, 100%);
  gap: 12px;
  padding: 22px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--sheet);
  box-shadow: var(--shadow);
}

.login-card label {
  display: grid;
  gap: 5px;
  color: var(--muted);
  font-size: 0.76rem;
  font-weight: 850;
  text-transform: uppercase;
}

.login-card .login-remember {
  grid-template-columns: 18px 1fr;
  align-items: center;
  color: var(--ink);
  font-size: 0.82rem;
  text-transform: none;
}

.login-card input,
.login-card button {
  height: 38px;
  border: 1px solid var(--line-dark);
  border-radius: 6px;
  background: #fff;
  color: var(--ink);
}

.login-card .login-remember input {
  width: 16px;
  height: 16px;
  padding: 0;
}

.login-card input {
  padding: 0 10px;
  text-transform: none;
}

.login-card button {
  cursor: pointer;
  font-weight: 900;
}

#loginStatus {
  min-height: 18px;
  color: var(--red-ink);
  font-size: 0.78rem;
  font-weight: 800;
}

.cash-app {
  display: grid;
  grid-template-rows: auto auto auto minmax(0, 1fr);
  gap: 8px;
  height: 100vh;
  min-width: 0;
  padding: 8px;
  overflow: hidden;
}

.cash-app > * {
  min-width: 0;
}

.sheet-header,
.app-menu,
.sheet-toolbar,
.movement-panel {
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--sheet);
  box-shadow: var(--shadow);
}

.sheet-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 8px 12px;
}

.eyebrow {
  margin: 0;
  color: var(--muted);
  font-size: 0.74rem;
  font-weight: 800;
  letter-spacing: 0;
  text-transform: uppercase;
}

h1,
h2 {
  margin: 3px 0 0;
  line-height: 1.15;
}

h1 {
  font-size: 1.16rem;
}

h2 {
  font-size: 1rem;
}

.status-bar {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 8px;
}

.status-bar span {
  display: inline-flex;
  align-items: center;
  min-height: 26px;
  padding: 0 8px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #f8fafc;
  color: var(--muted);
  font-size: 0.82rem;
  font-weight: 700;
}

.logout-button {
  min-height: 26px;
  padding: 0 9px;
  border: 1px solid var(--line-dark);
  border-radius: 6px;
  background: #fff;
  color: var(--ink);
  cursor: pointer;
  font-size: 0.78rem;
  font-weight: 850;
}

.app-menu {
  display: grid;
  grid-template-columns: minmax(0, auto) minmax(190px, 260px);
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 6px 8px;
}

.menu-primary {
  min-width: 0;
  display: inline-flex;
  gap: 4px;
  padding: 3px;
  border: 1px solid var(--line-dark);
  border-radius: 6px;
  background: #f8fafc;
}

.menu-primary .view-button {
  height: 28px;
  padding: 0 10px;
  border: 0;
  border-radius: 5px;
  background: transparent;
  color: var(--muted);
  font-weight: 850;
  cursor: pointer;
}

.menu-primary .view-button.active {
  background: #fff;
  color: var(--ink);
  box-shadow: 0 1px 4px rgba(15, 23, 42, 0.12);
}

.menu-more {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  align-items: center;
  gap: 7px;
  color: var(--muted);
  font-size: 0.72rem;
  font-weight: 800;
  text-transform: uppercase;
}

.menu-more select {
  height: 28px;
  min-width: 0;
  padding: 0 8px;
  border: 1px solid var(--line-dark);
  border-radius: 6px;
  background: #fff;
  color: var(--ink);
  text-transform: none;
}

.sheet-toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: end;
  gap: 8px;
  padding: 6px 8px;
}

.sheet-toolbar > div {
  display: grid;
  gap: 4px;
}

.sheet-toolbar label {
  color: var(--muted);
  font-size: 0.72rem;
  font-weight: 800;
  text-transform: uppercase;
}

.sheet-toolbar select,
.sheet-toolbar button {
  height: 30px;
  border: 1px solid var(--line-dark);
  border-radius: 6px;
  background: #fff;
  color: var(--ink);
}

.sheet-toolbar select {
  min-width: 90px;
  padding: 0 8px;
}

.sheet-toolbar button {
  padding: 0 12px;
  cursor: pointer;
}

.sync-odoo-button {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  font-weight: 850;
}

.sync-odoo-button.is-syncing {
  border-color: #15803d;
  background: #effaf1;
  color: #14532d;
  cursor: wait;
}

.sync-spinner {
  display: none;
  width: 14px;
  height: 14px;
  border: 2px solid #bbd7c3;
  border-top-color: #15803d;
  border-radius: 999px;
}

.sync-odoo-button.is-syncing .sync-spinner {
  display: inline-block;
  animation: sync-spin 820ms linear infinite;
}

.sync-odoo-status {
  min-height: 30px;
  display: inline-flex;
  align-items: center;
  padding: 0 10px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #f8fafc;
  color: var(--muted);
  font-size: 0.76rem;
  font-weight: 850;
}

.sync-odoo-status[data-kind="success"] {
  border-color: #86b991;
  background: #edf8f0;
  color: #166534;
}

.sync-odoo-status[data-kind="error"] {
  border-color: #f2a79b;
  background: #fff0ed;
  color: #9f1239;
}

@keyframes sync-spin {
  to {
    transform: rotate(360deg);
  }
}

.sheet-shell,
.sources-view {
  min-width: 0;
  min-height: 0;
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--sheet);
  box-shadow: var(--shadow);
}

.user-admin-grid {
  display: grid;
  grid-template-columns: minmax(260px, 360px) minmax(520px, 1fr);
  gap: 12px;
  padding: 12px;
}

.admin-rules-layout {
  display: grid;
  gap: 12px;
  padding: 12px;
}

.user-form {
  display: grid;
  align-content: start;
  gap: 10px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #f8fafc;
}

.user-form label:not(.check-row) {
  display: grid;
  gap: 4px;
  color: var(--muted);
  font-size: 0.72rem;
  font-weight: 850;
  text-transform: uppercase;
}

.user-form input,
.user-form select {
  height: 32px;
  padding: 0 8px;
  border: 1px solid var(--line-dark);
  border-radius: 5px;
  background: #fff;
  color: var(--ink);
  text-transform: none;
}

.user-form fieldset {
  display: grid;
  gap: 6px;
  margin: 0;
  padding: 8px;
  border: 1px solid var(--line);
  border-radius: 6px;
}

.user-form legend {
  color: var(--muted);
  font-size: 0.68rem;
  font-weight: 900;
  text-transform: uppercase;
}

.block-permission-table {
  display: grid;
  grid-template-columns: minmax(170px, 1fr) 56px 64px;
  gap: 0;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fff;
}

.block-permission-header,
.block-permission-name,
.block-permission-check {
  min-height: 34px;
  padding: 7px 8px;
  border-bottom: 1px solid var(--line);
}

.admin-rule-form {
  display: grid;
  grid-template-columns: minmax(240px, 1fr) minmax(130px, 170px) minmax(190px, auto) minmax(150px, auto) auto;
  align-items: end;
  gap: 10px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #f8fafc;
}

.admin-rule-form label {
  display: grid;
  gap: 4px;
  color: var(--muted);
  font-size: 0.72rem;
  font-weight: 850;
  text-transform: uppercase;
}

.admin-rule-form .check-row {
  display: grid;
  align-self: center;
  grid-template-columns: 18px 1fr;
  align-items: center;
  color: var(--ink);
  text-transform: none;
}

.admin-rule-form select,
.admin-rule-form input {
  height: 32px;
  border: 1px solid var(--line-dark);
  border-radius: 4px;
  background: #fff;
  color: var(--ink);
  font: inherit;
}

.admin-rule-form button,
.admin-rule-actions button {
  height: 32px;
  padding: 0 10px;
  border: 1px solid var(--line-dark);
  border-radius: 5px;
  background: #fff;
  color: var(--ink);
  cursor: pointer;
  font-weight: 850;
}

.admin-rule-form input[type="checkbox"] {
  width: 17px;
  height: 17px;
}

.admin-rules-table input[type="number"] {
  width: 96px;
  height: 30px;
  border: 1px solid var(--line-dark);
  border-radius: 4px;
  background: #fff;
  color: var(--ink);
  font: inherit;
}

.admin-rules-table input[type="checkbox"] {
  width: 17px;
  height: 17px;
}

.admin-rule-actions {
  display: flex;
  gap: 6px;
  white-space: nowrap;
}

.block-permission-header {
  background: #f1f5f9;
  color: var(--muted);
  font-size: 0.68rem;
  font-weight: 900;
  text-transform: uppercase;
}

.block-permission-name {
  display: grid;
  gap: 1px;
}

.block-permission-name strong {
  color: var(--ink);
  font-size: 0.78rem;
}

.block-permission-name small {
  color: var(--muted);
  font-size: 0.64rem;
  font-weight: 800;
}

.block-permission-check {
  display: grid;
  place-items: center;
  border-left: 1px solid var(--line);
}

.block-permission-check input {
  width: 16px;
  height: 16px;
  padding: 0;
}

.user-edit,
.user-delete {
  height: 28px;
  margin-right: 4px;
  border: 1px solid var(--line-dark);
  border-radius: 5px;
  background: #fff;
  cursor: pointer;
}

.sheet-shell {
  height: 100%;
  max-height: none;
}

#cashflowView,
#configView,
#usersView,
#hiddenOrdersView,
#billingProjectionView,
#adminRulesView {
  min-width: 0;
  min-height: 0;
  height: 100%;
  overflow: hidden;
}

#configView,
#usersView,
#hiddenOrdersView,
#adminRulesView {
  overflow: auto;
}

.sources-view {
  height: 100%;
}

.cash-sheet {
  width: max-content;
  min-width: 100%;
  border-collapse: separate;
  border-spacing: 0;
  font-size: 0.8rem;
}

.cash-sheet th,
.cash-sheet td {
  min-width: 132px;
  height: 31px;
  padding: 3px 7px;
  border-right: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
  text-align: right;
  vertical-align: middle;
  font-variant-numeric: tabular-nums;
}

.cash-sheet thead th {
  position: sticky;
  top: 0;
  z-index: 3;
  background: #f8fafc;
  color: #334155;
  font-size: 0.74rem;
  font-weight: 850;
}

.cash-sheet thead small {
  display: block;
  margin-top: 2px;
  color: var(--muted);
  font-size: 0.63rem;
  font-weight: 650;
}

.row-label-col,
.row-label {
  position: sticky;
  left: 0;
  z-index: 2;
  min-width: 260px;
  max-width: 260px;
}

.cash-sheet .row-label-col,
.cash-sheet .row-label {
  text-align: left;
}

.row-label-col {
  z-index: 4;
  background: #f8fafc;
}

.row-label {
  background: #fff;
  font-weight: 760;
}

.row-label span {
  display: block;
}

.row-toggle {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  width: 100%;
  border: 0;
  padding: 0;
  background: transparent;
  color: inherit;
  font: inherit;
  text-align: left;
  cursor: pointer;
}

.row-toggle span {
  display: block;
}

.row-toggle-icon {
  position: relative;
  display: inline-block !important;
  flex: 0 0 13px;
  width: 13px;
  height: 13px;
  border-radius: 50%;
  background: #d8e4ef;
  box-shadow: inset 0 0 0 1px #b8c7d6;
}

.row-toggle-icon::after {
  content: "";
  position: absolute;
  top: 4px;
  left: 4px;
  width: 5px;
  height: 5px;
  border-right: 1.5px solid #475569;
  border-bottom: 1.5px solid #475569;
  transform: rotate(45deg);
  transition: transform 0.12s ease, top 0.12s ease;
}

.group-row.is-collapsed .row-toggle-icon {
  background: #eef4f8;
}

.group-row.is-collapsed .row-toggle-icon::after {
  top: 4px;
  transform: rotate(-45deg);
}

.row-toggle:hover .row-toggle-icon {
  background: #c7d7e5;
  box-shadow: inset 0 0 0 1px #9fb2c6;
}

.row-label small {
  display: block;
  margin-top: 0;
  color: var(--muted);
  font-size: 0.62rem;
  font-weight: 600;
}

.depth-1 {
  padding-left: 20px !important;
  font-weight: 680;
}

.group-row .row-label,
.group-row .group-cell {
  background: #edf2f7;
  font-weight: 850;
}

.section-row .row-label,
.section-row td {
  height: 27px;
  background: #1f2937;
  color: #fff;
  font-size: 0.78rem;
  font-weight: 900;
  text-transform: uppercase;
}

.section-row .row-label {
  z-index: 2;
}

.totals-group-row .row-label {
  background: #dbe4ef;
}

.total-row .row-label,
.total-row td {
  background: #dceadf;
  color: var(--green-ink);
  font-weight: 900;
}

.total-row.flow-expense .row-label,
.total-row.flow-expense td {
  background: #ffd6d1;
  color: var(--red-ink);
}

.total-row.flow-net .row-label,
.total-row.flow-net td {
  background: #e8f1ff;
  color: #1e3a8a;
}

.total-row.flow-opening_balance .row-label,
.total-row.flow-opening_balance td,
.total-row.flow-closing_balance .row-label,
.total-row.flow-closing_balance td {
  background: #edf2f7;
  color: #0f172a;
}

.total-row.flow-closing_balance .row-label,
.total-row.flow-closing_balance td {
  border-top: 2px solid var(--line-dark);
}

.certainty-certain:not(.row-label) {
  background: var(--green-dark);
}

.certainty-manageable_adm:not(.row-label) {
  background: var(--green-mid);
}

.certainty-manageable_op:not(.row-label) {
  background: var(--green-light);
}

.certainty-expense_fixed:not(.row-label) {
  background: var(--red-dark);
}

.certainty-expense_tax:not(.row-label) {
  background: var(--red-mid);
}

.certainty-expense_manageable:not(.row-label) {
  background: var(--red-light);
}

.flow-expense.group-row .row-label,
.flow-expense.group-row .group-cell {
  background: #ffe2de;
  color: var(--red-ink);
}

.flow-expense .row-label {
  border-left: 4px solid #fb7185;
}

.flow-income .row-label {
  border-left: 4px solid #22c55e;
}

.section-row .row-label {
  border-left: 0;
}

.editable-cell input {
  width: 100%;
  height: 23px;
  border: 1px solid transparent;
  border-radius: 4px;
  background: rgba(255, 255, 255, 0.82);
  color: var(--ink);
  text-align: right;
  font-variant-numeric: tabular-nums;
}

.usd-manual-cell input {
  height: 20px;
}

.manual-converted {
  display: block;
  margin-top: 1px;
  color: var(--green-ink);
  font-size: 0.6rem;
  font-weight: 850;
  text-align: right;
  white-space: nowrap;
}

.editable-cell input:focus {
  border-color: #15803d;
  outline: 2px solid rgba(21, 128, 61, 0.16);
}

.cell-button {
  display: grid;
  justify-items: end;
  width: 100%;
  min-height: 24px;
  padding: 0;
  border: 0;
  background: transparent;
  color: inherit;
  cursor: pointer;
  text-align: right;
}

.cell-button:disabled {
  cursor: default;
}

.cell-button small {
  color: var(--muted);
  font-size: 0.61rem;
  font-weight: 650;
}

.sources-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px 14px;
  border-bottom: 1px solid var(--line);
}

#sourceCount {
  color: var(--muted);
  font-size: 0.84rem;
  font-weight: 760;
}

.billing-projection-count {
  display: grid;
  justify-items: end;
  gap: 2px;
  color: var(--ink);
  font-variant-numeric: tabular-nums;
  text-align: right;
}

.billing-projection-count strong {
  font-size: 0.94rem;
  font-weight: 850;
}

.billing-projection-count small {
  color: var(--muted);
  font-size: 0.72rem;
  font-weight: 800;
}

.sources-table-wrap {
  overflow: auto;
}

.config-tabs {
  display: inline-flex;
  gap: 4px;
  margin: 10px 12px 0;
  padding: 3px;
  border: 1px solid var(--line-dark);
  border-radius: 6px;
  background: #f8fafc;
}

.config-tab {
  height: 28px;
  padding: 0 10px;
  border: 0;
  border-radius: 4px;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  font-weight: 850;
}

.config-tab.active {
  background: #fff;
  color: var(--ink);
  box-shadow: 0 1px 4px rgba(15, 23, 42, 0.12);
}

.sync-config-actions {
  align-items: center;
  justify-content: flex-start;
  margin: 12px;
}

.sync-log-table td small {
  display: block;
  color: var(--muted);
  font-weight: 750;
  margin-top: 2px;
}

.config-panel {
  display: grid;
  gap: 10px;
  padding: 12px;
}

.config-intro {
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #f8fafc;
  color: var(--muted);
  font-size: 0.82rem;
}

.config-card {
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fff;
}

.config-card header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 8px 10px;
  border-bottom: 1px solid var(--line);
  background: #f8fafc;
}

.config-card header small {
  display: block;
  margin-top: 2px;
  color: var(--muted);
  font-size: 0.72rem;
  font-weight: 750;
}

.config-enabled {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-weight: 900;
}

.config-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(170px, 1fr));
  gap: 10px;
  padding: 10px;
}

.sales-auto-rules-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
  gap: 10px;
  padding: 10px;
}

.config-card fieldset {
  display: grid;
  align-content: start;
  gap: 6px;
  min-width: 0;
  margin: 0;
  padding: 8px;
  border: 1px solid var(--line);
  border-radius: 6px;
}

.sales-auto-rules-grid label {
  display: grid;
  gap: 4px;
  color: var(--muted);
  font-size: 0.72rem;
  font-weight: 850;
  text-transform: uppercase;
}

.sales-auto-rules-grid .check-row {
  display: flex;
  color: var(--ink);
  text-transform: none;
}

.sales-auto-rules-grid input,
.sales-auto-rules-grid select {
  height: 30px;
  border: 1px solid var(--line-dark);
  border-radius: 4px;
  background: #fff;
  color: var(--ink);
  font: inherit;
}

.config-card legend {
  color: var(--muted);
  font-size: 0.68rem;
  font-weight: 900;
  text-transform: uppercase;
}

.check-row,
.config-card label:not(.config-enabled) {
  display: flex;
  align-items: center;
  gap: 7px;
  color: var(--ink);
  font-size: 0.78rem;
  font-weight: 700;
}

.config-card select {
  height: 28px;
  min-width: 130px;
  border: 1px solid var(--line-dark);
  border-radius: 4px;
  background: #fff;
}

.config-card select[multiple] {
  height: auto;
  min-height: 138px;
  width: 100%;
  padding: 4px;
  font: inherit;
}

.config-card textarea {
  width: 100%;
  min-height: 72px;
  resize: vertical;
  border: 1px solid var(--line-dark);
  border-radius: 4px;
  padding: 6px;
  font: inherit;
  font-size: 0.76rem;
}

.config-muted {
  color: var(--muted);
  font-size: 0.76rem;
}

.config-actions {
  position: sticky;
  bottom: 0;
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px;
  padding: 10px 0 0;
  background: var(--sheet);
}

.config-actions button {
  height: 32px;
  padding: 0 12px;
  border: 1px solid var(--line-dark);
  border-radius: 5px;
  background: #fff;
  color: var(--ink);
  cursor: pointer;
  font-weight: 800;
}

.config-actions button:disabled {
  cursor: wait;
  opacity: 0.65;
}

.config-save-feedback {
  min-height: 32px;
  display: inline-flex;
  align-items: center;
  padding: 0 10px;
  border: 1px solid var(--line);
  border-radius: 5px;
  background: #f8fafc;
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 850;
}

.config-save-feedback[data-kind="success"] {
  border-color: #86b991;
  background: #edf8f0;
  color: #166534;
}

.config-save-feedback[data-kind="error"] {
  border-color: #f2a79b;
  background: #fff0ed;
  color: #9f1239;
}

.sources-header.embedded {
  margin-top: 8px;
  border-top: 1px solid var(--line);
}

.sources-table,
.movement-table {
  width: 100%;
  min-width: 980px;
  border-collapse: separate;
  border-spacing: 0;
  font-size: 0.84rem;
}

.source-modal .movement-table {
  min-width: 1120px;
}

.planner-modal {
  width: min(1440px, 98vw);
}

.planner-modal .movement-table {
  width: max-content;
  min-width: 100%;
  font-size: 0.78rem;
}

.projection-shell {
  max-height: 72vh;
  margin: 14px 16px 16px;
}

.projection-table {
  width: max-content;
  min-width: 100%;
  font-size: 0.78rem;
}

.movement-table caption {
  position: sticky;
  left: 0;
  z-index: 3;
  width: min(1120px, calc(96vw - 42px));
  padding: 12px;
  border-bottom: 1px solid var(--line);
  background: #f8fafc;
  caption-side: top;
  text-align: left;
}

.planner-modal .movement-table caption {
  width: min(1360px, calc(98vw - 42px));
  padding: 9px 10px;
}

.planner-caption {
  display: flex;
  flex-wrap: wrap;
  align-items: end;
  justify-content: space-between;
  gap: 8px 16px;
  color: var(--ink);
  font-size: 0.78rem;
  text-transform: none;
}

.planner-search {
  display: grid;
  gap: 4px;
  min-width: 260px;
  max-width: 420px;
  flex: 1 1 280px;
  color: var(--muted);
  font-size: 0.68rem;
  font-weight: 850;
  text-transform: uppercase;
}

.planner-search input,
.billing-projection-search select {
  width: 100%;
  height: 32px;
  padding: 6px 10px;
  border: 1px solid var(--line-strong);
  border-radius: 6px;
  background: #ffffff;
  color: var(--ink);
  font: inherit;
  font-size: 0.78rem;
  font-weight: 650;
  text-transform: none;
}

.planner-empty-row td {
  color: var(--muted);
  font-weight: 750;
  text-align: center;
}

.sources-table th,
.sources-table td,
.movement-table th,
.movement-table td {
  padding: 10px;
  border-right: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
  text-align: left;
  vertical-align: top;
}

.planner-modal .movement-table th,
.planner-modal .movement-table td {
  min-width: 126px;
  height: 46px;
  padding: 4px 6px;
  vertical-align: middle;
}

.projection-table th,
.projection-table td {
  min-width: 126px;
  height: 46px;
  padding: 4px 6px;
  vertical-align: middle;
}

.projection-table thead th {
  position: sticky;
  top: 0;
  z-index: 2;
  background: #f8fafc;
}

.projection-order-col,
.projection-order-label {
  position: sticky;
  left: 0;
  z-index: 3;
  min-width: 300px !important;
  max-width: 340px;
  background: #fff;
}

.projection-table thead .projection-order-col {
  z-index: 4;
  background: #f8fafc;
}

.projection-sort-button {
  width: 100%;
  padding: 0;
  border: 0;
  background: transparent;
  color: var(--ink);
  cursor: pointer;
  font: inherit;
  font-size: 0.78rem;
  font-weight: 900;
  text-align: left;
}

.projection-sort-button:hover {
  color: #166534;
}

.projection-unplanned-col,
.projection-unplanned-cell {
  min-width: 156px !important;
  background: #f8fafc;
}

.projection-unplanned-cell.has-chip {
  background: #fef9c3;
}

.sources-table th,
.movement-table th {
  position: sticky;
  top: 0;
  background: #f8fafc;
  color: #334155;
  font-size: 0.72rem;
  font-weight: 850;
  text-transform: uppercase;
}

.planner-modal .movement-table thead th {
  text-align: center;
}

.planner-modal .movement-table thead small {
  display: block;
  margin-top: 2px;
  color: var(--muted);
  font-size: 0.62rem;
  font-weight: 650;
  text-transform: none;
}

.sort-header {
  width: 100%;
  padding: 0;
  border: 0;
  background: transparent;
  color: inherit;
  cursor: pointer;
  font: inherit;
  font-weight: inherit;
  text-align: left;
  text-transform: uppercase;
}

.sort-header.active {
  color: #166534;
}

.sources-table code {
  color: #166534;
  overflow-wrap: anywhere;
}

.source-row {
  cursor: pointer;
}

.source-row:hover td {
  background: #f3f8f5;
}

.source-detail-meta {
  display: grid;
  gap: 6px;
  text-transform: none;
}

.source-detail-meta span {
  color: var(--ink);
  font-size: 0.78rem;
  font-weight: 650;
}

.source-detail-meta code {
  color: #166534;
  overflow-wrap: anywhere;
}

.source-search-row,
.source-detail-controls {
  display: grid;
  gap: 8px;
  text-transform: none;
}

.source-search-row {
  max-width: 520px;
}

.source-detail-controls {
  grid-template-columns: minmax(260px, 1fr) minmax(150px, 190px) 110px auto;
  align-items: end;
  margin-top: 12px;
}

.source-search-row label,
.source-detail-controls label {
  display: grid;
  gap: 4px;
  color: var(--muted);
  font-size: 0.72rem;
  font-weight: 850;
  text-transform: uppercase;
}

.source-search-row input,
.source-detail-controls input,
.source-detail-controls select,
.pager button {
  height: 32px;
  border: 1px solid var(--line-dark);
  border-radius: 4px;
  background: #fff;
  color: var(--ink);
}

.source-search-row input,
.source-detail-controls input,
.source-detail-controls select {
  padding: 0 8px;
}

.pager {
  display: inline-flex;
  align-items: center;
  justify-content: flex-end;
  gap: 8px;
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 800;
}

.pager button {
  padding: 0 10px;
  cursor: pointer;
}

.pager button:disabled {
  cursor: default;
  opacity: 0.45;
}

.modal-backdrop[hidden],
[hidden] {
  display: none !important;
}

.modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 20;
  display: grid;
  place-items: center;
  padding: 20px;
  background: rgba(15, 23, 42, 0.38);
}

.modal-card {
  display: grid;
  grid-template-rows: auto minmax(0, 1fr);
  width: min(1180px, 96vw);
  max-height: 86vh;
  overflow: hidden;
  border: 1px solid var(--line-dark);
  border-radius: 8px;
  background: #fff;
  box-shadow: 0 24px 80px rgba(15, 23, 42, 0.28);
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 14px 16px;
  border-bottom: 1px solid var(--line);
}

.close-button {
  flex: 0 0 auto;
  height: 34px;
  padding: 0 12px;
  border: 1px solid var(--line-dark);
  border-radius: 6px;
  background: #fff;
  cursor: pointer;
}

.modal-body {
  overflow: auto;
}

.movement-table strong,
.movement-table small {
  display: block;
}

.movement-table small,
.rule-note {
  color: var(--muted);
  font-size: 0.74rem;
}

.movement-table .money-cell {
  text-align: right;
  font-weight: 850;
  white-space: nowrap;
}

.planner-movement-label {
  position: sticky !important;
  left: 0;
  top: auto !important;
  z-index: 2;
  min-width: 260px !important;
  max-width: 260px;
  background: #fff !important;
  text-transform: none !important;
}

.planner-modal .movement-table thead th:first-child {
  left: 0;
  z-index: 4;
}

.planner-movement-label strong,
.planner-movement-label small,
.planner-movement-label em {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.planner-label-button {
  display: grid;
  width: 100%;
  gap: 1px;
  padding: 0;
  border: 0;
  background: transparent;
  color: inherit;
  cursor: pointer;
  font: inherit;
  text-align: left;
}

.planner-label-button:hover strong {
  color: #166534;
  text-decoration: underline;
}

.planner-date-button {
  display: block;
  width: fit-content;
  max-width: 100%;
  margin-top: 2px;
  border: 0;
  padding: 0;
  background: transparent;
  color: var(--green-ink);
  cursor: pointer;
  font: inherit;
  font-size: 0.72rem;
  font-weight: 850;
  text-align: left;
}

.planner-date-button:hover {
  color: #166534;
  text-decoration: underline;
}

.planner-movement-label strong {
  color: var(--ink);
  font-size: 0.78rem;
}

.planner-movement-label em {
  display: block;
  color: var(--green-ink);
  font-size: 0.72rem;
  font-style: normal;
  font-weight: 850;
}

.planner-drop-cell {
  background: var(--green-light);
  text-align: center !important;
  transition:
    background 120ms ease,
    box-shadow 120ms ease;
}

.planner-drop-cell.has-chip {
  background: var(--green-mid);
}

.planner-drop-cell.drag-over {
  background: #d7f5df;
  box-shadow: inset 0 0 0 2px #16a34a;
}

.projection-drop-cell {
  min-width: 140px;
}

.projection-chip + .projection-chip {
  margin-top: 4px;
}

.movement-chip {
  display: grid;
  width: 100%;
  min-height: 36px;
  place-items: center;
  gap: 1px;
  padding: 4px 6px;
  border: 1px solid #86b991;
  border-radius: 5px;
  background: #fff;
  color: var(--ink);
  cursor: grab;
  font: inherit;
  font-variant-numeric: tabular-nums;
  box-shadow: 0 1px 3px rgba(20, 83, 45, 0.12);
}

.movement-chip:active {
  cursor: grabbing;
}

.movement-chip.dragging {
  opacity: 0.55;
}

.movement-chip strong {
  font-size: 0.76rem;
  line-height: 1.1;
}

.movement-chip small {
  color: var(--muted);
  font-size: 0.62rem;
  font-weight: 800;
}

.movement-chip.status-unplanned {
  border-color: #d6b656;
  background: #fff7d6;
  color: #713f12;
}

.movement-chip.status-missing-admin {
  border-color: #f59e0b;
  background: #ffedd5;
  color: #7c2d12;
}

.movement-chip.status-planned {
  border-color: #63b37a;
  background: #effaf1;
  color: #14532d;
}

.movement-chip.status-partial {
  border-color: #38bdf8;
  background: #e0f2fe;
  color: #075985;
}

.movement-chip.status-unplanned small,
.movement-chip.status-missing-admin small,
.movement-chip.status-planned small,
.movement-chip.status-partial small {
  color: inherit;
}

.movement-detail-modal .movement-table {
  min-width: 680px;
  width: 100%;
}

.movement-detail-header {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px 14px;
  color: var(--ink);
  font-size: 0.8rem;
  text-transform: none;
}

.movement-detail-header button {
  height: 30px;
  padding: 0 10px;
  border: 1px solid var(--line-dark);
  border-radius: 5px;
  background: #fff;
  color: var(--ink);
  cursor: pointer;
  font-weight: 800;
}

.work-planning-form {
  display: grid;
  gap: 10px;
  max-width: 520px;
}

.work-planning-form label {
  display: grid;
  gap: 4px;
  color: var(--muted);
  font-size: 0.7rem;
  font-weight: 850;
  text-transform: uppercase;
}

.work-planning-form input {
  height: 34px;
  padding: 6px 9px;
  border: 1px solid var(--line-strong);
  border-radius: 6px;
  background: #fff;
  color: var(--ink);
  font: inherit;
  font-size: 0.82rem;
  font-weight: 700;
}

.work-planning-form output {
  display: block;
  padding: 8px 10px;
  border: 1px solid #bbd7c3;
  border-radius: 6px;
  background: #effaf1;
  color: #14532d;
  font-size: 0.76rem;
  font-weight: 850;
}

.work-planning-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.work-planning-actions button {
  height: 32px;
  padding: 0 11px;
  border: 1px solid var(--line-dark);
  border-radius: 6px;
  background: #fff;
  color: var(--ink);
  cursor: pointer;
  font-weight: 850;
}

.work-planning-actions button:first-child {
  border-color: #15803d;
  background: #15803d;
  color: #fff;
}

.work-planning-actions button:disabled {
  cursor: not-allowed;
  opacity: 0.45;
}

.billing-plan-block {
  display: grid;
  gap: 10px;
}

.billing-plan-block p {
  margin: 0;
  color: var(--muted);
  font-size: 0.72rem;
  font-weight: 700;
}

.billing-plan-summary {
  display: flex;
  flex-wrap: wrap;
  gap: 8px 16px;
  font-size: 0.76rem;
}

.billing-plan-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.74rem;
}

.billing-plan-table th,
.billing-plan-table td {
  padding: 6px 7px !important;
  border: 1px solid var(--line);
  white-space: nowrap;
}

.billing-plan-table th {
  background: #f1f5f9;
  color: var(--muted);
  font-weight: 900;
  text-transform: uppercase;
}

.billing-plan-table button,
.billing-line-form button {
  height: 30px;
  border: 1px solid var(--line-dark);
  border-radius: 6px;
  background: #fff;
  color: var(--ink);
  cursor: pointer;
  font-weight: 850;
}

.billing-line-form {
  display: grid;
  grid-template-columns: minmax(150px, 1fr) minmax(150px, 1fr) 110px auto;
  gap: 8px;
  align-items: end;
}

.billing-line-form label {
  display: grid;
  gap: 4px;
  color: var(--muted);
  font-size: 0.68rem;
  font-weight: 850;
  text-transform: uppercase;
}

.billing-line-form input {
  height: 32px;
  padding: 6px 8px;
  border: 1px solid var(--line-strong);
  border-radius: 6px;
  color: var(--ink);
  font: inherit;
  font-size: 0.78rem;
  font-weight: 700;
}

.billing-line-form button {
  padding: 0 10px;
  border-color: #15803d;
  background: #15803d;
  color: #fff;
}

.single-detail-body th,
.single-detail-body td {
  height: auto !important;
  min-width: 0 !important;
  padding: 8px 10px !important;
  vertical-align: top !important;
}

.single-detail-body th {
  width: 230px;
  color: var(--muted);
  font-size: 0.72rem;
  text-transform: uppercase;
}

.audit-section-row th {
  padding-top: 14px !important;
  background: #e7eef5 !important;
  color: var(--ink) !important;
  font-size: 0.76rem !important;
  letter-spacing: 0.02em;
}

.audit-entry-row td strong,
.audit-entry-row td span,
.audit-entry-row td small,
.audit-entry-row td em {
  display: block;
}

.audit-entry-row td strong {
  color: var(--ink);
  font-size: 0.82rem;
}

.audit-entry-row td span {
  margin-top: 2px;
  color: var(--muted);
  font-size: 0.72rem;
  font-weight: 800;
}

.audit-entry-row td small {
  margin-top: 4px;
  color: #14532d;
  font-size: 0.72rem;
  font-weight: 800;
}

.audit-entry-row td em {
  margin-top: 2px;
  color: var(--muted);
  font-size: 0.68rem;
  font-style: normal;
}

.audit-empty-row td {
  color: var(--muted);
  font-weight: 700;
}

.single-detail-body td {
  color: var(--ink);
  font-size: 0.82rem;
  overflow-wrap: anywhere;
}

.movement-comment-row th,
.movement-comment-row td,
.movement-classification-row th,
.movement-classification-row td,
.movement-hidden-order-row th,
.movement-hidden-order-row td,
.movement-confirmation-row th,
.movement-confirmation-row td {
  background: #f8fafc;
}

.movement-classification-row label,
.movement-hidden-order-row label,
.movement-confirmation-row label {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  color: var(--ink);
  font-weight: 850;
}

.movement-classification-row input,
.movement-hidden-order-row input,
.movement-confirmation-row input {
  width: 16px !important;
  height: 16px !important;
}

.movement-classification-row small,
.movement-hidden-order-row small,
.movement-confirmation-row small {
  display: block;
  margin-top: 4px;
  color: var(--muted);
  font-size: 0.72rem;
}

.hidden-orders-search {
  margin: 0 0 10px;
}

.billing-projection-search {
  grid-template-columns: minmax(260px, 1fr) minmax(170px, 230px) minmax(170px, 230px) minmax(150px, auto);
  max-width: none;
  align-items: end;
  gap: 12px;
  margin: 0;
  padding: 12px 16px 14px;
  border-top: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
  background: #f8fafc;
}

.billing-projection-search label {
  min-width: 0;
}

.billing-projection-check {
  display: flex !important;
  align-items: center;
  gap: 8px !important;
  min-height: 34px;
  color: var(--ink) !important;
  text-transform: none !important;
}

.billing-projection-check input {
  width: 16px !important;
  height: 16px !important;
}

.billing-projection-search input,
.billing-projection-search select {
  width: 100%;
  height: 34px;
  min-width: 0;
  padding: 6px 10px;
  border: 1px solid var(--line-strong);
  border-radius: 6px;
  background: #ffffff;
  color: var(--ink);
  font: inherit;
  font-size: 0.78rem;
  font-weight: 700;
}

.work-admin-rule-note {
  color: #166534;
  font-size: 0.72rem;
  font-weight: 750;
  text-transform: none;
}

.restore-hidden-order {
  height: 30px;
  padding: 0 10px;
  border: 1px solid #15803d;
  border-radius: 5px;
  background: #fff;
  color: #14532d;
  cursor: pointer;
  font-weight: 850;
}

.movement-comment-row textarea {
  width: 100%;
  min-height: 86px;
  resize: vertical;
  padding: 8px 10px;
  border: 1px solid var(--line-dark);
  border-radius: 5px;
  background: #fff;
  color: var(--ink);
  font: inherit;
  line-height: 1.35;
}

.movement-table select,
.movement-table input {
  width: 100%;
  height: 30px;
  border: 1px solid var(--line-dark);
  border-radius: 4px;
  background: #fff;
}

.rule-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(80px, 1fr));
  gap: 6px;
  min-width: 390px;
}

.rule-grid label {
  display: grid;
  gap: 3px;
  color: var(--muted);
  font-size: 0.7rem;
  font-weight: 800;
  text-transform: uppercase;
}

.rule-grid .check-label {
  align-content: end;
  grid-template-columns: 18px 1fr;
  align-items: center;
  min-height: 30px;
}

.rule-grid .check-label input {
  width: 16px;
  height: 16px;
}

.empty-detail,
.error-panel {
  margin: 0;
  padding: 16px;
  color: var(--muted);
}

@media (max-width: 780px) {
  .sheet-header,
  .sources-header,
  .modal-header {
    align-items: stretch;
    flex-direction: column;
  }

  .close-button {
    width: fit-content;
  }

  .status-bar {
    justify-content: flex-start;
  }

  .row-label-col,
  .row-label {
    min-width: 210px;
    max-width: 210px;
  }

  .source-detail-controls {
    grid-template-columns: 1fr;
  }

  .config-grid {
    grid-template-columns: 1fr;
  }
}
