:root {
  --ink: #13262f;
  --muted: #667176;
  --line: #d8dedc;
  --soft: #f6f3ec;
  --paper: #ffffff;
  --teal: #0f8b8d;
  --teal-strong: #0b6668;
  --berry: #9a344f;
  --amber: #d89d2b;
  --green: #28764f;
  --red: #b64444;
  --shadow: 0 16px 36px rgba(19, 38, 47, 0.08);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  color: var(--ink);
  background: #edf1ee;
}

* {
  box-sizing: border-box;
}

html {
  min-width: 320px;
}

body {
  margin: 0;
  min-height: 100vh;
  background:
    linear-gradient(180deg, rgba(246, 243, 236, 0.9), rgba(237, 241, 238, 0.92)),
    repeating-linear-gradient(90deg, rgba(19, 38, 47, 0.035) 0 1px, transparent 1px 96px);
  color: var(--ink);
}

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

button {
  border: 0;
  cursor: pointer;
}

.shell {
  width: min(1480px, calc(100% - 32px));
  margin: 0 auto;
  padding: 20px 0 32px;
}

.topbar {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 16px;
  align-items: start;
  padding: 18px;
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
}

.brand {
  display: flex;
  gap: 14px;
  align-items: center;
  min-width: 0;
}

.mark {
  width: 44px;
  height: 44px;
  border-radius: 8px;
  background: var(--ink);
  display: grid;
  place-items: center;
  color: var(--soft);
  font-weight: 800;
  flex: 0 0 auto;
}

h1,
h2,
h3,
p {
  margin: 0;
}

h1 {
  font-size: clamp(1.35rem, 2.1vw, 2.1rem);
  line-height: 1.12;
  font-weight: 780;
  letter-spacing: 0;
}

.subtle {
  color: var(--muted);
  font-size: 0.95rem;
  margin-top: 5px;
  line-height: 1.45;
}

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

.button,
button.button,
label.button,
a.button {
  min-height: 40px;
  padding: 0 13px;
  border-radius: 8px;
  background: var(--ink);
  color: white;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  font-weight: 700;
  line-height: 1.1;
  white-space: nowrap;
  text-decoration: none;
}

.button:hover,
.button:focus-visible {
  background: #0c1a20;
}

.button.secondary {
  background: #e8eeeb;
  color: var(--ink);
  border: 1px solid #cfd8d4;
}

.button.secondary:hover,
.button.secondary:focus-visible {
  background: #dce7e2;
}

.button.ghost {
  background: transparent;
  color: var(--teal-strong);
  border: 1px solid rgba(15, 139, 141, 0.32);
}

.button.danger {
  background: #fbebeb;
  color: var(--red);
  border: 1px solid #efc9c9;
}

.button.small {
  min-height: 34px;
  padding: 0 10px;
  font-size: 0.9rem;
}

.status {
  min-height: 40px;
  padding: 10px 12px;
  margin: 14px 0 0;
  border-radius: 8px;
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.78);
  color: var(--muted);
  line-height: 1.35;
}

.status.error {
  color: var(--red);
  background: #fbebeb;
  border-color: #efc9c9;
}

.status.ok {
  color: var(--green);
  background: #eaf6ef;
  border-color: #c8e6d4;
}

.kpis {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 10px;
  margin: 14px 0;
}

.kpi {
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 14px;
  min-height: 92px;
}

.kpi span {
  display: block;
  color: var(--muted);
  font-size: 0.83rem;
  margin-bottom: 8px;
}

.kpi strong {
  display: block;
  font-size: clamp(1.15rem, 2vw, 1.6rem);
  line-height: 1.12;
  overflow-wrap: anywhere;
}

.tabs {
  display: flex;
  gap: 6px;
  padding: 6px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.76);
  position: sticky;
  top: 0;
  z-index: 5;
  backdrop-filter: blur(12px);
  overflow-x: auto;
}

.tab {
  min-height: 42px;
  padding: 0 14px;
  border-radius: 8px;
  background: transparent;
  color: var(--muted);
  font-weight: 750;
  white-space: nowrap;
}

.tab.active {
  background: var(--ink);
  color: white;
}

.workspace {
  margin-top: 14px;
}

.view {
  display: none;
}

.view.active {
  display: block;
}

.split {
  display: grid;
  grid-template-columns: minmax(330px, 420px) 1fr;
  gap: 14px;
  align-items: start;
}

.panel {
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
  overflow: hidden;
}

.panel-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 15px 16px;
  border-bottom: 1px solid var(--line);
  background: #fbfcfb;
}

.panel-head h2 {
  font-size: 1rem;
  line-height: 1.2;
}

.panel-body {
  padding: 16px;
}

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

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

.field.full {
  grid-column: 1 / -1;
}

label {
  font-size: 0.88rem;
  font-weight: 730;
  color: #31444b;
}

input,
select,
textarea {
  width: 100%;
  min-height: 42px;
  border: 1px solid #ccd6d2;
  border-radius: 8px;
  background: #fff;
  color: var(--ink);
  padding: 9px 10px;
  outline: none;
}

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

input:focus,
select:focus,
textarea:focus {
  border-color: var(--teal);
  box-shadow: 0 0 0 3px rgba(15, 139, 141, 0.14);
}

.form-actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  margin-top: 14px;
}

.list-tools {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 10px;
  margin-bottom: 12px;
}

.table-wrap {
  overflow-x: auto;
  border: 1px solid var(--line);
  border-radius: 8px;
}

table {
  width: 100%;
  border-collapse: collapse;
  min-width: 760px;
  background: #fff;
}

th,
td {
  padding: 11px 12px;
  border-bottom: 1px solid #e7ecea;
  text-align: left;
  vertical-align: top;
  font-size: 0.92rem;
  line-height: 1.35;
}

th {
  position: sticky;
  top: 0;
  background: #f7faf8;
  color: #435258;
  font-size: 0.8rem;
  text-transform: uppercase;
  font-weight: 800;
  z-index: 1;
}

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

.right {
  text-align: right;
}

.nowrap {
  white-space: nowrap;
}

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

.amount-pos {
  color: var(--green);
  font-weight: 800;
}

.amount-neg {
  color: var(--berry);
  font-weight: 800;
}

.pill {
  display: inline-flex;
  align-items: center;
  min-height: 24px;
  padding: 2px 8px;
  border-radius: 999px;
  border: 1px solid #d9e1dd;
  background: #f4f7f5;
  color: #31444b;
  font-size: 0.8rem;
  font-weight: 760;
  white-space: nowrap;
}

.pill.debit {
  border-color: rgba(40, 118, 79, 0.25);
  background: rgba(40, 118, 79, 0.08);
  color: var(--green);
}

.pill.credit {
  border-color: rgba(154, 52, 79, 0.25);
  background: rgba(154, 52, 79, 0.08);
  color: var(--berry);
}

.row-actions {
  display: flex;
  gap: 6px;
  justify-content: flex-end;
  flex-wrap: wrap;
}

.line-builder {
  display: grid;
  grid-template-columns: 1.2fr 0.45fr 0.55fr 1fr auto;
  gap: 10px;
  align-items: end;
  margin-bottom: 12px;
}

.line-list {
  display: grid;
  gap: 8px;
  margin-top: 10px;
}

.line-row {
  display: grid;
  grid-template-columns: 1fr auto auto;
  gap: 10px;
  align-items: center;
  padding: 10px;
  border: 1px solid #e2e8e5;
  border-radius: 8px;
  background: #fbfcfb;
}

.line-row strong {
  font-size: 0.92rem;
}

.statement-layout {
  display: grid;
  grid-template-columns: 320px 1fr;
  gap: 14px;
  align-items: start;
}

.statement-summary {
  display: grid;
  gap: 10px;
}

.total-card {
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfcfb;
}

.total-card span {
  display: block;
  color: var(--muted);
  font-size: 0.83rem;
  margin-bottom: 6px;
}

.total-card strong {
  font-size: 1.24rem;
  overflow-wrap: anywhere;
}

.empty {
  border: 1px dashed #bfc9c5;
  border-radius: 8px;
  padding: 18px;
  color: var(--muted);
  background: #fbfcfb;
  line-height: 1.5;
}

.notice {
  border-left: 4px solid var(--amber);
  padding: 10px 12px;
  background: #fff8e8;
  color: #5b4520;
  border-radius: 8px;
  margin-bottom: 12px;
  line-height: 1.45;
  font-size: 0.92rem;
}

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

.login-card {
  width: min(420px, 100%);
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
  padding: 22px;
}

.login-card form {
  display: grid;
  gap: 12px;
  margin-top: 18px;
}

.print-area {
  display: none;
}

@media (max-width: 1040px) {
  .split,
  .statement-layout {
    grid-template-columns: 1fr;
  }

  .line-builder {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .line-builder .field.full-mobile {
    grid-column: 1 / -1;
  }
}

@media (max-width: 720px) {
  .shell {
    width: min(100% - 20px, 1480px);
    padding-top: 10px;
  }

  .topbar {
    grid-template-columns: 1fr;
  }

  .actions {
    justify-content: flex-start;
  }

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

  .form-grid,
  .line-builder,
  .list-tools {
    grid-template-columns: 1fr;
  }

  table {
    min-width: 720px;
  }
}

@media (max-width: 460px) {
  .kpis {
    grid-template-columns: 1fr;
  }

  .brand {
    align-items: flex-start;
  }

  .mark {
    width: 38px;
    height: 38px;
  }
}

@media print {
  body {
    background: white;
  }

  .shell {
    display: none;
  }

  .print-area {
    display: block;
    padding: 18px;
    color: #111;
  }

  .print-head {
    display: flex;
    justify-content: space-between;
    gap: 20px;
    border-bottom: 2px solid #111;
    padding-bottom: 12px;
    margin-bottom: 14px;
  }

  .print-head h1 {
    font-size: 22px;
  }

  .print-area table {
    min-width: 0;
    font-size: 11px;
  }

  .print-area th,
  .print-area td {
    padding: 7px 6px;
    border-color: #bbb;
  }
}

