/**
 * @nhom        : Styles
 * @chucnang    : Design system CSS chung — biến màu, typography, layout, components
 * @lienquan    : login.html, admin.html, update.html, accommodation.html, change-password.html
 * @alias       : common-css, design-system, shared-styles
 */

/* ============================================================
   CSS VARIABLES — Bảng màu và token thiết kế
   ============================================================ */
:root {
  /* Màu chính */
  --blue: #185fa5;
  --blue-light: #e6f1fb;
  --blue-dark: #0f3d73;
  --bg: #f3f6fa;
  --card: #fff;
  --line: #dfe6ef;
  --text: #18202f;
  --muted: #677386;

  /* Trạng thái */
  --green: #0f766e;
  --green-bg: #d0f0e4;
  --red: #dc4c4c;
  --red-bg: #fcebeb;
  --amber: #b7791f;
  --amber-bg: #faeeda;
  --purple: #534ab7;
  --purple-bg: #eeedfe;

  /* Border & Shadow */
  --radius: 6px;
  --radius-sm: 4px;
  --shadow-sm: 0 1px 4px rgba(0,0,0,.04);
  --shadow-md: 0 8px 24px rgba(15,43,76,.15);
  --shadow-lg: 0 25px 60px rgba(0,0,0,.25);

  /* Gradient header */
  --gradient-header: linear-gradient(135deg, #0F2B4C, #1A5276, #2471A3);
  --gradient-bg: linear-gradient(135deg, #0F2B4C 0%, #1A5276 40%, #2471A3 100%);
}

/* ============================================================
   RESET & BASE
   ============================================================ */
* { box-sizing: border-box; margin: 0; padding: 0; }

body {
  font-family: 'Roboto', Arial, 'Times New Roman', sans-serif;
  background: var(--bg);
  color: var(--text);
  font-size: 14px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

body, input, select, textarea, button {
  overflow-wrap: anywhere;
}

/* ============================================================
   PAGE LAYOUT — Sidebar + Content
   ============================================================ */
.app-layout {
  display: flex;
  min-height: 100vh;
}

/* Sidebar */
.sidebar {
  width: 240px;
  background: linear-gradient(180deg, #0a1e38 0%, #0f2b4c 100%);
  color: #fff;
  display: flex;
  flex-direction: column;
  position: fixed;
  top: 0;
  left: 0;
  bottom: 0;
  z-index: 100;
  transition: transform .25s ease;
}

.sidebar-brand {
  padding: 18px 16px;
  border-bottom: 1px solid rgba(255,255,255,.08);
}

.sidebar-brand-icon {
  font-size: 28px;
  margin-bottom: 4px;
}

.sidebar-brand h2 {
  font-size: 13px;
  font-weight: 600;
  opacity: .9;
  line-height: 1.4;
}

.sidebar-nav {
  flex: 1;
  padding: 12px 8px;
  display: flex;
  flex-direction: column;
  gap: 2px;
  overflow-y: auto;
}

.sidebar-link {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  color: rgba(255,255,255,.7);
  text-decoration: none;
  font-size: 13px;
  font-weight: 600;
  transition: all .15s;
  cursor: pointer;
  border: none;
  background: none;
  width: 100%;
  text-align: left;
  font-family: inherit;
  min-width: 0;
  white-space: normal;
}

.sidebar-link:hover {
  background: rgba(255,255,255,.1);
  color: #fff;
}

.sidebar-link.active {
  background: rgba(255,255,255,.15);
  color: #fff;
}

.sidebar-link .icon {
  font-size: 18px;
  width: 24px;
  text-align: center;
  flex-shrink: 0;
}

.sidebar-section {
  font-size: 10px;
  font-weight: 700;
  color: rgba(255,255,255,.35);
  text-transform: uppercase;
  letter-spacing: .5px;
  padding: 16px 12px 6px;
}

.sidebar-user {
  padding: 14px 16px;
  border-top: 1px solid rgba(255,255,255,.08);
  display: flex;
  align-items: center;
  gap: 10px;
}

.sidebar-avatar {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  background: rgba(255,255,255,.15);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 14px;
  font-weight: 700;
  flex-shrink: 0;
}

.sidebar-user-info {
  flex: 1;
  min-width: 0;
}

.sidebar-user-name {
  font-size: 12px;
  font-weight: 700;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.sidebar-user-role {
  font-size: 10px;
  opacity: .6;
}

/* Toggle sidebar trên mobile */
.sidebar-toggle {
  display: none;
  position: fixed;
  top: 12px;
  left: 12px;
  z-index: 200;
  width: 40px;
  height: 40px;
  border-radius: var(--radius-sm);
  background: var(--card);
  border: 1px solid var(--line);
  font-size: 20px;
  cursor: pointer;
  align-items: center;
  justify-content: center;
  box-shadow: var(--shadow-sm);
}

/* Main content */
.main-content {
  flex: 1;
  margin-left: 240px;
  padding: 20px 24px 40px;
  max-width: 1400px;
  min-width: 0;
}

/* ============================================================
   PAGE HEADER
   ============================================================ */
.page-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 12px;
  margin-bottom: 20px;
  flex-wrap: wrap;
}

.page-header h1 {
  font-size: 22px;
  font-weight: 800;
  color: var(--text);
  line-height: 1.25;
}

.page-header .subtitle {
  font-size: 13px;
  color: var(--muted);
  margin-top: 2px;
}

/* ============================================================
   FORM INPUTS
   ============================================================ */
input, select, textarea {
  height: 40px;
  border: 1.5px solid #d1d9e5;
  border-radius: var(--radius-sm);
  padding: 0 12px;
  font: inherit;
  font-size: 13px;
  background: #f9fafc;
  transition: border-color .15s, box-shadow .15s;
  color: var(--text);
}

textarea {
  height: auto;
  padding: 10px 12px;
  min-height: 60px;
  resize: vertical;
}

input:focus, select:focus, textarea:focus {
  outline: none;
  border-color: var(--blue);
  box-shadow: 0 0 0 3px rgba(24,95,165,.1);
  background: #fff;
}

/* ============================================================
   BUTTONS
   ============================================================ */
.btn {
  border: 0;
  border-radius: var(--radius-sm);
  padding: 9px 16px;
  font-size: 13px;
  font-weight: 700;
  cursor: pointer;
  font-family: inherit;
  transition: all .15s;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  white-space: nowrap;
  min-height: 36px;
}

.btn:active { transform: scale(.97); }

.btn-primary { background: var(--blue); color: #fff; }
.btn-primary:hover { filter: brightness(1.08); box-shadow: 0 4px 14px rgba(24,95,165,.25); }

.btn-success { background: var(--green); color: #fff; }
.btn-success:hover { filter: brightness(.92); }

.btn-danger { background: var(--red); color: #fff; }
.btn-danger:hover { filter: brightness(.92); }

.btn-ghost { background: #f1f3f7; color: var(--text); border: 1px solid var(--line); }
.btn-ghost:hover { background: #e8ecf2; }

.btn-sm { padding: 5px 10px; font-size: 11px; }

/* ============================================================
   STAT CARDS
   ============================================================ */
.stat-row {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(130px, 1fr));
  gap: 10px;
  margin-bottom: 16px;
}

.stat-box {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 14px 16px;
  box-shadow: var(--shadow-sm);
  transition: border-color .15s, transform .15s;
}

.stat-box:hover {
  border-color: #b9c6d8;
  transform: translateY(-1px);
}

.stat-box .lbl {
  font-size: 10px;
  color: var(--muted);
  text-transform: uppercase;
  font-weight: 700;
  letter-spacing: .3px;
}

.stat-box .val {
  font-size: 26px;
  font-weight: 800;
  margin-top: 2px;
}

/* ============================================================
   PANELS / CARDS
   ============================================================ */
.panel {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 20px;
  box-shadow: var(--shadow-sm);
}

.panel h2 {
  font-size: 15px;
  font-weight: 700;
  margin: 0 0 16px;
  display: flex;
  align-items: center;
  gap: 8px;
}

.panel h2 .icon { font-size: 18px; }

/* ============================================================
   TABLE
   ============================================================ */
table { width: 100%; border-collapse: collapse; }

th, td {
  border: 1px solid #cdd5df;
  padding: 10px 10px;
  text-align: left;
  font-size: 12px;
  vertical-align: middle;
  overflow-wrap: anywhere;
}

th {
  font-size: 10px;
  text-transform: uppercase;
  color: var(--muted);
  font-weight: 700;
  letter-spacing: .3px;
  border: 1px solid #cdd5df;
  background: #f1f5f9;
}

tr:hover td { background: #f5f8fc; }

/* ============================================================
   ROLE BADGES
   ============================================================ */
.role {
  display: inline-flex;
  align-items: center;
  padding: 3px 8px;
  border-radius: 20px;
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .3px;
}

.role-admin { background: #FEE2E2; color: #991B1B; }
.role-manager { background: #DBEAFE; color: #1E40AF; }
.role-user { background: #D1FAE5; color: #065F46; }
.role-viewer { background: #F3F4F6; color: #4B5563; }

/* ============================================================
   TABS
   ============================================================ */
.tabs { display: flex; gap: 6px; margin-bottom: 16px; flex-wrap: wrap; }

.tab {
  padding: 9px 18px;
  border-radius: var(--radius-sm);
  font-size: 13px;
  font-weight: 700;
  cursor: pointer;
  border: 1.5px solid var(--line);
  background: var(--card);
  color: var(--muted);
  transition: all .15s;
}

.tab:hover { border-color: #b9c6d8; }
.tab.on { background: var(--blue); color: #fff; border-color: var(--blue); }

/* ============================================================
   TOAST NOTIFICATION
   ============================================================ */
.toast {
  position: fixed;
  bottom: 24px;
  right: 24px;
  background: #18202f;
  color: #fff;
  padding: 14px 20px;
  border-radius: var(--radius);
  font-size: 13px;
  font-weight: 600;
  box-shadow: 0 12px 32px rgba(0,0,0,.25);
  transform: translateY(120px);
  opacity: 0;
  transition: all .35s cubic-bezier(.4,0,.2,1);
  z-index: 999;
  max-width: 400px;
}

.toast.show {
  transform: translateY(0);
  opacity: 1;
}

/* ============================================================
   MODAL
   ============================================================ */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.45);
  backdrop-filter: blur(4px);
  z-index: 999;
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  pointer-events: none;
  transition: opacity .2s;
}

.modal-overlay.active {
  opacity: 1;
  pointer-events: all;
}

.modal-box {
  background: #fff;
  border-radius: 14px;
  padding: 28px;
  max-width: 440px;
  width: 90%;
  box-shadow: 0 25px 60px rgba(0,0,0,.2);
  transform: scale(.94);
  transition: transform .25s cubic-bezier(.4,0,.2,1);
}

.modal-overlay.active .modal-box {
  transform: scale(1);
}

.modal-box h3 {
  font-size: 17px;
  font-weight: 700;
  margin-bottom: 8px;
}

.modal-box p {
  font-size: 13px;
  color: var(--muted);
  margin-bottom: 18px;
  line-height: 1.5;
}

.modal-btns {
  display: flex;
  gap: 8px;
  justify-content: flex-end;
}

/* ============================================================
   PASSWORD INPUT — Show/Hide toggle
   ============================================================ */
.password-wrap {
  position: relative;
}

.password-wrap input {
  padding-right: 44px;
}

.password-toggle {
  position: absolute;
  right: 4px;
  top: 50%;
  transform: translateY(-50%);
  width: 36px;
  height: 36px;
  border: none;
  background: none;
  cursor: pointer;
  font-size: 18px;
  color: var(--muted);
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 6px;
  transition: background .15s;
}

.password-toggle:hover {
  background: rgba(0,0,0,.05);
}

/* ============================================================
   LOADING STATE
   ============================================================ */
.btn.loading {
  pointer-events: none;
  opacity: .7;
}

.btn.loading::after {
  content: '';
  width: 14px;
  height: 14px;
  border: 2px solid rgba(255,255,255,.3);
  border-top-color: #fff;
  border-radius: 50%;
  animation: spin .6s linear infinite;
  margin-left: 6px;
}

@keyframes spin { to { transform: rotate(360deg); } }

/* ============================================================
   RESPONSIVE — Mobile
   ============================================================ */
@media (max-width: 900px) {
  .sidebar {
    transform: translateX(-100%);
  }

  .sidebar.open {
    transform: translateX(0);
  }

  .sidebar-toggle {
    display: flex;
  }

  .main-content {
    margin-left: 0;
    padding: 16px;
    padding-top: 60px;
  }
}

@media (max-width: 600px) {
  .stat-row {
    grid-template-columns: repeat(2, 1fr);
  }
}

/* ============================================================
   NOTIFICATION BELL — Widget chuông thông báo trên sidebar
   ============================================================ */

/**
 * @nhom        : Notification Widget
 * @chucnang    : Styles cho chuông thông báo, badge số, dropdown panel
 */

.noti-bell {
  position: relative;
  cursor: pointer;
  padding: 8px;
  border-radius: var(--radius-sm);
  transition: background .15s;
  border: none;
  background: none;
  color: rgba(255,255,255,.7);
  font-size: 20px;
}

.noti-bell:hover {
  background: rgba(255,255,255,.1);
  color: #fff;
}

.noti-badge {
  position: absolute;
  top: 2px;
  right: 2px;
  min-width: 18px;
  height: 18px;
  border-radius: 50%;
  background: var(--red);
  color: #fff;
  font-size: 10px;
  font-weight: 800;
  display: flex;
  align-items: center;
  justify-content: center;
  border: 2px solid #0a1e38;
  padding: 0 3px;
  animation: noti-pulse 2s ease-in-out infinite;
}

@keyframes noti-pulse {
  0%, 100% { transform: scale(1); }
  50% { transform: scale(1.15); }
}

.noti-panel {
  position: fixed;
  left: 248px;
  top: 12px;
  width: 380px;
  max-height: 520px;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 12px;
  box-shadow: 0 16px 48px rgba(0,0,0,.2);
  z-index: 500;
  display: flex;
  flex-direction: column;
  opacity: 0;
  transform: translateX(-10px);
  pointer-events: none;
  transition: all .2s ease;
}

.noti-panel.open {
  opacity: 1;
  transform: translateX(0);
  pointer-events: all;
}

.noti-panel-header {
  padding: 14px 16px;
  border-bottom: 1px solid var(--line);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.noti-panel-header h3 {
  font-size: 14px;
  font-weight: 700;
}

.noti-panel-body {
  flex: 1;
  overflow-y: auto;
  max-height: 400px;
}

.noti-item {
  padding: 12px 16px;
  border-bottom: 1px solid #f0f2f5;
  cursor: pointer;
  transition: background .15s;
  display: flex;
  gap: 10px;
  align-items: flex-start;
}

.noti-item:hover {
  background: #f7f9fc;
}

.noti-item.unread {
  background: #f0f7ff;
  border-left: 3px solid var(--blue);
}

.noti-item.unread:hover {
  background: #e6f1fb;
}

.noti-icon {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 16px;
  flex-shrink: 0;
}

.noti-icon.deadline { background: #FEF3C7; }
.noti-icon.overdue { background: #FEE2E2; }
.noti-icon.info { background: #DBEAFE; }
.noti-icon.warning { background: #FDE68A; }
.noti-icon.anomaly { background: #EDE9FE; }

.noti-content {
  flex: 1;
  min-width: 0;
}

.noti-title {
  font-size: 12px;
  font-weight: 700;
  color: var(--text);
  margin-bottom: 2px;
}

.noti-msg {
  font-size: 11px;
  color: var(--muted);
  line-height: 1.4;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.noti-time {
  font-size: 10px;
  color: #9ca3af;
  margin-top: 3px;
}

.noti-empty {
  padding: 32px 16px;
  text-align: center;
  color: var(--muted);
  font-size: 13px;
}

/* ============================================================
   HISTORY TIMELINE — Lịch sử thay đổi giá trị
   ============================================================ */

/**
 * @nhom        : History Timeline
 * @chucnang    : Styles cho panel timeline xem lịch sử thay đổi chỉ tiêu
 */

.history-panel {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 16px;
  margin-top: 10px;
}

.history-timeline {
  position: relative;
  padding-left: 24px;
}

.history-timeline::before {
  content: '';
  position: absolute;
  left: 8px;
  top: 0;
  bottom: 0;
  width: 2px;
  background: linear-gradient(to bottom, var(--blue), var(--line));
  border-radius: 1px;
}

.history-item {
  position: relative;
  padding: 10px 0 10px 16px;
  border-bottom: 1px solid #f5f7fa;
}

.history-item:last-child {
  border-bottom: none;
}

.history-dot {
  position: absolute;
  left: -20px;
  top: 14px;
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--blue);
  border: 2px solid var(--card);
  box-shadow: 0 0 0 2px var(--blue);
}

.history-dot.rollback {
  background: var(--amber);
  box-shadow: 0 0 0 2px var(--amber);
}

.history-meta {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 4px;
}

.history-user {
  font-size: 11px;
  font-weight: 700;
  color: var(--text);
}

.history-time {
  font-size: 10px;
  color: var(--muted);
}

.history-change {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 11px;
}

.history-old {
  padding: 2px 6px;
  background: var(--red-bg);
  color: var(--red);
  border-radius: 4px;
  text-decoration: line-through;
}

.history-arrow {
  color: var(--muted);
  font-size: 12px;
}

.history-new {
  padding: 2px 6px;
  background: var(--green-bg);
  color: var(--green);
  border-radius: 4px;
  font-weight: 600;
}

.history-rollback-btn {
  border: none;
  background: #FEF3C7;
  color: var(--amber);
  font-size: 10px;
  font-weight: 700;
  padding: 3px 8px;
  border-radius: 4px;
  cursor: pointer;
  transition: all .15s;
}

.history-rollback-btn:hover {
  background: #FDE68A;
}

/* ============================================================
   PERIOD BADGES — Kỳ báo cáo
   ============================================================ */

/**
 * @nhom        : Period Badges
 * @chucnang    : Styles cho badge trạng thái kỳ, form quản lý kỳ
 */

.period-badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 3px 10px;
  border-radius: 20px;
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .3px;
}

.period-open { background: var(--green-bg); color: var(--green); }
.period-locked { background: var(--red-bg); color: var(--red); }
.period-archived { background: #F3F4F6; color: #6B7280; }
.period-active { background: var(--blue-light); color: var(--blue); border: 1.5px solid var(--blue); }

.period-type {
  display: inline-flex;
  align-items: center;
  padding: 2px 8px;
  border-radius: 4px;
  font-size: 10px;
  font-weight: 600;
  background: #F3F4F6;
  color: #4B5563;
}

.period-card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 14px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  transition: all .15s;
}

.period-card:hover {
  border-color: #b9c6d8;
  box-shadow: 0 4px 12px rgba(0,0,0,.06);
}

.period-card.active {
  border-color: var(--blue);
  border-width: 2px;
  box-shadow: 0 4px 16px rgba(24,95,165,.12);
}

.period-info {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
}

.period-name {
  font-size: 14px;
  font-weight: 700;
  color: var(--text);
}

.period-dates {
  font-size: 11px;
  color: var(--muted);
  display: flex;
  align-items: center;
  gap: 4px;
}

.period-actions {
  display: flex;
  gap: 4px;
  flex-wrap: wrap;
}

/* ============================================================
   CHARTS ENHANCED — Biểu đồ nâng cao
   ============================================================ */

.chart-container {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 16px;
  box-shadow: var(--shadow-sm);
  min-width: 0;
}

.chart-title {
  font-size: 13px;
  font-weight: 700;
  color: var(--text);
  margin-bottom: 12px;
  display: flex;
  align-items: center;
  gap: 6px;
  line-height: 1.35;
}

.chart-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(320px, 1fr));
  gap: 12px;
  margin-bottom: 16px;
}

/* ============================================================
   PERIOD INDICATOR — Thanh hiển thị kỳ hiện tại trên trang update
   ============================================================ */

.period-bar {
  background: linear-gradient(135deg, #123B73, #1D75BD);
  color: #fff;
  border-radius: var(--radius);
  padding: 12px 16px;
  margin-bottom: 12px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
}

.period-bar-info {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
}

.period-bar-icon {
  font-size: 20px;
}

.period-bar-name {
  font-size: 14px;
  font-weight: 700;
  overflow-wrap: anywhere;
}

.period-bar-dates {
  font-size: 11px;
  opacity: .8;
}

.period-bar-status {
  padding: 4px 12px;
  border-radius: 20px;
  font-size: 11px;
  font-weight: 700;
}

.period-bar-status.open { background: rgba(255,255,255,.2); color: #fff; }
.period-bar-status.locked { background: #dc4c4c; color: #fff; }

.period-locked-banner {
  background: #FEF2F2;
  border: 1px solid #FECACA;
  border-radius: var(--radius);
  padding: 14px 16px;
  margin-bottom: 12px;
  color: #991B1B;
  font-size: 13px;
  font-weight: 600;
  display: flex;
  align-items: center;
  gap: 8px;
}

/* ============================================================
   RESPONSIVE — Mobile cho tính năng mới
   ============================================================ */

@media (max-width: 900px) {
  .noti-panel {
    left: 8px;
    right: 8px;
    width: auto;
    top: auto;
    bottom: 60px;
  }

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

  .period-bar {
    flex-direction: column;
    align-items: flex-start;
  }
}

/* ============================================================
   APPROVAL WORKFLOW — Luồng phê duyệt
   ============================================================ */

/**
 * @nhom        : Approval Styles
 * @chucnang    : Badges trạng thái, bảng duyệt, form review
 */

.approval-badge {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  padding: 2px 8px;
  border-radius: 12px;
  font-size: 10px;
  font-weight: 700;
  letter-spacing: .2px;
  white-space: normal;
}

.approval-draft { background: #F3F4F6; color: #6B7280; }
.approval-pending { background: #FEF3C7; color: #92400E; animation: approval-pulse 2s infinite; }
.approval-approved { background: var(--green-bg); color: var(--green); }
.approval-rejected { background: var(--red-bg); color: var(--red); }

@keyframes approval-pulse {
  0%, 100% { box-shadow: 0 0 0 0 rgba(217,119,6,.3); }
  50% { box-shadow: 0 0 0 4px rgba(217,119,6,0); }
}

.approval-card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 14px;
  margin-bottom: 8px;
  transition: all .15s;
}

.approval-card:hover {
  border-color: #b9c6d8;
  box-shadow: 0 4px 12px rgba(0,0,0,.06);
}

.approval-card.pending {
  border-left: 3px solid #D97706;
}

.approval-card.approved {
  border-left: 3px solid var(--green);
}

.approval-card.rejected {
  border-left: 3px solid var(--red);
}

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

.approval-stt {
  font-weight: 800;
  font-size: 13px;
  color: var(--blue);
}

.approval-ind-name {
  font-size: 12px;
  color: var(--text);
  font-weight: 600;
  flex: 1;
}

.approval-detail {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
  font-size: 11px;
  margin-bottom: 8px;
}

.approval-field label {
  display: block;
  font-size: 9px;
  text-transform: uppercase;
  color: var(--muted);
  font-weight: 700;
  margin-bottom: 2px;
}

.approval-field span {
  font-weight: 600;
  color: var(--text);
}

.approval-meta {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 10px;
  color: var(--muted);
  border-top: 1px solid var(--line);
  padding-top: 6px;
  margin-top: 6px;
}

.approval-actions {
  display: flex;
  gap: 6px;
}

.review-input {
  width: 100%;
  padding: 8px 10px;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  font-size: 12px;
  margin-top: 6px;
  resize: none;
  min-height: 36px;
}

/* ============================================================
   ALERT SUMMARY — Card tổng hợp cảnh báo
   ============================================================ */

/**
 * @nhom        : Alert Summary
 * @chucnang    : Card tổng hợp cảnh báo active trên dashboard
 */

.alert-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: 8px;
  margin-bottom: 16px;
}

.alert-card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 12px;
  text-align: center;
  transition: all .15s;
  cursor: default;
}

.alert-card:hover {
  box-shadow: 0 4px 12px rgba(0,0,0,.06);
}

.alert-card.danger {
  border-color: #FECACA;
  background: #FEF2F2;
}

.alert-card.warning {
  border-color: #FDE68A;
  background: #FFFBEB;
}

.alert-card.info {
  border-color: #BFDBFE;
  background: #EFF6FF;
}

.alert-icon {
  font-size: 22px;
  margin-bottom: 4px;
}

.alert-count {
  font-size: 24px;
  font-weight: 800;
  line-height: 1;
  margin-bottom: 2px;
}

.alert-card.danger .alert-count { color: var(--red); }
.alert-card.warning .alert-count { color: #D97706; }
.alert-card.info .alert-count { color: var(--blue); }

.alert-label {
  font-size: 10px;
  color: var(--muted);
  font-weight: 600;
}

/* ============================================================
   ALERT RULES — Quản lý rules cảnh báo
   ============================================================ */

.rule-card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 12px 14px;
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 8px;
  transition: all .15s;
}

.rule-card:hover {
  box-shadow: 0 4px 12px rgba(0,0,0,.06);
}

.rule-card.disabled {
  opacity: .5;
}

.rule-toggle {
  position: relative;
  width: 40px;
  height: 22px;
  flex-shrink: 0;
}

.rule-toggle input {
  display: none;
}

.rule-toggle label {
  position: absolute;
  inset: 0;
  background: #D1D5DB;
  border-radius: 11px;
  cursor: pointer;
  transition: background .2s;
}

.rule-toggle input:checked + label {
  background: var(--green);
}

.rule-toggle label::after {
  content: '';
  position: absolute;
  left: 2px;
  top: 2px;
  width: 18px;
  height: 18px;
  background: #fff;
  border-radius: 50%;
  transition: transform .2s;
  box-shadow: 0 1px 3px rgba(0,0,0,.2);
}

.rule-toggle input:checked + label::after {
  transform: translateX(18px);
}

.rule-info {
  flex: 1;
  min-width: 0;
}

.rule-name {
  font-size: 13px;
  font-weight: 700;
  color: var(--text);
}

.rule-desc {
  font-size: 11px;
  color: var(--muted);
  margin-top: 2px;
}

.rule-meta {
  display: flex;
  gap: 8px;
  margin-top: 4px;
}

.rule-tag {
  padding: 1px 6px;
  border-radius: 3px;
  font-size: 9px;
  font-weight: 700;
  text-transform: uppercase;
}

.rule-tag.deadline { background: #FEF3C7; color: #92400E; }
.rule-tag.no_input { background: #DBEAFE; color: #1E40AF; }
.rule-tag.threshold { background: #EDE9FE; color: #5B21B6; }
.rule-tag.anomaly { background: #FCE7F3; color: #9D174D; }
.rule-tag.custom { background: #F3F4F6; color: #4B5563; }

.pending-badge-tab {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 18px;
  height: 18px;
  border-radius: 50%;
  background: #EF4444;
  color: #fff;
  font-size: 10px;
  font-weight: 800;
  margin-left: 6px;
  padding: 0 4px;
}

/* ============================================================
   SCORING GAUGE — Đồng hồ điểm tổng hợp
   ============================================================ */

/**
 * @nhom        : Scoring Styles
 * @chucnang    : Gauge chart, grade badge, section score bars
 */

.scoring-section {
  margin-bottom: 20px;
}

.scoring-header {
  display: flex;
  align-items: center;
  gap: 20px;
  padding: 20px;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  margin-bottom: 16px;
  min-width: 0;
}

.gauge-wrap {
  position: relative;
  width: 160px;
  height: 160px;
  flex-shrink: 0;
}

.gauge-svg {
  width: 100%;
  height: 100%;
  transform: rotate(-90deg);
}

.gauge-bg {
  fill: none;
  stroke: #E5E7EB;
  stroke-width: 12;
}

.gauge-fill {
  fill: none;
  stroke-width: 12;
  stroke-linecap: round;
  transition: stroke-dashoffset 1.5s ease;
}

.gauge-center {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
}

.gauge-score {
  font-size: 32px;
  font-weight: 900;
  line-height: 1;
}

.gauge-label {
  font-size: 10px;
  color: var(--muted);
  font-weight: 600;
  margin-top: 2px;
}

.grade-info {
  flex: 1;
  min-width: 0;
}

.grade-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 16px;
  border-radius: 20px;
  font-size: 18px;
  font-weight: 900;
  color: #fff;
  margin-bottom: 8px;
}

.grade-text {
  font-size: 14px;
  font-weight: 700;
  color: var(--text);
  margin-bottom: 8px;
}

.scoring-bars {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 8px;
}

.score-bar-item {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  padding: 10px 12px;
}

.score-bar-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 6px;
  font-size: 11px;
  font-weight: 700;
  gap: 8px;
}

.score-bar-header .sec-label {
  color: var(--text);
  min-width: 0;
  overflow-wrap: anywhere;
}

.score-bar-header .sec-pct {
  font-weight: 800;
}

.score-bar-track {
  height: 8px;
  background: #E5E7EB;
  border-radius: 4px;
  overflow: hidden;
}

.score-bar-fill {
  height: 100%;
  border-radius: 4px;
  transition: width 1s ease;
}

.score-bar-meta {
  display: flex;
  justify-content: space-between;
  margin-top: 4px;
  font-size: 9px;
  color: var(--muted);
}

/* ============================================================
   PRIORITY MATRIX — Ma trận ưu tiên
   ============================================================ */

.priority-section {
  margin-bottom: 20px;
}

.priority-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  margin-bottom: 16px;
}

.priority-quadrant {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 10px 12px;
  min-height: 80px;
}

.priority-quadrant.critical {
  border-color: #FECACA;
  background: #FEF2F2;
}

.priority-quadrant.important {
  border-color: #FDE68A;
  background: #FFFBEB;
}

.priority-quadrant.urgent {
  border-color: #BFDBFE;
  background: #EFF6FF;
}

.priority-quadrant.monitor {
  border-color: #D1FAE5;
  background: #ECFDF5;
}

.pq-title {
  font-size: 11px;
  font-weight: 800;
  text-transform: uppercase;
  margin-bottom: 6px;
}

.pq-title.critical { color: #DC2626; }
.pq-title.important { color: #D97706; }
.pq-title.urgent { color: #2563EB; }
.pq-title.monitor { color: #059669; }

.pq-item {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 11px;
  padding: 3px 0;
  color: var(--text);
  min-width: 0;
}

.pq-item .stt {
  font-weight: 800;
  color: var(--blue);
  min-width: 28px;
}

.priority-table {
  width: 100%;
  border-collapse: separate;
  border-spacing: 0;
  font-size: 11px;
  table-layout: auto;
}

.priority-table th {
  background: #F3F4F6;
  padding: 8px 10px;
  text-align: left;
  font-weight: 700;
  font-size: 9px;
  text-transform: uppercase;
  color: var(--muted);
  border-bottom: 2px solid var(--line);
}

.priority-table td {
  padding: 8px 10px;
  border-bottom: 1px solid var(--line);
  color: var(--text);
  overflow-wrap: anywhere;
}

.priority-table tr:hover td {
  background: #F9FAFB;
}

.urgency-bar {
  display: inline-block;
  height: 6px;
  border-radius: 3px;
  min-width: 20px;
}

/* ============================================================
   AI REPORT — Preview báo cáo
   ============================================================ */

.report-section {
  margin-bottom: 20px;
}

.report-controls {
  display: flex;
  gap: 8px;
  margin-bottom: 12px;
  flex-wrap: wrap;
  align-items: center;
}

.report-type-btn {
  padding: 6px 14px;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: var(--card);
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  transition: all .15s;
}

.report-type-btn:hover {
  border-color: var(--blue);
  color: var(--blue);
}

.report-type-btn.active {
  background: var(--blue);
  color: #fff;
  border-color: var(--blue);
}

.report-preview {
  background: #fff;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 24px 28px;
  max-height: 600px;
  overflow-y: auto;
  font-size: 13px;
  line-height: 1.7;
  color: var(--text);
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

.report-preview h2 {
  font-size: 16px;
  color: var(--text);
  margin: 16px 0 8px;
  border-bottom: 1px solid var(--line);
  padding-bottom: 4px;
}

.report-preview h3 {
  font-size: 14px;
  color: var(--blue);
  margin: 12px 0 6px;
}

.report-preview ul, .report-preview ol {
  padding-left: 20px;
}

.report-preview strong {
  color: var(--text);
}

.report-toolbar {
  display: flex;
  gap: 6px;
  margin-top: 10px;
  justify-content: flex-end;
}

.report-loading {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 40px;
  color: var(--muted);
  font-size: 13px;
}

.report-loading .spinner {
  width: 36px;
  height: 36px;
  border: 3px solid #E5E7EB;
  border-top: 3px solid var(--blue);
  border-radius: 50%;
  animation: spin 1s linear infinite;
  margin-bottom: 12px;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

@media (max-width: 768px) {
  .scoring-header { flex-direction: column; text-align: center; }
  .priority-grid { grid-template-columns: 1fr; }
  .scoring-bars { grid-template-columns: 1fr; }
}

/* ============================================================
   PRINT MODE (Chế độ in ấn cho hành chính nhà nước)
   ============================================================ */
@media print {
  .sidebar, .sidebar-toggle, .filter-bar, .chat-fab, .chat-popup, #hdrActions, .noti-panel, .noti-bell, .tab-row {
    display: none !important;
  }
  .main-content {
    margin-left: 0 !important;
    padding: 0 !important;
    max-width: 100% !important;
  }
  body {
    background: #fff !important;
    color: #000 !important;
  }
  .page {
    padding: 0 !important;
  }
  .hdr {
    box-shadow: none !important;
    border: none !important;
    background: none !important;
    color: #000 !important;
    padding: 0 0 20px 0 !important;
  }
  .hdr-l {
    color: #000 !important;
  }
  .hdr-l div[style*="color: #fff"] {
    color: #000 !important;
  }
  .hdr-l hr {
    border-top: 1px solid #000 !important;
  }
  .hdr-l h1, .hdr-l p {
    color: #000 !important;
  }
  .hdr-l h1 span {
    color: #333 !important;
  }
  .stat-box, .chart-card, .sum-card, .panel, .metric-card {
    border: 1px solid #000 !important;
    box-shadow: none !important;
    background: #fff !important;
  }
  th {
    background: #f1f1f1 !important;
    color: #000 !important;
  }
  th, td {
    border: 1px solid #000 !important;
  }
}
