:root {
  color-scheme: light;
  --bg: #f4f6f8;
  --surface: #ffffff;
  --surface-strong: #f9fafb;
  --text: #18202a;
  --muted: #657180;
  --line: #d9e0e7;
  --line-strong: #b7c2ce;
  --accent: #0f766e;
  --accent-dark: #0b5e58;
  --amber: #a16207;
  --red: #b42318;
  --blue: #2563eb;
  --shadow: 0 12px 30px rgba(15, 23, 42, 0.08);
  font-family:
    Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI",
    sans-serif;
}

* {
  box-sizing: border-box;
}

[hidden] {
  display: none !important;
}

body {
  min-width: 320px;
  margin: 0;
  color: var(--text);
  background: var(--bg);
}

button,
input,
select {
  font: inherit;
}

button {
  cursor: pointer;
}

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

.login-card {
  width: min(100%, 420px);
  display: grid;
  gap: 16px;
  padding: 24px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  box-shadow: var(--shadow);
}

.login-card .primary-action {
  width: 100%;
}

.login-error {
  min-height: 22px;
  margin: 0;
  color: var(--red);
  font-size: 0.92rem;
  font-weight: 700;
}

.app-shell {
  width: min(1440px, calc(100% - 32px));
  margin: 0 auto;
  padding: 24px 0 40px;
}

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

h1 {
  margin: 0;
  font-size: clamp(1.55rem, 1.3rem + 0.9vw, 2.2rem);
  line-height: 1.1;
  letter-spacing: 0;
}

p {
  margin: 6px 0 0;
  color: var(--muted);
}

.status-pill {
  display: inline-flex;
  align-items: center;
  min-height: 32px;
  padding: 5px 10px;
  border: 1px solid #b8d9d4;
  border-radius: 999px;
  color: var(--accent-dark);
  background: #e8f6f4;
  font-size: 0.88rem;
  font-weight: 650;
  white-space: nowrap;
}

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

.secondary-action {
  min-height: 32px;
  padding: 5px 10px;
  border: 1px solid var(--line-strong);
  border-radius: 6px;
  color: var(--text);
  background: #ffffff;
  font-weight: 700;
}

.secondary-action:hover {
  border-color: var(--accent);
}

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

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

.file-panel {
  display: grid;
  gap: 10px;
  min-height: 126px;
  padding: 18px;
  border-style: dashed;
  cursor: pointer;
}

.file-panel.is-dragging {
  border-color: var(--accent);
  background: #f0fdfa;
}

.panel-title {
  color: var(--text);
  font-size: 1rem;
  font-weight: 750;
}

.file-panel input {
  width: 100%;
  color: var(--muted);
}

.file-meta {
  min-height: 22px;
  color: var(--muted);
  font-size: 0.92rem;
}

.controls-panel {
  padding: 16px;
  margin-bottom: 16px;
}

.control-grid {
  display: grid;
  grid-template-columns: repeat(6, minmax(120px, 1fr)) auto;
  gap: 12px;
  align-items: end;
}

label span {
  display: block;
  margin-bottom: 6px;
  color: var(--muted);
  font-size: 0.82rem;
  font-weight: 700;
}

input[type="number"],
input[type="password"],
input[type="text"],
select {
  width: 100%;
  min-height: 40px;
  padding: 8px 10px;
  border: 1px solid var(--line-strong);
  border-radius: 6px;
  color: var(--text);
  background: #ffffff;
}

input[type="number"]:focus,
input[type="password"]:focus,
input[type="text"]:focus,
select:focus {
  outline: 3px solid rgba(15, 118, 110, 0.18);
  border-color: var(--accent);
}

.primary-action,
.exports button,
.tab {
  min-height: 40px;
  border: 1px solid var(--line-strong);
  border-radius: 6px;
  background: #ffffff;
  color: var(--text);
  font-weight: 700;
}

.primary-action {
  min-width: 112px;
  border-color: var(--accent);
  color: #ffffff;
  background: var(--accent);
}

.primary-action:hover {
  background: var(--accent-dark);
}

.messages {
  display: grid;
  gap: 8px;
  margin-bottom: 16px;
}

.message {
  padding: 10px 12px;
  border: 1px solid #f1d59a;
  border-radius: 6px;
  color: #6f4b05;
  background: #fff7e6;
  font-size: 0.92rem;
}

.message.is-error {
  border-color: #f1b4ad;
  color: var(--red);
  background: #fff1f0;
}

.metrics {
  display: grid;
  grid-template-columns: repeat(6, minmax(0, 1fr));
  gap: 12px;
  margin-bottom: 16px;
}

.metric {
  min-height: 86px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
}

.metric-value {
  display: block;
  color: var(--text);
  font-size: 1.55rem;
  line-height: 1.1;
  font-weight: 800;
}

.metric-label {
  display: block;
  margin-top: 8px;
  color: var(--muted);
  font-size: 0.82rem;
  font-weight: 700;
}

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

.section-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px;
  border-bottom: 1px solid var(--line);
  background: var(--surface-strong);
}

.tabs,
.exports {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.tab {
  padding: 8px 12px;
}

.tab.is-active {
  border-color: #96c7c0;
  color: var(--accent-dark);
  background: #e8f6f4;
}

.exports button {
  min-height: 34px;
  padding: 6px 10px;
  font-size: 0.86rem;
}

.exports button:hover,
.tab:hover {
  border-color: var(--accent);
}

.table-wrap {
  width: 100%;
  overflow: auto;
}

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

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

th {
  position: sticky;
  top: 0;
  z-index: 1;
  color: #344054;
  background: #eef2f6;
  font-size: 0.78rem;
  letter-spacing: 0;
  text-transform: uppercase;
}

td {
  color: #263241;
}

tbody tr:hover {
  background: #f8fbfb;
}

.mono {
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono",
    monospace;
}

.status {
  display: inline-flex;
  align-items: center;
  min-height: 24px;
  padding: 2px 8px;
  border-radius: 999px;
  font-size: 0.78rem;
  font-weight: 800;
  white-space: nowrap;
}

.status.payable {
  color: var(--accent-dark);
  background: #e8f6f4;
}

.status.manual {
  color: var(--amber);
  background: #fff7e6;
}

.status.unmatched,
.status.ignored {
  color: var(--red);
  background: #fff1f0;
}

.empty-state {
  min-height: 180px;
  display: grid;
  place-items: center;
  color: var(--muted);
  font-weight: 700;
}

.truncate {
  max-width: 360px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

@media (max-width: 1180px) {
  .control-grid {
    grid-template-columns: repeat(3, minmax(130px, 1fr));
  }

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

@media (max-width: 760px) {
  .app-shell {
    width: min(100% - 20px, 1440px);
    padding-top: 14px;
  }

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

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

  .upload-grid,
  .control-grid,
  .metrics {
    grid-template-columns: 1fr;
  }

  .status-pill {
    width: fit-content;
  }

  table {
    min-width: 820px;
  }
}
