:root {
  color-scheme: light;
  --bg: #f4f7fa;
  --panel: #ffffff;
  --ink: #102033;
  --muted: #647386;
  --muted-2: #8390a1;
  --line: #dbe3ec;
  --line-strong: #c7d3df;
  --mk-blue: #0b2f57;
  --mk-blue-2: #123f6c;
  --mk-steel: #5d7287;
  --mk-lime: #d7ee32;
  --mk-lime-soft: #f6fbd6;
  --ok: #1f7a4d;
  --ok-bg: #ecf8f1;
  --warn: #9a6700;
  --warn-bg: #fff7e6;
  --bad: #b42318;
  --bad-bg: #fff1f0;
  --edited: #fff9dc;
  --shadow: 0 12px 30px rgba(16, 32, 51, 0.06);
}

* {
  box-sizing: border-box;
}

[hidden] {
  display: none !important;
}

body {
  margin: 0;
  min-width: 320px;
  background:
    linear-gradient(180deg, #ffffff 0, #f6f8fb 260px, var(--bg) 100%);
  color: var(--ink);
  font-family: Segoe UI, Arial, sans-serif;
  letter-spacing: 0;
}

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

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

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

.brand-mark {
  display: grid;
  place-items: center;
  flex: 0 0 auto;
  width: 72px;
  height: 48px;
  border-radius: 8px;
  background: var(--mk-blue);
  color: #ffffff;
  font-size: 18px;
  font-weight: 800;
  letter-spacing: 0;
  box-shadow: inset 0 -4px 0 var(--mk-lime);
}

.local-badge {
  flex: 0 0 auto;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: #ffffff;
  color: var(--mk-blue);
  font-size: 13px;
  font-weight: 700;
  padding: 8px 12px;
}

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

.user-badge {
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--mk-lime-soft);
  color: var(--mk-blue);
  font-size: 13px;
  font-weight: 800;
  padding: 8px 12px;
}

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

h1 {
  color: var(--mk-blue);
  font-size: clamp(30px, 4vw, 42px);
  font-weight: 800;
  line-height: 1.12;
}

h2 {
  color: var(--mk-blue);
  font-size: 20px;
  font-weight: 750;
  line-height: 1.2;
}

h3 {
  color: var(--mk-blue);
  font-size: 17px;
  line-height: 1.25;
}

.topbar p,
.summary-meta,
.file-list,
.muted {
  color: var(--muted);
}

.topbar p {
  margin-top: 5px;
  font-size: 14px;
}

.section-kicker {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  color: var(--mk-steel);
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.section-kicker::before {
  content: "";
  width: 26px;
  height: 3px;
  border-radius: 999px;
  background: var(--mk-lime);
}

label {
  font-size: 13px;
  font-weight: 650;
}

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

input[type="text"],
input[type="date"],
input[type="password"],
select,
textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: #ffffff;
  color: var(--ink);
  padding: 9px 10px;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

input[type="text"]:focus,
input[type="date"]:focus,
input[type="password"]:focus,
select:focus,
textarea:focus {
  border-color: var(--mk-blue-2);
  box-shadow: 0 0 0 3px rgba(11, 47, 87, 0.08);
  outline: none;
}

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

button {
  border: 0;
  border-radius: 7px;
  background: var(--mk-blue);
  color: #ffffff;
  cursor: pointer;
  font-weight: 750;
  min-height: 40px;
  padding: 10px 16px;
  transition: background 0.15s ease, box-shadow 0.15s ease, transform 0.15s ease;
}

button:hover {
  background: var(--mk-blue-2);
  box-shadow: 0 8px 18px rgba(11, 47, 87, 0.12);
}

button:active {
  transform: translateY(1px);
}

button:disabled {
  background: #a9b7c7;
  box-shadow: none;
  cursor: wait;
}

button.secondary,
.row-action {
  border: 1px solid var(--line);
  background: #f5f8fb;
  color: var(--mk-blue);
}

button.secondary:hover,
.row-action:hover {
  background: #edf3f8;
  box-shadow: none;
}

.auth-panel,
.upload-panel,
.export-panel,
.log-panel,
.statement-block,
.summary-card,
.duplicates,
.admin-panel,
.admin-form {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
}

.auth-panel {
  display: grid;
  place-items: center;
  min-height: 420px;
  padding: 28px;
}

.auth-card {
  display: grid;
  width: min(460px, 100%);
  gap: 14px;
}

.upload-panel {
  position: relative;
  overflow: hidden;
  padding: 22px;
}

.upload-panel::before {
  content: "";
  position: absolute;
  inset: 0 0 auto;
  height: 4px;
  background: linear-gradient(90deg, var(--mk-blue) 0%, var(--mk-blue) 72%, var(--mk-lime) 72%, var(--mk-lime) 100%);
}

.upload-heading {
  display: grid;
  gap: 6px;
  margin-bottom: 16px;
}

.drop-zone {
  position: relative;
  display: grid;
  place-items: center;
  gap: 12px;
  min-height: 178px;
  border: 1.5px dashed var(--line-strong);
  border-radius: 8px;
  background: #fbfdff;
  cursor: pointer;
  overflow: hidden;
  text-align: center;
  transition: border-color 0.15s ease, background 0.15s ease, box-shadow 0.15s ease;
}

.drop-zone::after {
  content: "";
  position: absolute;
  bottom: 0;
  left: 50%;
  width: 88px;
  height: 4px;
  border-radius: 999px 999px 0 0;
  background: var(--mk-lime);
  transform: translateX(-50%);
}

.drop-zone.dragover {
  border-color: var(--mk-blue);
  background: #f4f8fc;
  box-shadow: inset 0 0 0 1px rgba(11, 47, 87, 0.08);
}

.drop-label {
  color: var(--mk-blue);
  font-size: clamp(19px, 2.6vw, 24px);
  font-weight: 800;
  line-height: 1.2;
}

.drop-zone strong {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 38px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: #ffffff;
  color: var(--mk-blue);
  font-size: 14px;
  padding: 8px 14px;
}

.drop-zone input {
  display: none;
}

.upload-actions,
.export-panel,
.export-actions,
.export-options {
  display: flex;
  align-items: center;
  gap: 14px;
}

.upload-actions {
  justify-content: space-between;
  margin-top: 16px;
}

.file-list {
  display: flex;
  flex: 1 1 auto;
  flex-wrap: wrap;
  min-width: 0;
  gap: 8px;
  font-size: 13px;
}

.file-chip {
  max-width: min(360px, 100%);
  border: 1px solid var(--line);
  border-radius: 999px;
  background: #ffffff;
  color: var(--ink);
  overflow: hidden;
  padding: 7px 10px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.process-status {
  margin-top: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #f8fafc;
  color: var(--mk-blue);
  font-size: 14px;
  font-weight: 700;
  padding: 11px 12px;
}

.process-status.running {
  border-color: #b7c8da;
  background: #f2f7fc;
}

.process-status.done {
  border-color: #c8d99b;
  background: var(--mk-lime-soft);
}

.messages,
.summaries,
.duplicates,
.statements,
.export-panel,
.log-panel {
  margin-top: 18px;
}

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

.message {
  border: 1px solid var(--line);
  border-left: 4px solid var(--mk-steel);
  border-radius: 8px;
  background: #ffffff;
  color: var(--ink);
  padding: 11px 12px;
}

.message.blocking {
  border-left-color: var(--bad);
  background: var(--bad-bg);
}

.message.warning {
  border-left-color: var(--warn);
  background: var(--warn-bg);
}

.message.info {
  border-left-color: var(--mk-blue);
}

.summaries {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(330px, 1fr));
  gap: 14px;
}

.summary-card {
  position: relative;
  overflow: hidden;
  padding: 16px;
}

.summary-card::before {
  content: "";
  position: absolute;
  top: 0;
  left: 0;
  width: 5px;
  height: 100%;
  background: var(--mk-lime);
}

.summary-card.attention::before {
  background: var(--bad);
}

.summary-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 12px;
}

.summary-meta {
  margin-top: 4px;
  overflow-wrap: anywhere;
  font-size: 13px;
}

.status-ok,
.status-bad {
  flex: 0 0 auto;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 800;
  padding: 7px 10px;
  text-transform: uppercase;
}

.status-ok {
  background: var(--ok-bg);
  color: var(--ok);
}

.status-bad {
  background: var(--bad-bg);
  color: var(--bad);
}

.summary-context {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 14px;
}

.summary-context span {
  border: 1px solid var(--line);
  border-radius: 999px;
  background: #f8fafc;
  color: var(--muted);
  font-size: 13px;
  padding: 7px 10px;
}

.summary-context strong {
  color: var(--ink);
}

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

.metric {
  min-width: 0;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #ffffff;
  padding: 11px;
}

.metric span {
  display: block;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
  margin-bottom: 5px;
}

.metric strong {
  display: block;
  color: var(--ink);
  font-size: 17px;
  font-weight: 800;
  overflow-wrap: anywhere;
}

.metric.highlight {
  border-color: #c7d6e4;
  background: #f5f8fb;
}

.metric.highlight strong {
  color: var(--mk-blue);
  font-size: 21px;
}

.metric.ok strong {
  color: var(--ok);
}

.metric.bad strong {
  color: var(--bad);
}

.duplicates {
  padding: 16px;
}

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

.duplicate-item {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--warn-bg);
  color: var(--ink);
  padding: 10px;
}

.statement-block {
  margin-top: 16px;
  overflow: hidden;
}

.statement-title {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  padding: 14px 16px;
  border-bottom: 1px solid var(--line);
  background: #fbfdff;
}

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

table {
  width: 100%;
  border-collapse: collapse;
  table-layout: fixed;
}

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

th {
  background: #f8fafc;
  color: var(--mk-steel);
  font-size: 12px;
  font-weight: 800;
  text-transform: uppercase;
}

.col-date,
.col-value-date {
  width: 142px;
}

.col-money {
  width: 132px;
}

.col-ofx {
  width: 132px;
}

.col-source {
  width: 92px;
}

.col-actions {
  width: 112px;
}

tr.modified {
  background: var(--edited);
}

tr.deleted {
  opacity: 0.48;
  text-decoration: line-through;
}

.ofx-amount {
  color: var(--mk-blue);
  font-weight: 800;
}

.statement-actions {
  padding: 12px 16px;
  background: #fbfdff;
}

.export-panel {
  justify-content: space-between;
  padding: 16px;
  flex-wrap: wrap;
}

.export-options label {
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--ink);
}

.export-options input {
  width: auto;
  accent-color: var(--mk-blue);
}

.log-panel {
  padding: 16px;
}

pre {
  margin: 0;
  color: #344054;
  font-size: 13px;
  white-space: pre-wrap;
}

.admin-panel {
  padding: 18px;
}

.admin-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 14px;
}

.admin-form {
  display: grid;
  gap: 14px;
  padding: 16px;
  margin-bottom: 16px;
  box-shadow: none;
}

.form-grid,
.audit-filters {
  display: grid;
  grid-template-columns: repeat(5, minmax(130px, 1fr));
  gap: 12px;
}

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

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

.admin-table-wrap + .admin-header {
  margin-top: 22px;
}

.admin-table-wrap table {
  min-width: 980px;
}

.admin-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.admin-actions button {
  min-height: 34px;
  padding: 7px 10px;
}

.switch-row {
  display: flex;
  align-items: center;
  gap: 8px;
  white-space: nowrap;
}

.switch-row input {
  width: auto;
  accent-color: var(--mk-blue);
}

.audit-title {
  margin-top: 22px;
}

.audit-filters {
  margin-bottom: 12px;
}

@media (max-width: 900px) {
  .topbar,
  .top-actions,
  .upload-actions,
  .export-panel,
  .export-actions,
  .export-options {
    align-items: stretch;
    flex-direction: column;
  }

  .local-badge {
    align-self: flex-start;
  }

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

  .form-grid,
  .form-grid.two,
  .audit-filters {
    grid-template-columns: 1fr;
  }

  button {
    width: 100%;
  }
}

@media (max-width: 560px) {
  .shell {
    width: min(100% - 20px, 1420px);
    padding-top: 18px;
  }

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

  .brand-mark {
    width: 62px;
    height: 42px;
    font-size: 16px;
  }

  .upload-panel {
    padding: 16px;
  }

  .drop-zone {
    min-height: 156px;
  }

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

  .summary-head,
  .statement-title {
    flex-direction: column;
  }

  .status-ok,
  .status-bad {
    align-self: flex-start;
  }
}
