:root {
  color-scheme: light;
  --bg: #f6f7f9;
  --surface: #ffffff;
  --line: #d9dde4;
  --text: #1c2430;
  --muted: #657184;
  --primary: #1267b3;
  --primary-strong: #0c4f8d;
  --danger: #b42318;
  --ok: #16803c;
  --warn: #9a6700;
}

* {
  box-sizing: border-box;
}

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

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

a:hover {
  text-decoration: underline;
}

button,
input {
  font: inherit;
}

button {
  min-height: 36px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--surface);
  color: var(--text);
  padding: 0 12px;
  cursor: pointer;
  white-space: nowrap;
}

button:hover {
  border-color: var(--primary);
}

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

button.primary:hover {
  background: var(--primary-strong);
}

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

button.link-button {
  min-height: auto;
  border: 0;
  border-radius: 0;
  background: transparent;
  color: var(--primary);
  padding: 0;
  font-weight: 700;
}

button.link-button:hover {
  text-decoration: underline;
}

button.icon-button {
  width: 36px;
  padding: 0;
  font-size: 24px;
  line-height: 1;
}

input {
  min-height: 36px;
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: white;
  padding: 0 10px;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 22px max(20px, calc((100vw - 1180px) / 2));
  border-bottom: 1px solid var(--line);
  background: var(--surface);
}

.topbar h1,
.section h2,
.login-panel h1 {
  margin: 0;
  letter-spacing: 0;
}

.topbar h1 {
  font-size: 24px;
}

.topbar p {
  margin: 4px 0 0;
  color: var(--muted);
}

.layout {
  width: min(1180px, calc(100vw - 40px));
  margin: 24px auto 48px;
}

.section {
  margin-top: 20px;
  padding: 20px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
}

.section-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 16px;
}

.section h2 {
  font-size: 18px;
}

.inline-form,
.actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

.inline-form input {
  width: min(320px, 45vw);
}

.table-wrap {
  width: 100%;
  overflow-x: auto;
  border: 1px solid var(--line);
  border-radius: 8px;
}

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

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

th {
  background: #f0f3f7;
  color: #344054;
  font-size: 13px;
  font-weight: 700;
}

tbody tr:last-child td {
  border-bottom: 0;
}

.stats {
  display: grid;
  grid-template-columns: repeat(5, minmax(120px, 1fr));
  gap: 10px;
  margin-bottom: 16px;
}

.stats div {
  min-height: 68px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 10px 12px;
}

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

.stats strong {
  display: block;
  margin-top: 6px;
  overflow-wrap: anywhere;
}

.pill {
  display: inline-flex;
  align-items: center;
  min-height: 24px;
  border-radius: 999px;
  padding: 0 9px;
  font-size: 13px;
  font-weight: 700;
}

.pill.ok {
  background: #e8f5ee;
  color: var(--ok);
}

.pill.warn {
  background: #fff6dc;
  color: var(--warn);
}

.pill.muted {
  background: #edf0f4;
  color: var(--muted);
}

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

.error-text {
  color: var(--danger);
  overflow-wrap: anywhere;
}

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

.alert {
  margin: 0 0 16px;
  border-radius: 8px;
  padding: 12px 14px;
}

.alert.success {
  border: 1px solid #b8dfc8;
  background: #eaf7ef;
  color: #145d30;
}

.alert.error {
  border: 1px solid #f2b8b5;
  background: #fff0ee;
  color: var(--danger);
}

.posts-dialog {
  width: min(920px, calc(100vw - 28px));
  max-height: min(760px, calc(100vh - 28px));
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 0;
  background: var(--surface);
  color: var(--text);
}

.posts-dialog::backdrop {
  background: rgb(16 24 40 / 52%);
}

.dialog-shell {
  margin: 0;
}

.dialog-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  padding: 18px 20px;
  border-bottom: 1px solid var(--line);
}

.dialog-header h2 {
  margin: 0;
  font-size: 20px;
  letter-spacing: 0;
}

.dialog-header p {
  margin: 4px 0 0;
  color: var(--muted);
}

.dialog-body {
  max-height: min(640px, calc(100vh - 150px));
  overflow: auto;
  padding: 0;
}

.post-list {
  list-style: none;
  margin: 0;
  padding: 0;
}

.post-list-item {
  padding: 15px 20px;
  border-bottom: 1px solid var(--line);
}

.post-list-item:last-child {
  border-bottom: 0;
}

.post-list-item a {
  display: block;
  font-weight: 700;
  overflow-wrap: anywhere;
}

.post-meta {
  margin: 5px 0 0;
  color: var(--muted);
  font-size: 13px;
}

.post-summary {
  margin: 8px 0 0;
  color: #344054;
}

.modal-empty {
  padding: 28px 20px;
  margin: 0;
}

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

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

.login-panel h1 {
  font-size: 22px;
  margin-bottom: 22px;
}

.stack {
  display: grid;
  gap: 14px;
}

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

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

  .layout {
    width: min(100vw - 24px, 1180px);
    margin-top: 12px;
  }

  .section {
    padding: 14px;
  }

  .inline-form,
  .actions {
    width: 100%;
    align-items: stretch;
  }

  .inline-form input {
    width: 100%;
  }

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