:root {
  --primary: #1b4d89;
  --primary-dark: #123a68;
  --sidebar-w: 250px;
}
/* Global font-size scale-down - every page/component built with Bootstrap's
   rem units (buttons, tables, forms, modals, badges, ...) shrinks with it,
   so this one change covers the whole app instead of editing page-by-page. */
html {
  font-size: 15px;
}
body {
  font-family: 'Noto Sans Lao', 'Phetsarath OT', Tahoma, sans-serif;
  background: #f4f6fa;
}
.app-wrapper { display: flex; min-height: 100vh; }
.sidebar {
  width: var(--sidebar-w);
  background: linear-gradient(180deg, var(--primary), var(--primary-dark));
  color: #fff;
  position: fixed;
  top: 0; bottom: 0; left: 0;
  overflow-y: auto;
  z-index: 1000;
}
.sidebar-brand {
  padding: 20px 18px;
  font-size: 1.25rem;
  font-weight: 700;
  border-bottom: 1px solid rgba(255,255,255,0.15);
}
.sidebar-brand i { margin-right: 8px; }
.menu-section {
  padding: 14px 18px 6px;
  margin-top: 6px;
  font-size: 0.72rem;
  letter-spacing: .05em;
  text-transform: uppercase;
  color: rgba(255,255,255,0.55);
  border-top: 1px solid rgba(255,255,255,0.1);
}
.sidebar-menu > .menu-section:first-child { margin-top: 0; border-top: none; }
.menu-subsection {
  padding: 8px 18px 4px 34px;
  margin-top: 2px;
  font-size: 0.68rem;
  letter-spacing: .03em;
  color: rgba(255,255,255,0.42);
  position: relative;
}
.menu-subsection::before {
  content: '';
  position: absolute;
  left: 20px;
  top: 50%;
  width: 8px;
  height: 1px;
  background: rgba(255,255,255,0.3);
}
.sidebar-menu a {
  display: block;
  padding: 10px 18px;
  color: rgba(255,255,255,0.9);
  text-decoration: none;
  font-size: 0.92rem;
  border-left: 3px solid transparent;
}
.sidebar-menu a i { width: 22px; display: inline-block; }
.sidebar-menu a:hover, .sidebar-menu a.active {
  background: rgba(255,255,255,0.12);
  border-left-color: #ffc107;
}
.sidebar-menu a.menu-sublink {
  padding-left: 46px;
  font-size: 0.85rem;
  color: rgba(255,255,255,0.7);
}
.sidebar-menu a.menu-parent {
  display: flex;
  align-items: center;
  cursor: pointer;
}
.sidebar-menu a.menu-parent .menu-caret {
  width: auto;
  margin-left: auto;
  font-size: 0.7rem;
  transition: transform 0.2s ease;
}
.sidebar-menu a.menu-parent[aria-expanded="true"] .menu-caret {
  transform: rotate(180deg);
}
.main-area { margin-left: var(--sidebar-w); flex: 1; display: flex; flex-direction: column; min-height: 100vh; }
.topbar {
  height: 60px;
  background: #fff;
  display: flex;
  align-items: center;
  padding: 0 20px;
  box-shadow: 0 1px 4px rgba(0,0,0,0.08);
  position: sticky;
  top: 0;
  z-index: 900;
}
.topbar-icon { font-size: 1.25rem; color: #555; text-decoration: none; padding: 6px; }
.lang-switcher .fi { border-radius: 2px; box-shadow: 0 0 0 1px rgba(0,0,0,.1); vertical-align: middle; }
.topbar-greeting { line-height: 1.3; }
.topbar-greeting .tg-text { font-weight: 700; font-size: 1.35rem; color: #333; white-space: nowrap; }
.topbar-greeting .tg-datetime { font-size: 1.35rem; font-weight: 700; color: #1b4d89; margin-left: 16px; white-space: nowrap; }
@media (max-width: 767.98px) {
  .topbar-greeting .tg-text { font-size: 1rem; }
  .topbar-greeting .tg-datetime { font-size: 1rem; margin-left: 10px; }
}
@media (max-width: 575.98px) {
  .topbar-greeting .tg-text { display: none; }
  .topbar-greeting .tg-datetime { margin-left: 0; font-size: 0.95rem; }
}
.notif-badge { position: absolute; top: 0; right: 0; font-size: 0.6rem; }
.user-chip { color: #333; }
.content-area { padding: 24px; flex: 1; }
.card { border: none; border-radius: 14px; box-shadow: 0 2px 10px rgba(20,40,80,0.06); }
.card-header { border-bottom: 1px solid #f0f2f6; padding: 13px 18px; border-radius: 14px 14px 0 0 !important; }
.card-header.bg-white { background: #fff !important; }
.card-header.fw-bold i { color: var(--primary); margin-right: 2px; }

.kpi-card {
  border-radius: 14px;
  color: #fff;
  padding: 20px 22px;
  position: relative;
  overflow: hidden;
  isolation: isolate;
  transition: transform 0.18s ease, box-shadow 0.18s ease;
  box-shadow: 0 6px 16px rgba(20,30,60,0.12);
}
.kpi-card:hover { transform: translateY(-3px); box-shadow: 0 14px 30px rgba(20,30,60,0.2); }
.kpi-card small {
  position: relative;
  z-index: 1;
  display: block;
  opacity: .9;
  font-weight: 600;
  letter-spacing: .02em;
  text-transform: uppercase;
  font-size: .72rem;
}
.kpi-card h3 { position: relative; z-index: 1; font-size: 2.15rem; margin: 6px 0 0; font-weight: 700; }
.kpi-card > i {
  position: absolute;
  right: 12px;
  bottom: 4px;
  font-size: 3.4rem;
  opacity: 0.16;
  z-index: 0;
  transform: rotate(-8deg);
}
.bg-kpi-1 { background: linear-gradient(135deg,#1b4d89,#2f6fbb); }
.bg-kpi-2 { background: linear-gradient(135deg,#c0392b,#e74c3c); }
.bg-kpi-3 { background: linear-gradient(135deg,#e67e22,#f39c12); }
.bg-kpi-4 { background: linear-gradient(135deg,#27ae60,#2ecc71); }
.bg-kpi-5 { background: linear-gradient(135deg,#0f766e,#14b8a6); }
.bg-kpi-6 { background: linear-gradient(135deg,#7c2d12,#c2410c); }
.bg-kpi-7 { background: linear-gradient(135deg,#6d28d9,#9333ea); }
.bg-kpi-8 { background: linear-gradient(135deg,#374151,#6b7280); }
.bg-kpi-9 { background: linear-gradient(135deg,#0e7490,#06b6d4); }
.bg-kpi-10 { background: linear-gradient(135deg,#b45309,#d97706); }

.list-group-item { border-color: #f2f4f8; padding: 12px 18px; transition: background .15s ease; }
.list-group-item-action:hover { background: #f7f9fc; }
.list-group-flush > .list-group-item:last-child { border-bottom-left-radius: 14px; border-bottom-right-radius: 14px; }
.badge { border-radius: 6px; font-weight: 600; padding: 5px 9px; letter-spacing: .01em; }
.table thead th { background: #eef2f8; font-size: 0.85rem; }
.login-wrapper {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(135deg, var(--primary), #274472);
}
.login-card { width: 100%; max-width: 400px; border: none; border-radius: 16px; box-shadow: 0 20px 60px rgba(10,30,60,0.25); }
.signature-canvas { border: 1px dashed #999; background: #fff; touch-action: none; cursor: crosshair; }

/* Split-screen login page (auth/login.php) */
.login-split {
  min-height: 100vh;
  display: flex;
  background: #eef1f6;
}
.login-split-left {
  flex: 1 1 55%;
  position: relative;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: 60px 70px;
  background:
    radial-gradient(560px circle at 15% 12%, rgba(255,255,255,0.10), transparent 60%),
    linear-gradient(150deg, #1e5799 0%, var(--primary) 45%, #0f2745 100%);
  color: #fff;
}
.login-split-left::before {
  content: "";
  position: absolute;
  inset: 0;
  background-image:
    linear-gradient(rgba(255,255,255,0.045) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255,255,255,0.045) 1px, transparent 1px);
  background-size: 34px 34px;
  mask-image: radial-gradient(circle at 50% 40%, #000 0%, transparent 75%);
  pointer-events: none;
}
.login-brand-mark {
  width: 168px;
  height: 168px;
  border-radius: 32px;
  background: rgba(255,255,255,0.12);
  border: 1px solid rgba(255,255,255,0.22);
  backdrop-filter: blur(6px);
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  font-size: 2.4rem;
  margin: 0 auto 30px;
  position: relative;
  z-index: 1;
  box-shadow: 0 10px 30px rgba(0,0,0,0.25);
}
.login-brand-mark.has-logo { background: transparent; border-color: transparent; box-shadow: none; backdrop-filter: none; }
.login-split-title {
  font-size: 2.15rem;
  font-weight: 700;
  line-height: 1.35;
  letter-spacing: -0.01em;
  margin-bottom: 14px;
  position: relative;
  z-index: 1;
  text-shadow: 0 2px 18px rgba(0,0,0,0.2);
}
.login-split-subtitle {
  color: rgba(255,255,255,0.72);
  font-size: 0.98rem;
  margin-bottom: 40px;
  position: relative;
  z-index: 1;
}
.login-feature-list {
  list-style: none;
  padding: 0;
  margin: 0;
  position: relative;
  z-index: 1;
  text-align: left;
}
.login-feature-list li {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 12px 6px;
  font-size: 0.94rem;
  color: rgba(255,255,255,0.92);
  border-radius: 10px;
  transition: background 0.2s ease;
}
.login-feature-list li:hover { background: rgba(255,255,255,0.06); }
.login-feature-list li i {
  flex-shrink: 0;
  width: 36px;
  height: 36px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 10px;
  background: rgba(255,193,7,0.16);
  color: #ffc107;
  font-size: 1.05rem;
}
.login-split-deco {
  position: absolute;
  border-radius: 50%;
  background: rgba(255,255,255,0.06);
  pointer-events: none;
}
.login-split-deco.deco-1 { width: 340px; height: 340px; top: -130px; right: -130px; }
.login-split-deco.deco-2 { width: 240px; height: 240px; bottom: -110px; right: 50px; background: rgba(255,193,7,0.09); }
.login-split-right {
  flex: 1 1 45%;
  display: flex;
  align-items: center;
  justify-content: center;
  background:
    radial-gradient(900px circle at 85% 15%, rgba(27,77,137,0.05), transparent 55%),
    #fbfcfe;
  padding: 40px 24px;
}
.login-form-wrap {
  width: 100%;
  max-width: 400px;
  background: #fff;
  border-radius: 20px;
  padding: 44px 40px;
  box-shadow: 0 4px 24px rgba(20,40,80,0.06), 0 1px 3px rgba(20,40,80,0.04);
  border: 1px solid #eef1f6;
  animation: login-card-in 0.45s ease both;
}
@keyframes login-card-in {
  from { opacity: 0; transform: translateY(10px); }
  to { opacity: 1; transform: translateY(0); }
}
.input-icon-group { position: relative; }
.input-icon-group i {
  position: absolute;
  left: 14px;
  top: 50%;
  transform: translateY(-50%);
  color: #9aa3b2;
  font-size: 0.95rem;
  transition: color 0.2s ease;
}
.input-icon-group .form-control {
  padding-left: 40px;
  border-radius: 10px;
  padding-top: 11px;
  padding-bottom: 11px;
  border-color: #e3e7ee;
  background: #fbfcfe;
  transition: border-color 0.2s ease, box-shadow 0.2s ease, background 0.2s ease;
}
.input-icon-group .form-control:focus {
  border-color: var(--primary);
  background: #fff;
  box-shadow: 0 0 0 4px rgba(27,77,137,0.1);
}
.input-icon-group .form-control:focus ~ i,
.input-icon-group:focus-within i { color: var(--primary); }
.login-submit-btn {
  border-radius: 10px;
  padding: 11px;
  font-weight: 600;
  border: none;
  background: linear-gradient(135deg, var(--primary), var(--primary-dark));
  box-shadow: 0 8px 20px rgba(27,77,137,0.28);
  transition: transform 0.15s ease, box-shadow 0.15s ease, filter 0.15s ease;
}
.login-submit-btn:hover, .login-submit-btn:focus {
  transform: translateY(-1px);
  box-shadow: 0 10px 26px rgba(27,77,137,0.35);
  filter: brightness(1.05);
}
.login-submit-btn:active { transform: translateY(0); }
.login-demo-hint {
  margin-top: 28px;
  padding: 10px 14px;
  border-radius: 10px;
  background: #f4f6fa;
  border: 1px dashed #dde3ec;
  color: #666;
  font-size: 0.82rem;
  text-align: center;
}
.login-demo-hint code { color: var(--primary); font-weight: 600; }

.lang-switcher-corner .topbar-icon {
  background: rgba(255,255,255,0.9);
  border: 1px solid #e6e9f0;
  border-radius: 999px;
  padding: 6px 12px;
  box-shadow: 0 4px 14px rgba(20,40,80,0.08);
  backdrop-filter: blur(6px);
}
.lang-switcher-corner .topbar-icon:hover { background: #fff; }

@media (max-width: 991.98px) {
  .login-split-left { display: none; }
  .login-split-right { flex: 1 1 100%; }
  .login-form-wrap { box-shadow: 0 10px 34px rgba(20,40,80,0.10); }
}
/* Document tracking timeline (documents/show.php, documents/track.php) */
.doc-timeline { position: relative; padding: 4px 2px; }
.dtl-node {
  position: relative;
  display: flex;
  align-items: flex-start;
  padding-left: 60px;
  padding-bottom: 26px;
}
.dtl-node:last-child { padding-bottom: 0; }
.dtl-node:not(:last-child)::before {
  content: '';
  position: absolute;
  left: 21px;
  top: 44px;
  bottom: -26px;
  width: 3px;
  border-radius: 3px;
  background: #0d9488;
  z-index: 0;
}
.dtl-dot {
  position: absolute;
  left: 0;
  top: 0;
  width: 44px;
  height: 44px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  font-size: 1.15rem;
  box-shadow: 0 0 0 4px #fff, 0 2px 8px rgba(0,0,0,0.15);
  z-index: 1;
  transition: transform 0.15s ease;
}
.dtl-dot.dtl-done { background: #14b8a6; }
.dtl-dot.dtl-done-green { background: #22a866; }
.dtl-dot.dtl-pending { background: #ef4444; }
.dtl-dot.dtl-rejected { background: #8a94a0; }
.dtl-node:hover .dtl-dot { transform: scale(1.06); }
.dtl-content {
  flex: 1;
  min-width: 0;
  padding: 6px 12px;
  margin-top: -4px;
  border-radius: 10px;
  transition: background-color 0.15s ease;
}
.dtl-node:hover .dtl-content { background: #f7f9fb; }
.dtl-title { font-weight: 700; font-size: 0.88rem; color: #1f2937; letter-spacing: .01em; }
.dtl-sub { font-size: 0.85rem; color: #0d6efd; font-weight: 500; margin-top: 1px; }

/* ຜູ້ຕິດຕາມ (followers) - ຍ້ອຍລົງໃນ node "ສ້າງເອກະສານ", ມີເສັ້ນສີເຫຼືອງແຍກຕ່າງຫາກ
   ຂອງມັນເອງ ບໍ່ໄປປົນກັບເສັ້ນສີຟ້າຫຼັກ (ຜູ້ສົ່ງ/ອະນຸມັດ). */
.dtl-followers {
  position: relative;
  margin: 12px 0 2px;
  padding: 12px 0 4px 16px;
  border-left: 2px solid #fde8a8;
}
.dtlf-node {
  position: relative;
  display: flex;
  align-items: flex-start;
  padding-left: 46px;
  padding-bottom: 20px;
}
.dtlf-node:last-child { padding-bottom: 0; }
.dtlf-node:not(:last-child)::before {
  content: '';
  position: absolute;
  left: 15px;
  top: 36px;
  bottom: -20px;
  width: 3px;
  border-radius: 3px;
  background: #f5b301;
}
.dtlf-dot {
  position: absolute;
  left: 0;
  top: 0;
  width: 34px;
  height: 34px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #6b5300;
  background: #f5b301;
  font-size: 0.9rem;
  box-shadow: 0 0 0 3px #fff, 0 2px 6px rgba(0,0,0,0.12);
  z-index: 1;
  transition: transform 0.15s ease;
}
.dtlf-node:hover .dtlf-dot { transform: scale(1.08); }
.dtl-followers .dtl-title { font-size: 0.8rem; }
.dtl-followers .dtl-sub, .dtl-followers .dtl-date { font-size: 0.76rem; }

/* Full-width, two-sided tracking timeline (documents/show.php, full row below
   the detail/QR cards): main flow (create/approve/pending) text sits to the
   LEFT of a single centered spine, ຜູ້ຕິດຕາມ (followers) sit to the RIGHT. */
.dtl2 { position: relative; padding: 8px 0; }
.dtl2-line {
  position: absolute;
  left: 50%;
  top: 22px;
  bottom: 22px;
  width: 3px;
  margin-left: -1.5px;
  border-radius: 3px;
  background: #0d9488;
  z-index: 0;
}
.dtl2-row {
  position: relative;
  display: grid;
  grid-template-columns: 1fr 60px 1fr;
  align-items: start;
  margin-bottom: 18px;
}
.dtl2-row:last-child { margin-bottom: 0; }
.dtl2-col.dtl2-left { text-align: right; padding-right: 18px; }
.dtl2-col.dtl2-mid { display: flex; justify-content: center; position: relative; z-index: 1; }
.dtl2-col.dtl2-right { padding-left: 18px; }
.dtl2-followers { display: flex; flex-direction: column; }
/* Short connector bridging the creator's dot to the ຜູ້ຕິດຕາມ (followers)
   list on the right, so the follower group visibly branches off of the
   person who created the document. */
.dtl2-connector {
  position: absolute;
  left: 100%;
  top: 20px;
  width: 26px;
  height: 3px;
  border-radius: 3px;
  background: #f5b301;
  z-index: 0;
}
@media (max-width: 767.98px) {
  .dtl2-connector { display: none; }
}
@media (max-width: 767.98px) {
  /* Not enough room for two side columns on phones - collapse to a single
     stacked column (dot fixed on the left, both text blocks below it) so
     nothing gets hidden. */
  .dtl2-row { display: flex; flex-direction: column; padding-left: 52px; position: relative; }
  .dtl2-col.dtl2-mid { position: absolute; left: 0; top: 0; z-index: 1; }
  .dtl2-col.dtl2-left { order: 1; text-align: left; padding-right: 0; }
  .dtl2-col.dtl2-right { order: 2; padding-left: 0; margin-top: 8px; }
  .dtl2-line { left: 22px; margin-left: 0; }
}
.dtl-comment {
  font-size: 0.8rem;
  color: #555;
  font-style: italic;
  margin: 4px 0;
  padding: 6px 10px;
  background: #f4f6fa;
  border-left: 3px solid #cbd5e1;
  border-radius: 4px;
}
.dtl-date { font-size: 0.76rem; color: #8a94a0; line-height: 1.5; margin-top: 2px; }
.dtl-date i { margin-right: 3px; }

/* Notification dropdown (topbar bell) */
.notif-dropdown {
  width: 360px;
  max-width: 90vw;
  border: none;
  border-radius: 14px;
  box-shadow: 0 10px 30px rgba(20,30,60,0.16);
  overflow: hidden;
}
.notif-dropdown-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 16px;
  border-bottom: 1px solid #eef1f6;
  background: #fff;
}
.notif-mark-all { color: var(--primary); text-decoration: none; font-weight: 500; }
.notif-mark-all:hover { text-decoration: underline; }
.notif-dropdown-list { max-height: 360px; overflow-y: auto; background: #fff; }
.notif-item-form { margin: 0; }
.notif-item-wrap { position: relative; }
.notif-item-wrap:hover .notif-clear-btn { opacity: 1; pointer-events: auto; }
.notif-clear-btn {
  position: absolute;
  top: 10px;
  right: 10px;
  width: 22px;
  height: 22px;
  border: none;
  border-radius: 50%;
  background: #eef1f6;
  color: #888;
  font-size: 0.7rem;
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  pointer-events: none;
  transition: opacity .15s ease, background .15s ease, color .15s ease;
  z-index: 2;
}
.notif-clear-btn:hover { background: #dc3545; color: #fff; }
.notif-item {
  width: 100%;
  display: flex;
  align-items: flex-start;
  gap: 12px;
  padding: 12px 40px 12px 16px;
  border: none;
  background: none;
  text-align: left;
  cursor: pointer;
  position: relative;
  border-bottom: 1px solid #f4f6fa;
  transition: background .15s ease;
}
.notif-item:hover { background: #f6f8fc; }
.notif-item.notif-unread { background: #f2f7ff; }
.notif-item.notif-unread:hover { background: #e9f1ff; }
.notif-icon {
  flex: 0 0 auto;
  width: 38px;
  height: 38px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1rem;
}
.notif-body { flex: 1 1 auto; min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.notif-title { font-size: 0.88rem; font-weight: 600; color: #222; }
.notif-message {
  font-size: 0.8rem;
  color: #666;
  overflow: hidden;
  text-overflow: ellipsis;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
}
.notif-time { font-size: 0.72rem; color: #9aa3b2; }
.notif-dot {
  flex: 0 0 auto;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #0d6efd;
  margin-top: 6px;
}
.notif-empty { text-align: center; padding: 40px 16px; color: #bbb; }
.notif-empty i { font-size: 2rem; }
.notif-dropdown-footer {
  display: block;
  text-align: center;
  padding: 10px;
  font-size: 0.85rem;
  font-weight: 500;
  color: var(--primary);
  text-decoration: none;
  background: #fff;
  border-top: 1px solid #eef1f6;
}
.notif-dropdown-footer:hover { background: #f6f8fc; color: var(--primary-dark); }
.notif-page-card { border-radius: 12px; overflow: hidden; }
.notif-page-item {
  display: flex;
  align-items: flex-start;
  gap: 14px;
  padding: 16px 18px;
}
.notif-page-item.notif-unread { background: #f2f7ff; }
.notif-page-item .notif-title { font-weight: 600; color: #222; }
.notif-page-item .notif-message { font-size: 0.88rem; color: #555; margin-top: 2px; }
.notif-page-item .notif-time { font-size: 0.78rem; color: #9aa3b2; margin-top: 4px; }
.notif-badge { animation: notifPulse 1.8s ease-in-out infinite; }
@keyframes notifPulse {
  0%, 100% { transform: scale(1); }
  50% { transform: scale(1.15); }
}

@media (max-width: 992px) {
  .sidebar { transform: translateX(-100%); transition: transform .2s; }
  .sidebar.show { transform: translateX(0); }
  .main-area { margin-left: 0; }
}
