*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

body {
  font-family: -apple-system, "Microsoft YaHei", "PingFang SC", sans-serif;
  font-size: 16px;
  color: #1e293b;
  background: #f0f4f8;
  line-height: 1.7;
  min-height: 100vh;
}

a { color: #2563eb; text-decoration: none; }
a:hover { color: #1d4ed8; text-decoration: underline; }

button:focus, a:focus { outline: none; }

/* ── Login ── */
.login-page {
  display: flex; align-items: center; justify-content: center; min-height: 100vh;
  background: #e2e8f0;
}
.login-card {
  background: #fff; padding: 48px 40px; border-radius: 4px; width: 380px; max-width: 94vw;
  box-shadow: 0 1px 3px rgba(0,0,0,.08);
}
.login-card h1 { text-align: center; font-size: 24px; color: #2563eb; margin-bottom: 4px; }
.login-sub { text-align: center; color: #64748b; font-size: 14px; margin-bottom: 28px; }
.login-error { background: #fef2f2; color: #dc2626; padding: 10px; margin-bottom: 16px;
  border-left: 3px solid #dc2626; font-size: 14px; }
.login-card input {
  display: block; width: 100%; padding: 12px 14px; margin-bottom: 14px;
  border: 1px solid #cbd5e1; font-size: 15px; outline: none; transition: border .2s;
}
.login-card input:focus { border-color: #2563eb; }
.login-card button {
  width: 100%; padding: 13px; background: #2563eb; color: #fff; border: none;
  font-size: 16px; cursor: pointer; transition: background .2s;
}
.login-card button:hover { background: #1d4ed8; }

/* ── Topbar ── */
.topbar { background: #fff; border-bottom: 1px solid #e2e8f0; position: sticky; top: 0; z-index: 10; }
.topbar-inner { width: 98%; margin: 0 auto; padding: 0 20px; display: flex;
  align-items: center; justify-content: space-between; height: 52px; }
.logo { font-size: 18px; font-weight: 600; color: #2563eb; }
.topbar-right { display: flex; align-items: center; gap: 18px; font-size: 14px; }
.user-name { color: #64748b; }

/* Category dropdown */
.nav-dropdown { position: relative; display: inline-block; }
.nav-dropbtn {
  background: none; border: 1px solid #e2e8f0; color: #475569; font-size: 14px;
  padding: 5px 12px; cursor: pointer; border-radius: 4px; font-family: inherit;
}
.nav-dropbtn:hover { background: #f1f5f9; }
.nav-dropdown-content {
  display: none; position: absolute; top: 100%; left: 0; background: #fff;
  min-width: 160px; box-shadow: 0 4px 12px rgba(0,0,0,.1); border-radius: 4px;
  z-index: 100; overflow: hidden;
}
.nav-dropdown-content a {
  display: block; padding: 8px 16px; font-size: 13px; color: #334155;
  text-decoration: none; border-bottom: 1px solid #f1f5f9;
}
.nav-dropdown-content a:hover { background: #f0f4ff; color: #2563eb; }
.nav-dropdown:hover .nav-dropdown-content { display: block; }

.topbar-left { display: flex; align-items: center; gap: 12px; }

/* Moscow clock */
.moscow-clock {
  font-size: 13px; color: #64748b; white-space: nowrap;
  background: #f1f5f9; padding: 4px 10px; border-radius: 12px;
  display: inline-flex; align-items: center; gap: 5px;
}
.msk-date { font-size: 11px; color: #94a3b8; font-weight: 600; }
.msk-temp { font-size: 12px; color: #0284c7; font-weight: 600; }
.msk-time { font-weight: 700; color: #dc2626; font-variant-numeric: tabular-nums; }
.msk-label { font-size: 10px; color: #94a3b8; font-weight: 600; }

/* Exchange rate badge */
.fx-badge {
  font-size: 13px; color: #0369a1; white-space: nowrap;
  background: #f0f9ff; padding: 4px 10px; border-radius: 12px;
  border: 1px solid #bae6fd;
}

/* Holiday countdown */
.holiday-badge {
  font-size: 13px; color: #a21caf; white-space: nowrap;
  background: #fdf4ff; padding: 4px 10px; border-radius: 12px;
  border: 1px solid #f0abfc;
}

@media (max-width: 600px) {
  .topbar-inner { padding: 0 12px; gap: 8px; flex-wrap: wrap; }
  .topbar-left { gap: 6px; }
  .fx-badge { font-size: 12px; padding: 3px 8px; }
  .moscow-clock { order: 3; width: 100%; justify-content: center; padding: 4px 0 2px; }
  .logo { font-size: 15px; }
  .topbar-right { gap: 10px; font-size: 12px; }
  .moscow-clock { font-size: 12px; padding: 3px 8px; }
  .msk-date { display: none; }
  .msk-label { display: inline; font-size: 11px; color: #64748b; }
  .holiday-badge { display: none; }
}

/* ── Main ── */
.main { width: 98%; margin: 0 auto; padding: 28px 20px 60px; }

/* ── Breadcrumb ── */
.breadcrumb { font-size: 14px; color: #64748b; margin-bottom: 20px; }
.breadcrumb a { color: #2563eb; }

/* ── Page title + action ── */
.page-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 20px; }
.page-head h2 { font-size: 22px; color: #1e293b; }
.btn {
  display: inline-block; padding: 8px 18px; background: #2563eb; color: #fff;
  font-size: 14px; cursor: pointer; border: none; outline: none; transition: background .2s; text-decoration: none;
}
.btn:hover { background: #1d4ed8; text-decoration: none; color: #fff; }
.btn-sm { padding: 4px 12px; font-size: 13px; }
.btn-danger { background: #dc2626; }
.btn-danger:hover { background: #b91c1c; }
.btn-outline { background: transparent; color: #2563eb; border: 1px solid #2563eb; }
.btn-outline:hover { background: #2563eb; color: #fff; }

/* Color picker buttons */
.color-btn {
  width: 22px; height: 22px; border: 2px solid #e2e8f0; border-radius: 4px;
  cursor: pointer; display: inline-block; vertical-align: middle;
  padding: 0; margin: 0 2px; transition: transform .12s;
}
.color-btn:hover { transform: scale(1.25); border-color: #94a3b8; }

/* ── Editor ── */
.editor-container { border: 1px solid #e2e8f0; border-radius: 6px; overflow: hidden; }
.editor-toolbar {
  display: flex; align-items: center; gap: 2px; flex-wrap: wrap;
  padding: 6px 8px; background: #f8fafc; border-bottom: 1px solid #e2e8f0;
}
.editor-toolbar button {
  font-size: 14px; padding: 4px 10px; border: 1px solid #e2e8f0; border-radius: 4px;
  background: #fff; color: #475569; cursor: pointer; font-family: inherit;
  line-height: 1.4; outline: none; transition: background .12s;
}
.editor-toolbar button:hover { background: #e2e8f0; }
.editor-toolbar button.color-btn {
  width: 22px; height: 22px; padding: 0; border-radius: 3px;
}
.editor-visual, .editor-source {
  min-height: 200px; max-height: 500px; overflow-y: auto;
  padding: 12px 16px; font-size: 15px; line-height: 1.8; outline: none;
}
.editor-source { min-height: 200px !important; }
.editor-visual { display: block; }
.editor-source { display: none; width: 100%; border: none; resize: vertical; font-family: 'Consolas','Courier New',monospace; font-size: 14px; }
.editor-hidden { display: none; }

/* ── Cards / Lists ── */
.card { background: #fff; padding: 20px 24px; margin-bottom: 12px;
  border: 1px solid #e2e8f0; transition: box-shadow .15s; }
.card:hover { box-shadow: 0 2px 8px rgba(0,0,0,.04); }
.card-title { font-size: 17px; font-weight: 600; }
.card-meta { font-size: 13px; color: #94a3b8; margin-top: 6px; }
.card-meta span { margin-right: 16px; }
.card-desc { font-size: 14px; color: #64748b; margin-top: 6px; }

.category-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 12px; }
@media (max-width: 640px) { .category-grid { grid-template-columns: 1fr; } }

.cat-stats { font-size: 13px; color: #94a3b8; margin-top: 6px; }
.cat-stats span { margin-right: 14px; }

/* ── Tables in posts/replies ── */
.topic-content table, .reply-body table {
  border-collapse: separate;
  border-spacing: 0;
  width: 100%;
  margin: 14px 0;
  font-size: 14px;
  line-height: 1.7;
}
.topic-content td, .topic-content th,
.reply-body td, .reply-body th {
  padding: 10px 14px;
  border: 1px solid #e2e8f0;
  vertical-align: top;
}
.topic-content th, .reply-body th {
  background: #f1f5f9;
  font-weight: 700;
  font-size: 13px;
  color: #334155;
  white-space: nowrap;
}
.topic-content td, .reply-body td {
  background: #fff;
}

/* ── Topic detail ── */
.topic-content { font-size: 15px; line-height: 1.8; margin-bottom: 20px; white-space: pre-wrap; }
.topic-meta { font-size: 13px; color: #94a3b8; margin-bottom: 20px; }

.reply-card { background: #fff; border: 1px solid #e2e8f0; padding: 16px 20px; margin-bottom: 10px; }
.reply-card:nth-child(even) { background: #f8fafc; }
.reply-head { display: flex; justify-content: space-between; font-size: 13px; color: #94a3b8; margin-bottom: 8px; }
.reply-body { font-size: 15px; line-height: 1.8; white-space: pre-wrap; }

/* ── Forms ── */
.ff { background: #fff; padding: 24px; border: 1px solid #e2e8f0; }
.ff label { display: block; font-size: 14px; color: #64748b; margin-bottom: 4px; }
.ff input[type="text"],
.ff input[type="password"],
.ff select,
.ff textarea {
  display: block; width: 100%; padding: 10px 12px; margin-bottom: 16px;
  border: 1px solid #cbd5e1; font-size: 15px; outline: none; font-family: inherit;
}
.ff input:focus, .ff textarea:focus, .ff select:focus { border-color: #2563eb; }
.ff textarea { min-height: 140px; resize: vertical; }

/* ── Admin table ── */
.tbl { width: 100%; border-collapse: collapse; background: #fff; border: 1px solid #e2e8f0; }
.tbl th { text-align: left; padding: 10px 14px; background: #f8fafc; color: #64748b; font-size: 13px;
  border-bottom: 1px solid #e2e8f0; }
.tbl td { padding: 10px 14px; font-size: 14px; border-bottom: 1px solid #f1f5f9; }
.tbl tr:last-child td { border-bottom: none; }

/* ── Pagination ── */
.pagination { text-align: center; margin-top: 24px; font-size: 14px; }
.pagination a, .pagination strong { padding: 6px 12px; margin: 0 2px; }
.pagination strong { background: #2563eb; color: #fff; }

/* ── Footer ── */
.footer { text-align: center; padding: 24px; color: #94a3b8; font-size: 13px; }

/* ── Flash message ── */
.flash { padding: 10px 16px; margin-bottom: 16px; font-size: 14px; }
.flash-ok { background: #f0fdf4; color: #16a34a; border-left: 3px solid #16a34a; }
.flash-err { background: #fef2f2; color: #dc2626; border-left: 3px solid #dc2626; }

/* ── Misc ── */
.inline-actions { display: inline-flex; gap: 8px; margin-left: 8px; }
.empty { text-align: center; color: #94a3b8; padding: 40px 0; font-size: 15px; }

/* ── Mobile (?68px) ── */
@media (max-width: 768px) {

  /* ── Topbar: multi-row ── */
  .topbar { position: relative; }
  .topbar-inner {
    flex-wrap: wrap; height: auto; padding: 8px 12px; gap: 6px;
  }

  /* Logo on top, tools wrap below */
  .topbar-left {
    flex: 1 1 auto; flex-wrap: wrap; gap: 6px;
    min-width: 0;
  }
  .topbar-left > *:not(.logo) {
    /* second row items */
  }
  .logo { font-size: 16px; width: 100%; }

  .nav-dropbtn { font-size: 12px; padding: 4px 8px; }
  .moscow-clock { font-size: 11px; padding: 3px 7px; }
  .fx-badge { font-size: 11px; }
  .holiday-badge { font-size: 11px; padding: 3px 7px; }
  .msk-date { display: none; }
  .msk-label { display: inline; font-size: 11px; color: #64748b; }

  /* Right: compact */
  .topbar-right {
    position: absolute; top: 10px; right: 12px; gap: 8px; font-size: 12px;
  }
  .user-name { font-size: 12px; }

  /* ── Main content ── */
  .main { padding: 16px 10px 40px; width: 100%; }
  .page-head { flex-direction: column; align-items: flex-start; gap: 8px; }
  .page-head h2 { font-size: 18px; }

  /* ── Cards ?full width ── */
  .card { padding: 14px 16px; }
  .card-title { font-size: 15px; }
  .card-meta { font-size: 12px; }

  /* ── Breadcrumb ── */
  .breadcrumb { font-size: 12px; margin-bottom: 12px; }

  /* ── Topic detail ── */
  .topic-content { font-size: 14px; }
  .reply-card { padding: 12px 14px; }
  .reply-head { flex-direction: column; gap: 2px; }
  .reply-body { font-size: 14px; }

  /* ── Forms ── */
  .ff { padding: 16px; }
  .ff input[type="text"],
  .ff input[type="password"],
  .ff select,
  .ff textarea { font-size: 14px; padding: 8px 10px; }

  /* ── Editor toolbar ?wrap + smaller ── */
  .editor-container { border-radius: 4px; }
  .editor-toolbar { gap: 1px; padding: 4px 6px; }
  .editor-toolbar button { font-size: 12px; padding: 3px 7px; }
  .editor-toolbar .sep { height: 18px; margin: 0 1px; }
  .editor-visual, .editor-source { min-height: 140px; padding: 10px 12px; font-size: 14px; }

  /* ── Admin tables ?scroll ── */
  .tbl { display: block; overflow-x: auto; white-space: nowrap; }
  .tbl th, .tbl td { font-size: 12px; padding: 8px 10px; }
}


/* Keep numeric monitor columns on one line, especially on mobile. */
.topic-content table th:nth-child(4),
.topic-content table td:nth-child(4),
.topic-content table th:nth-child(5),
.topic-content table td:nth-child(5),
.topic-content table th:nth-child(6),
.topic-content table td:nth-child(6),
.reply-body table th:nth-child(4),
.reply-body table td:nth-child(4),
.reply-body table th:nth-child(5),
.reply-body table td:nth-child(5),
.reply-body table th:nth-child(6),
.reply-body table td:nth-child(6) {
  white-space: nowrap;
  min-width: 86px;
}


/* 首页帖子 ID 移到第二行，保持轻量不抢标题?*/
.topic-id-meta {
  display: inline-flex;
  align-items: center;
  margin-right: 4px;
  padding: 1px 5px;
  border-radius: 999px;
  background: #f1f5f9;
  color: #64748b;
  font-size: 11px;
  font-weight: 600;
  line-height: 1.35;
  vertical-align: middle;
  white-space: nowrap;
}
 }

/* ö */
.topic-title-pinned {
  color: #D32F2F !important;
  font-weight: 700;
}


/* Forum search */
.top-search { display: flex; align-items: center; min-width: 220px; height: 32px; border: 1px solid #cbd5e1; border-radius: 16px; background: #fff; overflow: hidden; }
.top-search input { width: 100%; border: 0; outline: 0; padding: 6px 10px 6px 12px; font-size: 13px; font-family: inherit; color: #334155; }
.top-search button { border: 0; background: #2563eb; color: #fff; height: 100%; padding: 0 10px; cursor: pointer; }
.top-search button:hover { background: #1d4ed8; }
.search-page-form { display: flex; gap: 10px; margin: 18px 0 14px; }
.search-page-form input { flex: 1; min-width: 0; padding: 12px 14px; border: 1px solid #cbd5e1; border-radius: 4px; font-size: 15px; font-family: inherit; }
.search-page-form input:focus { border-color: #2563eb; outline: none; }
.search-summary { color: #64748b; margin: 0 0 14px; font-size: 14px; }
@media (max-width: 900px) { .topbar-inner { height: auto; min-height: 52px; flex-wrap: wrap; gap: 8px; padding-top: 8px; padding-bottom: 8px; } .topbar-left { flex-wrap: wrap; } .top-search { order: 10; width: 100%; min-width: 180px; } }
