* { box-sizing: border-box; }
body {
  font-family: 'Sarabun', 'Tahoma', Arial, sans-serif;
  background: #f4f5f7;
  color: #222;
  margin: 0;
}

/* ---- Proxmox VE-inspired shell: dark top bar + light tree sidebar ---- */
.pve-topbar {
  background: #1c2b36;
  color: #fff;
  padding: 0 20px;
  height: 48px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  position: sticky;
  top: 0;
  z-index: 300;
}
.pve-topbar-brand { display: flex; align-items: center; gap: 10px; font-size: 15px; font-weight: 600; }
.pve-topbar-brand-sep { opacity: .5; font-weight: 400; }
.pve-topbar-user { display: flex; align-items: center; gap: 14px; font-size: 13px; }
.pve-topbar-username { opacity: .85; }
.pve-logout-link { color: #fff; text-decoration: none; opacity: .85; }
.pve-logout-link:hover { opacity: 1; text-decoration: underline; }

.pve-topbar-burger {
  display: none;
  background: none;
  border: none;
  color: #fff;
  padding: 6px;
  margin-right: 4px;
  cursor: pointer;
}
.pve-topbar-burger svg { width: 24px; height: 24px; display: block; }

.pve-shell { display: flex; align-items: flex-start; min-height: calc(100vh - 48px); }
.pve-sidebar {
  width: 230px;
  flex-shrink: 0;
  background: #f5f5f5;
  border-right: 1px solid #e0e0e0;
  height: calc(100vh - 48px);
  position: sticky;
  top: 48px;
  overflow-y: auto;
  padding: 10px 0;
}
.pve-sidebar-backdrop { display: none; }
.pve-treelist { display: flex; flex-direction: column; }
.pve-tree-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 16px;
  margin: 2px 6px;
  border-radius: 4px;
  color: #000;
  text-decoration: none;
  font-size: 14px;
}
.pve-tree-icon { width: 18px; height: 18px; flex-shrink: 0; color: #555; }
.pve-tree-item:hover { background: #e2eff9; }
.pve-tree-item.active { background: #c2ddf2; }
.pve-tree-item.active .pve-tree-icon { color: #3892d4; }
.pve-tree-label {
  font-size: 11px;
  color: #999;
  text-transform: uppercase;
  letter-spacing: .04em;
  padding: 14px 16px 4px;
}
.pve-tree-label:first-child { padding-top: 4px; }
.pve-main { flex: 1; min-width: 0; }

.container { max-width: none; margin: 24px 0; padding: 0 24px; }
.card { background: #fff; border-radius: 10px; padding: 20px; box-shadow: 0 1px 3px rgba(0,0,0,.08); margin-bottom: 20px; }
h1, h2, h3 { margin-top: 0; }
table { width: 100%; border-collapse: collapse; }
th, td { padding: 10px 8px; border-bottom: 1px solid #eee; text-align: left; font-size: 14px; }
th { background: #f9fafb; color: #444; }
tr:last-child td { border-bottom: none; }
.text-right { text-align: right; }

.btn {
  display: inline-block; padding: 8px 16px; border-radius: 6px; border: none;
  background: #3892d4; color: #fff; text-decoration: none; cursor: pointer; font-size: 14px;
}
.btn:hover { background: #2f7ab8; }
.btn.gray { background: #6b7280; }
.btn.gray:hover { background: #4b5563; }
.btn.red { background: #dc2626; }
.btn.red:hover { background: #b91c1c; }
.btn.green { background: #16a34a; }
.btn.green:hover { background: #15803d; }
.btn.small { padding: 5px 10px; font-size: 12px; }

input, select, textarea {
  width: 100%; padding: 8px 10px; border: 1px solid #d1d5db; border-radius: 6px; font-size: 14px; font-family: inherit;
}
label { display: block; margin: 12px 0 4px; font-size: 13px; color: #444; font-weight: 600; }

.badge { display: inline-block; padding: 3px 10px; border-radius: 999px; font-size: 12px; font-weight: 600; }
.badge-gray { background: #f3f4f6; color: #4b5563; }
.badge-blue { background: #dbeafe; color: #1d4ed8; }
.badge-green { background: #dcfce7; color: #15803d; }
.badge-red { background: #fee2e2; color: #b91c1c; }

.filters { display: flex; gap: 10px; margin-bottom: 16px; flex-wrap: wrap; align-items: flex-end; }
.filters select, .filters input { width: auto; min-width: 220px; }
.filters label { margin: 0 0 4px; }

.flash { padding: 10px 14px; border-radius: 6px; margin-bottom: 16px; font-size: 14px; }
.flash-ok { background: #dcfce7; color: #15803d; }
.flash-err { background: #fee2e2; color: #b91c1c; }

.login-wrap { max-width: 360px; margin: 80px auto; }

.row-actions { display: flex; gap: 6px; align-items: center; flex-wrap: nowrap; }
.inline-form { display: inline-block; margin: 0; }

.pagination {
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 12px;
  margin-top: 16px;
  padding-top: 12px;
  border-top: 1px solid #eee;
}
.pagination-pages { display: flex; gap: 4px; }
.page-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 30px;
  height: 30px;
  padding: 0 6px;
  border-radius: 4px;
  border: 1px solid #e0e0e0;
  color: #333;
  text-decoration: none;
  font-size: 13px;
}
.page-btn:hover { background: #f3f4f6; }
.page-btn.active { background: #3892d4; color: #fff; border-color: #3892d4; }
.pagination-total { color: #888; font-size: 13px; }

.muted { color: #6b7280; font-size: 13px; }

/* ---- Stat tiles (dashboard) ---- */
.stat-cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: 12px; margin-bottom: 24px; }
.stat-card { background: #fff; border-radius: 10px; padding: 16px; box-shadow: 0 1px 3px rgba(0,0,0,.08); }
.stat-card .num { font-size: 28px; font-weight: 700; }
.stat-card .label { font-size: 13px; color: #6b7280; margin-top: 4px; }

/* ---- App-specific: profile, posts, group messages, live tabs ---- */
.profile-card { display: flex; gap: 20px; align-items: flex-start; }
.avatar-lg { width: 96px; height: 96px; border-radius: 50%; object-fit: cover; flex-shrink: 0; }
.avatar-placeholder { background: #e5e7eb; }
.post-card { background: #fff; border-radius: 10px; padding: 16px; box-shadow: 0 1px 3px rgba(0,0,0,.08); margin-bottom: 12px; }
.post-media { max-width: 100%; max-height: 360px; border-radius: 8px; margin-top: 8px; display: block; }
.thumb { width: 64px; height: 64px; object-fit: cover; border-radius: 6px; }
.thumb-placeholder { width: 64px; height: 64px; border-radius: 6px; background: #e5e7eb; }
.tabs { display: flex; gap: 4px; margin-bottom: 16px; }
.tabs a { padding: 8px 16px; border-radius: 6px; text-decoration: none; color: #4b5563; font-size: 14px; font-weight: 600; background: #fff; box-shadow: 0 1px 3px rgba(0,0,0,.08); }
.tabs a.active { background: #3892d4; color: #fff; }
.msg-row { background: #fff; border-radius: 8px; padding: 10px 14px; margin-bottom: 8px; box-shadow: 0 1px 3px rgba(0,0,0,.06); }
.msg-row .sender { font-weight: 600; font-size: 13px; }
.msg-row .msg-time { color: #6b7280; font-size: 12px; margin-left: 8px; }
.msg-row img.msg-media { max-width: 240px; max-height: 240px; border-radius: 6px; margin-top: 6px; display: block; }

/* ---- mobile / tablet ---- */
@media screen and (max-width: 860px) {
  .pve-topbar-burger { display: inline-flex; align-items: center; justify-content: center; }
  .pve-topbar-brand span:not(.pve-topbar-brand-sep) { font-size: 13px; }
  .pve-topbar-username { display: none; }

  .pve-sidebar {
    position: fixed;
    top: 48px;
    left: 0;
    bottom: 0;
    height: auto;
    z-index: 200;
    transform: translateX(-100%);
    transition: transform .2s ease;
    box-shadow: 2px 0 12px rgba(0,0,0,.15);
    overflow-y: auto;
  }
  .pve-sidebar.open { transform: translateX(0); }
  .pve-sidebar-backdrop {
    display: block;
    position: fixed;
    inset: 48px 0 0 0;
    background: rgba(0,0,0,.4);
    z-index: 190;
    opacity: 0;
    pointer-events: none;
    transition: opacity .2s ease;
  }
  .pve-sidebar-backdrop.open { opacity: 1; pointer-events: auto; }
  .pve-main { width: 100%; }
}

@media screen and (max-width: 700px) {
  .container { padding: 0 10px; margin: 14px 0; }
  .card { padding: 14px; }
  .filters { flex-direction: column; align-items: stretch; }
  .filters select, .filters input { width: 100%; min-width: 0; }
  .row-actions { flex-wrap: wrap; }
  .login-wrap { margin: 36px auto; }
}
