:root {
  --bg: #f6f7f8;
  --surface: #ffffff;
  --text: #17202a;
  --muted: #687381;
  --line: #d9dee5;
  --primary: #2454a6;
  --primary-strong: #173e82;
  --danger: #a32626;
  --ok: #1f7a4d;
  --warn: #946200;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  font-size: 15px;
  line-height: 1.45;
}

a {
  color: var(--primary);
  text-decoration: none;
}

a:hover {
  text-decoration: underline;
}

h1,
h2,
p {
  margin-top: 0;
}

h1 {
  font-size: 28px;
  margin-bottom: 4px;
}

h2 {
  font-size: 18px;
  margin-bottom: 10px;
}

.auth-page {
  display: grid;
  min-height: 100vh;
  place-items: start center;
  padding: 96px 18px 32px;
}

.auth-card {
  width: min(100%, 420px);
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  padding: 28px;
  box-shadow: 0 18px 40px rgba(23, 32, 42, 0.08);
}

.auth-heading {
  margin-bottom: 22px;
  text-align: center;
}

.auth-logo {
  display: block;
  width: 210px;
  max-width: 100%;
  height: auto;
  margin: 0 auto 22px;
}

.auth-heading h1 {
  margin-bottom: 0;
  text-align: center;
}

.auth-form .field {
  margin-bottom: 16px;
}

.checkbox-field {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 2px 0 18px;
  color: var(--muted);
  font-size: 14px;
}

.checkbox-field input {
  width: auto;
}

.auth-submit {
  width: 100%;
}

.auth-links {
  margin-top: 16px;
  text-align: center;
  font-size: 14px;
}

input,
select,
button {
  font: inherit;
}

input,
select {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 9px 10px;
  background: #fff;
}

.admin-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-height: 58px;
  padding: 0 28px;
  background: var(--surface);
  border-bottom: 1px solid var(--line);
}

.admin-brand {
  display: inline-flex;
  align-items: center;
}

.admin-logo {
  display: block;
  width: 170px;
  height: auto;
}

.admin-nav {
  display: flex;
  align-items: center;
  gap: 18px;
}

.admin-main {
  width: min(1180px, calc(100% - 32px));
  margin: 28px auto;
}

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

.page-header p {
  color: var(--muted);
  margin-bottom: 0;
}

.header-actions,
.form-actions,
.row-actions {
  display: flex;
  align-items: center;
  gap: 10px;
}

.toolbar {
  display: flex;
  justify-content: space-between;
  gap: 18px;
  margin-bottom: 18px;
}

.inline-form {
  display: flex;
  gap: 8px;
  width: min(420px, 100%);
}

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

.filters a {
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 6px 10px;
  background: var(--surface);
}

.filters a.active {
  border-color: var(--primary);
  background: #e9f0ff;
  color: var(--primary-strong);
}

.button,
input[type="submit"].button,
button.button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 38px;
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 8px 13px;
  background: var(--surface);
  color: var(--text);
  cursor: pointer;
  white-space: nowrap;
}

.button.primary {
  border-color: var(--primary);
  background: var(--primary);
  color: #fff;
}

.button.disabled {
  color: var(--muted);
  cursor: default;
  opacity: 0.55;
}

.link-button {
  border: 0;
  padding: 0;
  background: transparent;
  color: var(--primary);
  cursor: pointer;
}

.link-button.danger {
  color: var(--danger);
}

.admin-table {
  width: 100%;
  border-collapse: collapse;
  overflow: hidden;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
}

.admin-table th,
.admin-table td {
  padding: 11px 12px;
  border-bottom: 1px solid var(--line);
  text-align: left;
  vertical-align: top;
}

.admin-table th {
  color: var(--muted);
  font-size: 13px;
  font-weight: 600;
  background: #fbfcfd;
}

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

.pagination {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-top: 18px;
}

.pagination p {
  color: var(--muted);
  margin-bottom: 0;
}

.pagination nav,
.pagy {
  display: flex;
  gap: 8px;
}

.pagy a,
.pagy span,
.pagy em {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 38px;
  min-height: 38px;
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 8px 11px;
  background: var(--surface);
  color: var(--text);
  font-style: normal;
}

.pagy a:hover {
  text-decoration: none;
  border-color: var(--primary);
}

.pagy .current {
  border-color: var(--primary);
  background: var(--primary);
  color: #fff;
}

.pagy .gap,
.pagy .disabled {
  color: var(--muted);
  opacity: 0.55;
}

.status {
  display: inline-block;
  border-radius: 999px;
  padding: 3px 9px;
  background: #eef1f4;
  font-size: 13px;
  font-weight: 600;
}

.status-synced {
  background: #e4f5ed;
  color: var(--ok);
}

.status-failed {
  background: #fdeaea;
  color: var(--danger);
}

.status-syncing,
.status-pending {
  background: #fff3d8;
  color: var(--warn);
}

.detail-list {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 12px;
  margin: 0 0 24px;
}

.detail-list div,
.admin-form,
.code-block {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
}

.detail-list div {
  padding: 12px;
}

.detail-list dt {
  color: var(--muted);
  font-size: 13px;
}

.detail-list dd {
  margin: 4px 0 0;
}

.admin-form {
  max-width: 520px;
  padding: 20px;
}

.field {
  margin-bottom: 14px;
}

.field label {
  display: block;
  margin-bottom: 5px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 600;
}

.code-block {
  overflow: auto;
  max-height: 420px;
  padding: 14px;
  white-space: pre-wrap;
}

.flash {
  width: min(1180px, calc(100% - 32px));
  margin: 14px auto;
  border-radius: 6px;
  padding: 10px 12px;
}

.flash-notice {
  background: #e4f5ed;
  color: var(--ok);
}

.flash-alert {
  background: #fdeaea;
  color: var(--danger);
}

@media (max-width: 760px) {
  .admin-header,
  .page-header,
  .toolbar {
    align-items: stretch;
    flex-direction: column;
  }

  .admin-nav,
  .filters {
    justify-content: flex-start;
  }

  .inline-form,
  .header-actions {
    width: 100%;
  }
}
