:root {
  --navy: #14213d;
  --blue: #2563eb;
  --blue-dark: #1d4ed8;
  --bg: #f3f6fb;
  --text: #172033;
  --muted: #657085;
  --border: #dce3ef;
  --card: #ffffff;
  --success: #087a4c;
  --danger: #b42318;
}

* { box-sizing: border-box; }
body { margin: 0; background: var(--bg); color: var(--text); font-family: Tahoma, "Noto Sans Thai", Arial, sans-serif; font-size: 15px; line-height: 1.5; }
body.modal-open { overflow: hidden; }
a { color: var(--blue); text-decoration: none; }
a:hover { text-decoration: underline; }
.topbar { min-height: 64px; padding: 0 5vw; display: flex; align-items: center; gap: 32px; background: var(--navy); color: #fff; }
.brand { font-size: 18px; color: #fff; font-weight: 700; letter-spacing: .2px; white-space: nowrap; }
.topbar nav { display: flex; align-self: stretch; gap: 5px; }
.topbar nav a { padding: 20px 11px; color: #dfe8ff; }
.topbar nav a:hover { text-decoration: none; color: #fff; background: rgba(255,255,255,.08); }
.account { display: flex; align-items: center; margin-left: auto; gap: 15px; color: #dfe8ff; white-space: nowrap; }
.account a { color: #fff; }
.container { max-width: 1180px; margin: 0 auto; padding: 36px 24px 60px; }
.login-layout { min-height: 100vh; display: grid; place-items: center; padding: 24px; }
.card { background: var(--card); border: 1px solid var(--border); border-radius: 12px; box-shadow: 0 3px 12px rgba(29, 48, 86, .05); padding: 26px; }
.auth-card { width: min(100%, 410px); }
.eyebrow { color: var(--blue); font-size: 12px; font-weight: 700; letter-spacing: 1.1px; text-transform: uppercase; }
h1, h2 { margin: 0; line-height: 1.25; }
h1 { margin-top: 4px; font-size: 29px; }
h2 { font-size: 20px; }
.muted { color: var(--muted); margin: 8px 0 0; }
.page-heading { display: flex; justify-content: space-between; align-items: flex-end; gap: 20px; margin-bottom: 25px; }
.form-stack { display: grid; gap: 17px; margin-top: 24px; }
.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 20px; }
label { display: grid; gap: 7px; font-weight: 600; }
input, select, textarea { width: 100%; min-height: 42px; padding: 9px 11px; border: 1px solid #bdc8d9; border-radius: 7px; color: var(--text); background: #fff; font: inherit; font-weight: 400; }
textarea { resize: vertical; }
input:focus, select:focus, textarea:focus { outline: 3px solid #bfdbfe; border-color: var(--blue); }
input[readonly] { color: #48556a; background: #f5f7fb; }
small { color: var(--muted); font-weight: 400; font-size: 12px; }
.optional { color: var(--muted); font-size: 12px; font-weight: 400; }
.form-note { margin: -5px 0 0; color: var(--muted); }
button, .button-secondary { display: inline-block; appearance: none; border: 0; border-radius: 7px; padding: 10px 17px; color: #fff; background: var(--blue); font: inherit; font-weight: 700; cursor: pointer; }
button:hover { background: var(--blue-dark); }
.button-secondary { color: #34445f; background: #e8edf5; }
.button-secondary:hover { text-decoration: none; background: #dce5f2; }
.full { grid-column: 1 / -1; }
.actions { margin-top: 2px; }
.section-gap { margin-top: 34px; }
.section-gap h2 { margin-bottom: 13px; }
.section-title-row { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; }
.no-top-gap { margin-top: 0; }
.alert { margin-bottom: 20px; padding: 12px 15px; border-radius: 8px; }
.alert-success { color: #075f3b; background: #eafaf2; border: 1px solid #bcebd2; }
.alert-error { color: #8e1d15; background: #fff0ee; border: 1px solid #f4c7c3; }
.table-wrap { overflow-x: auto; border: 1px solid var(--border); border-radius: 10px; background: #fff; }
table { width: 100%; border-collapse: collapse; min-width: 640px; }
th, td { padding: 12px 14px; text-align: left; border-bottom: 1px solid var(--border); vertical-align: middle; }
th { color: #536078; background: #f7f9fc; font-size: 13px; white-space: nowrap; }
tbody tr:last-child td { border-bottom: 0; }
td small { display: block; }
code { font-family: Consolas, monospace; font-size: 13px; color: #334155; }
.external-link { white-space: nowrap; }
.empty { padding: 27px; border: 1px dashed #c9d3e1; border-radius: 9px; color: var(--muted); background: #fff; text-align: center; }
.stat-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); gap: 17px; margin: 24px 0 0; }
.stat { padding: 20px; border-radius: 10px; color: #2c3b55; background: #eaf1ff; }
.stat span { display: block; color: #51627e; font-size: 13px; }
.stat strong { display: block; margin-top: 4px; color: #14213d; font-size: 29px; }
.stat.compact { min-width: 170px; padding: 12px 17px; }
.stat.compact strong { font-size: 24px; }
.duplicate { color: var(--danger); font-weight: 700; }
.filter-card { padding: 18px 22px; }
.filter-form { display: flex; align-items: end; flex-wrap: wrap; gap: 14px; }
.filter-form label { min-width: 150px; }
.filter-actions { display: flex; align-items: center; gap: 12px; padding-bottom: 1px; }
.badge { display: inline-block; padding: 3px 8px; border-radius: 99px; font-size: 12px; font-weight: 700; }
.badge-success { color: #075f3b; background: #dff7e9; }
.badge-muted { color: #596579; background: #e8edf3; }
.badge-post { color: #075f3b; background: #dff7e9; }
.badge-comment { color: #794900; background: #fff2cc; }
.post-count { color: #075f3b; font-weight: 700; }
.comment-count { color: #8a5700; font-weight: 700; }
.row-actions { display: flex; align-items: center; gap: 11px; white-space: nowrap; }
.row-actions form { display: inline; }
.link-button { padding: 0; color: var(--blue); background: transparent; font-weight: 400; }
.link-button:hover { color: var(--blue-dark); background: transparent; text-decoration: underline; }
.danger-link, .danger-link:hover { color: var(--danger); }
.pagination { display: flex; justify-content: center; align-items: center; flex-wrap: wrap; gap: 6px; margin-top: 20px; }
.pagination a { min-width: 38px; padding: 7px 10px; border: 1px solid var(--border); border-radius: 7px; color: #43536d; background: #fff; text-align: center; }
.pagination a:hover, .pagination a.active { color: #fff; border-color: var(--blue); background: var(--blue); text-decoration: none; }
.tabs { display: flex; gap: 4px; overflow-x: auto; border-bottom: 1px solid var(--border); }
.tab-button { padding: 11px 15px; border: 0; border-bottom: 3px solid transparent; border-radius: 7px 7px 0 0; color: #52617a; background: transparent; white-space: nowrap; font-weight: 600; }
.tab-button:hover { color: var(--blue); background: #eff5ff; }
.tab-button.active { color: var(--blue); border-bottom-color: var(--blue); background: #eff5ff; }
.tab-button span { display: inline-block; min-width: 20px; margin-left: 4px; padding: 0 5px; border-radius: 20px; color: inherit; background: #dceafe; font-size: 12px; }
.tab-panel { padding-top: 20px; }
.modal[hidden] { display: none; }
.modal { position: fixed; z-index: 20; inset: 0; display: grid; place-items: center; padding: 20px; }
.modal-backdrop { position: absolute; inset: 0; background: rgba(15, 23, 42, .58); }
.modal-dialog { position: relative; z-index: 1; width: min(100%, 680px); max-height: calc(100vh - 40px); overflow-y: auto; padding: 28px; border-radius: 13px; background: #fff; box-shadow: 0 22px 60px rgba(15, 23, 42, .28); }
.modal-close { position: absolute; top: 11px; right: 13px; width: 34px; min-height: 34px; padding: 0; border-radius: 50%; color: #52617a; background: #eef2f7; font-size: 25px; font-weight: 400; line-height: 1; }
.modal-close:hover { color: #26364f; background: #dfe6ef; }
.modal-dialog .form-stack, .modal-dialog .form-grid { margin-top: 22px; }
.permission-options { display: grid; gap: 11px; margin: 0; padding: 15px; border: 1px solid var(--border); border-radius: 8px; }
.permission-options legend { padding: 0 4px; color: #4d5d77; font-weight: 700; }
.checkbox-field { display: flex; align-items: center; gap: 9px; font-weight: 400; cursor: pointer; }
.checkbox-field input { width: 18px; min-height: auto; height: 18px; margin: 0; padding: 0; accent-color: var(--blue); }
.radio-options { display: flex; flex-wrap: wrap; gap: 12px; margin: 0; padding: 15px; border: 1px solid var(--border); border-radius: 8px; }
.radio-options legend { width: 100%; padding: 0 4px; color: #4d5d77; font-weight: 700; }
.radio-field { display: flex; align-items: center; gap: 9px; min-width: 160px; padding: 11px 13px; border: 1px solid var(--border); border-radius: 8px; background: #f8fafc; font-weight: 600; cursor: pointer; }
.radio-field:has(input:checked) { color: #174eae; border-color: #77a6ff; background: #eff5ff; }
.radio-field input { width: 18px; min-height: auto; height: 18px; margin: 0; padding: 0; accent-color: var(--blue); }

@media (max-width: 700px) {
  .topbar { padding: 12px 20px; flex-wrap: wrap; gap: 7px 18px; }
  .topbar nav { order: 3; width: 100%; overflow-x: auto; }
  .topbar nav a { padding: 8px 3px; margin-right: 15px; }
  .account { margin-left: auto; }
  .container { padding: 26px 16px 48px; }
  .page-heading { align-items: start; flex-direction: column; }
  .form-grid, .stat-grid { grid-template-columns: 1fr; }
  .stat.compact { width: 100%; }
  .card { padding: 20px; }
  .modal { padding: 12px; }
  .modal-dialog { max-height: calc(100vh - 24px); padding: 24px 18px; }
}
