:root {
  --navy: #1B3A2B;
  --teal: #2E7031;
  --leaf: #6D9F2F;
  --gold: #B7952C;
  --bg: #f4f6f8;
  --card-bg: #ffffff;
  --border: #e2e6ea;
  --text: #23303d;
  --text-muted: #64707d;
  --danger: #c0392b;
  --success: #1f7a3d;
  --warning: #a86a00;
  --radius: 10px;
  --shadow: 0 1px 3px rgba(20, 30, 45, 0.08);
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font-family: -apple-system, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
  font-size: 15px;
  line-height: 1.5;
}
a { color: var(--teal); text-decoration: none; }
a:hover { text-decoration: underline; }
h1, h2, h3 { margin: 0 0 8px; color: var(--navy); }
p { margin: 0 0 12px; }

/* ---------- App shell ---------- */
.app-shell { display: flex; min-height: 100vh; }
.sidebar {
  width: 240px;
  background: var(--navy);
  color: #eef2f6;
  display: flex;
  flex-direction: column;
  flex-shrink: 0;
  position: sticky;
  top: 0;
  height: 100vh;
}
.brand { display: flex; align-items: center; gap: 8px; font-weight: 700; font-size: 18px; padding: 20px 18px; border-bottom: 1px solid rgba(255,255,255,0.12); }
.brand-mark { width: 34px; height: 34px; object-fit: contain; display: block; flex-shrink: 0; }
.nav { flex: 1; padding: 12px 10px; overflow-y: auto; }
.nav-link { display: flex; align-items: center; gap: 10px; padding: 10px 12px; border-radius: 8px; color: #d7e0e9; font-size: 14px; margin-bottom: 2px; }
.nav-link:hover { background: rgba(255,255,255,0.08); text-decoration: none; }
.nav-link.active { background: var(--teal); color: #fff; font-weight: 600; }
.nav-icon { width: 20px; text-align: center; }
.sidebar-footer { padding: 14px; border-top: 1px solid rgba(255,255,255,0.12); }
.user-chip { display: flex; align-items: center; gap: 10px; margin-bottom: 10px; }
.user-avatar { width: 34px; height: 34px; border-radius: 50%; background: var(--gold); color: #2b2205; display: flex; align-items: center; justify-content: center; font-weight: 700; flex-shrink: 0; }
.user-name { font-size: 13px; font-weight: 600; color: #fff; }
.user-role { font-size: 11px; color: #b7c4d1; }

.main { flex: 1; min-width: 0; }
.topbar { background: var(--card-bg); border-bottom: 1px solid var(--border); padding: 18px 28px; }
.topbar h1 { font-size: 20px; }
.content { padding: 24px 28px 60px; max-width: 1300px; }

/* ---------- Auth pages ---------- */
.auth-shell { min-height: 100vh; display: flex; align-items: center; justify-content: center; background: linear-gradient(135deg, var(--navy), var(--teal)); padding: 20px; }
.auth-card { background: #fff; border-radius: 14px; padding: 36px; width: 100%; max-width: 420px; box-shadow: 0 10px 40px rgba(0,0,0,0.2); }
.auth-card h1 { text-align: center; font-size: 22px; }
.auth-sub { text-align: center; color: var(--text-muted); margin-bottom: 22px; font-size: 13px; }
.auth-links { text-align: center; margin-top: 16px; font-size: 13px; }

/* ---------- Cards / tables ---------- */
.card { background: var(--card-bg); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); margin-bottom: 20px; }
.card-title { font-weight: 700; padding: 14px 18px; border-bottom: 1px solid var(--border); color: var(--navy); font-size: 15px; }
.card-body { padding: 18px; }

.grid { display: grid; gap: 16px; }
.grid-4 { grid-template-columns: repeat(4, 1fr); }
.grid-3 { grid-template-columns: repeat(3, 1fr); }
.grid-2 { grid-template-columns: repeat(2, 1fr); }
@media (max-width: 900px) { .grid-4, .grid-3, .grid-2 { grid-template-columns: 1fr 1fr; } }

.stat { background: var(--card-bg); border: 1px solid var(--border); border-radius: var(--radius); padding: 16px 18px; box-shadow: var(--shadow); }
.stat-label { font-size: 12px; color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.04em; margin-bottom: 6px; }
.stat-value { font-size: 26px; font-weight: 700; color: var(--navy); }
.stat-sub { font-size: 12px; color: var(--text-muted); margin-top: 4px; }

table { width: 100%; border-collapse: collapse; font-size: 14px; }
th, td { text-align: left; padding: 10px 12px; border-bottom: 1px solid var(--border); vertical-align: top; }
th { background: #f8fafb; color: var(--text-muted); font-weight: 600; font-size: 12px; text-transform: uppercase; letter-spacing: 0.03em; }
tr:last-child td { border-bottom: none; }
.table-wrap { overflow-x: auto; }

/* ---------- Forms ---------- */
label { display: block; font-size: 13px; font-weight: 600; margin-bottom: 5px; color: var(--text); }
input[type=text], input[type=password], input[type=email], input[type=tel], input[type=date], input[type=datetime-local], input[type=number], select, textarea {
  width: 100%; padding: 9px 11px; border: 1px solid #cfd6dc; border-radius: 7px; font-size: 14px; font-family: inherit; background: #fff; color: var(--text);
}
textarea { resize: vertical; min-height: 70px; }
.form-row { margin-bottom: 14px; }
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
@media (max-width: 700px) { .form-grid { grid-template-columns: 1fr; } }
.help-text { font-size: 12px; color: var(--text-muted); margin-top: 4px; }

.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; padding: 9px 16px; border-radius: 7px; border: 1px solid transparent; font-size: 14px; font-weight: 600; cursor: pointer; background: var(--teal); color: #fff; }
.btn:hover { opacity: 0.92; text-decoration: none; }
.btn-primary { background: var(--teal); }
.btn-navy { background: var(--navy); }
.btn-gold { background: var(--gold); color: #2b2205; }
.btn-danger { background: var(--danger); }
.btn-outline { background: #fff; border-color: #cfd6dc; color: var(--text); }
.btn-ghost { background: rgba(255,255,255,0.08); color: #eef2f6; border-color: rgba(255,255,255,0.2); }
.btn-sm { padding: 5px 10px; font-size: 12px; }
.btn-block { width: 100%; }
.btn-group { display: flex; gap: 8px; flex-wrap: wrap; }

.badge { display: inline-block; align-self: flex-start; flex-shrink: 0; padding: 3px 9px; border-radius: 999px; font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.03em; white-space: nowrap; line-height: 1.4; }
.badge-default { background: #e7ebee; color: var(--text-muted); }
.badge-info { background: #dbeafe; color: #1d4ed8; }
.badge-success { background: #dcf5e3; color: var(--success); }
.badge-warning { background: #fdecc8; color: var(--warning); }
.badge-danger { background: #fbdedb; color: var(--danger); }
.badge-teal { background: #d7f0ec; color: var(--teal); }
.badge-gold { background: #f6ecd0; color: #7a5f13; }

.flash { padding: 12px 16px; border-radius: 8px; margin-bottom: 18px; font-size: 14px; }
.flash-success { background: #dcf5e3; color: var(--success); }
.flash-error { background: #fbdedb; color: var(--danger); }
.flash-info { background: #dbeafe; color: #1d4ed8; }

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

.avail-grid { display: grid; grid-template-columns: 120px repeat(7, 1fr); gap: 6px; align-items: center; }
.avail-grid .head { font-size: 12px; font-weight: 700; text-align: center; color: var(--text-muted); }
.avail-cell { text-align: center; }
.avail-cell label { display: flex; flex-direction: column; align-items: center; gap: 4px; font-weight: 400; font-size: 11px; color: var(--text-muted); cursor: pointer; }
.avail-cell input { width: auto; }

.tag-list { display: flex; flex-wrap: wrap; gap: 6px; }
.tag { background: #eef2f6; border-radius: 6px; padding: 2px 8px; font-size: 12px; color: var(--text-muted); }

.section-title { font-size: 13px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.04em; color: var(--text-muted); margin: 24px 0 10px; }
.muted { color: var(--text-muted); }
.text-right { text-align: right; }
.mb-0 { margin-bottom: 0; }
hr.sep { border: none; border-top: 1px solid var(--border); margin: 18px 0; }

/* ---------- Huong dan trong trang soan thao ---------- */
.editor-guide {
  background: #FDF6E7; border: 1px solid #F0DDB2; border-left: 4px solid #E0982F;
  border-radius: 8px; padding: 14px 16px; margin-bottom: 18px;
  font-size: 13.5px; line-height: 1.7; color: #5B4A24;
}
.editor-guide b { color: #3F3213; }
.editor-guide code {
  background: #fff; border: 1px solid #E7D9B6; border-radius: 4px;
  padding: 1px 6px; font-size: 12.5px; color: #8A5A12;
}

/* ---------- Thu vien anh ---------- */
.media-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(210px, 1fr)); gap: 16px; }
.media-item { border: 1px solid var(--border); border-radius: 10px; overflow: hidden; background: #fff; }
.media-item img { width: 100%; height: 140px; object-fit: cover; display: block; background: #f1f5f7; }
.media-meta { padding: 10px 11px 12px; }
.media-name { font-size: 13px; font-weight: 600; margin-bottom: 3px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.media-path {
  width: 100%; margin-top: 7px; font-size: 12px; font-family: ui-monospace, Menlo, Consolas, monospace;
  padding: 5px 7px; background: #F4F7F9; cursor: pointer;
}

/* ---------- Xem truoc bai viet trong trang quan tri ---------- */
.post-preview {
  border: 1px solid var(--border); border-radius: 10px; padding: 18px 20px;
  background: #fff; font-size: 15px; line-height: 1.75; max-height: 520px; overflow: auto;
}
.post-preview h3 { font-size: 18px; margin: 20px 0 8px; }
.post-preview img { max-width: 100%; height: auto; border-radius: 8px; }
.post-preview .post-figure { text-align: center; }
.post-preview ul { padding-left: 20px; }

/* ---------- Sap xep muc noi dung ---------- */
.item-row { border: 1px solid var(--border); border-radius: 10px; padding: 14px 16px; margin-bottom: 12px; background: #fff; }
.item-row.inactive { opacity: .58; background: #FAFBFC; }
.item-head { display: flex; align-items: center; gap: 10px; margin-bottom: 10px; }
.item-head .idx { font-size: 12px; font-weight: 700; color: var(--text-muted); background: #EEF2F6; border-radius: 6px; padding: 2px 8px; }
.item-actions { margin-left: auto; display: flex; gap: 6px; }
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
@media (max-width: 720px) { .grid-2 { grid-template-columns: 1fr; } }
.card.item-hidden { opacity: .62; background: #FAFBFC; }
.card.item-hidden .card-title { color: var(--text-muted); }

.auth-logo { display: block; margin: 0 auto 6px; max-width: 190px; height: auto; }

/* ---------- Video trong thu vien va khung xem thu ---------- */
.media-item video { width: 100%; height: 140px; object-fit: cover; display: block; background: #12261B; }
.media-item.is-video { border-color: #C9DCC4; }
.post-preview .post-video { margin: 18px 0; }
.post-preview .post-video iframe,
.post-preview .post-video video {
  display: block; width: 100%; aspect-ratio: 16 / 9; height: auto;
  border: 0; border-radius: 8px; background: #0D1F16;
}
.post-preview .post-video-file video { aspect-ratio: auto; max-height: 340px; }
.post-preview .post-video-loi {
  background: #FDF3E3; border-left: 4px solid #E0982F; border-radius: 6px;
  padding: 9px 12px; font-size: 13.5px; color: #6B5216;
}

/* ---------- Danh gia cua gia dinh nguoi benh ---------- */
.stars { color: #E8A020; letter-spacing: 1px; font-size: 15px; }
.rating-pick { display: flex; flex-direction: column; gap: 6px; }
.rating-opt { display: flex; align-items: center; gap: 9px; padding: 7px 11px; border: 1px solid var(--border); border-radius: 8px; cursor: pointer; font-weight: 400; }
.rating-opt:hover { border-color: var(--teal); background: #F3F8F2; }
.rating-opt input { width: auto; margin: 0; }
.rating-opt b { font-weight: 600; }
tr.row-warn td { background: #FDF3E3; }

/* ============ Ho so ca nhan & phan quyen (ban 2) ============ */
.user-chip { text-decoration: none; color: inherit; border-radius: 10px; transition: background 0.15s ease; }
.user-chip:hover { background: rgba(255, 255, 255, 0.08); }
.user-avatar-img { border-radius: 50%; object-fit: cover; display: block; }

.profile-head { display: flex; align-items: center; gap: 18px; margin-bottom: 20px; }
.profile-name { font-size: 22px; font-weight: 700; color: #1B3A2B; }
.profile-meta { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; margin-top: 6px; }
.avatar-row { display: flex; align-items: center; gap: 16px; flex-wrap: wrap; }
.avatar-row input[type="file"] { max-width: 100%; }

.cell-user { display: flex; align-items: center; gap: 10px; }
.cell-user .user-avatar { flex: 0 0 auto; }

.perm-presets { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; margin-bottom: 14px; padding-bottom: 12px; border-bottom: 1px dashed #DCE4DA; }
.perm-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); gap: 16px; }
.perm-group { border: 1px solid #E3E9E0; border-radius: 10px; padding: 12px 14px; background: #FBFCFA; }
.perm-group-title { font-size: 12px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.4px; color: #6D8A6F; margin-bottom: 10px; }
.perm-item { display: flex; align-items: flex-start; gap: 10px; padding: 8px; border-radius: 8px; cursor: pointer; font-weight: 400; }
.perm-item:hover { background: #F1F5EF; }
.perm-item input[type="checkbox"] { width: auto; margin-top: 3px; flex: 0 0 auto; }
.perm-item b { display: block; font-size: 14px; color: #1B3A2B; }
.perm-item em { display: block; font-style: normal; font-size: 12.5px; color: #6B7A6E; line-height: 1.45; margin-top: 2px; }
.perm-item-warn b { color: #8A5A12; }
.perm-flag { display: inline-block; font-size: 10px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.3px; color: #8A5A12; background: #FDF1DC; border-radius: 4px; padding: 1px 5px; vertical-align: 2px; }

.perm-tags { display: flex; flex-wrap: wrap; gap: 4px; }
.perm-tag { display: inline-block; font-size: 11.5px; background: #EEF4EA; color: #2E7031; border: 1px solid #DCE7D6; border-radius: 5px; padding: 2px 7px; }
.perm-tag-more { background: #F4F4F4; color: #6B7A6E; border-color: #E2E2E2; }

@media (max-width: 640px) {
  .profile-head { gap: 12px; }
  .perm-grid { grid-template-columns: 1fr; }
}
