:root {
  --green: #217346;
  --green-dark: #0e5c2f;
  --ink: #242424;
  --muted: #605e5c;
  --line: #d0d0d0;
  --paper: #ffffff;
  --wash: #f3f2f1;
  --today: #c7e6d4;
}

* { box-sizing: border-box; }

html, body { height: 100%; }

body {
  margin: 0;
  font-family: "Segoe UI", Calibri, Arial, sans-serif;
  color: var(--ink);
  background: var(--wash);
}

.site {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

.site-head {
  min-height: 52px;
  background: var(--green);
  color: #fff;
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 12px 22px;
  padding: 8px 16px;
}

.brand {
  color: #fff;
  font-size: 18px;
  font-weight: 700;
  text-decoration: none;
}

.site-nav {
  display: flex;
  gap: 6px;
}

.site-nav a {
  color: #fff;
  text-decoration: none;
  padding: 6px 10px;
  border-radius: 4px;
  font-size: 14px;
}

.site-nav a.is-current {
  background: rgba(255, 255, 255, 0.18);
}

.signal-app {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

.site .signal-app {
  min-height: 0;
  flex: 1;
}

.titlebar {
  height: 48px;
  background: var(--green);
  color: #fff;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 0 16px;
  font-weight: 650;
}

.mark {
  width: 22px;
  height: 22px;
  background: #fff;
  color: var(--green);
  border-radius: 2px;
  display: grid;
  place-items: center;
  font-size: 14px;
  font-weight: 700;
}

.toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  gap: 14px 18px;
  padding: 12px 16px;
  background: var(--paper);
  border-bottom: 1px solid #edebe9;
}

.field {
  display: flex;
  flex-direction: column;
  gap: 4px;
  font-size: 12px;
  color: var(--muted);
}

.field input {
  height: 32px;
  width: 150px;
  border: 1px solid #c8c6c4;
  padding: 0 8px;
  font: 15px Calibri, "Segoe UI", sans-serif;
  color: var(--ink);
  background: #fff;
}

.field input:focus {
  outline: 2px solid var(--green);
  border-color: transparent;
}

.hint {
  flex: 1 1 220px;
  margin: 0;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.35;
}

.quotas {
  flex: 1 1 100%;
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  gap: 8px 10px;
}

.quotas-label {
  flex: 1 1 100%;
  font-size: 12px;
  color: var(--muted);
}

.field.quota input {
  width: 56px;
  text-align: center;
}

.workspace {
  flex: 1;
  display: grid;
  grid-template-columns: minmax(0, 1.45fr) minmax(300px, 0.8fr);
  gap: 16px;
  padding: 16px;
  align-items: start;
}

.months {
  display: grid;
  gap: 16px;
}

.month {
  background: var(--paper);
  border: 1px solid var(--line);
  padding: 12px;
}

.month h2 {
  margin: 0 0 10px;
  font-size: 18px;
  font-weight: 650;
}

.weekdays,
.grid {
  display: grid;
  grid-template-columns: repeat(7, minmax(0, 1fr));
  gap: 4px;
}

.weekdays span {
  text-align: center;
  font-size: 12px;
  color: var(--muted);
  font-weight: 650;
  padding-bottom: 4px;
}

.weekdays span.weekend { color: #a4262c; }

.pad { min-height: 74px; }

.day {
  min-height: 74px;
  border: 1px solid var(--line);
  background: #fafafa;
  color: inherit;
  text-align: left;
  padding: 6px;
  display: flex;
  flex-direction: column;
  gap: 2px;
  cursor: pointer;
  font: inherit;
}

.day:hover { background: #f3faf6; }

.day.has-data {
  background: #fff;
  border-color: #b7d7c4;
}

.day.today { box-shadow: inset 0 0 0 1px var(--green); }

.day.selected {
  background: #e8f5ee;
  border-color: var(--green-dark);
  box-shadow: inset 0 0 0 2px var(--green-dark);
}

.day-num {
  font-size: 14px;
  font-weight: 700;
}

.day.weekend .day-num { color: #a4262c; }

.day-range,
.day-sum {
  font-size: 11px;
  line-height: 1.2;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
}

.day.has-data .day-sum {
  color: var(--ink);
  font-size: 12px;
}

.detail {
  background: var(--paper);
  border: 1px solid var(--line);
  position: sticky;
  top: 12px;
}

.detail-head {
  padding: 12px 14px 8px;
  border-bottom: 1px solid #edebe9;
}

.detail-head h2 {
  margin: 0;
  font-size: 18px;
  font-weight: 650;
}

.detail-head p {
  margin: 4px 0 0;
  color: var(--muted);
  font-size: 13px;
}

.sheet-wrap { overflow: auto; }

table.sheet {
  width: 100%;
  border-collapse: separate;
  border-spacing: 0;
  table-layout: fixed;
}

.sheet th,
.sheet td {
  border-right: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
  height: 28px;
  padding: 0;
  font-weight: 400;
}

.sheet th {
  background: #f4f4f4;
  color: #616161;
  font-size: 12px;
  font-weight: 650;
  text-align: center;
}

.sheet td.rowhead,
.sheet th.corner {
  width: 52px;
  text-align: center;
  background: #f4f4f4;
  color: #616161;
  font-size: 12px;
}

.sheet td.num {
  text-align: right;
  padding: 0 10px;
  font-family: Calibri, "Segoe UI", sans-serif;
  font-size: 15px;
  font-variant-numeric: tabular-nums;
  cursor: cell;
}

.sheet tr:hover td.num { background: #f3faf6; }

.sheet td.selected { box-shadow: inset 0 0 0 2px var(--green-dark); }

.formula-bar {
  display: grid;
  grid-template-columns: 64px 1fr;
  gap: 8px;
  align-items: center;
  padding: 8px 12px 12px;
  color: #605e5c;
  font-size: 13px;
}

.formula-bar strong {
  font-weight: 650;
  color: var(--ink);
}

.empty-day {
  padding: 20px 14px 24px;
  color: var(--muted);
}

.statusbar {
  height: 28px;
  background: var(--green);
  color: #fff;
  display: flex;
  align-items: center;
  padding: 0 14px;
  font-size: 12px;
}

@media (max-width: 980px) {
  .workspace { grid-template-columns: 1fr; }
  .detail { position: static; }
}

.home-layout {
  width: min(1100px, calc(100% - 32px));
  margin: 20px auto 32px;
  display: grid;
  grid-template-columns: minmax(0, 1fr) 280px;
  gap: 20px;
  align-items: start;
}

.home-main h1 {
  margin: 0 0 8px;
  font-size: 32px;
  font-weight: 650;
}

.home-lead {
  margin: 0 0 18px;
  max-width: 40rem;
  color: var(--muted);
  line-height: 1.45;
}

.home-cards {
  display: grid;
  gap: 12px;
}

.home-card {
  display: block;
  background: #fff;
  border: 1px solid var(--line);
  padding: 16px 18px;
  text-decoration: none;
  color: inherit;
}

.home-card h2 {
  margin: 0 0 6px;
  font-size: 18px;
  color: var(--green-dark);
}

.home-card p {
  margin: 0;
  color: var(--muted);
  line-height: 1.4;
}

.home-card:hover { border-color: var(--green); }

.ads {
  background: #fff;
  border: 1px solid var(--line);
  padding: 14px;
}

.ads h2 {
  margin: 0 0 10px;
  font-size: 14px;
  font-weight: 650;
  color: var(--muted);
}

.ad-slot {
  min-height: 180px;
  border: 1px dashed #b7b7b7;
  background: #fafafa;
  display: flex;
  align-items: center;
  justify-content: center;
  margin-bottom: 10px;
  overflow: hidden;
  text-align: center;
  padding: 12px;
}

.ad-slot:last-child { margin-bottom: 0; }

.ad-placeholder,
.ad-hint,
.ad-label {
  color: #8a8886;
  font-size: 13px;
}

.ad-hint { margin: 8px 0 0; }

.ad-slot img,
.ad-slot iframe {
  max-width: 100%;
  height: auto;
}

.ledger {
  width: min(960px, calc(100% - 32px));
  margin: 20px auto 32px;
}

.ledger h1 {
  margin: 0 0 8px;
  font-size: 28px;
  font-weight: 650;
}

.ledger-note {
  margin: 0 0 14px;
  color: var(--muted);
  line-height: 1.4;
}

.ledger-bar,
.ledger-form {
  display: flex;
  flex-wrap: wrap;
  gap: 10px 14px;
  align-items: flex-end;
  background: #fff;
  border: 1px solid var(--line);
  padding: 12px;
  margin-bottom: 12px;
}

.ledger select {
  height: 32px;
  border: 1px solid #c8c6c4;
  background: #fff;
  font: 15px Calibri, "Segoe UI", sans-serif;
  padding: 0 8px;
}

.ledger-table-wrap {
  background: #fff;
  border: 1px solid var(--line);
  overflow: auto;
}

.ledger table {
  width: 100%;
  border-collapse: collapse;
}

.ledger th,
.ledger td {
  border-bottom: 1px solid var(--line);
  padding: 8px 10px;
  text-align: left;
  font-weight: 400;
  font-size: 14px;
}

.ledger th.num,
.ledger td.num {
  text-align: right;
  font-variant-numeric: tabular-nums;
}

.ledger td.empty {
  color: var(--muted);
  text-align: center;
  padding: 18px 10px;
}

.totals {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
  margin-top: 12px;
}

.total {
  background: #fff;
  border: 1px solid var(--line);
  padding: 12px;
}

.total span {
  display: block;
  color: var(--muted);
  font-size: 12px;
  margin-bottom: 4px;
}

.total strong {
  font-size: 20px;
  font-variant-numeric: tabular-nums;
}

.total.result strong { color: var(--green-dark); }
.total.result.is-negative strong { color: #a4262c; }

button.primary {
  height: 32px;
  background: var(--green);
  color: #fff;
  border: 0;
  padding: 0 14px;
  cursor: pointer;
  font: 14px "Segoe UI", sans-serif;
}

button.quiet {
  border: 0;
  background: transparent;
  color: #a4262c;
  cursor: pointer;
  font: 13px "Segoe UI", sans-serif;
}

@media (max-width: 800px) {
  .home-layout,
  .totals { grid-template-columns: 1fr; }
}
.auth-page {
  width: min(440px, 100%);
  margin: 28px auto;
  padding: 0 16px 32px;
}

.auth-page.cabinet { width: min(640px, 100%); }

.auth-card {
  background: #fff;
  border: 1px solid var(--line);
  padding: 22px 20px 18px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.auth-card h1 { margin: 0 0 4px; font-size: 24px; }

.auth-card .field {
  display: flex;
  flex-direction: column;
  gap: 4px;
  font-size: 13px;
  color: var(--muted);
}

.auth-card input {
  height: 34px;
  border: 1px solid #c8c6c4;
  padding: 0 8px;
  font: 15px Calibri, "Segoe UI", sans-serif;
  width: 100%;
}

.auth-card button.primary { align-self: flex-start; }

.auth-error { margin: 0; color: #a4262c; font-size: 14px; }

.auth-links { margin: 4px 0 0; font-size: 14px; }

.auth-links a { color: var(--green-dark); }

.cabinet-line {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  margin: 0;
  font-size: 15px;
}

.cabinet-line span { color: var(--muted); }

.cabinet .home-cards { margin-top: 6px; }

.cabinet .quiet { align-self: flex-start; margin-top: 4px; }
.cabinet-shell {
  display: grid;
  grid-template-columns: 220px minmax(0, 1fr);
  gap: 16px;
  width: min(1100px, calc(100% - 32px));
  margin: 20px auto 32px;
}

.cabinet-menu {
  background: #fff;
  border: 1px solid var(--line);
  padding: 8px;
  display: flex;
  flex-direction: column;
  align-self: start;
}

.cabinet-menu a,
.cabinet-menu button {
  display: block;
  width: 100%;
  text-align: left;
  text-decoration: none;
  color: var(--ink);
  background: transparent;
  border: 0;
  padding: 8px 10px;
  font: 14px "Segoe UI", sans-serif;
  cursor: pointer;
}

.cabinet-menu a.is-current {
  background: var(--today);
  color: var(--green-dark);
  font-weight: 600;
}

.cabinet-body {
  background: #fff;
  border: 1px solid var(--line);
  padding: 18px 18px 22px;
  min-width: 0;
}

.cabinet-body h1 {
  margin: 0 0 8px;
  font-size: 28px;
  font-weight: 650;
}

.cabinet-body .home-cards { margin-top: 8px; }

.doc-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px 14px;
  margin-top: 14px;
}

.doc-grid .field input,
.doc-grid .field select,
.line-row input {
  width: 100%;
}

.field-wide { grid-column: 1 / -1; }

.row-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px 12px;
  align-items: center;
  margin: 12px 0;
}

.row-actions button,
.line-row button {
  height: 32px;
  border: 1px solid #c8c6c4;
  background: #fff;
  padding: 0 12px;
  cursor: pointer;
  font: 14px "Segoe UI", sans-serif;
}

.row-actions button.primary {
  border: 0;
  background: var(--green);
  color: #fff;
}

.cabinet-body select {
  height: 32px;
  border: 1px solid #c8c6c4;
  background: #fff;
  font: 15px Calibri, "Segoe UI", sans-serif;
  padding: 0 8px;
  width: 100%;
}

.cabinet-body .ledger-table-wrap { margin-top: 8px; }

.cabinet-body table {
  width: 100%;
  border-collapse: collapse;
}

.cabinet-body th,
.cabinet-body td {
  border-bottom: 1px solid var(--line);
  padding: 8px 10px;
  text-align: left;
  font-weight: 400;
  font-size: 14px;
}

.cabinet-body th.num,
.cabinet-body td.num { text-align: right; font-variant-numeric: tabular-nums; }

.cabinet-body td.empty {
  color: var(--muted);
  text-align: center;
  padding: 18px 10px;
}

.cabinet-body tr.is-picked { background: #eef6f1; }

.line-head,
.line-row {
  display: grid;
  grid-template-columns: minmax(0, 1.6fr) 90px 120px 120px 88px;
  gap: 8px;
  align-items: center;
}

.line-head {
  margin-top: 8px;
  color: var(--muted);
  font-size: 12px;
}

.line-row { margin-top: 8px; }

.line-sum { text-align: right; font-variant-numeric: tabular-nums; }

.invoice-sums {
  display: flex;
  flex-wrap: wrap;
  gap: 8px 18px;
  margin-top: 8px;
}

.invoice-sheet {
  margin-top: 18px;
  padding-top: 12px;
  border-top: 1px solid var(--line);
}

.invoice-sheet h1 { font-size: 22px; }

.sheet-sides {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
}

.invoice-sheet h2 { margin: 0 0 6px; font-size: 16px; }

.invoice-sheet p { margin: 0 0 10px; line-height: 1.4; }

.invoice-sheet table { margin-top: 8px; }

.sheet-total { text-align: right; }

@media (max-width: 800px) {
  .cabinet-shell,
  .doc-grid,
  .sheet-sides,
  .line-head,
  .line-row { grid-template-columns: 1fr; }
}

@media print {
  .site-head, .cabinet-menu, .no-print { display: none !important; }
  .cabinet-shell { display: block; width: auto; margin: 0; }
  .cabinet-body { border: 0; padding: 0; }
  .invoice-sheet { border: 0; }
}

.field[hidden] { display: none !important; }
