:root {
  color-scheme: light;
  --bg: #f5f7f3;
  --panel: #ffffff;
  --soft: #edf2ea;
  --line: #d9dfd4;
  --text: #1d241b;
  --muted: #687264;
  --accent: #2f6f4e;
  --accent-strong: #234f3b;
  --danger: #a6372d;
  --warn: #8a5b14;
}

* {
  box-sizing: border-box;
}

[hidden] {
  display: none !important;
}

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

.sidebar {
  background: #183527;
  color: #fff;
  padding: 24px 18px;
}

.sidebar-head {
  display: grid;
  gap: 10px;
}

.brand {
  display: grid;
  gap: 6px;
  margin-bottom: 28px;
}

.brand-logo {
  display: block;
  width: min(170px, 100%);
  max-height: 96px;
  object-fit: contain;
  object-position: left center;
  margin-bottom: 6px;
}

.brand strong {
  font-size: 20px;
}

.brand span {
  color: #c9d8cf;
  font-size: 14px;
}

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

.menu-toggle {
  display: none;
  border: 1px solid rgb(255 255 255 / 28%);
  border-radius: 6px;
  min-height: 38px;
  padding: 8px 12px;
  background: #2f6f4e;
  color: #fff;
  cursor: pointer;
}

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

.nav,
.primary,
.secondary,
.danger {
  border: 0;
  border-radius: 6px;
  min-height: 38px;
  padding: 8px 12px;
  cursor: pointer;
}

button:disabled,
button.is-busy {
  opacity: 0.62;
  cursor: wait;
}

.nav {
  width: 100%;
  text-align: left;
  color: #eef6f1;
  background: transparent;
}

.nav.active,
.nav:hover {
  background: #2f6f4e;
}

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

header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 16px;
  margin-bottom: 20px;
}

.header-actions {
  display: flex;
  align-items: center;
  gap: 12px;
}

.account-menu {
  position: relative;
}

.account-trigger {
  width: 46px;
  height: 46px;
  min-height: 46px;
  border-radius: 999px;
  padding: 0;
  overflow: hidden;
  display: flex;
  align-items: center;
  justify-content: center;
  line-height: 1;
}

.account-trigger img,
.profile-preview img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: center center;
}

.account-trigger span {
  font-weight: 800;
}

.account-dropdown {
  position: absolute;
  right: 0;
  top: 52px;
  min-width: 170px;
  background: var(--panel);
  border: 1px solid var(--line);
  box-shadow: 0 10px 30px rgb(20 32 24 / 14%);
  padding: 6px;
  z-index: 10;
}

.account-dropdown button {
  width: 100%;
  justify-content: flex-start;
  background: transparent;
}

.auth-panel {
  max-width: 460px;
}

.forgot-form {
  margin-top: 22px;
  padding-top: 18px;
  border-top: 1px solid var(--line);
}

.error {
  color: var(--danger);
  font-weight: 650;
}

h1,
h2,
h3 {
  margin: 0;
  line-height: 1.2;
}

h1 {
  font-size: 30px;
}

h2 {
  font-size: 20px;
  margin-bottom: 14px;
}

h3 {
  font-size: 16px;
  margin-bottom: 10px;
}

#message {
  min-height: 24px;
  color: var(--warn);
}

.grid {
  display: grid;
  gap: 18px;
}

.cols {
  grid-template-columns: minmax(320px, 420px) minmax(0, 1fr);
}

.users-grid {
  grid-template-columns: minmax(0, 1fr);
}

.user-editor-panel {
  max-width: 820px;
}

.stats {
  grid-template-columns: repeat(4, minmax(150px, 1fr));
}

.panel,
.card {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
}

.panel {
  padding: 18px;
}

.card {
  padding: 14px;
}

.cards {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 12px;
}

.stat-value {
  display: block;
  font-size: 28px;
  font-weight: 700;
  margin-top: 6px;
}

form {
  display: grid;
  gap: 12px;
}

.form-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

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

input,
select,
textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 6px;
  min-height: 38px;
  padding: 8px 10px;
  background: #fff;
  color: var(--text);
}

textarea {
  resize: vertical;
  min-height: 120px;
}

.check {
  display: flex;
  align-items: center;
  gap: 9px;
}

.check input {
  width: 18px;
  min-height: 18px;
}

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

td.actions {
  display: table-cell;
  white-space: nowrap;
}

td.actions button + button {
  margin-left: 8px;
}

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

.secondary {
  background: #e7ece4;
  color: var(--text);
}

.danger {
  background: #f5dddd;
  color: var(--danger);
}

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 14px;
}

.table-scroll {
  width: 100%;
  max-width: 100%;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  background: #fff;
  border-radius: 6px;
}

.table-scroll table {
  width: max-content;
  min-width: 100%;
  background: #fff;
}

.table-scroll .list-table {
  min-width: 980px;
}

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

th {
  color: var(--muted);
  font-weight: 650;
}

.total-row td {
  background: var(--soft);
  font-weight: 700;
}

.club-logo-preview {
  display: block;
  max-width: 320px;
  max-height: 180px;
  object-fit: contain;
  margin-bottom: 18px;
}

.profile-preview {
  width: 140px;
  height: 140px;
  border-radius: 999px;
  background: var(--soft);
  display: grid;
  place-items: center;
  overflow: hidden;
  margin-bottom: 18px;
  font-size: 48px;
  font-weight: 800;
  color: var(--accent-strong);
}

#permission-editor input[type="checkbox"] {
  width: 13px;
  min-height: 13px;
  padding: 0;
}

.permissions-table {
  table-layout: fixed;
  width: 100%;
  max-width: 100%;
  font-size: 13px;
}

.permissions-table th,
.permissions-table td {
  padding: 8px 10px;
  vertical-align: middle;
}

.permissions-table th:not(:first-child),
.permissions-table td:not(:first-child) {
  width: 76px;
  text-align: center;
}

.permissions-table th:first-child,
.permissions-table td:first-child {
  width: auto;
}

.permissions-table input[type="checkbox"] {
  margin: 0 auto;
}

.sort-button {
  border: 0;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  font: inherit;
  font-weight: 650;
  min-height: 28px;
  padding: 0;
  text-align: left;
}

.sort-button:hover {
  color: var(--accent-strong);
}

.right {
  text-align: right;
}

.muted {
  color: var(--muted);
}

.pill {
  display: inline-flex;
  border-radius: 999px;
  padding: 3px 8px;
  background: #edf2ea;
  color: #31513f;
  font-size: 12px;
}

.select-list {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
  gap: 8px;
  max-height: 260px;
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 10px;
}

.select-list label {
  color: var(--text);
}

.rate-select-grid {
  display: grid;
  gap: 12px;
}

.search-field {
  margin-bottom: 12px;
}

.list-toolbar {
  display: flex;
  justify-content: flex-start;
  margin: 0 0 12px;
}

.inline-editor {
  margin: 0 0 16px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fbfcfa;
}

.inline-editor h3 {
  margin-top: 0;
}

.summary-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 12px;
  margin-bottom: 16px;
}

.summary-grid div {
  display: grid;
  gap: 4px;
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 10px;
  background: #fbfcfa;
}

.summary-grid strong {
  font-size: 14px;
}

.invoice-controls {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 12px;
  margin-bottom: 12px;
}

.invoice-duplex {
  align-self: end;
  min-height: 38px;
  padding-bottom: 6px;
}

.segmented {
  display: inline-grid;
  grid-template-columns: repeat(2, minmax(180px, 1fr));
  gap: 4px;
  padding: 4px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #f1f5ee;
}

.segmented label {
  display: block;
  font-size: 14px;
  color: var(--text);
}

.segmented input {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}

.segmented span {
  display: grid;
  place-items: center;
  min-height: 38px;
  padding: 8px 12px;
  border-radius: 6px;
  cursor: pointer;
}

.segmented input:checked + span {
  background: var(--accent);
  color: #fff;
}

.example-table-wrap {
  overflow-x: auto;
}

.example-calculator-panel {
  display: grid;
  gap: 18px;
}

.example-calculator-head {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(220px, 300px);
  gap: 16px;
  align-items: start;
}

.example-calculator-head h2 {
  margin-bottom: 4px;
}

.example-total-card {
  border: 1px solid #b8d1c0;
  border-radius: 8px;
  background: #eef7ef;
  padding: 14px 16px;
}

.example-total-card span {
  display: block;
  color: var(--muted);
  font-size: 13px;
  font-weight: 650;
}

.example-total-card strong {
  display: block;
  margin-top: 4px;
  color: var(--accent-strong);
  font-size: 24px;
  line-height: 1.15;
}

.example-input-card {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfcfa;
  padding: 10px;
}

.example-table label {
  color: var(--muted);
}

.example-table input {
  min-width: 160px;
}

.content-input-table {
  table-layout: fixed;
}

.content-input-table th {
  background: #eef3ea;
}

.content-input-table td:first-child {
  font-weight: 700;
}

.content-input-table th:first-child,
.content-input-table td:first-child {
  width: 34%;
}

.content-input-table th:nth-child(2),
.content-input-table td:nth-child(2),
.content-input-table th:nth-child(3),
.content-input-table td:nth-child(3) {
  width: 33%;
}

.content-input-table label {
  min-width: 0;
}

.content-input-table input,
.content-input-table select {
  min-width: 0;
}

.input-error {
  border-color: var(--danger);
  box-shadow: 0 0 0 2px rgb(166 55 45 / 12%);
}

.field-error {
  display: block;
  color: var(--danger);
  font-size: 12px;
  font-weight: 650;
  line-height: 1.35;
  max-width: 100%;
  overflow-wrap: anywhere;
  white-space: normal;
}

.field-error.is-empty {
  visibility: hidden;
}

.analysis-block {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  overflow: hidden;
}

.analysis-block h3 {
  margin: 0;
  padding: 12px 14px;
  border-bottom: 1px solid var(--line);
  background: #edf2ea;
  color: var(--accent-strong);
  font-size: 18px;
}

.analysis-table {
  table-layout: fixed;
}

.analysis-table th,
.analysis-table td {
  vertical-align: top;
}

.analysis-table th {
  background: #f6f8f4;
  color: var(--muted);
}

.analysis-table th:first-child,
.analysis-table td:first-child {
  width: 22%;
}

.analysis-table th:nth-child(2),
.analysis-table td:nth-child(2) {
  width: 39%;
}

.analysis-table th:nth-child(3),
.analysis-table td:nth-child(3) {
  width: 39%;
}

.analysis-table p {
  margin: 0;
}

.analysis-table p + p {
  margin-top: 8px;
}

.analysis-table td:nth-child(3) {
  background: #fbfcfa;
}

.analysis-table .evaluation-item {
  border-left: 3px solid #b8d1c0;
  padding-left: 10px;
}

.evaluation-item strong {
  color: var(--text);
}

.error-text {
  color: var(--danger);
  font-weight: 650;
}

.error-text strong {
  color: var(--danger);
}

.compact-summary {
  margin-top: 14px;
}

.warning-box {
  border: 1px solid #d7b469;
  border-radius: 8px;
  background: #fff7df;
  color: #3f2f0b;
  padding: 12px;
  margin-top: 12px;
}

.example-warning-stack {
  display: grid;
  gap: 10px;
}

.example-warning-stack .warning-box {
  margin-top: 0;
}

.example-print-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: end;
  gap: 10px;
  justify-content: flex-start;
}

.example-email-form {
  display: flex;
  flex-wrap: wrap;
  align-items: end;
  gap: 10px;
}

.example-email-form label {
  min-width: 240px;
}

.warning-box p {
  margin: 8px 0 0;
}

.warning-box ul {
  margin: 8px 0 0;
  padding-left: 20px;
}

.danger-warning {
  border-color: #d7b469;
  background: #fff7df;
  color: #3f2f0b;
}

.memory-note {
  border: 1px solid #9cc6a9;
  border-radius: 8px;
  background: #eef8ef;
  color: #1f4a31;
  padding: 12px;
}

.memory-note p {
  margin: 8px 0 0;
}

.example-final-note {
  margin: 0;
  color: var(--text);
  line-height: 1.45;
}

.placeholder-text {
  font-weight: 800;
  letter-spacing: 0;
}

.legend {
  border-top: 1px solid var(--line);
  margin-top: 4px;
  padding-top: 10px;
  color: var(--muted);
  font-size: 13px;
}

.legend h3 {
  color: var(--text);
  margin-bottom: 6px;
}

.legend p {
  margin: 4px 0;
}

.rate-groups {
  display: grid;
  gap: 10px;
  margin-top: 14px;
}

.rate-group {
  border: 1px solid var(--line);
  border-radius: 8px;
  overflow: hidden;
  background: #fff;
}

.group-header {
  width: 100%;
  border: 0;
  min-height: 48px;
  padding: 10px 12px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  background: #f1f5ee;
  color: var(--text);
  cursor: pointer;
  text-align: left;
}

.group-header span:first-child {
  display: grid;
  gap: 2px;
}

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

.group-body {
  padding: 10px 12px 12px;
}

.group-print-text {
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fbfcfa;
  padding: 10px;
  margin-bottom: 10px;
}

.group-print-text p {
  margin: 4px 0 0;
  white-space: normal;
}

.group-actions {
  justify-content: flex-end;
  margin-top: 10px;
}

.total {
  font-weight: 700;
  font-size: 18px;
}

@media (max-width: 1100px) {
  body {
    grid-template-columns: 1fr;
    overflow-x: hidden;
  }

  .sidebar {
    position: sticky;
    top: 0;
    z-index: 20;
    padding: 12px 16px;
    box-shadow: 0 8px 20px rgb(10 24 16 / 18%);
  }

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

  .brand {
    display: flex;
    align-items: center;
    gap: 10px;
    min-width: 0;
    margin-bottom: 0;
  }

  .brand-logo {
    width: 74px;
    max-height: 48px;
    margin: 0;
    flex: 0 0 auto;
  }

  .brand strong {
    overflow-wrap: anywhere;
  }

  .menu-toggle {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    flex: 0 0 auto;
  }

  nav {
    display: none;
    gap: 8px;
    margin-top: 12px;
    max-height: calc(100vh - 120px);
    overflow-y: auto;
    padding-right: 2px;
  }

  body.menu-open nav {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  }

  .nav {
    width: 100%;
    white-space: normal;
    text-align: left;
  }

  main {
    padding: 16px;
  }

  .cols,
  .form-row,
  .stats {
    grid-template-columns: 1fr;
  }

  header {
    align-items: flex-start;
  }

  header h1 {
    min-width: 0;
    overflow-wrap: anywhere;
  }

  .header-actions {
    flex: 0 0 auto;
  }

  .example-calculator-head {
    grid-template-columns: 1fr;
  }

  .example-print-actions,
  .example-email-form {
    align-items: stretch;
  }

  .example-email-form label {
    min-width: min(280px, 100%);
  }

  table:not(.permissions-table):not(.content-input-table):not(.analysis-table),
  .example-table-wrap {
    display: block;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
  }

  .table-scroll table {
    display: table;
    overflow: visible;
  }

  .permissions-table,
  .content-input-table,
  .analysis-table {
    min-width: 760px;
  }
}

@media (max-width: 640px) {
  .sidebar {
    padding: 10px 12px;
  }

  .brand {
    gap: 8px;
  }

  .brand-logo {
    width: 58px;
    max-height: 38px;
  }

  .brand strong {
    font-size: 17px;
    line-height: 1.1;
  }

  .brand span {
    font-size: 12px;
  }

  .menu-toggle {
    min-width: 68px;
  }

  body.menu-open nav {
    grid-template-columns: 1fr;
  }

  .nav,
  .primary,
  .secondary,
  .danger {
    min-height: 36px;
    padding: 7px 10px;
  }

  main {
    padding: 12px;
  }

  header {
    gap: 10px;
    margin-bottom: 14px;
  }

  h1 {
    font-size: 24px;
  }

  h2 {
    font-size: 18px;
  }

  .account-trigger {
    width: 40px;
    height: 40px;
    min-height: 40px;
  }

  .account-dropdown {
    top: 46px;
    right: 0;
  }

  .panel,
  .card {
    border-radius: 6px;
  }

  .panel {
    padding: 14px;
  }

  .segmented {
    display: grid;
    grid-template-columns: 1fr;
    width: 100%;
  }

  .example-total-card strong {
    font-size: 21px;
  }

  .actions,
  .example-print-actions,
  .example-email-form {
    display: grid;
    grid-template-columns: 1fr;
  }

  .actions button,
  .example-print-actions button,
  .example-email-form button {
    width: 100%;
  }

  input,
  select,
  textarea {
    min-height: 40px;
  }

  .summary-grid,
  .invoice-controls,
  .cards {
    grid-template-columns: 1fr;
  }

  .content-input-table,
  .analysis-table {
    min-width: 680px;
  }

  .table-scroll table {
    min-width: 760px;
  }
}

@page {
  size: A4 portrait;
  margin: 15mm;
}

@media print {
  body {
    display: block;
    min-height: auto;
    background: #fff;
    color: #000;
    font-size: 9pt;
  }

  .sidebar,
  main > header,
  #app > .grid > .panel:first-child,
  .example-print-actions {
    display: none !important;
  }

  main {
    padding: 0;
  }

  #app,
  #app > .grid {
    display: block;
  }

  .example-calculator-panel {
    border: 0;
    border-radius: 0;
    padding: 0;
    gap: 8mm;
  }

  .example-calculator-head {
    grid-template-columns: minmax(0, 1fr) 58mm;
    gap: 8mm;
  }

  .example-total-card,
  .example-input-card,
  .analysis-block,
  .warning-box,
  .memory-note {
    break-inside: avoid;
  }

  .example-table-wrap,
  table {
    display: block;
    overflow: visible;
  }

  table {
    width: 100%;
  }

  th,
  td {
    padding: 5px 6px;
  }

  input,
  select {
    border: 0;
    padding: 0;
    background: transparent;
    color: #000;
    appearance: none;
  }

  .field-error.is-empty,
  .account-menu {
    display: none !important;
  }
}
