:root {
  --paper: #fff;
  --ink: #171717;
  --muted: #686868;
  --line: #b8b8b8;
  --soft: #eeeeee;
  --accent: #205c4d;
  --accent-dark: #174339;
  --danger: #8a2525;
  --bg: #f4f5f2;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  color: var(--ink);
  background: var(--bg);
  font-family: Arial, Helvetica, sans-serif;
}

body.locked .app-shell {
  display: none;
}

body:not(.locked) .login-screen {
  display: none;
}

button,
input,
select {
  font: inherit;
}

button {
  min-height: 38px;
  border: 1px solid var(--accent);
  border-radius: 6px;
  color: #fff;
  background: var(--accent);
  padding: 8px 13px;
  cursor: pointer;
}

button:hover {
  background: var(--accent-dark);
}

button.danger {
  border-color: var(--danger);
  background: #fff;
  color: var(--danger);
}

button.danger:hover {
  background: #f8eaea;
}

input,
select {
  width: 100%;
  min-height: 38px;
  border: 1px solid #bfc5bd;
  border-radius: 6px;
  background: #fff;
  padding: 8px 10px;
}

label {
  display: grid;
  gap: 6px;
  color: #343434;
  font-size: 13px;
  font-weight: 700;
}

.app-shell {
  max-width: 1260px;
  margin: 0 auto;
  padding: 24px;
}

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

.login-box {
  width: min(100%, 390px);
  display: grid;
  gap: 14px;
  border: 1px solid #d0d4ce;
  border-radius: 8px;
  background: #fff;
  padding: 22px;
}

.login-box h1 {
  font-size: 25px;
}

.login-error {
  min-height: 18px;
  margin: 0;
  color: var(--danger);
  font-size: 13px;
  font-weight: 700;
}

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

.panel-header,
.control-bar,
.section-title {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
}

.panel-header {
  border-bottom: 2px solid #d1d4ce;
  padding-bottom: 16px;
}

.eyebrow {
  margin: 0 0 4px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0;
  text-transform: uppercase;
}

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

h1 {
  font-size: 31px;
}

h2 {
  font-size: 19px;
}

.header-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  justify-content: flex-end;
  align-items: end;
}

.paid-month-control {
  min-width: 155px;
  color: #343434;
  text-align: left;
}

.paid-month-control select {
  min-height: 38px;
}

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

.menu-tab {
  border-color: #bfc5bd;
  background: #fff;
  color: var(--ink);
}

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

.menu-panel {
  display: none;
}

.menu-panel.active {
  display: grid;
  gap: 18px;
}

.control-bar {
  display: grid;
  grid-template-columns: minmax(220px, 1fr) auto auto;
  align-items: end;
}

.backup-bar {
  display: grid;
  grid-template-columns: minmax(240px, 1fr) auto auto auto;
  align-items: end;
  gap: 14px;
  border: 1px solid #d0d4ce;
  border-radius: 8px;
  background: #fff;
  padding: 12px 16px;
}

.save-status {
  grid-column: 1 / -1;
  margin: 0;
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
}

.save-status.unsaved {
  color: var(--danger);
}

.editor-grid {
  display: grid;
  grid-template-columns: minmax(260px, 390px) minmax(320px, 1fr);
  gap: 18px;
  align-items: start;
}

.client-form {
  display: grid;
  gap: 12px;
  border: 1px solid #d0d4ce;
  border-radius: 8px;
  background: #fff;
  padding: 16px;
}

.client-form button {
  width: fit-content;
}

.receipt-preview-wrap {
  display: grid;
  place-items: start center;
  min-height: 285px;
}

.client-list,
.archive-list {
  display: grid;
  gap: 8px;
}

.client-list-section {
  display: grid;
  gap: 12px;
}

.object-report-section {
  display: grid;
  gap: 12px;
  border: 1px solid #d0d4ce;
  border-radius: 8px;
  background: #fff;
  padding: 16px;
}

.object-report-controls {
  max-width: 430px;
}

.search-field {
  max-width: 430px;
}

.client-row,
.archive-row {
  display: grid;
  grid-template-columns: 28px 1.1fr 1fr 120px;
  align-items: center;
  gap: 10px;
  border: 1px solid #d0d4ce;
  border-radius: 8px;
  background: #fff;
  padding: 10px 12px;
}

.archive-row {
  grid-template-columns: 28px 90px 1fr 1fr 145px;
}

.client-row input,
.archive-row input,
.select-all-line input {
  width: 18px;
  min-height: 18px;
}

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

.report-summary {
  display: flex;
  flex-wrap: wrap;
  gap: 16px;
  align-items: center;
  color: #242424;
}

.object-report-table {
  overflow-x: auto;
}

.object-report-table table {
  width: 100%;
  border-collapse: collapse;
}

.object-report-table th,
.object-report-table td {
  border: 1px solid #d0d4ce;
  padding: 9px 10px;
  text-align: left;
}

.object-report-table th {
  background: var(--soft);
  font-weight: 800;
}

.select-all-line {
  display: flex;
  align-items: center;
  gap: 8px;
  white-space: nowrap;
}

.receipt {
  width: 100%;
  min-height: 84mm;
  border: 1.4px solid var(--ink);
  background: var(--paper);
  color: var(--ink);
  overflow: hidden;
}

.receipt-preview {
  width: min(100%, 640px);
  min-height: 235px;
}

.receipt-title {
  display: grid;
  place-items: center;
  min-height: 30px;
  border-bottom: 1.4px solid var(--ink);
  background: var(--soft);
  font-size: 18px;
  font-weight: 800;
  text-transform: uppercase;
}

.receipt-body {
  display: grid;
  gap: 10px;
  padding: 13px 14px;
}

.top-line,
.middle-line,
.bottom-line {
  display: grid;
  gap: 8px;
}

.top-line {
  grid-template-columns: 1fr 1fr;
}

.middle-line {
  grid-template-columns: 1fr 145px;
  align-items: end;
  border-top: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
  padding: 10px 0;
}

.bottom-line {
  grid-template-columns: 1.15fr 0.85fr;
}

.field-label {
  display: block;
  color: #2b2b2b;
  font-size: 11px;
  font-weight: 800;
  text-transform: uppercase;
}

.field-value {
  display: block;
  min-height: 20px;
  padding-top: 3px;
  font-size: 15px;
  font-weight: 700;
  word-break: break-word;
}

.service-text {
  font-size: 17px;
  font-weight: 800;
  text-transform: uppercase;
}

.print-area {
  display: none;
}

.a4-page {
  width: 210mm;
  min-height: 297mm;
  display: grid;
  grid-template-rows: repeat(4, 1fr);
  gap: 0;
  background: #fff;
}

.a4-page .receipt {
  height: 74.25mm;
  min-height: 74.25mm;
  border-width: 1px;
  page-break-inside: avoid;
}

@media (max-width: 820px) {
  .app-shell {
    padding: 16px;
  }

  .panel-header,
  .section-title {
    align-items: stretch;
    flex-direction: column;
  }

  .header-actions,
  .main-menu,
  .control-bar,
  .backup-bar,
  .editor-grid,
  .top-line,
  .middle-line,
  .bottom-line,
  .client-row,
  .archive-row {
    grid-template-columns: 1fr;
  }

  .header-actions {
    justify-content: stretch;
  }
}

@media print {
  @page {
    size: A4 portrait;
    margin: 0;
  }

  body {
    background: #fff;
  }

  .admin-panel {
    display: none;
  }

  .app-shell {
    max-width: none;
    margin: 0;
    padding: 0;
  }

  .print-area {
    display: block;
  }

  .a4-page {
    page-break-after: always;
  }
}
