*,
*::before,
*::after {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  font-size: 16px;
  line-height: 1.5;
  color: #1a1a1a;
  background: #f5f6f8;
}

.container {
  max-width: 960px;
  margin: 0 auto;
  padding: 1.5rem;
}

.site-header {
  background: #fff;
  border-bottom: 1px solid #dde1e6;
}

.header-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  flex-wrap: wrap;
  padding-top: 1rem;
  padding-bottom: 1rem;
}

.site-title {
  font-size: 1.25rem;
  font-weight: 700;
  color: #1a1a1a;
  text-decoration: none;
}

.site-nav {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem 1rem;
}

.nav-link {
  color: #444;
  text-decoration: none;
  padding: 0.25rem 0;
  border-bottom: 2px solid transparent;
}

.nav-link:hover {
  color: #111;
}

.nav-link.active {
  color: #0b5fff;
  border-bottom-color: #0b5fff;
  font-weight: 600;
}

.nav-link-logout {
  color: #666;
}

.nav-logout-form {
  display: inline;
  margin: 0;
  padding: 0;
}

.nav-logout-form button {
  background: none;
  border: none;
  font: inherit;
  cursor: pointer;
  padding: 0.25rem 0;
  border-bottom: 2px solid transparent;
}

.nav-logout-form button:hover {
  color: #111;
}

h1 {
  margin-top: 0;
  font-size: 1.75rem;
}

h2 {
  margin-top: 0;
  font-size: 1.25rem;
}

.page-intro {
  color: #555;
  margin-bottom: 1.5rem;
}

.status-line {
  color: #666;
  margin-bottom: 1.5rem;
}

.card-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
  gap: 1rem;
}

.card {
  display: block;
  background: #fff;
  border: 1px solid #dde1e6;
  border-radius: 8px;
  padding: 1.25rem;
  text-decoration: none;
  color: inherit;
  transition: border-color 0.15s, box-shadow 0.15s;
}

.card:hover {
  border-color: #0b5fff;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.06);
}

.card h2 {
  margin-bottom: 0.5rem;
}

.card p {
  margin: 0;
  color: #555;
  font-size: 0.95rem;
}

.form {
  max-width: 420px;
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.mapping-row {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  margin-bottom: 1rem;
  padding-bottom: 1rem;
  border-bottom: 1px solid #e8eaed;
}

.mapping-row:last-child {
  border-bottom: none;
  margin-bottom: 0;
  padding-bottom: 0;
}

.mapping-ynab-select {
  margin-left: 1.5rem;
}

.form-field {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
}

.form-field span,
.form-fieldset legend {
  font-weight: 600;
  font-size: 0.9rem;
}

.form-fieldset {
  border: 1px solid #dde1e6;
  border-radius: 6px;
  padding: 1rem;
  margin: 0;
}

.checkbox-label {
  display: block;
  margin-bottom: 0.5rem;
}

input[type="text"],
input[type="password"],
input:not([type]),
select {
  padding: 0.5rem 0.75rem;
  border: 1px solid #c4c9d0;
  border-radius: 6px;
  font-size: 1rem;
}

input:focus,
select:focus {
  outline: 2px solid #0b5fff;
  outline-offset: 1px;
}

.btn {
  display: inline-block;
  padding: 0.5rem 1rem;
  border: none;
  border-radius: 6px;
  font-size: 0.95rem;
  font-weight: 600;
  cursor: pointer;
  text-decoration: none;
  text-align: center;
}

.btn-primary {
  background: #0b5fff;
  color: #fff;
}

.btn-primary:hover {
  background: #0043ce;
}

.btn-secondary {
  background: #e8eaed;
  color: #1a1a1a;
}

.btn-secondary:hover {
  background: #dde1e6;
}

.btn-danger {
  background: #fff;
  color: #da1e28;
  border: 1px solid #da1e28;
  padding: 0.35rem 0.75rem;
  font-size: 0.85rem;
}

.btn-danger:hover {
  background: #fff1f1;
}

.action-links {
  display: flex;
  gap: 0.75rem;
  flex-wrap: wrap;
}

.secondary-link {
  margin-top: 1.5rem;
}

.flash {
  padding: 0.75rem 1rem;
  border-radius: 6px;
  margin-bottom: 1rem;
}

.flash-error {
  background: #fff1f1;
  color: #a2191f;
  border: 1px solid #ffb3b8;
}

.flash-success {
  background: #defbe6;
  color: #0e6027;
  border: 1px solid #74e892;
}

.data-table {
  width: 100%;
  border-collapse: collapse;
  background: #fff;
  border: 1px solid #dde1e6;
  border-radius: 8px;
  overflow: hidden;
}

.data-table th,
.data-table td {
  padding: 0.75rem 1rem;
  text-align: left;
  border-bottom: 1px solid #dde1e6;
}

.data-table th {
  background: #f5f6f8;
  font-weight: 600;
  font-size: 0.9rem;
}

.data-table tr:last-child td {
  border-bottom: none;
}

.status-summary {
  margin-bottom: 1rem;
}

.filter-bar {
  display: flex;
  flex-wrap: wrap;
  gap: 1rem;
  align-items: flex-end;
  margin-bottom: 1rem;
  padding: 1rem;
  background: #fff;
  border: 1px solid #dde1e6;
  border-radius: 8px;
}

.filter-bar label {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
  font-size: 0.9rem;
}

.filter-bar select {
  padding: 0.4rem 0.5rem;
  border: 1px solid #dde1e6;
  border-radius: 4px;
  font-size: 0.95rem;
}

.bulk-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 1rem;
  align-items: center;
  margin-bottom: 1rem;
}

.bulk-action-form {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  align-items: center;
}

.input-narrow {
  width: 4.5rem;
  padding: 0.35rem 0.5rem;
  border: 1px solid #dde1e6;
  border-radius: 4px;
}

.status-badge {
  display: inline-block;
  padding: 0.15rem 0.5rem;
  border-radius: 4px;
  font-size: 0.85rem;
  font-weight: 600;
  text-transform: lowercase;
}

.status-pending {
  background: #edf5ff;
  color: #0043ce;
}

.status-processing {
  background: #fff8e1;
  color: #8a6100;
}

.status-completed {
  background: #defbe6;
  color: #0e6027;
}

.status-failed {
  background: #fff1f1;
  color: #a2191f;
}

.status-paused {
  background: #f4f4f4;
  color: #525252;
}

.form-wide {
  max-width: 720px;
}

.settings-header {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-start;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 1.5rem;
}

.settings-header-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
}

.categorization-table .recategorize-form {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  min-width: 14rem;
}

.recategorize-scope {
  border: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
}

.mono-cell {
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 0.85rem;
  max-width: 10rem;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.btn-small {
  padding: 0.35rem 0.65rem;
  font-size: 0.85rem;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.settings-title {
  margin-bottom: 0.25rem;
}

.settings-meta {
  margin: 0;
  color: #666;
}

.field-hint {
  margin: 0.25rem 0 0;
  color: #666;
  font-size: 0.9rem;
}

.settings-mapping-table select {
  min-width: 12rem;
  padding: 0.35rem 0.5rem;
  border: 1px solid #dde1e6;
  border-radius: 4px;
}

.add-mapping-row {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 1rem;
}

.form-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
  align-items: center;
}

.checkbox-compact {
  font-weight: normal;
  font-size: 0.9rem;
}

.error-cell {
  max-width: 12rem;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 0.9rem;
  color: #666;
}

.pagination {
  display: flex;
  flex-wrap: wrap;
  gap: 1rem;
  align-items: center;
  margin-top: 1rem;
}

.pagination-info {
  color: #666;
  font-size: 0.9rem;
}

.btn-small {
  padding: 0.35rem 0.75rem;
  font-size: 0.85rem;
}

.inline-form {
  display: inline;
}

.detail-list {
  display: grid;
  grid-template-columns: 10rem 1fr;
  gap: 0.5rem 1rem;
  background: #fff;
  border: 1px solid #dde1e6;
  border-radius: 8px;
  padding: 1rem 1.25rem;
  margin: 1rem 0;
}

.detail-list dt {
  font-weight: 600;
  color: #444;
}

.detail-list dd {
  margin: 0;
}

.payload-block {
  background: #fff;
  border: 1px solid #dde1e6;
  border-radius: 8px;
  padding: 1rem;
  overflow-x: auto;
  font-family: ui-monospace, "Cascadia Code", "Segoe UI Mono", monospace;
  font-size: 0.85rem;
  line-height: 1.4;
  white-space: pre-wrap;
  word-break: break-word;
}

.error-block {
  background: #fff1f1;
  border-color: #ffb3b8;
  color: #a2191f;
}

.detail-actions {
  margin-top: 1.5rem;
}

.auth-body {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1.5rem;
}

.auth-card {
  background: #fff;
  border: 1px solid #dde1e6;
  border-radius: 8px;
  padding: 2rem;
  width: 100%;
  max-width: 420px;
}

.auth-title {
  margin-top: 0;
  margin-bottom: 1.5rem;
  text-align: center;
  font-size: 1.5rem;
}
