:root {
  --ink: #172033;
  --muted: #5f6b7c;
  --line: #d9dee8;
  --soft: #f6f8fb;
  --paper: #ffffff;
  --blue: #174c8f;
  --green: #2f7d54;
  --amber: #a45b16;
  --red: #b42318;
  --shadow: 0 16px 40px rgba(23, 32, 51, .08);
}

* { box-sizing: border-box; }
body {
  margin: 0;
  font-family: Arial, Helvetica, sans-serif;
  color: var(--ink);
  background: #eef2f6;
}

button, input, select, textarea { font: inherit; }
button, .file-button {
  border: 1px solid var(--line);
  background: var(--paper);
  color: var(--ink);
  border-radius: 6px;
  min-height: 36px;
  padding: 0 12px;
  cursor: pointer;
}
button.primary { background: var(--blue); color: #fff; border-color: var(--blue); }
button.ghost { background: #f9fbfd; }
button.icon { width: 32px; padding: 0; }
button.danger { color: var(--red); }
button.wide { width: 100%; margin-top: 10px; }
.file-button { display: inline-flex; align-items: center; }
.file-button input { display: none; }
.login-page { min-height: 100vh; display: grid; place-items: center; padding: 18px; }
.login-shell { width: min(420px, 100%); }
.login-box {
  display: grid;
  gap: 16px;
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
  padding: 24px;
}
.login-message { min-height: 20px; color: var(--red); font-weight: 700; }
.app-credit { margin-top: 2px; text-align: center; color: var(--green); font-size: 12px; font-weight: 700; text-transform: uppercase; }

.topbar {
  position: sticky;
  top: 0;
  z-index: 2;
  display: flex;
  justify-content: space-between;
  gap: 18px;
  align-items: center;
  padding: 14px 22px;
  background: rgba(255,255,255,.96);
  border-bottom: 1px solid var(--line);
}
.user-badge { color: var(--muted); font-weight: 700; align-self: center; }
.kicker { margin: 0 0 3px; color: var(--green); font-weight: 700; text-transform: uppercase; font-size: 12px; }
h1 { margin: 0; font-size: 22px; letter-spacing: 0; }
h2 { margin: 0; font-size: 17px; letter-spacing: 0; }
p { margin: 4px 0 0; color: var(--muted); }
.brand { display: flex; align-items: center; gap: 14px; min-width: 280px; }
.brand-logo { width: 70px; height: 54px; object-fit: contain; }
.login-brand { display: grid; gap: 6px; justify-items: center; text-align: center; }
.login-logo { width: 150px; height: auto; max-height: 96px; object-fit: contain; }
.actions { display: flex; flex-wrap: wrap; gap: 8px; justify-content: flex-end; }
.save-status {
  min-height: 36px;
  display: inline-flex;
  align-items: center;
  color: var(--green);
  font-size: 12px;
  font-weight: 700;
}
.save-status.is-error { color: var(--red); }

.workspace {
  display: grid;
  grid-template-columns: 280px minmax(0, 1fr);
  gap: 18px;
  padding: 18px;
  align-items: start;
}
.sidebar { position: sticky; top: 82px; display: grid; gap: 14px; }
.summary-panel, .band, .print-area {
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
}
.summary-panel { padding: 16px; }
.summary-panel dl { margin: 12px 0 0; display: grid; gap: 10px; }
.summary-panel dl div { border-top: 1px solid var(--line); padding-top: 10px; }
dt { color: var(--muted); font-size: 12px; text-transform: uppercase; font-weight: 700; }
dd { margin: 3px 0 0; font-size: 20px; font-weight: 700; }
.alerts { padding-left: 18px; margin: 12px 0 0; color: var(--amber); }
.alerts li + li { margin-top: 8px; }

.form-shell { display: grid; gap: 16px; }
.band { padding: 18px; }
.section-heading { margin-bottom: 14px; }
.row-heading { display: flex; justify-content: space-between; gap: 12px; align-items: center; }
.grid { display: grid; gap: 12px; }
.cols-4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.grid-spacer { min-height: 1px; }
label { display: grid; gap: 5px; color: var(--muted); font-size: 12px; font-weight: 700; text-transform: uppercase; }
.label-row { display: flex; justify-content: space-between; gap: 8px; align-items: center; }
.label-row strong { color: var(--ink); text-align: right; }
.inline-check { display: flex; align-items: center; gap: 8px; min-height: 24px; }
.inline-check input { width: 18px; min-height: 18px; padding: 0; }
.toggle { display: flex; align-items: center; gap: 8px; min-height: 64px; }
.sleeper-label { justify-content: center; text-align: center; }
input, select, textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fff;
  min-height: 38px;
  padding: 8px 10px;
  color: var(--ink);
}
input[readonly] { background: #eef2f6; color: #4b5563; }
input:disabled, select:disabled { background: #eef2f6; color: #4b5563; }
select[multiple] { min-height: 94px; padding: 6px 8px; }
textarea { min-height: 94px; resize: vertical; text-transform: none; font-weight: 400; }
input[type="number"]::-webkit-outer-spin-button,
input[type="number"]::-webkit-inner-spin-button { margin: 0; appearance: none; }
input[type="number"] { appearance: textfield; }

.table-wrap { overflow-x: auto; border: 1px solid var(--line); border-radius: 8px; }
table { width: 100%; border-collapse: collapse; }
th, td { border-bottom: 1px solid var(--line); padding: 8px; text-align: left; vertical-align: top; }
th { background: #edf4fb; font-size: 12px; text-transform: uppercase; }
td input, td select { min-width: 110px; }
td:nth-child(3) input { min-width: 220px; }
tfoot td { background: #f7fafc; }
tr:last-child td { border-bottom: 0; }
.row-total { min-width: 110px; font-weight: 700; white-space: nowrap; }
.expenses-table { table-layout: fixed; min-width: 920px; }
.expense-group-col { width: 13%; }
.expense-date-col { width: 15%; }
.expense-description-col { width: 32%; }
.expense-quantity-col { width: 8%; }
.expense-unit-col { width: 14%; }
.expense-invoice-col { width: 14%; }
.expense-action-col { width: 4%; }
.expenses-table td:nth-child(3) input { min-width: 300px; }
.expenses-table td:nth-child(4) input { min-width: 70px; }
.expenses-table td:nth-child(7) button { min-width: 32px; }
.volus-summary-wrap { margin-top: 10px; max-width: 520px; }
.volus-establishment { line-height: 1.35; min-width: 180px; }
.volus-category { min-width: 150px; }
.is-collapsed .fixed-costs { display: none; }
.settlement-total {
  display: inline-grid;
  gap: 4px;
  min-width: 240px;
  margin-bottom: 12px;
  border: 1px solid #b8dbc7;
  border-radius: 8px;
  padding: 12px;
  background: #e8f5ed;
}
.settlement-total span {
  color: var(--muted);
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
}
.settlement-total strong { font-size: 22px; }

.forecast-grid {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 10px;
  margin-bottom: 12px;
}
.forecast-grid div {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 12px;
  background: #fbfcfe;
}
.forecast-grid span {
  display: block;
  color: var(--muted);
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
}
.forecast-grid strong {
  display: block;
  margin-top: 5px;
  font-size: 18px;
}
.forecast-total {
  background: #e8f5ed !important;
  border-color: #b8dbc7 !important;
}
.forecast-table { margin-top: 10px; }

.fixed-costs {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
}
.fixed-cost {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 12px;
  display: grid;
  gap: 8px;
}
.fixed-cost strong { font-size: 13px; }

.print-area { display: none; }
.print-area .section-title { font-weight: 700; text-transform: uppercase; margin: 18px 0 8px; }
.print-header { display: grid; grid-template-columns: 110px 1fr 160px; gap: 14px; align-items: center; border-bottom: 2px solid var(--blue); padding-bottom: 10px; margin-bottom: 12px; }
.print-header img { width: 96px; max-height: 66px; object-fit: contain; }
.print-header h1 { font-size: 20px; }
.print-header p { color: var(--green); font-size: 11px; font-weight: 700; text-transform: uppercase; }
.print-date { text-align: right; font-size: 11px; color: var(--muted); }
.print-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; margin-bottom: 10px; }
.print-grid div { border: 1px solid #cfcfcf; padding: 6px; min-height: 42px; }
.print-grid span { display: block; color: var(--muted); font-size: 10px; text-transform: uppercase; font-weight: 700; }
.print-grid strong { display: block; margin-top: 3px; font-size: 12px; }
.right { text-align: right; }
.bold { font-weight: 700; }
.summary-table th { background: var(--blue); color: #fff; }
.total-row td { background: #e8f5ed; font-weight: 700; }
.alert-row td { background: #fff3e8; font-weight: 700; }
.cost-row td { background: #dbeafe; font-weight: 700; }
.signature-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 36px; margin-top: 36px; text-align: center; }
.signature-grid div { border-top: 1px solid var(--ink); padding-top: 8px; }

@media (max-width: 980px) {
  .workspace { grid-template-columns: 1fr; }
  .sidebar { position: static; grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .cols-4, .fixed-costs, .forecast-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .grid-spacer { display: none; }
}

@media (max-width: 680px) {
  .topbar { align-items: flex-start; flex-direction: column; }
  .brand { min-width: 0; }
  .workspace { padding: 10px; }
  .sidebar, .cols-4, .fixed-costs, .forecast-grid { grid-template-columns: 1fr; }
}

@media print {
  @page { size: A4; margin: 10mm; }
  * {
    -webkit-print-color-adjust: exact !important;
    print-color-adjust: exact !important;
  }
  body { background: #fff; color: #111; font-size: 11px; }
  .topbar, .sidebar, .form-shell { display: none; }
  .workspace { display: block; padding: 0; }
  .print-area { display: block; border: 0; box-shadow: none; padding: 0; margin: 0; }
  .print-area table { margin-bottom: 10px; page-break-inside: avoid; }
  .print-area th, .print-area td { border: 1px solid #cfcfcf; padding: 4px 5px; }
  .print-area th {
    background-color: #eef1f4 !important;
    color: #111;
    font-size: 10px;
  }
  .print-area tfoot td { background: #f3f6fa !important; }
  .print-area .section-title {
    display: block;
    margin: 10px 0 5px;
    padding: 4px 6px;
    background-color: #eef1f4 !important;
    border: 1px solid #cfcfcf;
    color: #111;
    page-break-after: avoid;
  }
  .print-header { grid-template-columns: 86px 1fr 120px; margin-bottom: 8px; }
  .print-header img { width: 78px; max-height: 54px; }
  .print-header h1 { font-size: 17px; }
  .print-grid { grid-template-columns: repeat(4, 1fr); gap: 5px; }
  .print-grid div { padding: 4px; min-height: 34px; }
  .signature-grid { page-break-inside: avoid; margin-top: 28px; }
}
