:root {
  color-scheme: light;
  --bg: #f4f6f8;
  --surface: #ffffff;
  --surface-soft: #f7f9fb;
  --ink: #17202a;
  --muted: #667085;
  --line: #d8dee6;
  --line-strong: #bac4d0;
  --green: #167a58;
  --green-soft: #e5f5ed;
  --red: #b23b3b;
  --red-soft: #fde8e8;
  --yellow: #a86800;
  --yellow-soft: #fff0d1;
  --blue: #2563a9;
  --blue-soft: #e6f0fb;
  --purple: #7057a6;
  --purple-soft: #eee9fb;
  --sidebar: #1f2b25;
  --shadow: 0 16px 42px rgba(19, 33, 48, 0.08);
  --radius: 8px;
}

* {
  box-sizing: border-box;
}

html {
  min-width: 320px;
}

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

body.modal-open {
  overflow: hidden;
}

body.auth-locked {
  overflow: hidden;
}

[hidden] {
  display: none !important;
}

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

button {
  cursor: pointer;
}

.shell {
  display: grid;
  grid-template-columns: 246px minmax(0, 1fr);
  min-height: 100vh;
}

body.auth-locked .shell,
body.auth-locked .plan-error-modal,
body.auth-locked .app-modal {
  display: none !important;
}

.auth-gate {
  display: none;
}

body.auth-locked .auth-gate {
  display: grid;
  min-height: 100vh;
  place-items: center;
  padding: 24px;
  background:
    linear-gradient(120deg, rgba(31, 43, 37, 0.94), rgba(23, 32, 42, 0.86)),
    var(--bg);
}

.auth-card {
  display: grid;
  width: min(440px, 100%);
  gap: 20px;
  padding: 28px;
  border: 1px solid rgba(255, 255, 255, 0.18);
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: var(--shadow);
}

.auth-brand {
  display: flex;
  align-items: center;
  gap: 12px;
  min-height: 46px;
}

.auth-brand small,
.auth-copy,
.auth-message {
  color: var(--muted);
}

.auth-card h1 {
  margin: 6px 0 0;
  font-size: 34px;
  line-height: 1.05;
}

.auth-copy {
  margin: 8px 0 0;
  line-height: 1.45;
}

.auth-form {
  display: grid;
  gap: 12px;
}

.auth-form label {
  display: grid;
  gap: 6px;
}

.auth-form label span {
  color: var(--muted);
  font-size: 12px;
  font-weight: 850;
}

.auth-form input {
  width: 100%;
  min-height: 42px;
  padding: 0 12px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--ink);
}

.auth-message {
  min-height: 20px;
  margin: 0;
  font-size: 13px;
  line-height: 1.45;
}

.auth-message.ok {
  color: var(--green);
}

.auth-message.error {
  color: var(--red);
}

.sidebar {
  position: sticky;
  top: 0;
  display: flex;
  flex-direction: column;
  gap: 22px;
  height: 100vh;
  padding: 22px 14px;
  background: var(--sidebar);
  color: #ffffff;
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  min-height: 46px;
}

.brand-mark {
  display: grid;
  place-items: center;
  width: 44px;
  height: 44px;
  border-radius: var(--radius);
  background: #f2c94c;
  color: #1f2b25;
  font-weight: 900;
}

.brand strong,
.brand small,
.label {
  display: block;
}

.brand strong {
  font-size: 15px;
  line-height: 1.15;
}

.brand small {
  margin-top: 3px;
  color: rgba(255, 255, 255, 0.64);
  font-size: 12px;
}

.nav {
  display: grid;
  gap: 6px;
}

.nav-item {
  display: grid;
  grid-template-columns: 20px 1fr;
  align-items: center;
  gap: 10px;
  min-height: 42px;
  padding: 0 12px;
  border: 0;
  border-radius: var(--radius);
  background: transparent;
  color: rgba(255, 255, 255, 0.72);
  text-align: left;
}

.nav-item:hover,
.nav-item.active {
  background: rgba(255, 255, 255, 0.1);
  color: #ffffff;
}

.nav-item svg,
.icon-button svg,
.primary-button svg,
.ghost-button svg,
.danger-button svg,
.search svg {
  width: 18px;
  height: 18px;
  stroke-width: 2;
}

.sidebar-card {
  margin-top: auto;
  padding: 16px;
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: var(--radius);
  background: rgba(255, 255, 255, 0.08);
}

.sidebar-card strong {
  display: block;
  margin-top: 8px;
  font-size: 27px;
  line-height: 1;
}

.sidebar-card small {
  display: block;
  margin-top: 8px;
  color: rgba(255, 255, 255, 0.64);
}

.label,
.eyebrow {
  margin: 0;
  color: var(--muted);
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 0;
  text-transform: uppercase;
}

.sidebar-card .label {
  color: rgba(255, 255, 255, 0.58);
}

.main {
  min-width: 0;
  padding: 22px;
}

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

.topbar h1,
.panel h2,
.sheet-toolbar h2 {
  margin: 0;
  line-height: 1.1;
}

.topbar h1 {
  margin-top: 6px;
  font-size: clamp(28px, 4vw, 40px);
  font-weight: 850;
}

.topbar-tools {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 10px;
  min-width: 0;
}

.date-control {
  display: grid;
  grid-template-columns: auto 150px;
  align-items: center;
  gap: 9px;
  height: 42px;
  padding: 0 11px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
}

.date-control span {
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}

.date-control input,
.search input {
  min-width: 0;
  border: 0;
  outline: 0;
  background: transparent;
  color: var(--ink);
}

.search {
  display: grid;
  grid-template-columns: 18px minmax(160px, 260px);
  align-items: center;
  gap: 8px;
  height: 42px;
  padding: 0 12px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--muted);
}

.primary-button,
.ghost-button,
.danger-button,
.icon-button,
.owner-tab {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 42px;
  border-radius: var(--radius);
  border: 1px solid transparent;
  white-space: nowrap;
}

.primary-button {
  padding: 0 16px;
  background: var(--green);
  color: #ffffff;
  font-weight: 800;
}

.primary-button:hover {
  background: #12684b;
}

.danger-button {
  padding: 0 16px;
  background: var(--red);
  color: #ffffff;
  font-weight: 800;
}

.danger-button:hover {
  background: #982f2f;
}

.ghost-button,
.owner-tab {
  padding: 0 12px;
  border-color: var(--line);
  background: var(--surface);
  color: var(--ink);
}

.icon-button {
  width: 42px;
  border-color: var(--line);
  background: var(--surface);
  color: var(--ink);
}

.view {
  display: none;
}

.view.active {
  display: block;
}

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

.metric-card,
.panel,
.sheet-panel {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: var(--shadow);
}

.metric-card {
  display: grid;
  gap: 8px;
  min-height: 112px;
  padding: 14px;
}

.metric-card strong {
  font-size: 27px;
  line-height: 1;
}

.metric-card small {
  color: var(--muted);
}

.metric-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.metric-icon {
  display: grid;
  place-items: center;
  width: 36px;
  height: 36px;
  border-radius: var(--radius);
}

.metric-icon svg {
  width: 18px;
  height: 18px;
}

.daily-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 320px;
  align-items: start;
  gap: 12px;
}

.content-grid,
.owner-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(300px, 0.38fr);
  gap: 12px;
}

.owner-layout {
  grid-template-columns: 250px minmax(0, 1fr);
}

.side-stack,
.daily-tables,
.owner-tabs,
.owner-summary,
.cashbox-list,
.expense-grid,
.rules-grid,
.security-grid,
.impact-panel {
  display: grid;
  gap: 12px;
}

.panel,
.sheet-panel {
  min-width: 0;
  padding: 16px;
}

.panel-header,
.sheet-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 14px;
}

.panel h2,
.sheet-toolbar h2 {
  margin-top: 5px;
  font-size: 20px;
}

.legend {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

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

.dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
}

.dot-green {
  background: var(--green);
}

.dot-blue {
  background: var(--blue);
}

.dot-red {
  background: var(--red);
}

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

table {
  width: 100%;
  border-collapse: collapse;
  min-width: 900px;
}

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

th {
  background: #eef2f6;
  color: #364152;
  font-size: 12px;
  font-weight: 850;
}

td {
  background: #ffffff;
  font-size: 13px;
}

.daily-block {
  overflow: hidden;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius);
}

.daily-block-title {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 10px 12px;
  border-bottom: 1px solid var(--line-strong);
  background: #f8fafc;
}

.daily-block-title strong {
  font-size: 14px;
}

.daily-table {
  min-width: 1180px;
}

.daily-table th,
.daily-table td {
  padding: 5px 6px;
  text-align: center;
}

.daily-table th:nth-child(1),
.daily-table td:nth-child(1),
.daily-table th:nth-child(11),
.daily-table td:nth-child(11),
.daily-table th:nth-child(12),
.daily-table td:nth-child(12) {
  text-align: left;
}

.daily-table input,
.daily-table select {
  width: 100%;
  min-width: 58px;
  height: 30px;
  padding: 0 6px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fff;
  color: var(--ink);
  outline: 0;
  text-align: center;
}

.daily-table .schedule-input {
  min-width: 106px;
  text-align: left;
}

.daily-table .graph-select {
  min-width: 68px;
}

.cash-choice {
  display: grid;
  grid-template-columns: minmax(62px, 1fr) 76px;
  gap: 4px;
  min-width: 142px;
}

.daily-table .cash-choice input,
.daily-table .cash-choice select {
  min-width: 0;
}

.daily-table .cash-status-select {
  font-weight: 800;
  color: var(--red);
}

.daily-table input:disabled,
.daily-table select:disabled {
  border-color: var(--line);
  background: #eef2f6;
  color: #98a2b3;
  cursor: not-allowed;
}

.daily-table .note-input {
  min-width: 160px;
  text-align: left;
}

.daily-table .money-input:focus,
.daily-table .schedule-input:focus,
.daily-table .cash-status-select:focus,
.daily-table .note-input:focus {
  border-color: var(--blue);
  box-shadow: 0 0 0 2px var(--blue-soft);
}

.daily-table .input-error {
  border-color: var(--red);
  box-shadow: 0 0 0 2px var(--red-soft);
}

.daily-table tr.selected-row td {
  background: #fffdf2;
}

.daily-table tr.day-paid td {
  background: #effaf3;
}

.daily-table tr.day-debt td {
  background: #fff0f0;
}

.daily-table tr.day-paid.selected-row td {
  background: #e7f7ed;
}

.daily-table tr.day-debt.selected-row td {
  background: #ffe8e8;
}

.daily-table tr.day-paid .plate-cell,
.daily-table tr.day-paid .number-cell,
.daily-table tr.day-paid .owner-cell {
  color: var(--green);
}

.daily-table tr.day-debt .plate-cell,
.daily-table tr.day-debt .number-cell,
.daily-table tr.day-debt .owner-cell {
  color: var(--red);
}

.daily-table tr.day-paid input,
.daily-table tr.day-paid select {
  border-color: rgba(22, 122, 88, 0.34);
  background: #f7fff9;
}

.daily-table tr.day-debt input,
.daily-table tr.day-debt select {
  border-color: rgba(178, 59, 59, 0.34);
  background: #fffafa;
}

.plate-cell {
  min-width: 92px;
  font-weight: 850;
}

.owner-cell {
  min-width: 105px;
  color: #344054;
  font-weight: 750;
}

.daily-cash-panel {
  position: sticky;
  top: 22px;
  display: grid;
  gap: 14px;
}

.daily-cash-actions {
  display: grid;
  grid-template-columns: 1fr;
  gap: 8px;
}

.daily-cash-summary {
  display: grid;
  gap: 8px;
}

.daily-cash-summary article,
.cash-operation-item,
.cash-delete-log-item,
.delete-summary {
  display: grid;
  gap: 4px;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface-soft);
}

.cash-operation-item {
  grid-template-columns: minmax(0, 1fr) 74px;
  align-items: center;
  gap: 8px;
}

.cash-operation-actions {
  display: grid;
  grid-template-columns: repeat(2, 34px);
  gap: 6px;
}

.cash-operation-body {
  min-width: 0;
}

.cash-operation-target {
  display: inline-flex;
  width: fit-content;
  margin: 2px 0;
  padding: 4px 8px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--surface);
  color: var(--muted);
  font-size: 11px;
  font-weight: 850;
}

.cash-operation-edit,
.cash-operation-delete {
  width: 34px;
  min-height: 34px;
  background: var(--surface);
}

.cash-operation-delete {
  color: var(--red);
}

.cash-operation-edit svg,
.cash-operation-delete svg {
  width: 16px;
  height: 16px;
}

.daily-cash-summary span,
.cash-operation-item p,
.cash-delete-log-item p,
.delete-summary p {
  margin: 0;
  color: var(--muted);
  font-size: 12px;
  font-weight: 750;
}

.daily-cash-summary strong,
.cash-operation-item strong,
.cash-delete-log-item strong,
.delete-summary strong {
  font-size: 18px;
  line-height: 1.1;
}

.cash-delete-log-item small {
  color: var(--muted);
  font-size: 11px;
  font-weight: 750;
}

.daily-cash-lists {
  display: grid;
  gap: 12px;
}

.daily-payroll-panel {
  display: grid;
  gap: 8px;
}

.compact-line {
  margin: 0;
}

.compact-line h3 {
  margin: 0;
  font-size: 14px;
}

.payroll-attendance-grid {
  display: grid;
  gap: 8px;
}

.payroll-attendance-button {
  display: grid;
  grid-template-columns: 34px minmax(0, 1fr);
  align-items: center;
  gap: 8px;
  width: 100%;
  min-height: 48px;
  padding: 8px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface-soft);
  color: var(--ink);
  text-align: left;
}

.payroll-attendance-button.active {
  border-color: rgba(22, 122, 88, 0.34);
  background: #f4fbf6;
  color: var(--green);
}

.payroll-attendance-button i {
  width: 18px;
  height: 18px;
}

.payroll-attendance-button span {
  display: grid;
  gap: 2px;
}

.payroll-attendance-button small {
  color: var(--muted);
  font-size: 11px;
  font-weight: 750;
}

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

.cash-operation-list h3 {
  margin: 0;
  font-size: 14px;
}

.empty-mini {
  padding: 10px;
  border: 1px dashed var(--line);
  border-radius: var(--radius);
  color: var(--muted);
  font-size: 12px;
  font-weight: 750;
  text-align: center;
}

.number-cell {
  font-variant-numeric: tabular-nums;
}

.debt-cell {
  color: var(--red);
  font-weight: 850;
}

.ok-cell {
  color: var(--green);
  font-weight: 850;
}

.plan-error-modal[hidden] {
  display: none;
}

.plan-error-modal {
  position: fixed;
  inset: 0;
  z-index: 1000;
  display: grid;
  place-items: center;
  padding: 24px;
  background: rgba(23, 32, 42, 0.72);
}

.plan-error-dialog {
  display: grid;
  gap: 14px;
  width: min(560px, 100%);
  padding: 28px;
  border: 1px solid rgba(178, 59, 59, 0.26);
  border-radius: var(--radius);
  background: #ffffff;
  box-shadow: 0 24px 80px rgba(23, 32, 42, 0.34);
  text-align: center;
}

.plan-error-icon {
  display: grid;
  place-items: center;
  width: 58px;
  height: 58px;
  margin: 0 auto;
  border-radius: var(--radius);
  background: var(--red-soft);
  color: var(--red);
}

.plan-error-icon svg {
  width: 30px;
  height: 30px;
}

.plan-error-dialog h2 {
  margin: 0;
  font-size: 30px;
  line-height: 1.1;
}

.plan-error-text,
.plan-error-hint {
  margin: 0;
  color: var(--muted);
  font-size: 16px;
  line-height: 1.5;
}

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

.plan-error-details {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
  margin: 4px 0;
}

.plan-error-details div {
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface-soft);
}

.plan-error-details dt {
  margin: 0 0 5px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
  text-transform: uppercase;
}

.plan-error-details dd {
  margin: 0;
  color: var(--red);
  font-size: 22px;
  font-weight: 900;
}

.plan-error-button {
  width: 100%;
  margin-top: 4px;
}

.status-text {
  display: inline-flex;
  align-items: center;
  min-height: 24px;
  padding: 0 8px;
  border-radius: 999px;
  background: var(--blue-soft);
  color: var(--blue);
  font-size: 12px;
  font-weight: 850;
}

.status-pill {
  display: inline-flex;
  align-items: center;
  min-height: 26px;
  padding: 0 9px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 850;
  white-space: nowrap;
}

.status-pill.ok,
.status-pill.enabled {
  background: var(--green-soft);
  color: var(--green);
}

.status-pill.warn {
  background: var(--yellow-soft);
  color: var(--yellow);
}

.status-pill.info,
.status-pill.review {
  background: var(--blue-soft);
  color: var(--blue);
}

.status-pill.danger,
.status-pill.disabled {
  background: var(--red-soft);
  color: var(--red);
}

.status-pill.neutral {
  background: #edf1f5;
  color: #475467;
}

.sheet-footer td {
  background: #f8fafc;
  font-weight: 850;
}

.sheet-footer .total-tax-daily {
  background: var(--yellow-soft);
  color: var(--yellow);
}

.impact-card,
.cashbox-item,
.owner-item,
.expense-card,
.rule-card,
.security-card,
.owner-total-card {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface-soft);
  padding: 12px;
}

.impact-card {
  display: grid;
  gap: 8px;
}

.impact-card strong,
.cashbox-item strong,
.owner-item strong,
.expense-card strong,
.rule-card strong,
.security-card strong {
  display: block;
  font-size: 14px;
}

.impact-card p,
.cashbox-item p,
.owner-item span,
.expense-card p,
.rule-card p,
.security-card p {
  margin: 4px 0 0;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.4;
}

.impact-list {
  margin: 0;
  padding: 0;
  list-style: none;
}

.impact-list li {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  padding: 7px 0;
  border-top: 1px solid var(--line);
  color: #344054;
  font-size: 12px;
}

.impact-list li:first-child {
  border-top: 0;
}

.impact-list b {
  white-space: nowrap;
}

.cashbox-item,
.owner-item {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  gap: 12px;
}

.cashbox-money,
.owner-money {
  text-align: right;
}

.cashbox-money strong,
.owner-money strong {
  color: var(--ink);
  font-size: 18px;
}

.negative {
  color: var(--red) !important;
}

.positive {
  color: var(--green) !important;
}

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

.compact-panel {
  align-self: start;
}

.owner-tab {
  justify-content: space-between;
  width: 100%;
  min-height: 44px;
}

.owner-tab.active {
  border-color: var(--ink);
  background: var(--ink);
  color: #ffffff;
}

.owner-sheet-panel {
  min-width: 0;
}

.owner-table-wrap {
  border: 1px solid var(--line);
  border-radius: var(--radius);
}

.owner-ledger {
  min-width: 1220px;
}

.owner-ledger th,
.owner-ledger td {
  min-width: 42px;
  padding: 5px 6px;
  text-align: center;
  font-size: 12px;
}

.owner-ledger th:nth-child(1),
.owner-ledger td:nth-child(1) {
  position: sticky;
  left: 0;
  z-index: 2;
  min-width: 84px;
  background: #f8fafc;
  text-align: left;
}

.owner-ledger th:nth-child(2),
.owner-ledger td:nth-child(2) {
  position: sticky;
  left: 84px;
  z-index: 2;
  min-width: 118px;
  background: #f8fafc;
  text-align: left;
}

.owner-ledger td.plan-cell {
  background: #f4fbf6;
}

.owner-ledger td.plan-paid {
  background: #e7f7ed;
  color: var(--green);
  font-weight: 850;
}

.owner-ledger td.plan-debt {
  background: #ffe8e8;
  color: var(--red);
  font-weight: 850;
}

.owner-ledger td.tax-cell {
  background: #fff1f1;
  color: var(--red);
  font-weight: 850;
}

.owner-ledger td.status-cell {
  background: var(--blue-soft);
  color: var(--blue);
  font-weight: 850;
}

.owner-ledger td.status-debt {
  background: #ffe8e8;
  color: var(--red);
}

.owner-ledger td.status-repair {
  background: var(--yellow-soft);
  color: var(--yellow);
}

.owner-ledger td.status-muted {
  background: #eef2f6;
  color: var(--muted);
}

.owner-ledger td.empty-ledger-cell {
  background: #ffffff;
  color: #b8c0cc;
}

.owner-totals {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 10px;
  margin-top: 12px;
}

.owner-total-card strong {
  display: block;
  margin-top: 4px;
  font-size: 20px;
}

.owner-opening-form,
.cashbox-opening-form {
  display: grid;
  gap: 8px;
  margin-top: 10px;
}

.owner-opening-form label,
.cashbox-opening-form label {
  display: grid;
  gap: 5px;
}

.owner-opening-form label span,
.cashbox-opening-form label span {
  color: var(--muted);
  font-size: 11px;
  font-weight: 850;
}

.owner-opening-form input[type="number"],
.cashbox-opening-form input[type="number"] {
  width: 100%;
  min-height: 38px;
  padding: 0 10px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--ink);
}

.payroll-grid {
  display: grid;
  gap: 12px;
}

.payroll-card {
  display: grid;
  gap: 12px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
}

.payroll-card-header {
  display: flex;
  align-items: start;
  justify-content: space-between;
  gap: 12px;
}

.payroll-card-header h3 {
  margin: 2px 0 0;
  font-size: 20px;
}

.salary-config-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
}

.salary-rate-control,
.salary-service-card {
  display: grid;
  gap: 6px;
}

.salary-rate-control span,
.salary-service-card span {
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}

.salary-rate-control input {
  height: 40px;
  padding: 0 10px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--surface-soft);
  color: var(--ink);
  font: inherit;
  font-weight: 800;
}

.salary-service-card {
  padding: 9px 10px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--surface-soft);
}

.salary-service-card strong {
  font-size: 16px;
}

.payroll-totals {
  grid-template-columns: repeat(4, minmax(0, 1fr));
  margin-top: 0;
}

.owner-expense-note {
  display: grid;
  gap: 4px;
  line-height: 1.35;
}

.owner-expense-note span {
  display: block;
}

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

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

.rules-table td,
.rules-table th {
  text-align: left;
}

.compact-rules-table {
  min-width: 560px;
}

.chasniki-layout {
  margin-bottom: 12px;
}

.debt-table td,
.debt-table th {
  text-align: left;
}

.expense-grid,
.rules-grid,
.security-grid {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.expense-card,
.rule-card,
.security-card {
  display: grid;
  gap: 8px;
  min-height: 112px;
}

.rule-card ul,
.security-card ul {
  display: grid;
  gap: 6px;
  margin: 0;
  padding-left: 18px;
  color: #344054;
  font-size: 13px;
  line-height: 1.45;
}

.backup-panel {
  margin-top: 18px;
}

.sync-panel {
  margin-top: 18px;
}

.sync-grid,
.backup-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
}

.sync-card,
.backup-card,
.audit-item {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface-soft);
  padding: 12px;
}

.sync-card span,
.backup-card span,
.audit-item span {
  display: block;
  color: var(--muted);
  font-size: 12px;
  font-weight: 750;
}

.sync-card strong,
.backup-card strong,
.audit-item strong {
  display: block;
  margin-top: 4px;
  font-size: 14px;
}

.sync-card p,
.backup-card p,
.audit-item p,
.audit-item small {
  display: block;
  margin: 4px 0 0;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.4;
}

.backup-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 14px;
}

.audit-preview {
  margin-top: 16px;
}

.audit-list {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
}

.sync-login-form,
.setup-note {
  margin-top: 14px;
}

.setup-note {
  padding: 12px;
  border: 1px dashed var(--line);
  border-radius: var(--radius);
  background: var(--surface-soft);
}

.stack-form {
  display: grid;
  gap: 12px;
}

.owner-vehicle-form {
  margin-top: 14px;
  padding-top: 14px;
  border-top: 1px solid var(--line);
}

.form-grid-two {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
}

.form-grid-three,
.form-grid-four {
  display: grid;
  gap: 10px;
}

.form-grid-three {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

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

.stack-form label {
  display: grid;
  gap: 6px;
}

.stack-form span {
  color: var(--muted);
  font-size: 12px;
  font-weight: 850;
}

.stack-form input,
.stack-form select,
.stack-form textarea {
  width: 100%;
  padding: 0 11px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--ink);
  outline: 0;
}

.stack-form input,
.stack-form select {
  height: 42px;
}

.stack-form textarea {
  min-height: 88px;
  padding-top: 10px;
  resize: vertical;
}

.full-width {
  width: 100%;
}

.form-message {
  min-height: 18px;
  margin: 0;
  color: var(--muted);
  font-size: 12px;
  font-weight: 750;
}

.form-message.error {
  color: var(--red);
}

.form-message.ok {
  color: var(--green);
}

.vehicle-layout {
  grid-template-columns: 360px minmax(0, 1fr);
}

.vehicle-list,
.vehicle-card,
.vehicle-section {
  display: grid;
  gap: 12px;
}

.vehicle-list {
  max-height: calc(100vh - 190px);
  overflow: auto;
  padding-right: 4px;
}

.vehicle-item-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 8px;
  align-items: stretch;
}

.vehicle-row-actions {
  display: grid;
  grid-template-columns: 42px;
  gap: 6px;
}

.vehicle-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  width: 100%;
  min-height: 58px;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--ink);
  text-align: left;
}

.vehicle-item.active {
  border-color: var(--ink);
  background: var(--ink);
  color: #ffffff;
}

.vehicle-item span,
.vehicle-item strong,
.vehicle-item small,
.vehicle-item em {
  display: block;
}

.vehicle-item small {
  margin-top: 3px;
  color: var(--muted);
  font-style: normal;
}

.vehicle-item.active small {
  color: rgba(255, 255, 255, 0.72);
}

.vehicle-item em {
  flex: 0 0 auto;
  color: var(--green);
  font-size: 12px;
  font-style: normal;
  font-weight: 850;
}

.vehicle-item.active em {
  color: #ffffff;
}

.danger-icon,
.danger-link {
  color: var(--red);
}

.danger-icon:hover,
.danger-link:hover {
  border-color: var(--red);
  background: var(--red-soft);
}

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

.vehicle-card-header h2 {
  margin: 4px 0 8px;
  font-size: 30px;
  line-height: 1.05;
}

.vehicle-card-header strong {
  font-size: 18px;
}

.vehicle-card-actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 8px;
}

.vehicle-detail-grid,
.vehicle-doc-grid {
  display: grid;
  gap: 10px;
}

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

.vehicle-doc-grid {
  grid-template-columns: repeat(5, minmax(0, 1fr));
}

.vehicle-detail,
.vehicle-doc {
  display: grid;
  gap: 6px;
  min-height: 82px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface-soft);
}

.vehicle-detail span,
.vehicle-doc span {
  color: var(--muted);
  font-size: 12px;
  font-weight: 850;
}

.vehicle-detail strong,
.vehicle-doc strong {
  overflow-wrap: anywhere;
}

.vehicle-doc em {
  width: max-content;
  padding: 3px 7px;
  border-radius: 999px;
  background: var(--green-soft);
  color: var(--green);
  font-size: 11px;
  font-style: normal;
  font-weight: 850;
}

.vehicle-doc.soon em {
  background: var(--yellow-soft);
  color: var(--yellow);
}

.vehicle-doc.expired em,
.vehicle-doc.missing em {
  background: var(--red-soft);
  color: var(--red);
}

.vehicle-section {
  padding-top: 4px;
}

.vehicle-section h3 {
  margin: 0;
  font-size: 17px;
}

.settings-actions,
.settings-catalog,
.settings-list {
  display: grid;
  gap: 12px;
}

.settings-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
}

.settings-card,
.settings-row {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface-soft);
}

.settings-card {
  display: grid;
  gap: 8px;
  padding: 14px;
}

.settings-card strong,
.settings-row strong {
  display: block;
}

.settings-card p,
.settings-row p {
  margin: 0;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.4;
}

.settings-card span,
.settings-row span {
  color: var(--green);
  font-size: 13px;
  font-weight: 850;
}

.settings-card-wide {
  background: var(--surface);
}

.settings-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  width: 100%;
  padding: 12px 14px;
  color: var(--ink);
  text-align: left;
}

button.settings-row {
  cursor: pointer;
}

button.settings-row:hover {
  border-color: var(--line-strong);
  background: var(--surface);
}

.app-modal[hidden] {
  display: none;
}

.app-modal {
  position: fixed;
  inset: 0;
  z-index: 950;
  display: grid;
  place-items: center;
  padding: 24px;
  background: rgba(23, 32, 42, 0.62);
}

.app-modal-dialog {
  display: grid;
  gap: 16px;
  width: min(520px, 100%);
  max-height: min(880px, calc(100vh - 48px));
  overflow: auto;
  padding: 20px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: 0 24px 80px rgba(23, 32, 42, 0.34);
}

.app-modal-wide {
  width: min(980px, 100%);
}

.modal-header,
.section-line {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.modal-header h2 {
  margin: 4px 0 0;
  font-size: 26px;
  line-height: 1.1;
}

.form-section {
  display: grid;
  gap: 10px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface-soft);
}

.form-section h3 {
  margin: 0;
  font-size: 15px;
}

.empty-state {
  display: grid;
  place-items: center;
  min-height: 120px;
  border: 1px dashed var(--line);
  border-radius: var(--radius);
  color: var(--muted);
  text-align: center;
}

@media (max-width: 1180px) {
  .shell {
    grid-template-columns: 84px minmax(0, 1fr);
  }

  .brand span:last-child,
  .nav-item span,
  .sidebar-card {
    display: none;
  }

  .nav-item {
    grid-template-columns: 1fr;
    justify-items: center;
  }

  .daily-layout,
  .content-grid,
  .owner-layout,
  .vehicle-layout {
    grid-template-columns: 1fr;
  }

  .daily-cash-panel {
    position: static;
  }

  .owner-tabs {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

  .metrics-grid,
  .expense-grid,
  .rules-grid,
  .security-grid,
  .sync-grid,
  .backup-grid,
  .audit-list,
  .form-grid-four,
  .vehicle-detail-grid,
  .vehicle-doc-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 760px) {
  .shell {
    display: block;
  }

  .sidebar {
    position: sticky;
    z-index: 20;
    height: auto;
    padding: 10px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
  }

  .brand {
    display: none;
  }

  .nav {
    display: flex;
    overflow-x: auto;
  }

  .nav-item {
    grid-template-columns: 20px max-content;
    min-width: max-content;
  }

  .nav-item span {
    display: inline;
  }

  .main {
    padding: 14px;
  }

  .topbar,
  .topbar-tools,
  .panel-header,
  .sheet-toolbar {
    align-items: stretch;
    flex-direction: column;
  }

  .backup-grid,
  .sync-grid,
  .audit-list {
    grid-template-columns: 1fr;
  }

  .backup-actions {
    display: grid;
  }

  .topbar h1 {
    font-size: 30px;
  }

  .date-control,
  .search {
    grid-template-columns: 1fr;
    height: auto;
    min-height: 42px;
    padding: 9px 11px;
  }

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

  .metrics-grid,
  .owner-tabs,
  .owner-totals,
  .form-grid-two,
  .form-grid-three,
  .form-grid-four,
  .expense-grid,
  .rules-grid,
  .security-grid,
  .settings-grid,
  .vehicle-detail-grid,
  .vehicle-doc-grid,
  .salary-config-grid,
  .payroll-totals {
    grid-template-columns: 1fr;
  }

  .modal-header,
  .section-line,
  .vehicle-card-header,
  .settings-row {
    align-items: stretch;
    flex-direction: column;
  }

  .vehicle-list {
    max-height: none;
  }

  .panel,
  .sheet-panel {
    padding: 12px;
  }

  .daily-table {
    min-width: 1120px;
  }

  .cashbox-item,
  .owner-item {
    grid-template-columns: 1fr;
  }

  .cashbox-money,
  .owner-money {
    text-align: left;
  }
}
