:root {
  --bg: #fff7fa;
  --panel: #ffffff;
  --ink: #2f2d32;
  --muted: #6f6574;
  --line: #eadde6;
  --brand: #ef3340;
  --brand-dark: #c92330;
  --accent: #8d62b0;
  --good: #138a54;
  --warn: #b7791f;
  --bad: #c0392b;
  --orange: #d97706;
  --blue: #2563eb;
  --pink: #db2777;
  --shadow: 0 12px 32px rgba(93, 59, 89, .10);
}

* { box-sizing: border-box; }

body {
  margin: 0;
  color: var(--ink);
  background: var(--bg);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  display: grid;
  grid-template-columns: 260px 1fr;
  min-height: 100vh;
}

body.locked {
  display: block;
}

body.locked .sidebar,
body.locked main {
  display: none;
}

.login-screen {
  position: fixed;
  inset: 0;
  background: linear-gradient(135deg, #2f2d32, #8d62b0 58%, #ef3340);
  display: none;
  place-items: center;
  padding: 22px;
  z-index: 20;
}

body.locked .login-screen {
  display: grid;
}

.login-card {
  width: min(420px, 100%);
  background: #fff;
  border-radius: 8px;
  padding: 26px;
  box-shadow: 0 24px 70px rgba(0, 0, 0, .22);
  display: grid;
  gap: 16px;
}

.login-brand {
  color: var(--ink);
  padding: 0 0 8px;
}

.login-brand span,
.login-hint {
  color: var(--muted);
}

.login-hint {
  font-size: 13px;
  text-align: center;
}

.sidebar {
  background: #1f1f24;
  color: #fff;
  padding: 22px 16px;
  position: sticky;
  top: 0;
  height: 100vh;
  overflow-y: auto;
}

.brand {
  display: flex;
  gap: 12px;
  align-items: center;
  padding: 4px 6px 14px;
}

.brand-logo {
  width: 58px;
  height: 42px;
  object-fit: contain;
  border-radius: 8px;
  background: #fff;
  border: 1px solid rgba(255, 255, 255, .75);
  box-shadow: 0 6px 16px rgba(0, 0, 0, .16);
  padding: 4px;
}

.brand-mark {
  width: 44px;
  height: 44px;
  border-radius: 8px;
  display: grid;
  place-items: center;
  background: var(--accent);
  font-weight: 800;
}

.brand span {
  display: block;
  color: #fff;
  font-size: 13px;
  margin-top: 3px;
}

nav {
  display: grid;
  gap: 5px;
}

.nav-group {
  display: grid;
  gap: 4px;
  margin: 8px 0;
  padding-top: 8px;
  border-top: 1px solid rgba(255, 255, 255, .12);
}

.nav-group > span {
  align-items: center;
  color: #fff;
  cursor: pointer;
  display: flex;
  font-size: 12px;
  font-weight: 800;
  justify-content: space-between;
  padding: 4px 12px;
  text-transform: uppercase;
  user-select: none;
}

.nav-group > span::after {
  color: #fff;
  content: "−";
  font-size: 15px;
  line-height: 1;
}

.nav-group.collapsed > span::after {
  content: "+";
}

.nav-group.collapsed .nav-btn.sub {
  display: none;
}

button, input, select, textarea {
  font: inherit;
}

button {
  border: 0;
  cursor: pointer;
}

.nav-btn {
  text-align: left;
  color: #fff;
  background: transparent;
  border-radius: 8px;
  padding: 9px 12px;
}

.nav-btn.sub {
  padding-left: 24px;
  font-size: 14px;
}

.nav-btn:hover, .nav-btn.active {
  background: rgba(239, 51, 64, .28);
  color: #fff;
}

main {
  min-width: 0;
  padding: 28px;
}

.topbar {
  display: flex;
  justify-content: space-between;
  gap: 20px;
  align-items: center;
  margin-bottom: 24px;
}

h1, h2, p { margin: 0; }

h1 {
  font-size: 28px;
  line-height: 1.15;
}

h2 {
  font-size: 18px;
}

.topbar p {
  color: var(--muted);
  margin-top: 6px;
}

.top-actions, .form-actions, .month-controls {
  display: flex;
  gap: 10px;
  align-items: center;
  flex-wrap: wrap;
}

.form-tabs {
  display: flex;
  gap: 8px;
  border-bottom: 1px solid var(--line);
  padding-bottom: 8px;
}

.form-tab {
  border: 1px solid var(--line);
  background: #fff;
  color: var(--muted);
  border-radius: 8px;
  padding: 9px 12px;
  font-weight: 800;
}

.form-tab.active {
  background: var(--brand);
  border-color: var(--brand);
  color: #fff;
}

.form-tab-panel {
  display: none;
  gap: 13px;
}

.form-tab-panel.active {
  display: grid;
}

.technical-summary {
  border-left: 3px solid var(--brand);
  background: #f4faf9;
  padding: 10px 12px;
  border-radius: 0 8px 8px 0;
  display: grid;
  gap: 6px;
}

.technical-summary p {
  margin: 0;
  color: var(--muted);
  font-size: 13px;
}

.technical-summary strong {
  color: var(--ink);
}

.help-box {
  border: 1px dashed var(--line);
  border-radius: 8px;
  background: #f8fafb;
  color: var(--muted);
  padding: 10px 12px;
  font-size: 13px;
  line-height: 1.45;
}

.questionnaire-box {
  display: grid;
  gap: 8px;
  border: 1px solid #f0c6d9;
  border-radius: 8px;
  background: #fff7fb;
  padding: 12px;
  margin: 10px 0 14px;
}

.questionnaire-box h3,
.questionnaire-box p {
  margin: 0;
}

.rating-options {
  display: grid;
  grid-template-columns: repeat(4, minmax(80px, 1fr));
  gap: 8px;
}

.rating-options span {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  color: var(--ink);
  font-weight: 800;
  padding: 8px;
  text-align: center;
}

.warning-box {
  border: 1px solid #f2c879;
  border-radius: 8px;
  background: #fffaf0;
  display: grid;
  gap: 10px;
  padding: 12px;
}

.warning-list {
  display: grid;
  gap: 8px;
}

.warning-list article {
  align-items: start;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 8px;
  display: flex;
  gap: 10px;
  justify-content: space-between;
  padding: 10px;
}

.warning-list p,
.warning-list small {
  color: var(--muted);
  display: block;
  margin: 4px 0 0;
}

.user-warning-history {
  border: 1px solid var(--line);
  border-radius: 8px;
  margin-top: 10px;
  padding: 10px;
}

.user-warning-history summary {
  cursor: pointer;
  font-weight: 800;
}

.client-history {
  border-top: 1px solid var(--line);
  margin-top: 10px;
  padding-top: 10px;
}

.client-history summary {
  cursor: pointer;
  font-weight: 800;
}

.user-card summary {
  align-items: center;
  cursor: pointer;
  display: flex;
  gap: 12px;
  justify-content: space-between;
  list-style: none;
}

.dashboard-party-card summary {
  align-items: center;
  cursor: pointer;
  display: flex;
  gap: 12px;
  justify-content: space-between;
  list-style: none;
}

.dashboard-party-card summary::-webkit-details-marker {
  display: none;
}

.dashboard-party-card summary::before {
  color: var(--brand);
  content: "+";
  font-weight: 900;
}

.dashboard-party-card[open] summary::before {
  content: "-";
}

.dashboard-party-card .sale-card {
  border-color: #dfe7ef;
  box-shadow: none;
  margin-top: 10px;
}

.user-card summary::-webkit-details-marker {
  display: none;
}

.user-card summary::before {
  color: var(--brand);
  content: "+";
  font-weight: 900;
}

.user-card[open] summary::before {
  content: "-";
}

.user-card-body {
  display: grid;
  gap: 10px;
  margin-top: 12px;
}

.contract-editor {
  position: fixed;
  inset: 0;
  z-index: 30;
  background: rgba(31, 41, 51, .45);
  padding: 24px;
  overflow: auto;
}

.contract-editor-panel {
  max-width: 900px;
  margin: 0 auto;
  display: grid;
  gap: 12px;
}

.contract-editor-actions {
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
  padding: 12px;
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: center;
  flex-wrap: wrap;
}

.editable-contract {
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
  padding: 32px;
  min-height: 640px;
  outline: none;
}

.document-header {
  align-items: center;
  border-bottom: 3px solid var(--brand);
  display: flex;
  gap: 18px;
  margin-bottom: 26px;
  padding-bottom: 16px;
}

.document-header img {
  background: #fff;
  height: 74px;
  object-fit: contain;
  width: 180px;
}

.document-header strong {
  color: var(--ink);
  display: block;
  font-size: 22px;
  line-height: 1.1;
}

.document-header span {
  color: var(--muted);
  display: block;
  font-size: 14px;
  font-weight: 700;
  margin-top: 6px;
}

.payment-modal {
  position: fixed;
  inset: 0;
  z-index: 28;
  background: rgba(31, 41, 51, .45);
  padding: 24px;
  overflow: auto;
}

.payment-modal.hidden {
  display: none;
}

.payment-panel {
  max-width: 820px;
  margin: 0 auto;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
  padding: 18px;
  display: grid;
  gap: 16px;
}

.payment-head {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: start;
}

.payment-head h2 {
  margin: 0;
}

.payment-head p {
  color: var(--muted);
  margin-top: 6px;
}

.user-badge {
  color: var(--muted);
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 9px 12px;
  font-size: 13px;
  font-weight: 800;
}

.hidden-by-permission {
  display: none !important;
}

.view {
  display: none;
}

.view.active {
  display: block;
}

.metrics {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 14px;
  margin-bottom: 18px;
}

.metrics article, .panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
}

.metrics article {
  padding: 18px;
}

.metrics span {
  color: var(--muted);
  font-size: 13px;
}

.metrics strong {
  display: block;
  font-size: 25px;
  margin-top: 8px;
}

.split {
  display: grid;
  grid-template-columns: minmax(360px, .95fr) minmax(420px, 1.2fr);
  gap: 18px;
  align-items: start;
}

.dashboard-analytics {
  margin-bottom: 18px;
}

.dashboard-category {
  margin: 16px 0 10px;
}

.dashboard-category h2 {
  margin: 0;
  font-size: 18px;
}

.dashboard-calendar-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(150px, 1fr));
  gap: 10px;
}

.dashboard-calendar-grid > section {
  min-width: 0;
  border: 1px solid #cbd7e3;
  border-radius: 8px;
  background: #fff;
  padding: 10px;
  box-shadow: 0 8px 20px rgba(31, 41, 51, .06);
}

.dashboard-panel-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(220px, 1fr));
  gap: 18px;
  align-items: start;
}

.filters {
  display: flex;
  align-items: end;
  gap: 10px;
  flex-wrap: wrap;
}

.filters label {
  min-width: 150px;
}

.mini-metrics {
  margin-bottom: 16px;
}

.chart-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 18px;
}

.chart-grid h3 {
  font-size: 14px;
  margin: 0 0 10px;
}

.bar-chart {
  display: grid;
  gap: 10px;
}

.bar-row {
  display: grid;
  grid-template-columns: 110px 1fr 110px;
  gap: 10px;
  align-items: center;
  font-size: 13px;
}

.bar-row strong {
  text-align: right;
}

.bar-row.compact {
  grid-template-columns: 88px 1fr 86px;
}

.bar-track {
  height: 12px;
  border-radius: 999px;
  background: #eef2f5;
  overflow: hidden;
}

.bar-track i {
  display: block;
  height: 100%;
  border-radius: inherit;
  background: var(--brand);
}

.bar-track i.receivable { background: var(--orange); }
.bar-track i.received { background: var(--blue); }
.bar-track i.paid { background: var(--good); }
.bar-track i.pending { background: var(--warn); }
.bar-track i.payable { background: var(--orange); }
.bar-track i.overdue { background: var(--bad); }

.panel {
  padding: 18px;
}

.panel:has(.calendar-popover) {
  position: relative;
}

.panel-head {
  display: flex;
  justify-content: space-between;
  gap: 14px;
  align-items: center;
  margin-bottom: 14px;
}

.form {
  display: grid;
  gap: 13px;
}

label {
  color: var(--muted);
  font-size: 13px;
  display: grid;
  gap: 6px;
}

fieldset {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 12px;
}

legend {
  color: var(--ink);
  font-weight: 800;
  padding: 0 6px;
}

.permission-box {
  display: grid;
  gap: 8px 12px;
  grid-template-columns: 1fr;
}

.permission-box label {
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--ink);
}

.permission-box input {
  width: auto;
}

.permission-category {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  padding: 10px;
}

.permission-category summary {
  align-items: center;
  cursor: pointer;
  display: flex;
  font-weight: 900;
  gap: 10px;
  justify-content: space-between;
  list-style: none;
}

.permission-category summary::-webkit-details-marker {
  display: none;
}

.permission-category-grid {
  display: grid;
  gap: 8px 12px;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  margin-top: 10px;
}

.fee-grid {
  display: grid;
  gap: 8px;
  grid-template-columns: repeat(5, minmax(74px, 1fr));
}

.cash-flow-grid {
  display: grid;
  gap: 8px;
  grid-template-columns: repeat(4, minmax(120px, 1fr));
}

.cash-flow-grid span {
  background: #f8fafc;
  border: 1px solid var(--line);
  border-radius: 8px;
  color: var(--muted);
  display: grid;
  font-size: 12px;
  font-weight: 800;
  gap: 4px;
  padding: 9px;
}

.cash-flow-grid strong {
  color: var(--ink);
  font-size: 14px;
}

input, select, textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 11px 12px;
  color: var(--ink);
  background: #fff;
  min-width: 0;
}

.locked-field input {
  background: #eef3f7;
  color: var(--muted);
  cursor: not-allowed;
}

.locked-field::after {
  content: "Controlado pelo administrador";
  color: var(--muted);
  font-size: 11px;
  font-weight: 700;
}

.conditional-field.hidden {
  display: none;
}

textarea {
  resize: vertical;
}

.two {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

.primary, .secondary, .ghost, .icon-btn {
  border-radius: 8px;
  padding: 11px 14px;
  font-weight: 700;
}

.primary {
  background: var(--brand);
  color: #fff;
}

.primary:hover { background: var(--brand-dark); }

.secondary {
  background: #e8f4f3;
  color: var(--brand-dark);
}

.ghost {
  background: #fff;
  color: var(--ink);
  border: 1px solid var(--line);
}

.small {
  padding: 8px 11px;
  font-size: 13px;
}

.icon-btn {
  width: 40px;
  height: 40px;
  padding: 0;
  background: #edf2f5;
  color: var(--ink);
  font-size: 25px;
  line-height: 1;
}

.file-btn {
  position: relative;
  overflow: hidden;
}

.file-btn input {
  position: absolute;
  inset: 0;
  opacity: 0;
  cursor: pointer;
}

.search {
  max-width: 300px;
}

.list {
  display: grid;
  gap: 10px;
}

.empty {
  color: var(--muted);
  border: 1px dashed var(--line);
  border-radius: 8px;
  padding: 20px;
  text-align: center;
}

.item {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 13px;
  display: grid;
  gap: 9px;
  background: #fff;
}

.item.cancelled-item {
  border-color: rgba(192, 57, 43, .35);
  background: #fffafa;
}

.sale-card {
  border: 3px solid #1f2933;
  box-shadow: 0 10px 26px rgba(31, 41, 51, .12);
}

.item-top {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: start;
}

.item h3 {
  margin: 0;
  font-size: 16px;
}

.item p {
  color: var(--muted);
  line-height: 1.45;
}

.meta {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.sale-summary {
  display: grid;
  grid-template-columns: repeat(4, minmax(130px, 1fr));
  gap: 8px;
}

.summary-cell,
.sale-detail-grid > div {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #f8fafc;
  padding: 10px;
  display: grid;
  gap: 4px;
}

.summary-cell span,
.sale-detail-grid span {
  color: var(--muted);
  font-size: 11px;
  font-weight: 800;
  text-transform: uppercase;
}

.summary-cell strong,
.sale-detail-grid strong {
  color: var(--ink);
  font-size: 14px;
}

.summary-cell.highlight {
  border-color: rgba(0, 109, 119, .25);
  background: #edf8f8;
}

.summary-cell.attention {
  border-color: rgba(183, 121, 31, .28);
  background: #fff8ea;
}

.summary-cell.ok {
  border-color: rgba(19, 138, 84, .25);
  background: #eefaf3;
}

.sale-detail-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(150px, 1fr));
  gap: 8px;
}

.financial-history {
  border: 1px solid #cbd7e3;
  border-radius: 8px;
  background: #fbfdff;
  overflow: hidden;
}

.financial-history summary {
  align-items: center;
  cursor: pointer;
  display: flex;
  gap: 12px;
  justify-content: space-between;
  list-style: none;
  padding: 11px 12px;
}

.financial-history summary::-webkit-details-marker {
  display: none;
}

.financial-history summary::before {
  content: "+";
  align-items: center;
  background: #edf2f5;
  border-radius: 999px;
  color: var(--brand);
  display: inline-grid;
  flex: 0 0 24px;
  font-weight: 900;
  height: 24px;
  place-items: center;
  width: 24px;
}

.financial-history[open] summary::before {
  content: "-";
}

.financial-history summary span {
  color: var(--ink);
  flex: 1;
  font-weight: 900;
}

.financial-history summary strong {
  color: var(--muted);
  font-size: 12px;
  text-align: right;
}

.financial-history-body {
  border-top: 1px solid var(--line);
  display: grid;
  gap: 8px;
  padding: 10px;
}

.financial-history-row {
  align-items: start;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 8px;
  display: grid;
  gap: 10px;
  grid-template-columns: minmax(0, 1fr) auto;
  padding: 10px;
}

.financial-history-row strong {
  display: block;
  font-size: 13px;
}

.financial-history-row span,
.financial-history-row p {
  color: var(--muted);
  font-size: 12px;
  margin: 2px 0 0;
}

.history-amount {
  display: grid;
  gap: 6px;
  justify-items: end;
  min-width: 120px;
}

.history-amount b {
  font-size: 14px;
}

.balance-row {
  border-color: rgba(0, 109, 119, .25);
  background: #f2fbfb;
}

.cancel-box {
  border: 1px solid rgba(192, 57, 43, .25);
  border-radius: 8px;
  background: #fdeceb;
  color: var(--bad);
  padding: 12px;
  display: grid;
  gap: 5px;
}

.cancel-box p {
  color: var(--ink);
  margin: 0;
}

.cancel-box span {
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

.pill {
  color: var(--ink);
  background: #edf2f5;
  border-radius: 999px;
  padding: 5px 9px;
  font-size: 12px;
  font-weight: 700;
}

.pill.good { color: var(--good); background: #e8f7ef; }
.pill.warn { color: var(--warn); background: #fff4dc; }
.pill.bad { color: var(--bad); background: #fdeceb; }
.pill.paid { color: var(--good); background: #e8f7ef; }
.pill.received { color: var(--blue); background: #eaf1ff; }
.pill.overdue { color: var(--bad); background: #fdeceb; }
.pill.payable { color: var(--orange); background: #fff3df; }
.pill.pending { color: var(--warn); background: #fff4dc; }

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

.actions button {
  background: #f2f5f7;
  color: var(--ink);
  border-radius: 8px;
  padding: 8px 10px;
  font-weight: 700;
}

.actions .danger {
  color: var(--bad);
}

.calendar-grid {
  display: grid;
  grid-template-columns: repeat(7, minmax(0, 1fr));
  gap: 8px;
  border: 1px solid #cbd7e3;
  border-radius: 8px;
  background: #f8fafc;
  padding: 10px;
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, .72);
}

.day-name {
  color: var(--muted);
  font-weight: 800;
  font-size: 12px;
  text-align: center;
  background: #eef3f7;
  border: 1px solid #dbe3ea;
  border-radius: 6px;
  padding: 7px 4px;
}

.day {
  min-height: 126px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  padding: 9px;
  display: grid;
  align-content: start;
  gap: 7px;
  color: inherit;
  text-align: left;
}

button.day:hover {
  border-color: var(--brand);
  box-shadow: inset 0 0 0 1px var(--brand);
}

button.day:focus-visible {
  outline: 3px solid rgba(0, 109, 119, .25);
  outline-offset: 2px;
}

.day.muted {
  background: #f8fafb;
  color: #a5acb4;
}

.day-number {
  font-weight: 800;
  font-size: 13px;
}

.event-chip {
  border-left: 4px solid var(--accent);
  background: #fff1f4;
  border-radius: 6px;
  padding: 6px;
  font-size: 12px;
  line-height: 1.25;
}

.event-chip.party-chip {
  border-left-color: var(--orange);
  background: #fff3df;
}

.event-chip.holiday-chip {
  border-left-color: var(--pink);
  background: #fdf2f8;
}

.calendar-popover {
  position: absolute;
  inset: 72px 18px auto 18px;
  z-index: 8;
  max-height: min(520px, calc(100vh - 170px));
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  box-shadow: var(--shadow);
  padding: 14px;
}

.calendar-popover.hidden {
  display: none;
}

.popover-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 12px;
}

.popover-head h3 {
  margin: 0;
  font-size: 17px;
}

.finance-chip {
  border-left-color: var(--good);
  background: #edf9f2;
}

.followup-chip {
  border-left-color: var(--brand);
  background: #e8f4f3;
}

.finance-chip.paid {
  border-left-color: var(--good);
  background: #edf9f2;
}

.finance-chip.overdue {
  border-left-color: var(--bad);
  background: #fdeceb;
}

.finance-chip.payable {
  border-left-color: var(--bad);
  background: #fdeceb;
}

.finance-chip.pending {
  border-left-color: var(--orange);
  background: #fff3df;
}

.finance-chip.receivable {
  border-left-color: var(--orange);
  background: #fff3df;
}

.finance-chip.received {
  border-left-color: var(--blue);
  background: #eff6ff;
}

.legend {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  color: var(--muted);
  font-size: 13px;
  margin: 8px 0 14px;
}

.legend span {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.legend-dot {
  width: 10px;
  height: 10px;
  border-radius: 999px;
  display: inline-block;
}

.legend-dot.green { background: var(--good); }
.legend-dot.red { background: var(--bad); }
.legend-dot.orange { background: var(--orange); }
.legend-dot.blue { background: var(--blue); }
.legend-dot.pink { background: var(--pink); }

.compact-item {
  padding: 11px;
}

.toast {
  position: fixed;
  right: 20px;
  bottom: 20px;
  background: #16232d;
  color: #fff;
  border-radius: 8px;
  padding: 12px 15px;
  box-shadow: var(--shadow);
  opacity: 0;
  transform: translateY(10px);
  transition: .2s ease;
  pointer-events: none;
}

.toast.show {
  opacity: 1;
  transform: translateY(0);
}

.button-link {
  align-items: center;
  background: #eef4ff;
  border: 1px solid #c8d9ff;
  border-radius: 8px;
  color: #1f4b99;
  display: inline-flex;
  font-size: 13px;
  font-weight: 700;
  min-height: 34px;
  padding: 0 12px;
  text-decoration: none;
}

.action-permission-box {
  grid-template-columns: 1fr;
}

#actionPermissionList {
  display: grid;
  gap: 8px;
}

.action-permission-group {
  display: grid;
  gap: 8px;
  margin-top: 10px;
}

.action-permission-row {
  align-items: center;
  border: 1px solid var(--line);
  border-radius: 8px;
  display: grid;
  gap: 8px;
  grid-template-columns: minmax(160px, 1.4fr) repeat(3, minmax(92px, 1fr));
  padding: 8px;
}

.action-permission-row label {
  margin: 0;
}

.mini-calendar {
  font-size: 12px;
  padding: 7px;
}

.compact-head {
  gap: 8px;
  margin-bottom: 8px;
}

.compact-head h3 {
  margin: 0;
}

.compact-head .month-controls strong {
  min-width: 96px;
  text-align: center;
}

.mini-calendar .day {
  min-height: 58px;
  padding: 5px;
  gap: 4px;
}

.mini-calendar .event-chip {
  font-size: 9px;
  line-height: 1.2;
  padding: 4px;
}

@media (max-width: 1040px) {
  body {
    grid-template-columns: 1fr;
  }

  .sidebar {
    height: auto;
    position: static;
  }

  nav {
    grid-template-columns: repeat(4, minmax(0, 1fr));
  }

  .split, .metrics, .dashboard-panel-grid, .sale-summary, .sale-detail-grid {
    grid-template-columns: 1fr 1fr;
  }
}

@media (max-width: 720px) {
  main {
    padding: 18px;
  }

  .topbar, .panel-head, .item-top {
    align-items: stretch;
    flex-direction: column;
  }

  nav, .split, .metrics, .two, .permission-box, .chart-grid, .dashboard-panel-grid, .sale-summary, .sale-detail-grid, .fee-grid, .cash-flow-grid {
    grid-template-columns: 1fr;
  }

  .bar-row {
    grid-template-columns: 1fr;
  }

  .financial-history summary,
  .financial-history-row {
    grid-template-columns: 1fr;
  }

  .financial-history summary {
    align-items: flex-start;
  }

  .history-amount {
    justify-items: start;
    min-width: 0;
  }

  .bar-row strong {
    text-align: left;
  }

  .calendar-grid {
    gap: 5px;
  }

  .day {
    min-height: 92px;
    padding: 6px;
  }

  .event-chip {
    font-size: 11px;
  }
}

@media print {
  body {
    display: block;
    background: #fff;
  }

  .sidebar, .topbar, .view, .toast, .contract-editor-actions, .payment-modal {
    display: none !important;
  }

  .contract-editor {
    position: static;
    padding: 0;
    background: #fff;
  }

  .contract-editor-panel {
    max-width: none;
  }

  .print-doc {
    display: block !important;
    color: #111;
    font-family: Arial, sans-serif;
    max-width: 760px;
    margin: 0 auto;
    line-height: 1.5;
  }

  .document-header {
    break-inside: avoid;
    margin-bottom: 24px;
  }

  .document-header img {
    height: 64px;
    width: 160px;
  }
}
