:root {
  --bg: #eef3f9;
  --panel: #ffffff;
  --panel-2: #f6f9fd;
  --ink: #1c2733;
  --muted: #5c6b7c;
  --line: #d5dfeb;
  --brand: #274c77;
  --brand-dark: #1a3555;
  --accent: #d9822b;
  --sky: #3b82c4;
  --danger: #b6413b;
  --good: #237447;
  --soft-brand: #e3edf8;
  --soft-accent: #fdf0e1;
  --soft-sky: #e8f2fb;
  --shadow: 0 18px 36px rgba(23, 43, 77, 0.12);
}

* {
  box-sizing: border-box;
}

html {
  color-scheme: light;
}

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

.konto-fab { position: fixed; right: 22px; bottom: 22px; z-index: 80; width: 58px; height: 58px; border-radius: 50%; font-size: 1.35rem; font-weight: 800; box-shadow: 0 8px 24px #0003; }
.konto-panel { position: fixed; z-index: 90; right: 18px; bottom: 18px; width: min(430px, calc(100vw - 24px)); height: min(680px, calc(100vh - 36px)); background: var(--surface, #fff); border: 1px solid #ccd3d8; border-radius: 16px; box-shadow: 0 16px 45px #0004; display: flex; flex-direction: column; overflow: hidden; }
.konto-panel > header { display: flex; justify-content: space-between; align-items: center; padding: 14px 16px; color: #fff; background: #274c77; }
.konto-panel > header div { display: grid; gap: 2px; }.konto-panel > header small { color: #eaf1f7; }
.konto-messages { flex: 1; overflow-y: auto; padding: 12px; background: #f4f7f9; }
.konto-message { max-width: 88%; margin: 0 0 10px; padding: 10px 12px; border-radius: 12px; background: #fff; box-shadow: 0 1px 3px #0001; }
.konto-message.user { margin-left: auto; background: #e5f0fb; }.konto-message.error { border-left: 3px solid #b33; }
.konto-message p { margin: 5px 0; }.konto-message pre { white-space: pre-wrap; overflow-wrap: anywhere; font-size: .78rem; }
.konto-form { padding: 10px; border-top: 1px solid #dce2e6; background: #fff; }.konto-form textarea { width: 100%; resize: vertical; }
.konto-form > div { display: flex; justify-content: space-between; margin-top: 7px; }.konto-attachment { padding: 7px 12px; cursor: pointer; background: #fff4d6; font-size: .86rem; }
.konto-proposal-actions { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px; }
@media (max-width: 600px) { .konto-panel { inset: 6px; width: auto; height: auto; }.konto-fab { right: 14px; bottom: 14px; } }

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

button {
  border: 0;
  border-radius: 8px;
  min-height: 38px;
  padding: 0 13px;
  background: var(--brand);
  color: #fff;
  font-weight: 750;
  cursor: pointer;
}

button:hover {
  filter: brightness(0.97);
}

button:focus-visible,
input:focus-visible,
select:focus-visible,
textarea:focus-visible {
  outline: 3px solid rgba(49, 120, 168, 0.27);
  outline-offset: 2px;
}

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

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

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

.hidden {
  display: none !important;
}

.login {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
  background: linear-gradient(150deg, #16283f 0%, #274c77 55%, #3b82c4 130%);
}

.login-panel {
  width: min(520px, 100%);
  display: grid;
  gap: 28px;
  padding: 36px;
  border: 1px solid rgba(255, 255, 255, 0.35);
  border-radius: 14px;
  background: var(--panel);
  box-shadow: 0 28px 60px rgba(10, 22, 40, 0.35);
}

.login-panel h1 {
  margin: 6px 0 0;
  font-size: 31px;
  line-height: 1.08;
}

.empty-state {
  display: grid;
  gap: 8px;
  color: var(--muted);
}

.empty-state p {
  margin: 0;
}

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

.sidebar {
  display: flex;
  flex-direction: column;
  gap: 18px;
  min-width: 0;
  min-height: 100vh;
  padding: 20px 14px;
  background: linear-gradient(180deg, #16283f 0%, #1f3d61 60%, #274c77 100%);
  color: #fff;
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 4px 8px 14px;
}

.brand-mark {
  display: grid;
  place-items: center;
  width: 44px;
  height: 44px;
  border-radius: 8px;
  background: var(--accent);
  font-weight: 900;
}

.brand small {
  display: block;
  margin-top: 2px;
  color: #b9c1c8;
}

.nav {
  display: grid;
  gap: 6px;
  min-width: 0;
}

.nav button {
  display: flex;
  align-items: center;
  justify-content: flex-start;
  gap: 10px;
  background: transparent;
  color: #c8d8ea;
  text-align: left;
  border-radius: 8px;
  transition: background 0.15s ease, color 0.15s ease;
}

.nav button:hover {
  background: rgba(255, 255, 255, 0.08);
  color: #fff;
  filter: none;
}

.nav button.active {
  background: rgba(255, 255, 255, 0.16);
  color: #fff;
  box-shadow: inset 3px 0 0 var(--sky);
}

.workspace {
  min-width: 0;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 5;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  min-height: 88px;
  padding: 16px 28px;
  border-bottom: 1px solid var(--line);
  background: rgba(250, 248, 243, 0.92);
  backdrop-filter: blur(12px);
}

.topbar h1 {
  margin: 4px 0 0;
  font-size: 25px;
}

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

.compact-label {
  width: 146px;
}

.eyebrow {
  margin: 0;
  color: var(--brand-dark);
  font-size: 12px;
  font-weight: 850;
  text-transform: uppercase;
}

.content {
  display: grid;
  gap: 22px;
  padding: 28px;
}

.notice {
  margin: 18px 28px 0;
  padding: 12px 14px;
  border: 1px solid #f0cf9f;
  border-radius: 6px;
  background: #fff7ea;
  color: #714412;
  font-weight: 700;
}

.toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
}

.toolbar-group {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 9px;
}

.search {
  width: min(340px, 100%);
}

.kpis {
  display: grid;
  grid-template-columns: repeat(6, minmax(130px, 1fr));
  gap: 12px;
}

.kpi,
.panel,
.table-wrap {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  box-shadow: var(--shadow);
}

.kpi {
  padding: 16px;
}

.kpi-button {
  min-height: 0;
  border: 1px solid var(--line);
  color: var(--ink);
  text-align: left;
}

.kpi-button.active {
  border-color: var(--brand);
  box-shadow: 0 0 0 3px rgba(39, 76, 119, 0.12), var(--shadow);
}

.kpi span {
  display: block;
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
  text-transform: uppercase;
}

.kpi strong {
  display: block;
  margin-top: 8px;
  font-size: 27px;
  line-height: 1.1;
}

.kpi small {
  display: block;
  margin-top: 7px;
  color: var(--muted);
  font-size: 12px;
}

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

.chip-button {
  min-height: 34px;
  border: 1px solid var(--line);
  background: var(--panel);
  color: var(--ink);
  font-size: 13px;
}

.chip-button.active {
  border-color: var(--brand);
  background: var(--brand);
  color: #fff;
}

.dashboard-grid,
.reports-grid {
  display: grid;
  grid-template-columns: 1.08fr 0.92fr;
  gap: 16px;
}

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

.dashboard-grid > *,
.reports-grid > *,
.official-grid > * {
  min-width: 0;
}

.panel {
  padding: 18px;
  min-width: 0;
}

.subtle-panel {
  margin: 12px 0;
  box-shadow: none;
  background: var(--panel-2);
}

.panel h2,
.panel h3 {
  margin: 0 0 14px;
}

.panel h2 {
  font-size: 18px;
}

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

.panel-heading h2 {
  margin: 0;
}

.chart {
  display: grid;
  gap: 10px;
}

.bar-row {
  display: grid;
  grid-template-columns: 86px minmax(80px, 1fr) 110px;
  gap: 10px;
  align-items: center;
  min-height: 34px;
}

.bar-track {
  position: relative;
  height: 12px;
  border-radius: 999px;
  overflow: hidden;
  background: #ece8df;
}

.bar-fill {
  position: absolute;
  inset: 0 auto 0 0;
  width: var(--size, 0%);
  border-radius: inherit;
  background: var(--brand);
}

.bar-fill.expense {
  background: var(--accent);
}

.bar-fill.tax {
  background: var(--sky);
}

.list {
  display: grid;
  gap: 8px;
}

.list-item {
  display: flex;
  justify-content: space-between;
  gap: 14px;
  padding: 11px 0;
  border-bottom: 1px solid var(--line);
}

.list-item:last-child {
  border-bottom: 0;
}

.book-card {
  display: grid;
  gap: 12px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel-2);
}

.book-card h3 {
  margin: 0;
  font-size: 16px;
}

.book-card p {
  margin: 0;
}

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

.validation-item {
  display: grid;
  grid-template-columns: 86px 1fr;
  gap: 10px;
  padding: 10px 0;
  border-bottom: 1px solid var(--line);
}

.validation-item:last-child {
  border-bottom: 0;
}

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

.agent-endpoint > div {
  display: grid;
  gap: 6px;
  min-width: 0;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel-2);
}

.agent-endpoint span {
  color: var(--muted);
  font-size: 12px;
  font-weight: 850;
  text-transform: uppercase;
}

.agent-endpoint code {
  overflow-wrap: anywhere;
  font-family: Consolas, "Courier New", monospace;
  font-size: 13px;
}

.verifactu-box {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 18px;
  align-items: start;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel-2);
}

.qr-frame {
  display: grid;
  justify-items: center;
  gap: 6px;
  min-width: 150px;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  text-align: center;
}

.qr-frame img,
.qr-frame canvas {
  width: 132px;
  height: 132px;
}

.hash {
  overflow-wrap: anywhere;
  font-family: Consolas, "Courier New", monospace;
  font-size: 12px;
}

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

.table-wrap {
  overflow: auto;
  min-width: 0;
}

.inline-table {
  overflow: auto;
  min-width: 0;
}

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

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

th {
  background: var(--panel-2);
  color: var(--muted);
  font-size: 12px;
  font-weight: 850;
  text-transform: uppercase;
}

tr:last-child td {
  border-bottom: 0;
}

.amount {
  white-space: nowrap;
  text-align: right;
  font-variant-numeric: tabular-nums;
}

.pill {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 25px;
  border-radius: 999px;
  padding: 0 10px;
  background: var(--soft-brand);
  color: var(--brand-dark);
  font-size: 12px;
  font-weight: 850;
  white-space: nowrap;
}

.pill.warning {
  background: var(--soft-accent);
  color: #9a5718;
}

.pill.info {
  background: var(--soft-sky);
  color: #215c83;
}

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

.pill.good {
  background: #e7f3ec;
  color: var(--good);
}

.icon-text {
  display: inline-flex;
  align-items: center;
  gap: 8px;
}

.ghost {
  border: 1px solid var(--line);
  background: #fff;
  color: var(--ink);
}

.subtle {
  background: var(--panel-2);
  color: var(--ink);
}

.danger-button {
  background: var(--danger);
}

.icon-button {
  display: inline-grid;
  place-items: center;
  width: 38px;
  min-width: 38px;
  padding: 0;
}

.icon {
  display: inline-block;
  width: 18px;
  height: 18px;
  flex: 0 0 auto;
}

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

.modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 20;
  display: grid;
  place-items: center;
  padding: 20px;
  background: rgba(32, 35, 38, 0.48);
}

.modal {
  width: min(760px, 100%);
  max-height: min(88vh, 820px);
  overflow: auto;
  border-radius: 8px;
  background: var(--panel);
  box-shadow: 0 24px 60px rgba(20, 18, 14, 0.24);
}

.modal header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  padding: 18px;
  border-bottom: 1px solid var(--line);
}

.modal h2 {
  margin: 0;
  font-size: 20px;
}

.modal-body {
  padding: 18px;
}

.form {
  display: grid;
  gap: 14px;
}

.grid-2 {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
}

.grid-3 {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 14px;
}

.quote-lines {
  display: grid;
  gap: 10px;
}

.quote-lines-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.quote-lines-header > span,
.quote-lines-labels span {
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
  text-transform: uppercase;
}

.quote-lines-grid {
  display: grid;
  grid-template-columns: 110px minmax(220px, 1fr) 150px 42px;
  gap: 10px;
  align-items: end;
}

.quote-line {
  margin-top: 10px;
}

.quote-line .icon-button {
  min-width: 42px;
  min-height: 42px;
}

.form-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  margin-top: 2px;
}

.error {
  min-height: 20px;
  margin: 0;
  color: var(--danger);
  font-weight: 750;
}

.totals {
  display: grid;
  grid-template-columns: repeat(4, minmax(120px, 1fr));
  gap: 10px;
}

.total-box {
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel-2);
}

.total-box span {
  display: block;
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
  text-transform: uppercase;
}

.total-box strong {
  display: block;
  margin-top: 7px;
  font-size: 22px;
}

.empty {
  padding: 30px 16px;
  color: var(--muted);
  text-align: center;
}

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

  .sidebar {
    min-height: auto;
    max-width: 100vw;
    overflow: hidden;
  }

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

  .nav button {
    flex: 0 0 132px;
  }

  .topbar {
    align-items: flex-start;
    flex-direction: column;
  }

  .topbar-actions {
    justify-content: flex-start;
    width: 100%;
  }

  .kpis {
    grid-template-columns: repeat(3, minmax(130px, 1fr));
  }

  .dashboard-grid,
  .reports-grid,
  .official-grid {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 680px) {
  .content {
    padding: 18px;
  }

  .topbar {
    padding: 16px 18px;
  }

  .toolbar {
    align-items: stretch;
    flex-direction: column;
  }

  .toolbar-group,
  .topbar-actions {
    align-items: stretch;
    flex-direction: column;
  }

  .compact-label,
  .search,
  .topbar-actions button {
    width: 100%;
  }

  .kpis,
  .totals,
  .grid-2,
  .grid-3 {
    grid-template-columns: 1fr;
  }

  .quote-lines-header {
    align-items: stretch;
    flex-direction: column;
  }

  .quote-lines-grid {
    grid-template-columns: 58px minmax(92px, 1fr) 82px 36px;
    gap: 6px;
  }

  .quote-lines-labels span {
    font-size: 10px;
    line-height: 1.15;
  }

  .quote-line input,
  .quote-line .icon-button {
    min-height: 38px;
    padding-left: 8px;
    padding-right: 8px;
  }

  .quote-line .icon-button {
    min-width: 36px;
    padding: 0;
  }

  .bar-row {
    grid-template-columns: 74px 1fr;
  }

  .verifactu-box {
    grid-template-columns: 1fr;
  }

  .agent-endpoint {
    grid-template-columns: 1fr;
  }

  .bar-row strong {
    grid-column: 1 / -1;
  }

  .form-footer {
    align-items: stretch;
    flex-direction: column;
  }
}
