:root {
  --app-bg: #f6f8fb;
  --app-surface: #ffffff;
  --app-line: #dbe3ee;
  --app-text: #1f2a37;
  --app-muted: #667085;
  --app-primary: #0f766e;
  --app-primary-dark: #0b5f59;
  --app-warning: #b45309;
  --app-danger: #b42318;
  --app-info: #245b89;
}

html {
  font-size: 15px;
}

body {
  min-height: 100vh;
  margin: 0;
  color: var(--app-text);
  background: var(--app-bg);
  font-family: "Segoe UI", Arial, sans-serif;
}

a {
  color: var(--app-primary-dark);
}

.app-header {
  background: var(--app-surface);
  border-bottom: 1px solid var(--app-line);
}

.navbar {
  min-height: 64px;
  padding: 0 24px;
}

.navbar-brand {
  color: var(--app-text);
  font-weight: 700;
}

.nav-link {
  color: var(--app-muted);
  font-weight: 600;
}

.nav-link:hover,
.nav-link:focus {
  color: var(--app-primary);
}

.app-shell {
  max-width: 1440px;
  margin: 0 auto;
  padding: 24px;
}

.page-title {
  display: flex;
  gap: 16px;
  align-items: flex-start;
  justify-content: space-between;
  margin-bottom: 20px;
}

.page-title h1 {
  margin: 0;
  font-size: 1.55rem;
  font-weight: 750;
}

.page-title p {
  max-width: 820px;
  margin: 6px 0 0;
  color: var(--app-muted);
}

.toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  align-items: center;
  margin-bottom: 16px;
}

.metric-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 14px;
  margin-bottom: 20px;
}

.metric {
  min-height: 116px;
  padding: 18px;
  background: var(--app-surface);
  border: 1px solid var(--app-line);
  border-radius: 8px;
}

.metric span {
  display: block;
  color: var(--app-muted);
  font-size: .9rem;
}

.metric strong {
  display: block;
  margin-top: 8px;
  font-size: 1.6rem;
  line-height: 1.1;
}

.content-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.25fr) minmax(340px, .75fr);
  gap: 16px;
}

.panel {
  margin-bottom: 16px;
  background: var(--app-surface);
  border: 1px solid var(--app-line);
  border-radius: 8px;
}

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

.panel-header h2 {
  margin: 0;
  font-size: 1rem;
  font-weight: 750;
}

.panel-body {
  padding: 16px;
}

.table {
  margin-bottom: 0;
  vertical-align: middle;
}

.table th {
  color: var(--app-muted);
  font-size: .82rem;
  font-weight: 750;
  text-transform: uppercase;
}

.status {
  display: inline-flex;
  min-width: 108px;
  justify-content: center;
  padding: 5px 8px;
  border-radius: 999px;
  font-size: .82rem;
  font-weight: 700;
  background: #eef2f7;
  color: #344054;
}

.status-new,
.status-draft {
  background: #e8f2ff;
  color: var(--app-info);
}

.status-progress,
.status-checking,
.status-disbursing {
  background: #fff4e5;
  color: var(--app-warning);
}

.status-approved,
.status-allocated {
  background: #e9f7ef;
  color: var(--app-primary-dark);
}

.status-completed,
.status-settled {
  background: #ecfdf3;
  color: #027a48;
}

.status-returned {
  background: #fee4e2;
  color: var(--app-danger);
}

.btn-primary {
  background: var(--app-primary);
  border-color: var(--app-primary);
}

.btn-primary:hover,
.btn-primary:focus {
  background: var(--app-primary-dark);
  border-color: var(--app-primary-dark);
}

.form-label {
  color: #344054;
  font-weight: 650;
}

.form-control,
.form-select {
  border-color: #cbd5e1;
  border-radius: 6px;
}

.form-control:focus,
.form-select:focus {
  border-color: var(--app-primary);
  box-shadow: 0 0 0 .2rem rgba(15, 118, 110, .14);
}

.timeline {
  display: grid;
  gap: 10px;
  padding: 0;
  margin: 0;
  list-style: none;
}

.timeline li {
  padding: 12px;
  background: #f8fafc;
  border: 1px solid var(--app-line);
  border-radius: 8px;
}

.timeline strong {
  display: block;
  margin-bottom: 4px;
}

.note {
  color: var(--app-muted);
  font-size: .92rem;
}

.money {
  white-space: nowrap;
  font-variant-numeric: tabular-nums;
}

.login-container {
  display: flex;
  justify-content: center;
  padding-top: 40px;
}

.login-form {
  width: 100%;
  max-width: 400px;
  padding: 32px;
  background: var(--app-surface);
  border: 1px solid var(--app-line);
  border-radius: 8px;
}

.login-hint ul {
  padding-left: 1.2rem;
  margin-bottom: 0;
}

.dept-badge {
  display: inline-block;
  padding: 2px 8px;
  font-size: .75rem;
  font-weight: 700;
  border-radius: 4px;
  background: var(--app-primary);
  color: #fff;
  max-width: 140px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.dept-section {
  margin-bottom: 12px;
}

.dept-section h3 {
  font-size: .85rem;
  font-weight: 700;
  text-transform: uppercase;
  color: var(--app-muted);
  margin: 0 0 8px;
  padding-bottom: 6px;
  border-bottom: 1px solid var(--app-line);
}

.dept-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 14px;
  margin-bottom: 20px;
}

.dept-card {
  padding: 16px;
  background: var(--app-surface);
  border: 1px solid var(--app-line);
  border-radius: 8px;
}

.dept-card h4 {
  font-size: .95rem;
  font-weight: 700;
  margin: 0 0 4px;
}

.dept-card p {
  font-size: .85rem;
  color: var(--app-muted);
  margin: 0 0 10px;
}

.dept-card .badge-list {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.dept-card .badge-list span {
  display: inline-block;
  padding: 2px 8px;
  font-size: .75rem;
  border-radius: 4px;
  background: #eef2f7;
  color: #344054;
}

/* ─── Sidebar Layout ─────────────────────────── */
.app-layout {
  display: flex;
  min-height: 100vh;
}

.sidebar {
  position: fixed;
  top: 0;
  left: 0;
  z-index: 1040;
  width: 280px;
  height: 100vh;
  display: flex;
  flex-direction: column;
  background: #fff;
  border-right: 1px solid var(--app-line);
  transition: width .2s ease, transform .2s ease;
  overflow: hidden;
}

.sidebar.collapsed {
  width: 64px;
}

.sidebar-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 60px;
  padding: 0 16px;
  border-bottom: 1px solid var(--app-line);
  flex-shrink: 0;
}

.sidebar-brand {
  display: flex;
  align-items: center;
  gap: 10px;
  text-decoration: none;
  color: var(--app-text);
  font-weight: 750;
  font-size: 1rem;
  white-space: nowrap;
  overflow: hidden;
}

.sidebar-brand:hover {
  color: var(--app-primary);
}

.sidebar-icon {
  flex-shrink: 0;
  width: 32px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 8px;
  background: var(--app-primary);
  color: #fff;
  font-size: 1rem;
}

.sidebar-toggle {
  flex-shrink: 0;
  width: 28px;
  height: 28px;
  display: flex;
  align-items: center;
  justify-content: center;
  border: 1px solid var(--app-line);
  border-radius: 6px;
  background: none;
  color: var(--app-muted);
  cursor: pointer;
  transition: all .15s;
}

.sidebar-toggle:hover {
  background: var(--app-bg);
  color: var(--app-text);
}

.sidebar-nav {
  flex: 1;
  overflow-y: auto;
  overflow-x: hidden;
  padding: 12px 0;
}

.sidebar-nav ul {
  list-style: none;
  padding: 0;
  margin: 0;
}

.nav-section {
  padding: 8px 16px 4px;
  color: var(--app-muted);
  font-size: .72rem;
  font-weight: 750;
  text-transform: uppercase;
  letter-spacing: .4px;
  white-space: nowrap;
  overflow: hidden;
}

.sidebar.collapsed .nav-section span {
  opacity: 0;
  width: 0;
}

.sidebar-nav li a {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 0;
  padding: 10px 16px;
  margin: 2px 8px;
  border-radius: 8px;
  text-decoration: none;
  color: var(--app-muted);
  font-weight: 600;
  white-space: nowrap;
  transition: all .12s;
}

.sidebar-nav li a:hover {
  background: var(--app-bg);
  color: var(--app-text);
}

.sidebar-nav li.active a {
  background: var(--app-primary);
  color: #fff;
}

.sidebar-nav li a i {
  flex-shrink: 0;
  width: 20px;
  font-size: 1rem;
  text-align: center;
}

.sidebar-text {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  transition: opacity .15s;
}

.sidebar.collapsed .sidebar-text {
  display: none;
}

.sidebar-footer {
  flex-shrink: 0;
  padding: 12px 16px;
  border-top: 1px solid var(--app-line);
}

.sidebar-user {
  display: flex;
  align-items: center;
  gap: 10px;
  overflow: hidden;
}

.sidebar-user-avatar {
  flex-shrink: 0;
  width: 34px;
  height: 34px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  background: var(--app-primary);
  color: #fff;
  font-weight: 700;
  font-size: .85rem;
}

.sidebar-user-info {
  line-height: 1.25;
  overflow: hidden;
}

.sidebar-user-info strong {
  display: block;
  font-size: .85rem;
  color: var(--app-text);
}

.sidebar-user-info small {
  font-size: .75rem;
  color: var(--app-muted);
}
.sidebar-user-role {
  font-size: .7rem;
  opacity: .8;
  display: flex;
  align-items: center;
  gap: 3px;
  margin-top: 1px;
}
.sidebar-user-role::before {
  content: "";
  display: inline-block;
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--app-primary);
  flex-shrink: 0;
}

.sidebar-logout {
  position: absolute;
  bottom: 16px;
  right: 16px;
  width: 34px;
  height: 34px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 8px;
  color: var(--app-muted);
  text-decoration: none;
  transition: all .12s;
}

.sidebar-logout:hover {
  background: #fee4e2;
  color: var(--app-danger);
}

.sidebar.collapsed .sidebar-logout {
  right: 15px;
}

.sidebar.collapsed .sidebar-user-info {
  display: none;
}

.sidebar.collapsed .sidebar-footer {
  padding: 12px 15px;
}

/* ─── Main area ──────────────────────────────── */
.main-area {
  flex: 1;
  margin-left: 280px;
  display: flex;
  flex-direction: column;
  min-height: 100vh;
  transition: margin-left .2s ease;
}

.main-area.sidebar-collapsed {
  margin-left: 64px;
}

.main-header {
  display: flex;
  align-items: center;
  gap: 12px;
  height: 60px;
  padding: 0 24px;
  background: #fff;
  border-bottom: 1px solid var(--app-line);
  flex-shrink: 0;
}

.mobile-toggle {
  display: none;
  width: 36px;
  height: 36px;
  align-items: center;
  justify-content: center;
  border: 1px solid var(--app-line);
  border-radius: 6px;
  background: none;
  color: var(--app-muted);
  cursor: pointer;
  font-size: 1.15rem;
}

.mobile-toggle:hover {
  background: var(--app-bg);
}

.main-header-title {
  flex: 1;
}

.main-header-title h5 {
  margin: 0;
  font-weight: 700;
  color: var(--app-text);
}

.main-header-actions {
  display: flex;
  align-items: center;
  gap: 10px;
}

.main-content {
  flex: 1;
  padding: 16px 24px 24px;
  width: 100%;
}

/* ─── Overlay for mobile ─────────────────────── */
.sidebar-overlay {
  display: none;
  position: fixed;
  inset: 0;
  z-index: 1030;
  background: rgba(0,0,0,.35);
}

.sidebar-overlay.show {
  display: block;
}

.no-scroll {
  overflow: hidden;
}

/* ─── Sub-menu (collapsible) ──────────────────── */
.has-submenu > .submenu-toggler {
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 0;
  padding: 10px 16px;
  margin: 2px 8px;
  border-radius: 8px;
  text-decoration: none;
  color: var(--app-muted);
  font-weight: 600;
  white-space: nowrap;
  transition: all .12s;
}

.has-submenu > .submenu-toggler:hover {
  background: var(--app-bg);
  color: var(--app-text);
}

.has-submenu .submenu-arrow {
  flex-shrink: 0;
  margin-left: auto;
  transition: transform .2s ease;
  font-size: .8rem;
}

.has-submenu.expanded > .submenu-toggler .submenu-arrow {
  transform: rotate(180deg);
}

.submenu {
  list-style: none;
  padding: 0;
  margin: 0;
  max-height: 0;
  overflow: hidden;
  transition: max-height .25s ease;
}

.has-submenu.expanded > .submenu {
  max-height: 500px;
}

.submenu li a {
  padding: 8px 16px 8px 48px;
  margin: 1px 8px;
  border-radius: 6px;
  display: flex;
  align-items: center;
  text-decoration: none;
  color: var(--app-muted);
  font-weight: 500;
  font-size: .9rem;
  white-space: nowrap;
  transition: all .12s;
}

.submenu li a:hover {
  background: var(--app-bg);
  color: var(--app-text);
}

.submenu li.active a {
  background: #e8f2ff;
  color: var(--app-primary-dark);
  font-weight: 650;
}

.sidebar-nav ul li.disabled a {
  opacity: .4;
  cursor: default;
  color: var(--app-muted) !important;
}

/* When sidebar is collapsed, hide submenus */
.sidebar.collapsed .submenu {
  max-height: 0 !important;
}

.sidebar.collapsed .submenu-arrow {
  display: none !important;
  width: 0;
  height: 0;
  margin: 0;
  opacity: 0;
}

.sidebar.collapsed .sidebar-header {
  justify-content: center;
  padding: 0 10px;
}

.sidebar.collapsed .sidebar-brand {
  display: none;
}

.sidebar.collapsed .sidebar-toggle {
  width: 34px;
  height: 34px;
  border-radius: 10px;
  background: #fff;
  box-shadow: 0 1px 4px rgba(15, 23, 42, .08);
}

.sidebar.collapsed .sidebar-nav {
  padding: 14px 8px;
}

.sidebar.collapsed .sidebar-nav > ul > li {
  display: block;
  width: 100%;
}

.sidebar.collapsed .sidebar-nav li a,
.sidebar.collapsed .has-submenu > .submenu-toggler {
  display: flex !important;
  width: 40px;
  height: 40px;
  justify-content: center !important;
  align-items: center !important;
  gap: 0 !important;
  padding: 0 !important;
  margin: 4px auto !important;
  border-radius: 12px;
}

.sidebar.collapsed .sidebar-nav li a i,
.sidebar.collapsed .has-submenu > .submenu-toggler > i:first-child {
  width: 20px;
  height: 20px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 1.08rem;
  line-height: 1;
  margin: 0 !important;
}

.sidebar.collapsed .sidebar-nav li a i::before,
.sidebar.collapsed .has-submenu > .submenu-toggler > i:first-child::before {
  display: block;
  line-height: 1;
}

.sidebar.collapsed .has-submenu > .submenu-toggler .submenu-arrow {
  display: none !important;
}

.sidebar.collapsed .sidebar-nav li.active > a {
  background: #e6f4f1;
  color: var(--app-primary-dark);
  box-shadow: inset 0 0 0 1px rgba(15, 118, 110, .14);
}

.sidebar.collapsed .sidebar-nav li a:hover,
.sidebar.collapsed .has-submenu > .submenu-toggler:hover {
  background: #f1f5f9;
  color: var(--app-primary-dark);
}

.sidebar.collapsed .sidebar-footer {
  display: flex;
  justify-content: center;
  padding: 12px 0;
}

.sidebar.collapsed .sidebar-user {
  justify-content: center;
}

.sidebar.collapsed .sidebar-user-avatar {
  width: 38px;
  height: 38px;
  box-shadow: 0 1px 4px rgba(15, 23, 42, .12);
}

.sidebar.collapsed .sidebar-logout {
  display: none;
}

/* ─── Responsive ─────────────────────────────── */
@media (max-width: 768px) {
  .sidebar {
    transform: translateX(-100%);
    width: 280px;
  }

  .sidebar.show-mobile {
    transform: translateX(0);
  }

  .sidebar.collapsed {
    width: 280px;
  }

  .sidebar.collapsed .sidebar-header {
    justify-content: space-between;
    padding: 0 16px;
  }

  .sidebar.collapsed .sidebar-brand {
    display: flex;
  }

  .sidebar.collapsed .sidebar-nav {
    padding: 12px 0;
  }

  .sidebar.collapsed .sidebar-nav > ul > li {
    display: block;
  }

  .sidebar.collapsed .sidebar-nav li a,
  .sidebar.collapsed .has-submenu > .submenu-toggler {
    width: auto;
    height: auto;
    justify-content: flex-start;
    gap: 12px;
    padding: 10px 16px;
    margin: 2px 8px;
    border-radius: 8px;
  }

  .sidebar.collapsed .sidebar-footer {
    display: block;
    padding: 12px 16px;
  }

  .sidebar.collapsed .sidebar-logout {
    display: flex;
  }

  .sidebar.collapsed .sidebar-text {
    opacity: 1;
    width: auto;
  }

  .sidebar.collapsed .nav-section span {
    opacity: 1;
    width: auto;
  }

  .sidebar.collapsed .sidebar-user-info {
    display: block;
  }

  .main-area {
    margin-left: 0 !important;
  }

  .mobile-toggle {
    display: flex;
  }

  .main-content {
    padding: 16px;
  }
}

@media (max-width: 1100px) {
  .metric-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

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

@media (max-width: 640px) {
  .main-content {
    padding: 12px;
  }

  .page-title {
    display: block;
  }

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

  .table-responsive {
    border: 1px solid var(--app-line);
    border-radius: 8px;
  }
}

/* ─── Metric cards (consistent with .metric) ──── */
.metric-card {
  min-height: 116px;
  padding: 18px;
  background: var(--app-surface);
  border: 1px solid var(--app-line);
  border-radius: 8px;
  display: flex;
  flex-direction: column;
  justify-content: center;
}

.metric-card .metric-value {
  font-size: 1.6rem;
  font-weight: 700;
  line-height: 1.1;
}

.metric-card .metric-label {
  color: var(--app-muted);
  font-size: .9rem;
  margin-top: 8px;
}

/* ─── Panel footer ──────────────────────────── */
.panel-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 16px;
  border-top: 1px solid var(--app-line);
}

.form-panel-narrow {
  max-width: 800px;
}

/* ─── Kanban (HSCV & XuLyTheoDoi) ──────────── */
.kanban-board {
  display: flex;
  gap: 16px;
  overflow-x: auto;
  padding-bottom: 16px;
}

.kanban-column {
  flex: 1;
  min-width: 260px;
  background: #f5f6fa;
  border-radius: 8px;
  display: flex;
  flex-direction: column;
}

.kanban-header {
  padding: 12px 16px;
  border-radius: 8px 8px 0 0;
  display: flex;
  justify-content: space-between;
  align-items: center;
  color: #fff;
}

.kanban-header.status-new { background: #6c757d; }
.kanban-header.status-progress { background: #0d6efd; }
.kanban-header.status-approved { background: #ffc107; color: #333; }
.kanban-header.status-completed { background: #198754; }
.kanban-header.status-purple { background: #6f42c1; }
.kanban-header.status-orange { background: #fd7e14; }

.kanban-header h5 {
  margin: 0;
  font-size: 15px;
  font-weight: 600;
}

.kanban-header .badge {
  background: rgba(255,255,255,0.25);
  font-size: 12px;
}

.kanban-body {
  padding: 12px;
  flex: 1;
  overflow-y: auto;
}

.kanban-empty {
  text-align: center;
  color: #999;
  padding: 24px 0;
  font-style: italic;
}

.card-hscv {
  background: #fff;
  border-radius: 8px;
  padding: 12px;
  margin-bottom: 10px;
  box-shadow: 0 1px 3px rgba(0,0,0,0.1);
}

.card-hscv:hover {
  box-shadow: 0 2px 8px rgba(0,0,0,0.15);
}

.card-hscv .card-title {
  font-weight: 600;
  font-size: 14px;
  margin-bottom: 6px;
}

.card-hscv .card-title a {
  color: #212529;
  text-decoration: none;
}

.card-hscv .card-title a:hover {
  color: #0d6efd;
}

.card-hscv .card-meta {
  font-size: 12px;
  color: #6c757d;
  margin-bottom: 4px;
}

.card-hscv .card-meta i {
  width: 16px;
}

.card-hscv .progress {
  height: 6px;
  margin-bottom: 6px;
}

.card-hscv .card-badges {
  display: flex;
  gap: 4px;
  flex-wrap: wrap;
  margin-bottom: 6px;
}

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

.card-hscv .card-actions form {
  display: inline;
}

.card-hscv .overdue-warning {
  font-size: 11px;
  font-weight: 600;
}

.card-hscv .overdue-warning.text-danger {
  color: #dc3545 !important;
}

.card-hscv .overdue-warning.text-warning {
  color: #fd7e14 !important;
}

.card-overdue {
  border-left: 3px solid #dc3545 !important;
}

.cursor-pointer {
  cursor: pointer;
}
