﻿/* =====================================================================
   ระบบวัสดุคงคลัง — UBU NAVY & GOLD (Glass Dark)
   Dark-glass dashboard with UBU navy + gold brand accents.
   GPU-light: only transform/opacity/box-shadow transitions (no jank).
   ===================================================================== */

:root {
  /* --- surfaces --- */
  --bg:        #070c1c;   /* deep UBU navy */
  --bg-2:      #0c1330;
  --surface:   rgba(255,255,255,.055);
  --surface-2: rgba(255,255,255,.085);
  --surface-3: rgba(255,255,255,.12);
  --border:    rgba(255,255,255,.12);
  --card:      var(--surface);

  /* --- text --- */
  --text:       #eaf0ff;
  --text-soft:  #b9c6e4;
  --text-light: #8392b8;
  --text-faint: #5b6a8e;

  /* --- brand (UBU blue -> royal blue) --- */
  --primary:       #4a79e0;
  --primary-2:     #f7b321;
  --primary-dark:  #20409a;
  --primary-light: rgba(74,121,224,.18);

  /* --- UBU identity (มหาวิทยาลัยอุบลราชธานี) --- */
  --ubu-gold: #f7b321;   /* สีเหลือง/ทองประจำมหาวิทยาลัย */
  --ubu-blue: #20409a;   /* สีน้ำเงินกรมท่า */
  --ubu-navy: #0d1752;

  /* --- semantic --- */
  --success:       #35e0a1;
  --success-light: rgba(53,224,161,.14);
  --danger:        #ff6b81;
  --danger-light:  rgba(255,107,129,.14);
  --warning:       #ffc857;
  --warning-light: rgba(255,200,87,.14);
  --info:          #7aa2ff;
  --info-light:    rgba(122,162,255,.16);

  /* --- UBU accents --- */
  --aurora-indigo: #4a79e0;
  --aurora-cyan:   #f7b321;
  --aurora-rose:   #e0455e;
  --aurora-gold:   #f7b321;

  /* --- effects --- */
  --grad:         linear-gradient(135deg, #2f5bd0 0%, #5b86f0 100%);
  --grad-soft:    linear-gradient(135deg, rgba(74,121,224,.25), rgba(32,64,154,.18));
  --shadow:       0 8px 28px rgba(3,7,18,.45);
  --shadow-lg:    0 22px 60px rgba(3,7,18,.55);
  --glow:         0 0 0 1px rgba(74,121,224,.30), 0 12px 40px rgba(32,64,154,.24);
  --radius:       16px;
  --radius-sm:    10px;

  --sidebar-width: 248px;
  --sidebar-collapsed: 80px;
  --topbar-height: 64px;

  /* --- fonts --- */
  --mono: 'Space Mono', 'Cascadia Code', 'Consolas', 'Courier New', monospace;
  --sans: 'Segoe UI', 'Leelawadee UI', Tahoma, 'Noto Sans Thai', system-ui, sans-serif;
}

* { margin: 0; padding: 0; box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
  font-family: var(--sans);
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
}

/* Aurora background (static, GPU-cheap: renders once) */
body::before {
  content: "";
  position: fixed;
  inset: -20%;
  z-index: -1;
  background:
    radial-gradient(42% 38% at 18% 22%,  rgba(47,91,208,.28), transparent 70%),
    radial-gradient(40% 34% at 82% 18%,  rgba(247,179,33,.10), transparent 70%),
    radial-gradient(46% 40% at 76% 82%,  rgba(32,64,154,.24), transparent 70%),
    radial-gradient(34% 30% at 12% 88%,  rgba(247,179,33,.07), transparent 70%),
    var(--bg);
  pointer-events: none;
}
body::after {
  content: "";
  position: fixed;
  inset: 0;
  z-index: -1;
  background: repeating-linear-gradient(
      to bottom,
      transparent 0,
      transparent 42px,
      rgba(255,255,255,.018) 42px,
      rgba(255,255,255,.018) 43px
  );
  pointer-events: none;
}

::selection { background: rgba(247,179,33,.45); color: #0b1224; }

/* Custom scrollbar */
::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: rgba(255,255,255,.14); border-radius: 8px; }
::-webkit-scrollbar-thumb:hover { background: rgba(255,255,255,.24); }

/* ===== Preloader ===== */
#preloader {
  position: fixed;
  inset: 0;
  background: var(--bg);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 9999;
  transition: opacity .4s;
}
#preloader.hidden { opacity: 0; pointer-events: none; }
.loader-content { text-align: center; }
#preloader .loader-content p {
  font-family: var(--mono);
  letter-spacing: .14em;
  margin-top: 18px;
  font-size: .8rem;
  color: var(--text-soft);
}
.spinner {
  width: 54px; height: 54px;
  margin: 0 auto;
  border-radius: 50%;
  border: 3px solid rgba(255,255,255,.08);
  border-top-color: var(--aurora-indigo);
  border-right-color: var(--aurora-cyan);
  animation: spin 1s linear infinite;
  box-shadow: var(--glow);
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ===== Topbar ===== */
.topbar {
  position: fixed;
  top: 0; left: 0; right: 0;
  height: var(--topbar-height);
  background: rgba(7,12,28,.78);
  backdrop-filter: blur(18px);
  -webkit-backdrop-filter: blur(18px);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  z-index: 100;
}
.topbar::after {
  content: "";
  position: absolute; left: 0; right: 0; bottom: 0; height: 2px;
  background: linear-gradient(90deg, var(--ubu-gold), var(--ubu-blue));
  opacity: .65;
  pointer-events: none;
}
.topbar-inner {
  width: 100%;
  max-width: 1640px;
  margin: 0 auto;
  padding: 0 18px;
  display: flex;
  align-items: center;
  gap: 14px;
}
.hamburger {
  background: none;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  font-size: 1.1rem;
  cursor: pointer;
  padding: 9px 12px;
  border-radius: var(--radius-sm);
  display: none;
  transition: background .15s, transform .1s;
}
.hamburger:hover { background: var(--surface-2); transform: translateY(-1px); }
.brand { display: flex; align-items: center; gap: 12px; flex: 1; min-width: 0; }
.brand-icon {
  width: 42px; height: 42px;
  border-radius: 12px;
  background: #fff;
  display: flex; align-items: center; justify-content: center;
  padding: 5px;
  flex-shrink: 0;
  box-shadow: 0 8px 22px rgba(247,179,33,.30);
}
.brand-logo-img { max-width: 100%; max-height: 100%; object-fit: contain; display: block; }
.brand-text h1 {
  font-size: 1.02rem; font-weight: 600; line-height: 1.2;
  letter-spacing: .01em;
  background: linear-gradient(90deg, #fff, var(--ubu-gold));
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
  color: transparent;
}
.brand-text span {
  font-size: .68rem; color: var(--text-light); display: block;
  font-family: var(--mono); letter-spacing: .02em;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.topbar-actions { display: flex; align-items: center; gap: 10px; }
.icon-btn {
  background: var(--surface);
  border: 1px solid var(--border);
  color: var(--text-soft);
  width: 40px; height: 40px;
  border-radius: 12px;
  cursor: pointer;
  font-size: 1rem;
  position: relative;
  transition: background .15s, color .15s, transform .1s, box-shadow .15s;
}
.icon-btn:hover {
  background: var(--surface-2);
  color: #fff;
  box-shadow: 0 6px 18px rgba(32,64,154,.25);
  transform: translateY(-1px);
}
.notification-btn .badge {
  position: absolute;
  top: -6px; right: -6px;
  background: linear-gradient(135deg, #f7b321, #ffd166);
  color: #1a1200;
  font-family: var(--mono);
  font-size: .68rem; font-weight: 700;
  min-width: 19px; height: 19px;
  border-radius: 10px;
  display: flex; align-items: center; justify-content: center;
  padding: 0 5px;
  box-shadow: 0 4px 10px rgba(247,179,33,.4);
}

/* ===== Notification Panel ===== */
.notif-panel {
  position: fixed;
  top: var(--topbar-height);
  right: 0;
  width: 350px;
  max-width: 100%;
  background: var(--bg-2);
  border: 1px solid var(--border);
  border-top: 0; border-right: 0;
  box-shadow: var(--shadow-lg);
  height: auto;
  max-height: calc(100vh - var(--topbar-height));
  z-index: 150;
  border-radius: 0 0 0 18px;
  transform: translateX(100%);
  transition: transform .28s cubic-bezier(.4,0,.2,1);
  display: flex;
  flex-direction: column;
}
.notif-panel.open { transform: translateX(0); }
.notif-panel-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 16px 18px;
  border-bottom: 1px solid var(--border);
}
.notif-panel-header h3 { font-size: .95rem; font-weight: 600; }
.notif-panel-header .icon-btn { color: var(--text-soft); background: var(--surface); }
.notif-panel-body { overflow-y: auto; padding: 12px; }
.notif-empty { text-align: center; color: var(--text-light); padding: 34px 0; font-size: .86rem; }
.notif-item {
  display: flex; gap: 12px;
  padding: 13px;
  border-radius: 14px;
  margin-bottom: 10px;
  border: 1px solid var(--border);
  background: var(--surface);
  align-items: flex-start;
  transition: border-color .15s, background .15s;
}
.notif-item:hover { border-color: rgba(255,255,255,.22); background: var(--surface-2); }
.notif-item .notif-icon { color: var(--warning); font-size: 1.05rem; margin-top: 2px; }
.notif-item h4 { font-size: .86rem; margin-bottom: 3px; font-weight: 600; }
.notif-item p { font-size: .78rem; color: var(--text-light); line-height: 1.5; }

/* ===== Layout ===== */
.layout { display: flex; padding-top: var(--topbar-height); min-height: 100vh; }

/* ===== Sidebar ===== */
.sidebar {
  width: var(--sidebar-width);
  background: rgba(7,12,28,.78);
  backdrop-filter: blur(18px);
  -webkit-backdrop-filter: blur(18px);
  border-right: 1px solid var(--border);
  position: fixed;
  top: var(--topbar-height);
  bottom: 0;
  left: 0;
  display: flex;
  flex-direction: column;
  transition: transform .28s cubic-bezier(.4,0,.2,1);
  z-index: 90;
}
.sidebar-header {
  display: flex; align-items: center; gap: 12px;
  padding: 16px 16px 14px;
  border-bottom: 1px solid var(--border);
  position: relative;
}
.sidebar-logo {
  width: 40px; height: 40px; flex-shrink: 0;
  background: #fff; border-radius: 11px; padding: 5px;
  display: flex; align-items: center; justify-content: center;
  box-shadow: 0 6px 16px rgba(247,179,33,.26);
}
.sidebar-logo img { max-width: 100%; max-height: 100%; object-fit: contain; display: block; }
.sidebar-header-text { min-width: 0; }
.sidebar-title { display: block; font-size: .84rem; font-weight: 700; color: #fff; line-height: 1.25; }
.sidebar-sub { display: block; font-size: .66rem; color: var(--text-light); line-height: 1.35; margin-top: 2px; }
.sidebar-collapse {
  margin-left: auto;
  width: 28px; height: 28px; flex-shrink: 0;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text-light);
  border-radius: 8px; cursor: pointer; font-size: .72rem;
  display: flex; align-items: center; justify-content: center;
  transition: background .15s, color .15s, transform .15s;
}
.sidebar-collapse:hover { background: var(--surface-2); color: var(--ubu-gold); }
.side-nav { flex: 1; padding: 16px 12px; overflow-y: auto; }
.nav-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 11px 14px;
  color: var(--text-soft);
  text-decoration: none;
  font-size: .88rem;
  font-weight: 500;
  margin-bottom: 4px;
  border-radius: 12px;
  transition: background .15s, color .15s, transform .1s;
}
.nav-item i { width: 20px; text-align: center; color: var(--text-faint); transition: color .15s; }
.nav-item:hover { background: var(--surface); color: #fff; transform: translateX(2px); }
.nav-item:hover i { color: var(--ubu-gold); }
.nav-item.active {
  background: rgba(247,179,33,.12);
  color: #fff;
  box-shadow: inset 0 0 0 1px rgba(247,179,33,.35);
}
.nav-item.active i { color: var(--ubu-gold); }
.side-nav { counter-reset: nav-seq; }
.nav-item { counter-increment: nav-seq; }
.nav-item::before {
  content: counter(nav-seq) ".";
  flex: 0 0 14px;
  text-align: right;
  font-family: var(--mono);
  font-size: .64rem;
  line-height: 1;
  color: var(--text-faint);
  opacity: .85;
}
.nav-item:hover::before { color: var(--ubu-gold); opacity: 1; }
.nav-item.active::before { color: var(--ubu-gold); opacity: 1; font-weight: 700; }
.nav-badge {
  margin-left: auto;
  background: linear-gradient(135deg, #f7b321, #ffd166);
  color: #1a1200;
  font-family: var(--mono);
  font-size: .66rem; font-weight: 700;
  min-width: 18px; height: 18px;
  border-radius: 9px;
  display: inline-flex; align-items: center; justify-content: center;
  padding: 0 5px;
  box-shadow: 0 3px 8px rgba(247,179,33,.35);
  animation: navBadgePulse 1.8s ease-in-out infinite;
}
@keyframes navBadgePulse {
  0%, 100% { transform: scale(1); }
  50% { transform: scale(1.12); }
}
.nav-divider { height: 1px; background: var(--border); margin: 12px 8px; }
.sidebar-footer {
  padding: 14px 16px;
  border-top: 1px solid var(--border);
  background: rgba(20,26,48,.4);
}
.storage-info {
  font-size: .7rem; color: var(--text-light);
  font-family: var(--mono);
  display: flex; align-items: center; gap: 8px; margin-bottom: 6px; word-break: break-all;
}
.storage-info i { color: var(--success); }
.copyright { font-size: .64rem; color: var(--text-faint); font-family: var(--mono); }

.overlay {
  position: fixed; inset: 0;
  background: rgba(5,8,18,.6);
  backdrop-filter: blur(2px);
  -webkit-backdrop-filter: blur(2px);
  z-index: 85;
  display: none;
}
.overlay.show { display: block; }

/* ===== Main Content ===== */
.main-content {
  flex: 1;
  margin-left: var(--sidebar-width);
  padding: 26px;
  min-height: 100vh;
}
.page { display: none; animation: fadeIn .3s cubic-bezier(.4,0,.2,1); }
.page.active { display: block; }
@keyframes fadeIn {
  from { opacity: 0; transform: translateY(10px); }
  to   { opacity: 1; transform: none; }
}

/* ===== Cards & Layout ===== */
.page-title {
  font-size: 1.55rem; font-weight: 700; margin-bottom: 4px;
  letter-spacing: -.01em;
  line-height: 1.15;
}
.page-subtitle {
  color: var(--text-light); font-size: .86rem; margin-bottom: 24px;
  font-family: var(--mono);
}
.card {
  background: linear-gradient(160deg, rgba(255,255,255,.07), rgba(255,255,255,.035));
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 22px;
  margin-bottom: 22px;
  transition: border-color .2s, box-shadow .2s, transform .15s;
}
.card:hover { border-color: rgba(255,255,255,.2); }
.card-title {
  font-size: 1rem; font-weight: 600; margin-bottom: 16px;
  display: flex; align-items: center; gap: 10px;
  color: var(--text);
}
.card-title i {
  color: var(--ubu-gold);
  background: rgba(247,179,33,.14);
  border-radius: 8px;
  width: 28px; height: 28px;
  display: inline-flex; align-items: center; justify-content: center;
  font-size: .82rem;
}

.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(210px, 1fr));
  gap: 16px;
  margin-bottom: 22px;
}
.stat-card {
  background: linear-gradient(160deg, rgba(255,255,255,.07), rgba(255,255,255,.03));
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 18px;
  display: flex; align-items: center; gap: 14px;
  position: relative; overflow: hidden;
  transition: transform .15s, border-color .2s, box-shadow .2s;
}
.stat-card::before {
  content: "";
  position: absolute;
  top: 0; left: 0; right: 0;
  height: 2px;
  background: linear-gradient(90deg, var(--ubu-gold), var(--ubu-blue));
  opacity: 0;
  transition: opacity .25s;
}
.stat-card:hover {
  transform: translateY(-3px);
  border-color: rgba(255,255,255,.24);
  box-shadow: var(--glow);
}
.stat-card:hover::before { opacity: 1; }
.stat-card.clickable-stat { cursor: pointer; }
.stat-link {
  color: var(--primary);
  font-weight: 600;
  display: inline-flex; align-items: center; gap: 5px;
  margin-top: 4px;
  font-size: .78rem;
}
.stat-card:hover .stat-link { text-decoration: underline; }
.stat-icon {
  width: 52px; height: 52px;
  border-radius: 14px;
  display: flex; align-items: center; justify-content: center;
  font-size: 1.3rem;
  flex-shrink: 0;
  box-shadow: var(--shadow);
}
.stat-icon.blue   { background: linear-gradient(135deg, #20409a, #4a79e0); color: #fff; }
.stat-icon.green  { background: linear-gradient(135deg, #1fae86, #35e0a1); color: #04261b; }
.stat-icon.red    { background: linear-gradient(135deg, #e0455e, #ff6b81); color: #fff; }
.stat-icon.orange { background: linear-gradient(135deg, #f7b321, #ffd166); color: #241503; }
.stat-icon.purple { background: linear-gradient(135deg, #2f5bd0, #7aa2ff); color: #fff; }
.stat-info h3 {
  font-size: 1.5rem; font-weight: 700; line-height: 1.05;
  font-family: var(--mono);
  color: #fff;
}
.stat-info p {
  font-size: .76rem; color: var(--text-light);
  font-weight: 500; margin-top: 1px;
}
/* ชื่อประเภทวัสดุ 8 ประเภทบนแดชบอร์ด — ขยายให้เด่นอ่านชัด */
.stat-info p.cat-name {
  font-size: 1rem;
  font-weight: 700;
  color: #fff;
  line-height: 1.25;
  margin-top: 3px;
  letter-spacing: .1px;
}
.stat-info .stat-sub {
  font-size: .72rem; color: var(--success); font-family: var(--mono); font-weight: 700;
}

.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 22px; }
.grid-2-1 { display: grid; grid-template-columns: 2fr 1fr; gap: 22px; }

/* ===== Buttons ===== */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 11px 20px;
  border: 1px solid transparent;
  border-radius: 12px;
  font-family: inherit;
  font-size: .88rem;
  font-weight: 600;
  cursor: pointer;
  transition: transform .12s, box-shadow .2s, background .2s, color .2s, border-color .2s;
  white-space: nowrap;
}
.btn:active { transform: translateY(1px) scale(.98); }
.btn-primary {
  background: var(--grad);
  color: #fff;
  box-shadow: 0 8px 22px rgba(80,130,255,.35);
}
.btn-primary:hover {
  transform: translateY(-2px);
  box-shadow: 0 14px 30px rgba(80,150,255,.45);
}
.btn-success { background: linear-gradient(135deg, #23d8a0, #0fbf8a); color: #04261b; box-shadow: 0 8px 22px rgba(35,216,160,.25); }
.btn-success:hover { transform: translateY(-2px); box-shadow: 0 14px 30px rgba(35,216,160,.35); }
.btn-danger { background: linear-gradient(135deg, #ff6b81, #ff4d6d); color: #fff; box-shadow: 0 8px 22px rgba(255,77,109,.28); }
.btn-danger:hover { transform: translateY(-2px); box-shadow: 0 14px 30px rgba(255,77,109,.38); }
.btn-warning { background: linear-gradient(135deg, #ffc857, #ffb347); color: #241503; box-shadow: 0 8px 22px rgba(255,200,87,.22); }
.btn-warning:hover { transform: translateY(-2px); box-shadow: 0 14px 30px rgba(255,200,87,.32); }
.btn-outline {
  background: var(--surface);
  color: var(--aurora-cyan);
  border-color: var(--border);
}
.btn-outline:hover { background: var(--surface-2); color: #fff; border-color: rgba(119,190,255,.5); transform: translateY(-2px); }
.btn-outline-danger { background: var(--surface); color: var(--danger); border-color: var(--border); }
.btn-outline-danger:hover { background: rgba(255,107,129,.15); border-color: rgba(255,107,129,.5); color: #ff8da0; transform: translateY(-2px); }
.btn-outline-success { background: var(--surface); color: var(--success); border-color: var(--border); }
.btn-outline-success:hover { background: rgba(53,224,161,.15); border-color: rgba(53,224,161,.5); transform: translateY(-2px); }
.btn-sm { padding: 6px 12px; font-size: .78rem; border-radius: 9px; }

/* ===== Pagination + bulk checkbox (control card master list) ===== */
.pagination { display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; gap: 10px; padding: 14px 6px 4px; }
.page-info { font-size: .78rem; color: var(--text-light); }
.page-nav { display: flex; gap: 4px; align-items: center; flex-wrap: wrap; }
.page-btn { min-width: 34px; height: 34px; padding: 0 10px; border: 1px solid var(--border); background: rgba(255,255,255,.03); color: var(--text-light); border-radius: 8px; cursor: pointer; font-size: .8rem; font-family: inherit; transition: all .15s; }
.page-btn:hover:not(:disabled) { border-color: rgba(247,179,33,.55); color: var(--aurora-cyan); transform: translateY(-1px); }
.page-btn.active { background: var(--aurora-indigo); border-color: var(--aurora-indigo); color: #fff; font-weight: 700; }
.page-btn:disabled { opacity: .35; cursor: not-allowed; }
.bulk-check { width: 16px; height: 16px; cursor: pointer; accent-color: var(--aurora-indigo); }
.btn-lg { padding: 15px 22px; font-size: 1rem; width: 100%; justify-content: center; border-radius: 14px; }
.btn:disabled { opacity: .45; cursor: not-allowed; transform: none !important; box-shadow: none; }

/* ===== Forms ===== */
.form-group { margin-bottom: 16px; }
.form-label {
  display: block; font-size: .82rem; font-weight: 500;
  margin-bottom: 7px; color: var(--text-soft);
}
.form-label .required { color: var(--danger); }
.form-control {
  width: 100%;
  padding: 12px 14px;
  border: 1px solid var(--border);
  border-radius: 12px;
  font-family: inherit;
  font-size: .9rem;
  color: var(--text);
  background: rgba(255,255,255,.05);
  transition: border-color .18s, box-shadow .18s, background .18s;
}
.form-control::placeholder { color: var(--text-faint); }
.form-control:focus {
  outline: none;
  border-color: rgba(74,121,224,.7);
  background: rgba(255,255,255,.07);
  box-shadow: 0 0 0 4px rgba(90,140,255,.14);
}
textarea.form-control { resize: vertical; min-height: 70px; }
.form-control.error { border-color: rgba(255,107,129,.7); box-shadow: 0 0 0 4px rgba(255,107,129,.12); }
.form-help { font-size: .74rem; color: var(--text-light); margin-top: 5px; }
.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
select.form-control option { background: var(--bg-2); color: var(--text); }

/* ===== Tables ===== */
.table-wrapper { overflow-x: auto; border: 1px solid var(--border); border-radius: var(--radius); background: rgba(255,255,255,.03); }
table { width: 100%; border-collapse: collapse; }
th, td { padding: 13px 15px; text-align: left; border-bottom: 1px solid rgba(255,255,255,.07); font-size: .85rem; }
th {
  background: linear-gradient(180deg, rgba(32,64,154,.55), rgba(32,64,154,.38));
  color: #eaf0ff;
  border-bottom: 1px solid rgba(247,179,33,.35);
  font-weight: 600;
  font-family: var(--mono);
  font-size: .74rem;
  letter-spacing: .04em;
  white-space: nowrap;
  position: sticky; top: 0;
}
td { color: var(--text-soft); }
tbody tr { transition: background .12s; }
tbody tr:hover { background: rgba(255,255,255,.05); }
tbody tr:last-child td { border-bottom: none; }
.empty-state {
  text-align: center;
  color: var(--text-light);
  padding: 44px 20px;
  font-size: .88rem;
}
.empty-state i { font-size: 2.6rem; display: block; margin-bottom: 12px; color: var(--text-faint); }

/* ===== Badges ===== */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 4px 11px;
  border-radius: 999px;
  font-family: var(--mono);
  font-size: .72rem;
  font-weight: 700;
  white-space: nowrap;
  letter-spacing: .02em;
}
.badge i { font-size: .68rem; }
.badge-blue   { background: var(--info-light);   color: var(--info); }
.badge-green  { background: var(--success-light); color: var(--success); }
.badge-red    { background: var(--danger-light);  color: var(--danger); }
.badge-yellow { background: var(--warning-light); color: var(--warning); }
.badge-gray   { background: rgba(255,255,255,.08); color: var(--text-light); }

/* ===== Modal ===== */
.modal-overlay {
  position: fixed; inset: 0;
  background: rgba(5,8,18,.62);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
  z-index: 200;
  display: flex; align-items: center; justify-content: center;
  padding: 16px;
  animation: fadeIn .18s;
}
.modal {
  background: linear-gradient(170deg, #141b36, #0e1428);
  border: 1px solid var(--border);
  border-radius: 20px;
  width: 100%;
  max-width: 560px;
  max-height: 90vh;
  overflow-y: auto;
  box-shadow: var(--shadow-lg);
  animation: slideUp .28s cubic-bezier(.4,0,.2,1);
}
@keyframes slideUp { from { transform: translateY(30px); opacity: 0; } to { transform: none; opacity: 1; } }
.modal-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 18px 22px;
  border-bottom: 1px solid var(--border);
  position: sticky; top: 0;
  background: rgba(20,27,54,.92);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  z-index: 1;
  border-radius: 20px 20px 0 0;
}
.modal-header h3 { font-size: 1rem; font-weight: 600; }
.modal-close {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  font-size: 1rem;
  cursor: pointer;
  color: var(--text-soft);
  padding: 5px 10px;
  transition: background .15s, color .15s;
}
.modal-close:hover { background: rgba(255,107,129,.15); color: #ff8da0; }
.modal-body { padding: 22px; }
.modal-footer {
  display: flex; gap: 10px; justify-content: flex-end;
  padding: 16px 22px;
  border-top: 1px solid var(--border);
  position: sticky; bottom: 0;
  background: rgba(14,20,40,.9);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  border-radius: 0 0 20px 20px;
}

/* ===== Toast ===== */
.toast-container {
  position: fixed;
  top: calc(var(--topbar-height) + 14px);
  right: 16px;
  z-index: 300;
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.toast {
  background: linear-gradient(160deg, #171f3d, #0e1428);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 13px 18px;
  box-shadow: var(--shadow-lg);
  display: flex; align-items: center; gap: 11px;
  font-size: .86rem; font-weight: 500;
  min-width: 260px;
  max-width: 360px;
  animation: slideIn .28s cubic-bezier(.4,0,.2,1);
}
.toast.success { border-color: rgba(53,224,161,.5); }
.toast.error   { border-color: rgba(255,107,129,.5); }
.toast.warning { border-color: rgba(255,200,87,.5); }
.toast.info    { border-color: rgba(79,183,255,.5); }
.toast.success i { color: var(--success); }
.toast.error i   { color: var(--danger); }
.toast.warning i { color: var(--warning); }
.toast.info i    { color: var(--info); }
@keyframes slideIn { from { transform: translateX(120%); opacity: 0; } to { transform: none; opacity: 1; } }
.toast.hide { animation: slideOut .28s forwards; }
@keyframes slideOut { to { transform: translateX(120%); opacity: 0; } }
.toast.toast-clickable { cursor: pointer; border-color: rgba(255,200,87,.75); box-shadow: 0 10px 30px rgba(255,200,87,.22); }
.toast.toast-clickable:hover { transform: translateY(-1px); background: linear-gradient(160deg, #202a4d, #121a33); }

/* ===== Search ===== */
.search-box { position: relative; flex: 1; max-width: 400px; }
.search-box i {
  position: absolute;
  left: 14px; top: 50%;
  transform: translateY(-50%);
  color: var(--text-faint);
  font-size: .9rem;
  pointer-events: none;
}
.search-box input { padding-left: 42px; }

/* ===== Toolbar ===== */
.toolbar {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
  margin-bottom: 20px;
}
.toolbar-actions { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }

/* ===== Receive/Issue entry ===== */
.entry-summary {
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: var(--info-light);
  border: 1px solid rgba(79,183,255,.3);
  border-radius: 12px;
  padding: 13px 16px;
  margin-bottom: 16px;
  font-size: .85rem;
}
.entry-summary .count { font-weight: 700; color: var(--info); font-size: 1rem; font-family: var(--mono); }

.material-picker {
  border: 1px dashed rgba(255,255,255,.35);
  border-radius: 12px;
  padding: 12px;
  margin-bottom: 8px;
}
.material-picker select { width: 100%; }

.cart-items { max-height: 400px; overflow-y: auto; margin-bottom: 16px; padding-right: 4px; }
.cart-item {
  display: flex;
  align-items: center;
  gap: 12px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 11px 13px;
  margin-bottom: 10px;
  transition: border-color .15s;
}
.cart-item:hover { border-color: rgba(255,255,255,.24); }
.cart-item .cart-info { flex: 1; min-width: 0; }
.cart-item .cart-name { font-size: .85rem; font-weight: 600; color: var(--text); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.cart-item .cart-cat { font-size: .7rem; color: var(--text-light); font-family: var(--mono); }
.cart-item .cart-qty { display: flex; align-items: center; gap: 8px; }
.cart-item .qty-input { width: 70px; text-align: center; padding: 7px; }
.cart-item .cart-remove { background: none; border: none; color: var(--danger); cursor: pointer; font-size: 1.05rem; }
.qty-btn {
  width: 32px; height: 32px;
  border-radius: 9px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  cursor: pointer;
  font-size: .9rem; font-weight: 700;
  display: flex; align-items: center; justify-content: center;
  transition: background .15s, color .15s;
}
.qty-btn:hover { background: var(--info-light); color: var(--aurora-cyan); }

.entry-total {
  display: flex; align-items: center; justify-content: space-between;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 14px 16px;
  font-weight: 600;
  margin-bottom: 16px;
}
.entry-total .total-label { color: var(--text-light); font-family: var(--mono); font-size: .82rem; }
.entry-total .total-amount {
  color: #fff;
  font-size: 1.3rem;
  font-family: var(--mono);
  background: var(--grad);
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
}

/* ===== Chart ===== */
.chart-box {
  position: relative;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: rgba(255,255,255,.03);
  padding: 14px;
}

/* ===== Low stock card on dashboard ===== */
.lowstock-list { max-height: 280px; overflow-y: auto; padding-right: 4px; }
.lowstock-item {
  display: flex; align-items: center; gap: 12px;
  padding: 12px;
  border-radius: 12px;
  margin-bottom: 9px;
  background: var(--warning-light);
  border: 1px solid rgba(255,200,87,.28);
}
.lowstock-item.stockout { background: var(--danger-light); border-color: rgba(255,107,129,.3); }
.lowstock-icon { color: var(--warning); font-size: 1.05rem; }
.lowstock-item.stockout .lowstock-icon { color: var(--danger); }
.lowstock-item h4 { font-size: .84rem; font-weight: 600; flex: 1; color: var(--text); }
.lowstock-item p { font-size: .72rem; color: var(--text-light); font-family: var(--mono); }
.lowstock-qty { text-align: right; }
.lowstock-qty .qty { font-weight: 700; font-size: .9rem; font-family: var(--mono); color: #fff; }
.lowstock-qty .min { font-size: .7rem; color: var(--text-light); font-family: var(--mono); }

/* ===== Filter chips ===== */
.filter-chips { display: flex; gap: 10px; flex-wrap: wrap; margin-bottom: 16px; }
.chip {
  padding: 7px 15px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text-soft);
  cursor: pointer;
  font-size: .78rem;
  font-family: inherit;
  font-weight: 500;
  transition: all .15s;
}
.chip:hover { border-color: rgba(74,121,224,.55); color: var(--aurora-cyan); }
.chip.active {
  background: var(--grad);
  border-color: transparent;
  color: #fff;
  box-shadow: 0 6px 18px rgba(80,130,255,.35);
}

/* ===== Recent transactions ===== */
.recent-list { max-height: 340px; overflow-y: auto; padding-right: 4px; }
.recent-item {
  display: flex; align-items: center; gap: 12px;
  padding: 10px 0;
  border-bottom: 1px solid rgba(255,255,255,.07);
}
.recent-item:last-child { border-bottom: none; }
.recent-icon {
  width: 36px; height: 36px;
  border-radius: 11px;
  display: flex; align-items: center; justify-content: center;
  font-size: .85rem; flex-shrink: 0;
}
.recent-icon.in  { background: var(--success-light); color: var(--success); }
.recent-icon.out { background: var(--danger-light); color: var(--danger); }
.recent-info { flex: 1; min-width: 0; }
.recent-info h4 { font-size: .83rem; font-weight: 500; color: var(--text); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.recent-info p { font-size: .7rem; color: var(--text-light); font-family: var(--mono); }
.recent-amount { font-weight: 700; font-size: .85rem; white-space: nowrap; font-family: var(--mono); }
.recent-amount.in { color: var(--success); }
.recent-amount.out { color: var(--danger); }

/* ===== Month bar ===== */
.month-bar-wrap { display: flex; gap: 4px; align-items: flex-end; height: 160px; }
.month-bar {
  flex: 1;
  background: linear-gradient(to top, rgba(32,64,154,.95) 0%, rgba(74,121,224,.9) 68%, rgba(247,179,33,.92) 100%);
  border-radius: 6px 6px 2px 2px;
  min-height: 4px;
  position: relative;
  transition: filter .15s;
}
.month-bar:hover { filter: brightness(1.2); }
.month-bar .bar-val {
  position: absolute;
  top: -20px; left: 50%;
  transform: translateX(-50%);
  font-size: .62rem;
  color: var(--text-light);
  font-family: var(--mono);
  white-space: nowrap;
}
.month-labels { display: flex; gap: 4px; margin-top: 6px; }
.month-label { flex: 1; text-align: center; font-size: .6rem; color: var(--text-light); font-family: var(--mono); white-space: nowrap; overflow: hidden; }
.month-summary { font-size: .8rem; color: var(--text-light); margin-top: 10px; font-family: var(--mono); }

/* ===== Snapshot info ===== */
.snapshot-notice {
  background: var(--info-light);
  border: 1px solid rgba(79,183,255,.32);
  color: var(--info);
  border-radius: 12px;
  padding: 13px 16px;
  font-size: .82rem;
  margin-bottom: 16px;
  display: flex; align-items: flex-start; gap: 10px;
}
.snapshot-notice i { margin-top: 3px; }
.snapshot-notice.warn {
  background: var(--warning-light);
  border-color: rgba(255,193,7,.35);
  color: var(--warning);
}

/* ===== Year-over-year stock analysis ===== */
.yoy-pos { color: var(--success); }
.yoy-neg { color: var(--danger); }
.yoy-reason { font-size: .8rem; color: var(--text-light); min-width: 180px; max-width: 340px; }
tr.yoy-high td { background: rgba(255,77,109,.06); }
tr.yoy-new td { background: rgba(79,183,255,.05); }

/* ===== Backup page ===== */
.backup-actions { display: flex; flex-direction: column; gap: 12px; margin-top: 15px; }
.backup-action {
  display: flex; align-items: center; gap: 16px;
  padding: 18px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  cursor: pointer;
  transition: all .18s;
  background: var(--surface);
}
.backup-action:hover {
  border-color: rgba(74,121,224,.45);
  transform: translateY(-2px);
  box-shadow: 0 12px 30px rgba(3,7,18,.5);
}
.backup-action i { font-size: 1.6rem; background: var(--grad); -webkit-background-clip: text; background-clip: text; -webkit-text-fill-color: transparent; }
.backup-action h4 { font-size: .95rem; font-weight: 600; margin-bottom: 3px; color: var(--text); }
.backup-action p { font-size: .76rem; color: var(--text-light); line-height: 1.5; }

img.material-pic { width: 40px; height: 40px; object-fit: cover; border-radius: 10px; border: 1px solid var(--border); }

/* ===== Material Picker ===== */
.picker-box { position: relative; margin-bottom: 15px; }
.picker-search { position: relative; display: flex; align-items: center; }
.picker-search i {
  position: absolute; left: 14px; top: 50%;
  transform: translateY(-50%);
  color: var(--text-faint); font-size: .9rem;
  pointer-events: none;
}
.picker-search input { padding-left: 42px; padding-right: 40px; }
.icon-btn-ghost {
  position: absolute; right: 6px; top: 50%;
  transform: translateY(-50%);
  background: none; border: none;
  color: var(--text-light);
  font-size: .95rem; cursor: pointer;
  padding: 6px 8px; border-radius: 8px;
}
.icon-btn-ghost:hover { background: var(--surface); color: var(--text); }
.picker-cats { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 10px; }
.picker-cats .chip { padding: 5px 12px; font-size: .72rem; }
.picker-results {
  position: absolute; left: 0; right: 0; top: 100%;
  background: #131a34;
  border: 1px solid var(--border);
  border-radius: 14px;
  box-shadow: var(--shadow-lg);
  margin-top: 6px; max-height: 300px; overflow-y: auto;
  z-index: 50; display: none;
}
.picker-results.show { display: block; }
.picker-item {
  width: 100%; text-align: left;
  display: flex; align-items: center; justify-content: space-between; gap: 10px;
  background: none; border: none; border-bottom: 1px solid rgba(255,255,255,.07);
  padding: 13px 15px; cursor: pointer; font-family: inherit;
  transition: background .12s;
}
.picker-item:last-child { border-bottom: none; }
.picker-item:not(.disabled):hover { background: var(--info-light); }
.picker-item .picker-item-name { font-size: .88rem; font-weight: 600; color: var(--text); }
.picker-item .picker-item-meta { font-size: .7rem; color: var(--text-light); font-family: var(--mono); white-space: nowrap; margin-left: auto; margin-right: 12px; }
.picker-item .picker-item-add { font-size: .8rem; font-weight: 700; color: var(--aurora-cyan); white-space: nowrap; font-family: var(--mono); }
.picker-item.chosen .picker-item-add { color: var(--success); }
.picker-item.chosen { background: var(--success-light); cursor: default; }
.picker-item.disabled { cursor: not-allowed; opacity: .5; }
.picker-item.disabled .picker-item-add { color: var(--text-light); }
.text-muted { color: var(--text-light); font-weight: 400; }
.picker-empty { padding: 24px 16px; text-align: center; color: var(--text-light); font-size: .85rem; }
.picker-empty i { font-size: 1.8rem; display: block; margin-bottom: 8px; color: var(--text-faint); }

@media (min-width: 769px) {
  .picker-item:hover .picker-item-name { color: var(--aurora-cyan); }
}

/* ===== Collapsed sidebar (desktop only) ===== */
@media (min-width: 769px) {
  body.collapsed .sidebar { width: var(--sidebar-collapsed); }
  body.collapsed .main-content { margin-left: var(--sidebar-collapsed); }
  body.collapsed .sidebar-header { justify-content: center; padding: 16px 0 14px; }
  body.collapsed .sidebar-header-text { display: none; }
  body.collapsed .sidebar-collapse {
    position: absolute; right: -13px; top: 50%;
    margin-left: 0;
    width: 24px; height: 24px; border-radius: 50%;
    transform: translateY(-50%);
    z-index: 5; background: var(--bg-2);
  }
  body.collapsed .sidebar-collapse:hover { transform: translateY(-50%) scale(1.08); }
  body.collapsed .sidebar-collapse i { transform: rotate(180deg); }
  body.collapsed .side-nav { padding: 16px 10px; }
  body.collapsed .nav-item { justify-content: center; padding: 12px 0; gap: 0; position: relative; }
  body.collapsed .nav-item::before { display: none; }
  body.collapsed .nav-item span { display: none; }
  body.collapsed .nav-item .nav-badge {
    display: inline-flex;
    position: absolute;
    top: 3px; right: 12px;
    min-width: 15px; height: 15px;
    font-size: .58rem;
    padding: 0 4px;
    animation: none;
  }
  body.collapsed .nav-item i { font-size: 1.05rem; }
  body.collapsed .sidebar-footer { display: none; }
}

/* ===== Responsive ===== */
@media (max-width: 900px) {
  .grid-2, .grid-2-1 { grid-template-columns: 1fr; }
}
@media (max-width: 768px) {
  .hamburger { display: block; }
  .sidebar-collapse { display: none; }
  .sidebar {
    transform: translateX(-100%);
    width: 264px;
    box-shadow: 20px 0 50px rgba(0,0,0,.4);
  }
  .sidebar.open { transform: translateX(0); }
  .main-content { margin-left: 0; padding: 18px 14px; }
  .brand-text span { display: none; }
  .stats-grid { grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 12px; }
  .toolbar { flex-direction: column; align-items: stretch; }
  .search-box { max-width: none; }
  .form-row { grid-template-columns: 1fr; }
  .page-title { font-size: 1.3rem; }
}
@media (max-width: 480px) {
  .stat-card { padding: 15px; }
  .stat-icon { width: 46px; height: 46px; font-size: 1.1rem; }
  .stat-info h3 { font-size: 1.25rem; }
  .brand-text h1 { font-size: .9rem; }
  .modal { max-width: 100%; }
}

/* ---------- User menu (topbar) ---------- */
.user-menu { position: relative; }
.user-chip {
  display: flex; align-items: center; gap: 8px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 5px 12px 5px 6px; cursor: pointer; color: var(--text);
  font-family: inherit; font-size: .82rem; font-weight: 500;
  transition: all .18s;
}
.user-chip:hover { border-color: rgba(74,121,224,.5); box-shadow: 0 6px 18px rgba(32,64,154,.25); }
.user-chip-icon {
  width: 28px; height: 28px; border-radius: 50%;
  background: var(--grad);
  color: #fff;
  display: inline-flex; align-items: center; justify-content: center; font-size: .8rem;
}
.user-chip-name { max-width: 130px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.user-dropdown {
  position: absolute; right: 0; top: calc(100% + 10px); z-index: 60;
  background: #131a34;
  border: 1px solid var(--border);
  border-radius: 16px;
  box-shadow: var(--shadow-lg);
  min-width: 235px; overflow: hidden;
  display: none;
}
.user-dropdown.open { display: block; animation: fadeIn .15s; }
.user-dropdown-head { padding: 14px; background: var(--surface); border-bottom: 1px solid var(--border); }
.user-dropdown-head strong { display: block; font-size: .9rem; color: #fff; }
.user-dropdown-head span { display: block; font-size: .74rem; color: var(--text-light); margin-top: 2px; font-family: var(--mono); }
.user-dropdown-menu { padding: 8px; }
.ud-item {
  display: flex; align-items: center; gap: 10px; padding: 10px 12px;
  border-radius: 10px; color: var(--text-soft); text-decoration: none; font-size: .85rem; font-weight: 500;
  transition: background .12s, color .12s;
}
.ud-item:hover { background: var(--surface-2); color: #fff; }
.ud-item i { width: 18px; text-align: center; }
.ud-logout { color: var(--danger); }
.ud-logout:hover { background: rgba(255,107,129,.15); color: #ff8da0; }

/* ---------- Login page ---------- */
.login-wrap {
  min-height: 100vh;
  display: flex; align-items: center; justify-content: center;
  padding: 24px;
  background: transparent;
}
.login-card {
  width: 100%; max-width: 400px;
  background: linear-gradient(170deg, rgba(255,255,255,.08), rgba(255,255,255,.04));
  border: 1px solid var(--border);
  border-radius: 24px;
  box-shadow: var(--shadow-lg);
  padding: 38px 34px 34px;
  text-align: center;
  position: relative;
  overflow: hidden;
}
.login-card::before {
  content: "";
  position: absolute;
  top: 0; left: 0; right: 0;
  height: 3px;
  background: linear-gradient(90deg, var(--ubu-gold), var(--ubu-blue));
}
.login-logo {
  width: 104px; height: 104px; margin: 0 auto 18px;
  border-radius: 26px;
  background: #fff;
  border: 1px solid var(--border);
  box-shadow: 0 14px 34px rgba(247,179,33,.28);
  display: flex; align-items: center; justify-content: center;
  padding: 12px;
}
.login-logo-img { max-width: 100%; max-height: 100%; object-fit: contain; display: block; }
.login-card h2 {
  font-size: 1.32rem; margin: 0; color: #fff; font-weight: 700;
  letter-spacing: -.01em;
}
.login-sub { font-size: .82rem; color: var(--text-light); margin: 6px 0 26px; line-height: 1.55; }
.login-sub-en { display: block; font-size: .72rem; color: var(--text-faint); margin-top: 2px; letter-spacing: .01em; }
.login-card form { text-align: left; }
.login-card .form-group { margin-bottom: 15px; }
.input-icon { position: relative; }
.input-icon i {
  position: absolute;
  left: 15px; top: 50%;
  transform: translateY(-50%);
  color: var(--text-faint); font-size: .9rem;
  pointer-events: none;
  z-index: 1;
}
.input-icon .form-control { padding-left: 44px; }
.login-hint {
  margin-top: 20px; padding: 13px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 13px;
  font-size: .78rem; color: var(--text-light); line-height: 1.7; text-align: left;
}
.login-hint code {
  background: var(--surface-2);
  border: 1px solid var(--border);
  color: var(--aurora-cyan);
  padding: 1px 6px; border-radius: 6px; font-size: .76rem;
  font-family: var(--mono);
}
.login-switch {
  margin-top: 14px; text-align: center;
}
.login-switch a {
  font-size: .82rem; color: var(--aurora-cyan);
  text-decoration: none; font-weight: 600;
}
.login-switch a:hover { text-decoration: underline; }

/* btn-block used in login */
.btn-block { display: flex; width: 100%; justify-content: center; }

input:-webkit-autofill,
input:-webkit-autofill:hover,
input:-webkit-autofill:focus {
  -webkit-text-fill-color: var(--text);
  -webkit-box-shadow: 0 0 0 1000px rgba(18,24,50,.92) inset;
  caret-color: var(--aurora-cyan);
  transition: background-color 9999s ease-out;
}

/* ===== Reduced motion ===== */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: .01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: .01ms !important;
  }
}

/* ===== Manual (คู่มือการใช้งาน) ===== */
.manual-toc { display:grid; grid-template-columns:repeat(auto-fill,minmax(230px,1fr)); gap:6px; }
.manual-toc a { font-size:.82rem; padding:7px 10px; border-radius:8px; text-decoration:none; }
.manual-toc a:hover { background:var(--tab-hover, rgba(74,121,224,.09)); color:var(--link, #f7b321); }
.manual-sec { font-size:.82rem; font-weight:600; margin:12px 0 4px 0; }
.manual-note { font-size:.8rem; background:var(--danger-light, #2a1520); border:1px solid rgba(255,107,129,.25); border-radius:8px; padding:8px 12px; margin-top:10px; }

/* ===== ใบคุมวัสดุ (Control Card) ===== */
.cc-paper { background:#fff; color:#111; border:1px solid #c8c8c8; border-radius:6px; padding:16px 18px; }
.cc-title { text-align:center; margin-bottom:12px; }
.cc-head { margin-bottom:8px; }
.cc-head-table { border-collapse:collapse; }
.cc-head-table td { border:1.2px solid #999; vertical-align:top; padding:0; }
.cc-head-table .cc-hrow { border-bottom:1px solid #bbb; padding:4px 10px; }
.cc-head-table .cc-hrow:last-child { border-bottom:none; }
.cc-head-table .cc-hrow span { display:block; font-weight:600; color:#555; font-size:.68rem; letter-spacing:.3px; }
.cc-head-table .cc-hrow b { font-size:.95rem; }
.cc-head-table .cc-hrow.cc-name b { font-size:1.12rem; }
.cc-head-table .cc-edit { display:block; }
.cc-edit input.form-control { max-width:100%; font-size:.8rem; padding:2px 8px; height:auto; min-height:28px; }
.cc-summary { margin-top:8px; font-size:.8rem; color:#b40000; }
.cc-org { text-align:center; margin-bottom:8px; }
.cc-org-main { font-size:.98rem; font-weight:700; }
.cc-org-sub { font-size:.85rem; margin-top:2px; }
.cc-table { width:100%; border-collapse:collapse; }
.cc-table th, .cc-table td { border:1px solid #bbb; padding:3px 6px; font-size:.74rem; line-height:1.45; }
.cc-table th { background:#eef1f7; color:#111; font-weight:600; }
.cc-table .r, .cc-table td.r { text-align:right; }
.cc-table tr.cc-opening td { background:#f7f7f7; }
.cc-table tr.cc-total td { background:#eef1f7; font-weight:600; }

/* ===== บัญชีวัสดุ (Ledger Form) ===== */
.ledger-paper { background:#fff; color:#111; border:1px solid #c8c8c8; border-radius:6px; padding:20px 22px; }
.ledger-paper .lg-headtop { position:relative; margin-bottom:14px; }
.ledger-paper .lg-title { text-align:center; font-size:1.35rem; font-weight:700; letter-spacing:2px; color:#111; }
.ledger-paper .lg-sheet { position:absolute; top:0; right:0; font-size:.85rem; font-weight:600; color:#111; }
.ledger-paper .lg-sheet .lgf-sheet { width:44px; text-align:center; }
.ledger-fields { width:100%; border-collapse:collapse; margin-bottom:16px; }
.ledger-fields td { border:1px solid #999; padding:5px 9px; vertical-align:middle; }
.ledger-fields td.g { border:none; width:10px; padding:0; }
.ledger-fields label { display:block; font-weight:600; color:#555; font-size:.72rem; margin-bottom:2px; white-space:nowrap; }
.ledger-fields .ta-c { text-align:center; }
.ledger-fields .ta-r { text-align:right; }
.ledger-fields .f { border:none; border-bottom:1px dotted #999; background:transparent; font-family:inherit; font-size:.85rem; color:#111; padding:2px 2px; width:100%; }
.ledger-fields .f:focus { outline:none; border-bottom:2px solid #20409a; background:#f7fbff; }
.lg-picker { position:relative; }
.lg-picker > i { position:absolute; left:6px; top:50%; transform:translateY(-50%); color:#999; font-size:.8rem; pointer-events:none; }
.lg-picker .f { padding-left:24px; padding-right:30px; }
.lg-picker .picker-results { z-index:60; }
.ledger-mat-line { font-size:.85rem; color:#333; margin-bottom:8px; }
.ledger-mat-line span { color:#555; font-size:.78rem; }
.ledger-table { width:100%; border-collapse:collapse; font-size:.78rem; color:#111; }
.ledger-table th, .ledger-table td { border:1px solid #999; padding:4px 6px; vertical-align:middle; }
.ledger-table thead th { background:#eef1f7; color:#111; text-align:center; font-weight:600; }
.ledger-table thead tr.group-row th { background:#f6f8fb; }
.ledger-table .r { text-align:right; }
.ledger-table tbody tr.opening td { background:#fafafa; }
.ledger-table tbody tr.total td { background:#eef1f7; font-weight:600; }

/* ============================================================
   Category icons — SVG realistic + accent color system
   ============================================================ */
.ci {
  width: 1.15em; height: 1.15em;
  display: inline-block; vertical-align: -0.16em; flex-shrink: 0;
}

/* soft 3D pop for every category icon */
.cat-stat .ci, .cat-badge-ico .ci, .isel-chip .ci {
  filter: drop-shadow(0 2px 3px rgba(8,12,30,.45));
  transition: transform .18s ease;
}

/* dashboard category tiles */
.stat-icon.cat-stat {
  position: relative;
  width: 62px; height: 62px; border-radius: 17px;
  background: linear-gradient(140deg, var(--c1), var(--c2));
  color: #fff;
  box-shadow: 0 16px 34px -12px var(--c1), var(--shadow);
}
.stat-icon.cat-stat::after {
  content: ""; position: absolute; inset: 0; border-radius: inherit;
  border: 1px solid rgba(255,255,255,.28);
  box-shadow: inset 0 1px 0 rgba(255,255,255,.5), inset 0 -12px 18px -14px rgba(0,0,0,.4);
}
.stat-icon.cat-stat .ci { width: 38px; height: 38px; }
.stat-icon.cat-stat:hover .ci { transform: scale(1.07) rotate(-2deg); }

/* category badge (tables: รายการวัสดุ / บัญชีวัสดุ) */
.cat-badge {
  display: inline-flex; align-items: center; gap: 8px;
  padding: 3px 12px 3px 5px; border-radius: 999px;
  font-size: .78rem; font-weight: 600; line-height: 1.3;
  background: linear-gradient(180deg, rgba(255,255,255,.07), transparent), var(--soft);
  color: var(--text);
  box-shadow: inset 0 0 0 1px var(--line), inset 0 1px 0 rgba(255,255,255,.1);
  white-space: nowrap;
}
.cat-badge-ico {
  display: inline-flex; align-items: center; justify-content: center;
  width: 25px; height: 25px; border-radius: 9px;
  background: linear-gradient(140deg, var(--c1), var(--c2));
  color: #fff; box-shadow: 0 5px 12px -3px var(--c1), inset 0 1px 0 rgba(255,255,255,.35);
}
.cat-badge-ico .ci { width: 17px; height: 17px; }

/* custom category select (dropdown พร้อมไอคอน) */
.isel-wrap { position: relative; min-width: 170px; }
.isel { position: relative; min-width: 170px; }
.isel-btn {
  display: flex; align-items: center; gap: 10px; width: 100%;
  cursor: pointer; text-align: left;
  background: var(--surface-2); color: var(--text);
  border: 1px solid var(--border); border-radius: var(--radius-sm);
  padding: 10px 12px; font-size: .87rem; font-weight: 500;
  transition: border-color .15s, background .15s;
}
.isel:hover .isel-btn, .isel.open .isel-btn { border-color: rgba(74,121,224,.6); background: var(--surface-3); box-shadow: 0 0 0 3px rgba(74,121,224,.12); }
.isel-btn:focus-visible { outline: 2px solid var(--primary); outline-offset: 1px; }
.isel-btn .is-ico { display: inline-flex; }
.isel-btn .is-label { flex: 1; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.isel-btn .is-caret { color: var(--text-light); font-size: .72rem; transition: transform .15s; }
.isel.open .is-caret { transform: rotate(180deg); }

.isel-chip {
  display: inline-flex; align-items: center; justify-content: center;
  width: 28px; height: 28px; border-radius: 9px;
  background: linear-gradient(140deg, var(--c1), var(--c2)); color: #fff;
  box-shadow: 0 4px 10px -3px var(--c1), inset 0 1px 0 rgba(255,255,255,.3);
}
.isel-chip .ci { width: 19px; height: 19px; }

.isel-menu {
  position: absolute; z-index: 80; top: calc(100% + 8px); left: 0;
  min-width: 100%; max-width: 320px; max-height: 360px; overflow: auto;
  background: var(--bg-2); border: 1px solid var(--border);
  border-radius: 14px; box-shadow: var(--shadow-lg); padding: 8px;
}
.isel-item {
  display: flex; align-items: center; gap: 12px;
  padding: 9px 12px; border-radius: 10px;
  cursor: pointer; font-size: .87rem; color: var(--text-soft);
}
.isel-item:hover { background: var(--surface-2); color: var(--text); }
.isel-item.active { background: var(--primary-light); color: var(--text); font-weight: 600; }
.isel-item .is-ico { display: inline-flex; color: var(--text-light); font-size: .8rem; }

/* category pill in modal (เพิ่ม/แก้ไขวัสดุ) */
.cat-pill { padding: 9px 14px 9px 9px; gap: 10px; font-size: .9rem; }
.cat-pill .isel-chip { width: 26px; height: 26px; border-radius: 9px; }

/* ============================================================
   คู่มือการใช้งาน (manual) — steps + flowchart
   ============================================================ */
.manual-print-btn {
  display: flex; justify-content: flex-end; margin-bottom: 10px;
}
.manual-print-btn .btn { box-shadow: 0 8px 20px -8px var(--primary); }

.mtag {
  display: inline-flex; align-items: center; justify-content: center;
  min-width: 30px; height: 30px; padding: 0 9px; border-radius: 9px;
  background: var(--grad); color: #fff; font-weight: 800; font-size: .85rem;
  margin-right: 5px; box-shadow: 0 5px 14px -6px var(--primary);
  flex-shrink: 0;
}
.card-title .mtag { font-size: .78rem; }

.msteps { display: flex; flex-direction: column; gap: 10px; margin: 10px 0 4px; }
.mstep {
  display: flex; gap: 12px; align-items: flex-start;
  background: linear-gradient(160deg, rgba(255,255,255,.06), rgba(255,255,255,.02));
  border: 1px solid var(--border); border-radius: 12px; padding: 11px 13px;
  transition: border-color .15s, background .15s, transform .15s;
}
.mstep:hover {
  border-color: rgba(74,121,224,.4);
  background: var(--surface-2);
  transform: translateX(2px);
}
.mstep-num {
  flex-shrink: 0; display: inline-flex; align-items: center; justify-content: center;
  width: 34px; height: 34px; border-radius: 10px;
  background: linear-gradient(140deg, #20409a, #4a79e0); color: #fff;
  font-weight: 800; font-size: 1rem;
  box-shadow: 0 6px 16px -7px var(--primary);
}
.mstep-num.alt { background: linear-gradient(140deg, #c98f00, #f7b321); color: #241503; box-shadow: 0 6px 16px -7px #f7b321; }
.mstep-body { min-width: 0; }
.mstep-title { font-weight: 700; font-size: .88rem; color: var(--text); }
.mstep-desc { font-size: .8rem; color: var(--text-soft); line-height: 1.6; margin-top: 2px; }
.mstep-desc strong, .mstep-title strong { color: #fff; }

.mflow { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; margin: 10px 0 6px; }
.mflow-step { display: flex; align-items: center; gap: 6px; }
.mflow-node {
  display: flex; flex-direction: column; align-items: center; gap: 6px;
  min-width: 96px; padding: 11px 12px;
  background: linear-gradient(175deg, var(--surface-2), var(--surface));
  border: 1px solid var(--border); border-radius: 13px; box-shadow: var(--shadow);
}
.mflow-badge {
  display: inline-flex; align-items: center; justify-content: center;
  width: 22px; height: 22px; border-radius: 50%;
  background: var(--grad); color: #fff; font-size: .7rem; font-weight: 800;
  box-shadow: 0 4px 10px -4px var(--primary);
}
.mflow-ico { font-size: 1.2rem; color: var(--aurora-cyan); }
.mflow-ico.alt { color: var(--ubu-gold); }
.mflow-label { font-size: .72rem; text-align: center; color: var(--text-soft); font-weight: 600; line-height: 1.35; }
.mflow-arrow { color: var(--text-faint); font-size: .9rem; }

.manual-sec {
  font-size: .85rem; font-weight: 700; color: var(--text);
  margin: 16px 0 4px; display: flex; align-items: center; gap: 7px;
}
.manual-sec::before { content: ''; width: 5px; height: 16px; border-radius: 3px; background: var(--grad); }

.manual-info {
  display: flex; align-items: center; gap: 10px;
  font-size: .83rem; line-height: 1.6; color: var(--text);
  background: linear-gradient(160deg, rgba(53,224,161,.12), rgba(79,183,255,.08));
  border: 1px solid rgba(53,224,161,.35); border-radius: 12px;
  padding: 11px 14px; margin-bottom: 10px;
}
.manual-info i { color: var(--success); font-size: 1.1rem; flex-shrink: 0; }
.manual-info strong { color: var(--success); }