:root {
  --bg: #f5f7fb;
  --panel: #ffffff;
  --ink: #172033;
  --muted: #697386;
  --line: #dde3ee;
  --brand: #0f766e;
  --brand-strong: #0b5f59;
  --warn: #c2410c;
  --danger: #b91c1c;
  --ok: #15803d;
  --shadow: 0 10px 30px rgba(23, 32, 51, .08);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "Microsoft YaHei", sans-serif;
  color: var(--ink);
  background: var(--bg);
}

a {
  color: inherit;
  text-decoration: none;
}

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

.login-card {
  width: min(420px, 100%);
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
  padding: 28px;
}

.login-card h1,
.page-title h1 {
  margin: 0;
  font-size: 24px;
  line-height: 1.25;
}

.login-card p,
.page-title p {
  margin: 8px 0 0;
  color: var(--muted);
}

.app-shell {
  min-height: 100vh;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 10;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 14px 24px;
  background: var(--panel);
  border-bottom: 1px solid var(--line);
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  font-weight: 700;
}

.brand-mark {
  width: 32px;
  height: 32px;
  display: grid;
  place-items: center;
  color: white;
  background: var(--brand);
  border-radius: 8px;
}

.topnav {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.topnav a,
.button,
button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 36px;
  padding: 0 13px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--panel);
  color: var(--ink);
  font-size: 14px;
  cursor: pointer;
}

.topnav a.active,
.button.primary,
button.primary {
  border-color: var(--brand);
  background: var(--brand);
  color: white;
}

.button.danger {
  border-color: #fecaca;
  background: #fff1f2;
  color: var(--danger);
}

.button.ghost {
  background: transparent;
}

.container {
  width: min(1780px, 100%);
  margin: 0 auto;
  padding: 24px 16px;
}

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

.stats {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 14px;
  margin-bottom: 18px;
}

.stat {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 16px;
}

.stat b {
  display: block;
  font-size: 26px;
  line-height: 1.1;
}

.stat span {
  color: var(--muted);
  font-size: 13px;
}

.panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: 0 8px 22px rgba(23, 32, 51, .04);
}

.panel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 16px;
  border-bottom: 1px solid var(--line);
}

.panel-header h2 {
  margin: 0;
  font-size: 18px;
}

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

.filters {
  padding: 16px;
  border-bottom: 1px solid var(--line);
}

.field {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.field label {
  color: var(--muted);
  font-size: 13px;
}

input,
select,
textarea {
  width: 100%;
  min-height: 38px;
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 8px 10px;
  font: inherit;
  color: var(--ink);
  background: white;
}

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

.span-2 {
  grid-column: span 2;
}

.span-4 {
  grid-column: span 4;
}

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

.muted {
  color: var(--muted);
}

.nowrap {
  white-space: nowrap;
}

.site-cards {
  display: grid;
  gap: 14px;
  padding: 16px;
}

.site-card {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #ffffff;
  overflow: hidden;
}

.site-card-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  padding: 14px 16px;
  background: #fbfdff;
  border-bottom: 1px solid #edf2f8;
}

.site-title h3 {
  margin: 0;
  font-size: 15px;
  line-height: 1.35;
}

.site-title p {
  margin: 6px 0 0;
  color: #475569;
  font-size: 13px;
  line-height: 1.65;
  overflow-wrap: anywhere;
}

.site-card-actions {
  display: flex;
  gap: 8px;
  flex: 0 0 auto;
}

.site-card-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 12px;
  padding: 14px 16px 16px;
}

.site-field {
  min-width: 0;
  padding: 10px;
  border: 1px solid #eef3f9;
  border-radius: 6px;
  background: #fcfdff;
}

.site-field > span,
.account-stack > em {
  display: block;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.6;
  margin-bottom: 5px;
  font-style: normal;
}

.money-field strong {
  display: block;
  min-height: 30px;
  padding: 5px 0;
  font-size: 14px;
}

.badge {
  display: inline-flex;
  align-items: center;
  min-height: 24px;
  padding: 0 8px;
  border-radius: 999px;
  font-size: 12px;
  border: 1px solid var(--line);
  background: #f8fafc;
}

.badge.ok {
  color: var(--ok);
  border-color: #bbf7d0;
  background: #f0fdf4;
}

.badge.warn {
  color: var(--warn);
  border-color: #fed7aa;
  background: #fff7ed;
}

.badge.danger {
  color: var(--danger);
  border-color: #fecaca;
  background: #fff1f2;
}

.flash,
.error {
  margin-bottom: 14px;
  padding: 12px 14px;
  border-radius: 8px;
}

.flash {
  color: var(--ok);
  background: #f0fdf4;
  border: 1px solid #bbf7d0;
}

.error {
  color: var(--danger);
  background: #fff1f2;
  border: 1px solid #fecaca;
}

.form-panel {
  padding: 18px;
}

.footer-actions {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  margin-top: 16px;
}

.empty {
  padding: 36px;
  text-align: center;
  color: var(--muted);
}

.hint {
  margin-top: 8px;
  color: var(--muted);
  font-size: 13px;
}

.password-cell {
  display: flex;
  align-items: center;
  gap: 6px;
}

.inline-edit {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 6px;
  align-items: center;
  min-width: 0;
}

.inline-edit input,
.inline-edit select {
  min-height: 30px;
  padding: 4px 7px;
  font-size: 13px;
}

.row-hint {
  margin-top: 6px;
}

.date-stack {
  min-width: 0;
}

.account-stack {
  min-width: 0;
}

.date-stack .inline-edit,
.account-stack .inline-edit {
  margin: 4px 0 8px;
}

.small-button {
  min-height: 28px;
  padding: 0 8px;
  font-size: 12px;
}

@media (max-width: 980px) {
  .stats,
  .filters,
  .form-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

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

@media (max-width: 680px) {
  .topbar,
  .page-title {
    align-items: stretch;
    flex-direction: column;
  }

  .container {
    padding: 16px;
  }

  .stats,
  .filters,
  .form-grid,
  .site-card-grid {
    grid-template-columns: 1fr;
  }

  .site-card-head {
    flex-direction: column;
  }

  .span-2,
  .span-4 {
    grid-column: span 1;
  }
}
