:root {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  color: #172033;
  background: #f4f6f9;
  letter-spacing: 0;
}

* {
  box-sizing: border-box;
}

body {
  min-width: 320px;
  margin: 0;
  background: #f4f6f9;
  font-size: 14px;
}

button,
input {
  font: inherit;
  letter-spacing: 0;
}

button {
  cursor: pointer;
}

button:disabled {
  cursor: not-allowed;
  opacity: 0.45;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-height: 72px;
  padding: 10px max(20px, calc((100vw - 1440px) / 2));
  color: #ffffff;
  background: #172033;
  border-bottom: 3px solid #2563eb;
}

.brand,
.topbar-actions {
  display: flex;
  align-items: center;
  gap: 11px;
}

.brand img {
  width: 42px;
  height: 42px;
}

.brand h1 {
  margin: 0 0 3px;
  font-size: 18px;
}

.brand span,
.sync-text {
  color: #cbd5e1;
  font-size: 12px;
}

.icon-button {
  display: grid;
  width: 34px;
  height: 34px;
  padding: 0;
  place-items: center;
  border: 1px solid #64748b;
  border-radius: 5px;
}

.icon-button img {
  width: 17px;
  height: 17px;
}

.icon-button.dark {
  background: #283449;
}

.icon-button.dark img {
  filter: brightness(0) invert(1);
}

main {
  width: min(1440px, 100%);
  margin: 0 auto;
  padding: 18px 20px 32px;
}

.stats-band {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  margin-bottom: 16px;
  background: #ffffff;
  border: 1px solid #d8dee8;
  border-radius: 6px;
}

.stat {
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-height: 64px;
  padding: 0 18px;
  border-left: 4px solid #94a3b8;
}

.stat + .stat {
  border-top: 0;
  border-right: 0;
  border-bottom: 0;
}

.stat.offline {
  border-left-color: #dc2626;
}

.stat.recovered {
  border-left-color: #16a34a;
}

.stat.error {
  border-left-color: #d97706;
}

.stat.sync {
  border-left-color: #2563eb;
}

.stat span {
  color: #64748b;
}

.stat strong {
  font-size: 22px;
}

.stat.sync strong {
  font-size: 14px;
}

.toolbar {
  display: grid;
  grid-template-columns: auto minmax(220px, 1fr) auto auto;
  gap: 10px;
  align-items: center;
  margin-bottom: 12px;
}

.tabs {
  display: inline-flex;
  height: 38px;
  padding: 3px;
  background: #e7ebf1;
  border-radius: 6px;
}

.tab {
  min-width: 88px;
  padding: 0 12px;
  color: #475569;
  background: transparent;
  border: 0;
  border-radius: 4px;
}

.tab.active {
  color: #172033;
  background: #ffffff;
  box-shadow: 0 1px 3px rgba(15, 23, 42, 0.15);
  font-weight: 650;
}

.search-box input {
  width: 100%;
  height: 38px;
  padding: 0 12px;
  color: #172033;
  background: #ffffff;
  border: 1px solid #b9c2d0;
  border-radius: 5px;
}

.tool-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  height: 38px;
  padding: 0 13px;
  color: #172033;
  background: #ffffff;
  border: 1px solid #b9c2d0;
  border-radius: 5px;
  white-space: nowrap;
}

.tool-button img {
  width: 16px;
  height: 16px;
}

.tool-button.primary {
  color: #ffffff;
  background: #2563eb;
  border-color: #1d4ed8;
}

.tool-button.primary img {
  filter: brightness(0) invert(1);
}

.table-section {
  overflow: hidden;
  background: #ffffff;
  border: 1px solid #d8dee8;
  border-radius: 6px;
}

.table-wrap {
  min-height: 350px;
  overflow-x: auto;
}

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

th,
td {
  padding: 11px 12px;
  border-bottom: 1px solid #e5e9f0;
  text-align: left;
  vertical-align: top;
}

th {
  color: #475569;
  background: #f8fafc;
  font-size: 12px;
  font-weight: 650;
}

th:nth-child(1) { width: 13%; }
th:nth-child(2) { width: 11%; }
th:nth-child(3) { width: 24%; }
th:nth-child(4) { width: 25%; }
th:nth-child(5) { width: 15%; }
th:nth-child(6) { width: 12%; }

td {
  color: #334155;
  line-height: 1.35;
  overflow-wrap: anywhere;
}

td strong {
  color: #172033;
}

.reason {
  color: #b91c1c;
}

.link-button {
  color: #1d4ed8;
  text-decoration: none;
  font-weight: 650;
}

.row-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  min-height: 30px;
}

.handled-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 5px;
  min-width: 96px;
  height: 30px;
  padding: 0 9px;
  color: #166534;
  background: #f0fdf4;
  border: 1px solid #86efac;
  border-radius: 4px;
  white-space: nowrap;
}

.handled-button img {
  width: 15px;
  height: 15px;
}

.handled-state {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  min-width: 76px;
  height: 30px;
  color: #166534;
  font-weight: 650;
  white-space: nowrap;
}

.handled-state img {
  width: 15px;
  height: 15px;
}

.empty-state {
  padding: 100px 20px;
  color: #64748b;
  text-align: center;
}

.pagination {
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-height: 52px;
  padding: 8px 12px;
  color: #64748b;
  background: #f8fafc;
}

.pagination div {
  display: flex;
  align-items: center;
  gap: 10px;
}

.pagination button {
  height: 30px;
  padding: 0 10px;
  color: #334155;
  background: #ffffff;
  border: 1px solid #b9c2d0;
  border-radius: 4px;
}

.notice {
  position: fixed;
  right: 20px;
  bottom: 20px;
  max-width: 360px;
  padding: 10px 13px;
  color: #ffffff;
  background: #172033;
  border-radius: 5px;
  box-shadow: 0 10px 30px rgba(15, 23, 42, 0.22);
}

.notice.error {
  background: #991b1b;
}

.login-overlay {
  position: fixed;
  inset: 0;
  display: grid;
  padding: 20px;
  place-items: center;
  background: rgba(15, 23, 42, 0.64);
}

.login-overlay[hidden] {
  display: none;
}

.login-dialog {
  width: min(360px, 100%);
  padding: 24px;
  background: #ffffff;
  border-radius: 7px;
  box-shadow: 0 20px 60px rgba(15, 23, 42, 0.3);
}

.login-dialog > img {
  width: 34px;
  height: 34px;
}

.login-dialog h2 {
  margin: 10px 0 18px;
  font-size: 20px;
}

.login-dialog label {
  display: block;
  margin-bottom: 12px;
}

.login-dialog label span {
  display: block;
  margin-bottom: 5px;
  color: #475569;
  font-size: 12px;
}

.login-dialog input {
  width: 100%;
  height: 40px;
  padding: 0 10px;
  border: 1px solid #b9c2d0;
  border-radius: 5px;
}

.login-dialog button {
  width: 100%;
  height: 40px;
  margin-top: 4px;
  color: #ffffff;
  background: #2563eb;
  border: 1px solid #1d4ed8;
  border-radius: 5px;
  font-weight: 650;
}

.login-dialog p {
  margin: 10px 0 0;
  color: #b91c1c;
  text-align: center;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

@media (max-width: 760px) {
  .topbar {
    padding: 10px 14px;
  }

  .sync-text {
    display: none;
  }

  main {
    padding: 12px;
  }

  .stats-band {
    grid-template-columns: 1fr;
  }

  .stat + .stat {
    border-top: 1px solid #e5e9f0;
  }

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

  .tabs,
  .search-box {
    grid-column: 1 / -1;
  }

  .tabs .tab {
    flex: 1;
  }

  table {
    min-width: 920px;
  }
}
