* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font: 14px -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  color: #172033;
  background: #eef2f7;
}

.hidden {
  display: none !important;
}

.auth-view {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
}

.auth-layout {
  width: min(1120px, 100%);
  display: grid;
  grid-template-columns: minmax(340px, 420px) minmax(440px, 1fr);
  gap: 64px;
  align-items: center;
}

.auth-panel {
  width: 100%;
  background: #ffffff;
  border: 1px solid #d8dee9;
  border-radius: 8px;
  padding: 22px;
  box-shadow: 0 18px 45px rgb(15 23 42 / 14%);
}

.auth-panel h1 {
  margin: 0 0 18px;
  font-size: 22px;
}

.auth-logo {
  display: block;
  width: min(630px, 100%);
  max-height: 540px;
  object-fit: contain;
}

.auth-brand {
  min-height: 520px;
  display: grid;
  place-items: center;
  padding: 24px;
}

.auth-brand picture {
  display: grid;
  place-items: center;
  width: 100%;
}

.auth-tabs {
  display: flex;
  gap: 8px;
  margin-bottom: 16px;
}

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

.auth-help {
  margin: 0;
  padding: 9px 10px;
  border: 1px solid #d8dee9;
  border-radius: 6px;
  color: #465066;
  background: #f7f9fc;
  line-height: 1.35;
}

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

#authStatus {
  min-height: 20px;
  margin: 14px 0 0;
  color: #536078;
}

.app {
  min-height: 100vh;
  display: grid;
  grid-template-rows: auto 1fr auto;
}

.toolbar {
  display: grid;
  grid-template-columns: 140px minmax(260px, 1fr) 140px minmax(220px, 0.75fr);
  gap: 10px 12px;
  align-items: end;
  padding: 16px;
  background: #ffffff;
  border-bottom: 1px solid #d8dee9;
}

.user-badge {
  grid-column: 1 / 5;
  justify-self: start;
  min-height: 28px;
  display: inline-flex;
  align-items: center;
  padding: 0 10px;
  border: 1px solid #d8dee9;
  border-radius: 6px;
  color: #465066;
  background: #f7f9fc;
  font-weight: 700;
}

label {
  display: contents;
  font-weight: 600;
  color: #465066;
}

input,
select {
  min-width: 0;
  height: 34px;
  border: 1px solid #c9d2e1;
  border-radius: 6px;
  padding: 0 10px;
  color: #172033;
  background: #fbfcfe;
}

.actions {
  grid-column: 2 / 5;
  display: flex;
  justify-content: flex-end;
  flex-wrap: wrap;
  gap: 8px;
}

.progress-row {
  grid-column: 2 / 5;
  display: grid;
  grid-template-columns: minmax(180px, 1fr) 48px;
  gap: 10px;
  align-items: center;
}

progress {
  width: 100%;
  height: 12px;
}

#progressText {
  font-variant-numeric: tabular-nums;
  color: #536078;
  text-align: right;
}

button {
  height: 34px;
  border: 1px solid #b8c4d8;
  border-radius: 6px;
  padding: 0 14px;
  color: #15213a;
  background: #ffffff;
  font-weight: 700;
  cursor: pointer;
}

button:hover:not(:disabled) {
  background: #f3f6fb;
}

button:disabled {
  color: #8b95a8;
  cursor: default;
}

#exportBtn {
  background: #174ea6;
  color: #ffffff;
  border-color: #174ea6;
}

.table-wrap {
  overflow: auto;
  padding: 14px 16px;
}

.totals-wrap {
  padding: 0 16px 14px;
}

.totals-panel {
  background: #ffffff;
  border: 1px solid #d8dee9;
  padding: 12px;
}

.totals-panel h2 {
  margin: 0 0 10px;
  font-size: 14px;
  color: #465066;
}

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

.totals-card {
  border: 1px solid #e4e9f2;
  background: #fbfcfe;
}

.totals-card h3 {
  margin: 0;
  padding: 8px 10px;
  font-size: 12px;
  color: #536078;
  background: #f7f9fc;
  border-bottom: 1px solid #e4e9f2;
}

.totals-table {
  width: 100%;
  border-collapse: collapse;
}

.totals-table td {
  padding: 7px 10px;
  border-bottom: 1px solid #edf1f7;
}

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

.totals-table td:last-child {
  text-align: right;
  font-variant-numeric: tabular-nums;
}

.totals-table td:only-child {
  text-align: right;
  font-variant-numeric: tabular-nums;
}

table {
  width: 100%;
  border-collapse: collapse;
  table-layout: fixed;
  background: #ffffff;
  border: 1px solid #d8dee9;
}

.col-file {
  width: 24%;
}

.col-date {
  width: 8%;
}

.col-company {
  width: 22%;
}

.col-category {
  width: 13%;
}

.col-amount {
  width: 8%;
}

.col-currency {
  width: 5%;
}

.col-cc {
  width: 4%;
}

.col-status {
  width: 10%;
}

.col-delete {
  width: 6%;
}

.user-mode .col-file,
.user-mode th:first-child,
.user-mode td:first-child {
  display: none;
}

.user-mode .col-date {
  width: 10%;
}

.user-mode .col-company {
  width: 30%;
}

.user-mode .col-category {
  width: 17%;
}

.user-mode .col-amount {
  width: 10%;
}

.user-mode .col-currency {
  width: 6%;
}

.user-mode .col-status {
  width: 17%;
}

.user-mode .col-delete {
  width: 6%;
}

th,
td {
  border-bottom: 1px solid #e4e9f2;
  padding: 8px;
  text-align: left;
  vertical-align: middle;
}

th {
  position: sticky;
  top: 0;
  background: #f7f9fc;
  color: #536078;
  font-size: 12px;
  text-transform: uppercase;
}

td input,
td select {
  width: 100%;
  height: 30px;
}

td {
  overflow: hidden;
  text-overflow: ellipsis;
}

td:nth-child(5) input {
  font-variant-numeric: tabular-nums;
}

td:nth-child(6) input {
  text-transform: uppercase;
}

.num {
  text-align: right;
}

.cc {
  text-align: center;
}

.err {
  color: #b42318;
}

.delete-btn {
  height: 28px;
  padding: 0 10px;
  color: #b42318;
  border-color: #f2b8b5;
  background: #fff8f7;
}

.modal {
  position: fixed;
  inset: 0;
  display: grid;
  place-items: center;
  background: rgb(15 23 42 / 42%);
  z-index: 20;
}

.modal.hidden {
  display: none;
}

.modal-panel {
  width: min(420px, calc(100vw - 32px));
  background: #ffffff;
  border: 1px solid #d8dee9;
  border-radius: 8px;
  padding: 18px;
  box-shadow: 0 18px 45px rgb(15 23 42 / 20%);
}

.modal-panel.wide {
  width: min(760px, calc(100vw - 32px));
}

.modal-panel h2 {
  margin: 0 0 10px;
  font-size: 18px;
}

.modal-panel p {
  margin: 0 0 18px;
  color: #465066;
}

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

button.danger {
  color: #ffffff;
  background: #b42318;
  border-color: #b42318;
}

button.primary {
  color: #ffffff;
  background: #174ea6;
  border-color: #174ea6;
}

.form-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  margin-bottom: 18px;
}

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

.form-grid .span-2 {
  grid-column: span 2;
}

.checkbox-field {
  align-content: end;
  grid-template-columns: 1fr auto;
  align-items: center;
}

.checkbox-field input {
  width: 18px;
  height: 18px;
  justify-self: start;
}

.users-list {
  display: grid;
  gap: 8px;
  margin: 12px 0 18px;
}

.user-row {
  display: grid;
  grid-template-columns: 1fr 90px 120px;
  gap: 10px;
  align-items: center;
  padding: 8px 0;
  border-bottom: 1px solid #edf1f7;
}

.user-row:last-child {
  border-bottom: 0;
}

.user-row span {
  color: #536078;
}

.user-row small {
  display: block;
  margin-top: 3px;
  color: #6b7486;
  font-weight: 500;
}

footer {
  min-height: 38px;
  padding: 10px 16px;
  background: #ffffff;
  border-top: 1px solid #d8dee9;
  color: #465066;
}

@media (max-width: 700px) {
  body {
    font-size: 13px;
  }

  .auth-view {
    padding: 16px;
    align-items: start;
  }

  .auth-layout {
    grid-template-columns: 1fr;
    gap: 18px;
  }

  .auth-brand {
    order: -1;
    min-height: 120px;
    padding: 0;
  }

  .auth-logo {
    width: min(300px, 78%);
    max-height: 180px;
  }

  .toolbar {
    grid-template-columns: 1fr 1fr;
    gap: 8px;
    padding: 10px;
  }

  .user-badge,
  .actions,
  .progress-row {
    grid-column: 1 / 3;
  }

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

  button {
    height: 32px;
    padding: 0 10px;
    font-size: 12px;
  }

  .table-wrap {
    padding: 8px;
  }

  table {
    width: max-content;
    min-width: 680px;
  }

  .user-mode table {
    min-width: 560px;
  }

  th,
  td {
    padding: 6px;
  }

  th {
    font-size: 10px;
  }

  td input,
  td select {
    height: 28px;
    padding: 0 6px;
    font-size: 13px;
  }

  .col-file {
    width: 150px;
  }

  .col-date,
  .user-mode .col-date {
    width: 58px;
  }

  .col-company,
  .user-mode .col-company {
    width: 150px;
  }

  .col-category,
  .user-mode .col-category {
    width: 108px;
  }

  .col-amount,
  .user-mode .col-amount {
    width: 88px;
  }

  .col-currency,
  .user-mode .col-currency {
    width: 56px;
  }

  .col-cc {
    width: 40px;
  }

  .col-status,
  .user-mode .col-status {
    width: 62px;
  }

  .col-delete,
  .user-mode .col-delete {
    width: 58px;
  }

  td:nth-child(5) input {
    min-width: 76px;
  }

  td:nth-child(6) input {
    min-width: 44px;
    padding: 0 4px;
  }

  .totals-wrap {
    padding: 0 8px 8px;
  }

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