/* ============================================================
   ATIT ENGINEERING ERP - Light Professional Theme - FULL WIDTH
   ============================================================ */

:root {
  --bg: #f0f4fa;
  --bg2: #ffffff;
  --bg3: #f7f9fc;
  --border: #e3e8f0;
  --border2: #c8d2e4;
  --text: #1a2035;
  --text2: #5a6a8a;
  --text3: #9aaabb;
  --accent: #2563eb;
  --accent2: #1d4ed8;
  --accent-light: #eff6ff;
  --green: #16a34a;
  --green-light: #f0fdf4;
  --red: #dc2626;
  --red-light: #fef2f2;
  --yellow: #d97706;
  --yellow-light: #fffbeb;
  --orange: #ea580c;
  --orange-light: #fff7ed;
  --purple: #7c3aed;
  --purple-light: #f5f3ff;
  --font: 'DM Sans', sans-serif;
  --mono: 'DM Mono', monospace;
  --radius: 8px;
  --radius2: 12px;
  --shadow: 0 1px 4px rgba(30,50,100,0.07), 0 4px 16px rgba(30,50,100,0.05);
  --shadow2: 0 4px 24px rgba(30,50,100,0.12);
  --sidebar-w: 240px;
}

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html, body { width: 100%; height: 100%; }
body { font-family: var(--font); background: var(--bg); color: var(--text); min-height: 100vh; overflow-x: hidden; }

/* ── LOGIN ── */
.login-wrap {
  min-height: 100vh;
  width: 100vw;
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(135deg, #e8f0fe 0%, #f0f4fa 50%, #e8f5ff 100%);
}
.login-card {
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 44px;
  width: 420px;
  box-shadow: var(--shadow2);
}
.login-logo { display: flex; align-items: center; gap: 16px; margin-bottom: 36px; }
.login-logo h1 { font-size: 18px; font-weight: 700; color: var(--text); }
.login-logo p { font-size: 12px; color: var(--text2); margin-top: 3px; font-style: italic; }
.logo-icon {
  font-size: 22px;
  background: linear-gradient(135deg, var(--accent), #60a5fa);
  color: white;
  width: 50px; height: 50px;
  border-radius: 14px;
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
  box-shadow: 0 4px 12px rgba(37,99,235,0.25);
}
/* Brand logo image (ATIT) — login page */
.brand-logo-img {
  height: 56px; width: auto; max-width: 130px;
  flex-shrink: 0; object-fit: contain;
  border-radius: 8px; background: #fff;
  padding: 2px 4px;
}
/* Brand logo image (ATIT) — sidebar header */
.sidebar-logo-img {
  height: 34px; width: auto; max-width: 90px;
  flex-shrink: 0; object-fit: contain;
}

/* ── APP LAYOUT - FULL WIDTH FIX ── */
#app {
  display: flex;
  width: 100vw;
  min-height: 100vh;
}

.sidebar {
  position: fixed;
  left: 0; top: 0; bottom: 0;
  width: var(--sidebar-w);
  background: var(--bg2);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  z-index: 100;
  overflow-y: auto;
  box-shadow: 2px 0 12px rgba(30,50,100,0.06);
  flex-shrink: 0;
}

.main-content {
  margin-left: var(--sidebar-w);
  width: calc(100vw - var(--sidebar-w));
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  background: var(--bg);
}

.topbar {
  background: var(--bg2);
  border-bottom: 1px solid var(--border);
  padding: 0 28px;
  height: 58px;
  display: flex;
  align-items: center;
  gap: 16px;
  position: sticky;
  top: 0;
  z-index: 50;
  box-shadow: 0 1px 4px rgba(30,50,100,0.06);
  width: 100%;
}

.content-area {
  flex: 1;
  padding: 28px 32px;
  width: 100%;
  overflow-x: auto;
}

/* ── SIDEBAR BRAND ── */
.sidebar-brand {
  padding: 18px 16px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  gap: 12px;
  background: linear-gradient(135deg, #eff6ff, #f8faff);
  flex-shrink: 0;
}
.sidebar-brand .logo-icon { font-size: 15px; width: 34px; height: 34px; border-radius: 10px; }
.brand-text strong { display: block; font-size: 13px; font-weight: 700; color: var(--accent); }
.brand-text small { font-size: 10px; color: var(--text3); }

/* ── NAV ── */
.sidebar-nav { flex: 1; padding: 10px 0; overflow-y: auto; }
.nav-section { padding: 14px 16px 4px; font-size: 10px; font-weight: 700; letter-spacing: 1.5px; color: var(--text3); text-transform: uppercase; }
.nav-item {
  display: flex; align-items: center; gap: 10px;
  padding: 9px 14px;
  color: var(--text2);
  text-decoration: none;
  font-size: 13px; font-weight: 500;
  border-radius: var(--radius);
  margin: 1px 8px;
  transition: all 0.15s;
  cursor: pointer;
  user-select: none;
}
.nav-item:hover { background: var(--bg3); color: var(--text); }
.nav-item.active { background: var(--accent-light); color: var(--accent); font-weight: 600; }
.nav-icon { font-size: 15px; width: 20px; text-align: center; flex-shrink: 0; }

/* ── SIDEBAR FOOTER ── */
.sidebar-footer {
  padding: 14px 16px;
  border-top: 1px solid var(--border);
  display: flex;
  align-items: center;
  gap: 10px;
  background: var(--bg3);
  flex-shrink: 0;
}
.user-badge { display: flex; align-items: center; gap: 10px; flex: 1; min-width: 0; }
.user-avatar {
  width: 34px; height: 34px; border-radius: 50%;
  background: linear-gradient(135deg, var(--accent), #60a5fa);
  color: white;
  display: flex; align-items: center; justify-content: center;
  font-size: 13px; font-weight: 700;
  flex-shrink: 0;
}
.user-info { min-width: 0; }
.user-info span { display: block; font-size: 12px; font-weight: 600; color: var(--text); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.user-info small { font-size: 11px; color: var(--text3); }
.btn-logout { background: none; border: 1px solid var(--border2); color: var(--text2); border-radius: 8px; width: 32px; height: 32px; cursor: pointer; font-size: 14px; transition: all 0.15s; flex-shrink: 0; }
.btn-logout:hover { background: var(--red-light); border-color: var(--red); color: var(--red); }

/* ── TOPBAR ── */
.topbar-title { font-size: 16px; font-weight: 700; flex: 1; color: var(--text); }
.sidebar-toggle { background: none; border: 1px solid var(--border); color: var(--text2); font-size: 16px; cursor: pointer; padding: 6px 10px; border-radius: 8px; display: none; }

/* ── NOTIFICATIONS ── */
.notif-wrap { position: relative; }
.notif-btn { background: var(--bg3); border: 1px solid var(--border); border-radius: 8px; color: var(--text2); padding: 7px 14px; cursor: pointer; font-size: 13px; font-weight: 500; transition: all 0.15s; }
.notif-btn:hover { background: var(--accent-light); border-color: var(--accent); color: var(--accent); }
.notif-badge { background: var(--red); color: #fff; border-radius: 10px; padding: 1px 6px; font-size: 10px; font-weight: 700; margin-left: 4px; }
.notif-dropdown { position: absolute; right: 0; top: calc(100% + 8px); width: 340px; background: var(--bg2); border: 1px solid var(--border); border-radius: var(--radius2); box-shadow: var(--shadow2); z-index: 200; max-height: 400px; overflow-y: auto; }
.notif-header { padding: 12px 16px; font-weight: 700; font-size: 13px; border-bottom: 1px solid var(--border); color: var(--text); }
.notif-item { padding: 12px 16px; border-bottom: 1px solid var(--border); cursor: pointer; }
.notif-item:hover { background: var(--bg3); }
.notif-item.unread { border-left: 3px solid var(--accent); background: var(--accent-light); }
.notif-item h5 { font-size: 12px; font-weight: 600; margin-bottom: 3px; color: var(--text); }
.notif-item p { font-size: 11px; color: var(--text2); }
.notif-item time { font-size: 10px; color: var(--text3); }

/* ── FORMS ── */
.field-group { margin-bottom: 16px; }
.field-group label { display: block; font-size: 12px; font-weight: 600; color: var(--text2); margin-bottom: 6px; }
.field-group input,
.field-group select,
.field-group textarea {
  width: 100%; background: var(--bg2); border: 1.5px solid var(--border);
  border-radius: var(--radius); padding: 9px 12px; color: var(--text);
  font-family: var(--font); font-size: 13px; outline: none;
  transition: border-color 0.15s, box-shadow 0.15s;
}
.field-group input:focus, .field-group select:focus, .field-group textarea:focus {
  border-color: var(--accent); box-shadow: 0 0 0 3px rgba(37,99,235,0.1);
}
.field-group input:hover, .field-group select:hover { border-color: var(--border2); }
.field-group textarea { resize: vertical; min-height: 80px; }
.field-group select option { background: var(--bg2); color: var(--text); }
.form-row { display: grid; gap: 16px; }
.form-row.cols-2 { grid-template-columns: 1fr 1fr; }
.form-row.cols-3 { grid-template-columns: 1fr 1fr 1fr; }
.form-row.cols-4 { grid-template-columns: 1fr 1fr 1fr 1fr; }
.error-msg { background: var(--red-light); border: 1px solid rgba(220,38,38,0.2); border-radius: var(--radius); padding: 10px 14px; color: var(--red); font-size: 12px; font-weight: 500; margin-bottom: 16px; }

/* ── BUTTONS ── */
.btn-primary { background: var(--accent); color: #fff; border: none; border-radius: var(--radius); padding: 10px 20px; font-family: var(--font); font-size: 13px; font-weight: 600; cursor: pointer; transition: all 0.15s; box-shadow: 0 2px 8px rgba(37,99,235,0.2); }
.btn-primary:hover { background: var(--accent2); transform: translateY(-1px); box-shadow: 0 4px 12px rgba(37,99,235,0.3); }
.btn-secondary { background: var(--bg2); color: var(--text); border: 1.5px solid var(--border); border-radius: var(--radius); padding: 9px 18px; font-family: var(--font); font-size: 13px; font-weight: 500; cursor: pointer; transition: all 0.15s; }
.btn-secondary:hover { border-color: var(--border2); background: var(--bg3); }
.btn-success { background: var(--green); color: #fff; border: none; border-radius: var(--radius); padding: 8px 16px; font-size: 12px; font-weight: 600; cursor: pointer; transition: opacity 0.15s; }
.btn-success:hover { opacity: 0.88; }
.btn-danger { background: var(--red); color: #fff; border: none; border-radius: var(--radius); padding: 8px 16px; font-size: 12px; font-weight: 600; cursor: pointer; }
.btn-warning { background: var(--yellow); color: #fff; border: none; border-radius: var(--radius); padding: 8px 16px; font-size: 12px; font-weight: 600; cursor: pointer; }
.btn-sm { padding: 5px 12px !important; font-size: 11px !important; }
.full-width { width: 100%; }
.btn-icon { background: var(--bg3); border: 1px solid var(--border); border-radius: 6px; color: var(--text2); padding: 5px 9px; cursor: pointer; font-size: 13px; transition: all 0.12s; }
.btn-icon:hover { background: var(--accent-light); border-color: var(--accent); color: var(--accent); }

/* ── PAGE HEADER ── */
.page-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 24px; flex-wrap: wrap; gap: 12px; }
.page-header h2 { font-size: 22px; font-weight: 700; color: var(--text); }
.page-header .actions { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }

/* ── CARDS ── */
.card { background: var(--bg2); border: 1px solid var(--border); border-radius: var(--radius2); padding: 20px; box-shadow: var(--shadow); width: 100%; }
.card-title { font-size: 11px; font-weight: 700; color: var(--text2); margin-bottom: 14px; letter-spacing: 0.8px; text-transform: uppercase; }

/* ── STATS GRID ── */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 16px;
  margin-bottom: 24px;
  width: 100%;
}
@media (max-width: 1200px) { .stats-grid { grid-template-columns: repeat(4, 1fr); } }
@media (max-width: 900px) { .stats-grid { grid-template-columns: repeat(2, 1fr); } }

.stat-card {
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: var(--radius2);
  padding: 20px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  transition: all 0.15s;
  box-shadow: var(--shadow);
  position: relative;
  overflow: hidden;
}
.stat-card::before { content: ''; position: absolute; top: 0; left: 0; right: 0; height: 3px; background: var(--border2); }
.stat-card:hover { box-shadow: var(--shadow2); transform: translateY(-2px); }
.stat-card .stat-label { font-size: 11px; color: var(--text3); letter-spacing: 0.8px; text-transform: uppercase; font-weight: 600; }
.stat-card .stat-value { font-size: 30px; font-weight: 700; font-family: var(--mono); color: var(--text); line-height: 1; }
.stat-card .stat-sub { font-size: 12px; color: var(--text2); }
.stat-card.alert::before { background: var(--red); }
.stat-card.alert .stat-value { color: var(--red); }
.stat-card.success::before { background: var(--green); }
.stat-card.success .stat-value { color: var(--green); }
.stat-card.warning::before { background: var(--yellow); }
.stat-card.warning .stat-value { color: var(--yellow); }
.stat-card.info::before { background: var(--accent); }
.stat-card.info .stat-value { color: var(--accent); }

/* ── TABLE ── */
.table-wrap { overflow-x: auto; width: 100%; }
table { width: 100%; border-collapse: collapse; font-size: 13px; }
thead th { background: var(--bg3); padding: 11px 14px; text-align: left; font-size: 11px; font-weight: 700; color: var(--text2); letter-spacing: 0.6px; text-transform: uppercase; white-space: nowrap; border-bottom: 2px solid var(--border); }
tbody td { padding: 12px 14px; border-bottom: 1px solid var(--border); vertical-align: middle; color: var(--text); }
tbody tr:hover td { background: #f5f8ff; }
tbody tr:last-child td { border-bottom: none; }
.mono { font-family: var(--mono); font-size: 12px; color: var(--accent); font-weight: 500; }

/* ── BADGES ── */
.badge { display: inline-flex; align-items: center; padding: 3px 10px; border-radius: 20px; font-size: 11px; font-weight: 600; white-space: nowrap; }
.badge-green { background: var(--green-light); color: var(--green); border: 1px solid rgba(22,163,74,0.2); }
.badge-red { background: var(--red-light); color: var(--red); border: 1px solid rgba(220,38,38,0.2); }
.badge-yellow { background: var(--yellow-light); color: var(--yellow); border: 1px solid rgba(217,119,6,0.2); }
.badge-blue { background: var(--accent-light); color: var(--accent); border: 1px solid rgba(37,99,235,0.2); }
.badge-gray { background: #f1f5f9; color: var(--text2); border: 1px solid var(--border); }
.badge-orange { background: var(--orange-light); color: var(--orange); border: 1px solid rgba(234,88,12,0.2); }
.badge-purple { background: var(--purple-light); color: var(--purple); border: 1px solid rgba(124,58,237,0.2); }

/* ── MODAL ── */
.modal-overlay {
  position: fixed !important;
  top: 0 !important;
  left: 0 !important;
  right: 0 !important;
  bottom: 0 !important;
  background: rgba(15,25,60,0.35);
  z-index: 9000;
  overflow-y: auto !important;
  overflow-x: hidden;
}
.modal-box {
  background: #ffffff;
  border: 1px solid #e3e8f0;
  border-radius: 14px;
  width: 90%;
  max-width: 780px;
  margin: 50px auto 80px auto;
  box-shadow: 0 8px 40px rgba(15,25,60,0.18);
}
@keyframes slideDown { from { opacity: 0; transform: translateY(-16px); } to { opacity: 1; transform: translateY(0); } }
.modal-header { display: flex; align-items: center; justify-content: space-between; padding: 16px 20px; border-bottom: 1px solid #e3e8f0; background: #f7f9fc; border-radius: 14px 14px 0 0; }
.modal-header h3 { font-size: 16px; font-weight: 700; color: var(--text); }
.modal-close { background: none; border: 1px solid var(--border); border-radius: 8px; color: var(--text2); width: 30px; height: 30px; cursor: pointer; font-size: 14px; transition: all 0.15s; }
.modal-close:hover { background: var(--red-light); border-color: var(--red); color: var(--red); }
.modal-body { padding: 20px 24px; }
.modal-footer { padding: 14px 24px; border-top: 1px solid #e3e8f0; display: flex; justify-content: flex-end; gap: 12px; background: #f7f9fc; border-radius: 0 0 14px 14px; }

/* ── TOAST ── */
#toast-container { position: fixed; bottom: 24px; right: 24px; z-index: 9999; display: flex; flex-direction: column; gap: 8px; }
.toast { background: var(--bg2); border: 1px solid var(--border); border-radius: var(--radius); padding: 13px 18px; font-size: 13px; font-weight: 500; min-width: 280px; box-shadow: var(--shadow2); animation: slideIn 0.2s ease; display: flex; align-items: center; gap: 10px; color: var(--text); }
.toast.success { border-left: 4px solid var(--green); }
.toast.error { border-left: 4px solid var(--red); }
.toast.warning { border-left: 4px solid var(--yellow); }
.toast.info { border-left: 4px solid var(--accent); }
@keyframes slideIn { from { opacity: 0; transform: translateX(20px); } to { opacity: 1; transform: translateX(0); } }

/* ── LINE ITEMS ── */
.line-items-wrap { overflow-x: auto; margin: 16px 0; border-radius: var(--radius); border: 1px solid var(--border); }
.line-items-table { width: 100%; border-collapse: collapse; font-size: 12px; }
.line-items-table th { background: var(--bg3); padding: 9px 10px; font-size: 10px; font-weight: 700; color: var(--text2); text-transform: uppercase; letter-spacing: 0.5px; white-space: nowrap; border-bottom: 1px solid var(--border); }
.line-items-table td { padding: 7px 8px; border-bottom: 1px solid var(--border); background: var(--bg2); }
.line-items-table tr:last-child td { border-bottom: none; }
.line-items-table input, .line-items-table select { background: var(--bg3); border: 1.5px solid var(--border); border-radius: 6px; padding: 5px 8px; color: var(--text); width: 100%; font-size: 12px; min-width: 80px; }
.line-items-table input:focus, .line-items-table select:focus { border-color: var(--accent); outline: none; background: #fff; }

/* ── UTILITIES ── */
.divider { border: none; border-top: 1px solid var(--border); margin: 20px 0; }
.text-right { text-align: right; }
.text-center { text-align: center; }
.mt-16 { margin-top: 16px; }
.mb-16 { margin-bottom: 16px; }
.gap-12 { display: flex; gap: 12px; }
.flex-between { display: flex; justify-content: space-between; align-items: center; }

.totals-box { background: var(--bg3); border: 1px solid var(--border); border-radius: var(--radius); padding: 16px 20px; min-width: 280px; }
.totals-box .total-row { display: flex; justify-content: space-between; padding: 5px 0; font-size: 13px; color: var(--text2); }
.totals-box .total-row.grand { border-top: 2px solid var(--border); margin-top: 8px; padding-top: 12px; font-weight: 700; font-size: 16px; color: var(--text); }

.empty-state { text-align: center; padding: 60px 20px; color: var(--text3); }
.empty-state .empty-icon { font-size: 48px; margin-bottom: 16px; }
.empty-state p { font-size: 14px; }

.search-bar { background: var(--bg2); border: 1.5px solid var(--border); border-radius: var(--radius); padding: 9px 14px; color: var(--text); font-family: var(--font); font-size: 13px; outline: none; width: 260px; transition: all 0.15s; }
.search-bar:focus { border-color: var(--accent); box-shadow: 0 0 0 3px rgba(37,99,235,0.1); }
.search-bar::placeholder { color: var(--text3); }

.two-col { display: grid; grid-template-columns: 1fr 1fr; gap: 24px; width: 100%; }
.three-col { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 24px; width: 100%; }

.alert-box { background: var(--yellow-light); border: 1px solid rgba(217,119,6,0.25); border-radius: var(--radius); padding: 11px 16px; color: var(--yellow); font-size: 12px; font-weight: 500; margin-bottom: 16px; }
.info-box { background: var(--accent-light); border: 1px solid rgba(37,99,235,0.15); border-radius: var(--radius); padding: 12px 16px; font-size: 12px; color: var(--text2); }
.info-box strong { color: var(--text); }

.section-title { font-size: 11px; font-weight: 700; color: var(--text2); margin-bottom: 12px; padding-bottom: 8px; border-bottom: 2px solid var(--border); letter-spacing: 0.8px; text-transform: uppercase; }

.label-value { display: grid; grid-template-columns: 150px 1fr; gap: 7px 12px; font-size: 13px; }
.label-value .lv-label { color: var(--text2); font-weight: 500; }
.label-value .lv-val { font-weight: 600; color: var(--text); }

.tabs { display: flex; gap: 4px; border-bottom: 2px solid var(--border); margin-bottom: 20px; }
.tab { padding: 10px 18px; font-size: 13px; font-weight: 500; cursor: pointer; border-bottom: 2px solid transparent; color: var(--text2); transition: all 0.15s; margin-bottom: -2px; }
.tab.active { border-bottom-color: var(--accent); color: var(--accent); font-weight: 600; }
.tab:hover { color: var(--text); }

.scan-input-wrap { display: flex; gap: 12px; align-items: flex-end; margin-bottom: 20px; }
.scan-input-wrap .field-group { flex: 1; margin: 0; }

::-webkit-scrollbar { width: 5px; height: 5px; }
::-webkit-scrollbar-track { background: var(--bg3); }
::-webkit-scrollbar-thumb { background: var(--border2); border-radius: 10px; }
::-webkit-scrollbar-thumb:hover { background: var(--text3); }

/* ── RESPONSIVE ── */
@media (max-width: 900px) {
  .sidebar { transform: translateX(-100%); }
  .sidebar.open { transform: none; box-shadow: 4px 0 20px rgba(0,0,0,0.15); }
  .main-content { margin-left: 0; width: 100vw; }
  .sidebar-toggle { display: flex; }
  .form-row.cols-2, .form-row.cols-3, .form-row.cols-4 { grid-template-columns: 1fr; }
  .two-col, .three-col { grid-template-columns: 1fr; }
  .content-area { padding: 16px; }
  .stats-grid { grid-template-columns: 1fr 1fr; }
}

/* Modal footer inside body - reset padding */
.modal-body .modal-footer {
  margin: 20px -24px -20px -24px;
  border-radius: 0 0 14px 14px;
}

/* ── BARCODE SCANNER STYLES ── */
.scan-result-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  margin-bottom: 16px;
}
.scan-result-item {
  background: #f7f9fc;
  border: 1px solid #e3e8f0;
  border-radius: 8px;
  padding: 10px 14px;
}
.sri-label {
  font-size: 10px;
  font-weight: 700;
  color: #9aaabb;
  text-transform: uppercase;
  letter-spacing: 0.8px;
  margin-bottom: 4px;
}
.sri-value {
  font-size: 14px;
  font-weight: 600;
  color: #1a2035;
}
.scan-alert {
  padding: 12px 16px;
  border-radius: 8px;
  font-size: 13px;
  font-weight: 500;
  margin-bottom: 12px;
}
.scan-alert.success { background: #f0fdf4; color: #16a34a; border: 1px solid rgba(22,163,74,0.2); }
.scan-alert.error { background: #fef2f2; color: #dc2626; border: 1px solid rgba(220,38,38,0.2); }
.scan-alert.warning { background: #fffbeb; color: #d97706; border: 1px solid rgba(217,119,6,0.2); }
.scan-alert.info { background: #eff6ff; color: #2563eb; border: 1px solid rgba(37,99,235,0.2); }
.scan-items-table { margin-top: 12px; }
.scan-items-table table { width: 100%; border-collapse: collapse; font-size: 12px; }
.scan-items-table th { background: #f7f9fc; padding: 8px 10px; font-size: 10px; font-weight: 700; color: #5a6a8a; text-transform: uppercase; border-bottom: 1px solid #e3e8f0; }
.scan-items-table td { padding: 8px 10px; border-bottom: 1px solid #e3e8f0; color: #1a2035; }

/* Scanner indicator in topbar */
.scanner-indicator {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  color: #16a34a;
  background: #f0fdf4;
  border: 1px solid rgba(22,163,74,0.2);
  padding: 5px 12px;
  border-radius: 20px;
  font-weight: 500;
}
.scanner-dot {
  width: 7px;
  height: 7px;
  background: #16a34a;
  border-radius: 50%;
  animation: pulse-dot 1.5s infinite;
}
@keyframes pulse-dot {
  0%, 100% { opacity: 1; transform: scale(1); }
  50% { opacity: 0.5; transform: scale(0.8); }
}

/* ── CSV FORMAT BOX ── */
.csv-format-box {
  background: #f0f7ff;
  border: 1px solid rgba(37,99,235,0.2);
  border-radius: 8px;
  padding: 12px 16px;
  margin-bottom: 16px;
}
.csv-format-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 10px;
  font-size: 13px;
  font-weight: 600;
  color: #1e40af;
}
.btn-download-sample {
  background: #2563eb;
  color: #fff;
  border: none;
  border-radius: 6px;
  padding: 5px 12px;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.15s;
}
.btn-download-sample:hover { background: #1d4ed8; }
.csv-columns {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}
.csv-col {
  background: #fff;
  border: 1px solid #c7d7f4;
  border-radius: 4px;
  padding: 3px 10px;
  font-size: 11px;
  font-weight: 600;
  color: #374151;
  font-family: monospace;
}
.csv-col.required {
  background: #eff6ff;
  border-color: #2563eb;
  color: #1d4ed8;
}
.csv-col.required::after {
  content: ' *';
  color: #dc2626;
}

/* ── FILE UPLOAD ── */
.file-upload-wrap {
  border: 2px dashed #c8d2e4;
  border-radius: 8px;
  padding: 12px;
  transition: border-color 0.15s;
}
.file-upload-wrap:hover { border-color: #2563eb; }
.file-upload-wrap input[type="file"] {
  width: 100%;
  border: none;
  background: none;
  padding: 0;
  font-size: 13px;
  cursor: pointer;
}
.file-upload-wrap input[type="file"]:focus { box-shadow: none; }
.file-name-display {
  margin-top: 6px;
  font-size: 12px;
  color: #5a6a8a;
  font-weight: 500;
}
/* ── PLANT TABS (Multi-Plant IMS — U-14 / M-15) ── */
.plant-tabs {
  display: flex;
  gap: 12px;
  margin-bottom: 18px;
  flex-wrap: wrap;
}
.plant-tab {
  flex: 1;
  min-width: 180px;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px 18px;
  background: var(--bg2);
  border: 2px solid var(--border);
  border-radius: 12px;
  cursor: pointer;
  text-align: left;
  font-family: var(--font);
  color: var(--text2);
  transition: all 0.18s ease;
  position: relative;
  box-shadow: var(--shadow);
}
.plant-tab:hover {
  border-color: var(--border2);
  background: var(--bg3);
  transform: translateY(-1px);
}
.plant-tab.active {
  border-color: var(--accent);
  background: var(--accent-light);
  color: var(--text);
  box-shadow: 0 4px 14px rgba(37,99,235,0.18);
}
.plant-tab.active::before {
  content: '';
  position: absolute;
  top: -2px; left: -2px; right: -2px; bottom: -2px;
  border-radius: 12px;
  border: 2px solid var(--accent);
  pointer-events: none;
}
.plant-tab-icon {
  font-size: 28px;
  line-height: 1;
}
.plant-tab-text {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
}
.plant-tab-text strong {
  font-size: 16px;
  font-weight: 700;
  color: var(--text);
  letter-spacing: 0.2px;
}
.plant-tab-text small {
  font-size: 11px;
  color: var(--text3);
  font-weight: 500;
}
.plant-tab.active .plant-tab-text strong { color: var(--accent2); }
.plant-tab.active .plant-tab-text small { color: var(--accent); font-weight: 600; }

/* Context bar shown above the stock table */
.ims-context-bar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 10px 16px;
  background: var(--bg3);
  border: 1px solid var(--border);
  border-radius: 8px;
  margin-bottom: 12px;
  font-size: 13px;
}
.ims-context-label {
  color: var(--text2);
  font-weight: 500;
  margin-right: 6px;
}
.ims-context-plant {
  font-weight: 700;
  color: var(--text);
}
.ims-context-stats {
  display: flex;
  gap: 16px;
  font-size: 12px;
  color: var(--text2);
}
.ims-context-stats strong { color: var(--text); }

/* ── Category sub-tabs (under the plant tabs in IMS) ── */
.cat-tabs {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 16px;
}
.cat-tabs-label {
  font-size: 12px;
  font-weight: 600;
  color: var(--text3);
  margin-right: 2px;
}
.cat-tab {
  padding: 6px 14px;
  border-radius: 999px;
  border: 1.5px solid var(--border);
  background: var(--bg2);
  color: var(--text2);
  font-family: var(--font);
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.15s ease;
}
.cat-tab:hover { border-color: var(--border2); background: var(--bg3); }
.cat-tab.active {
  border-color: var(--accent);
  background: var(--accent-light);
  color: var(--accent2);
  font-weight: 700;
}

/* ── Live / Daily-closing view toggle ── */
.ims-view-toggle {
  display: inline-flex;
  border: 1.5px solid var(--border);
  border-radius: 9px;
  overflow: hidden;
}
.ims-view-btn {
  padding: 8px 14px;
  border: none;
  background: var(--bg2);
  color: var(--text2);
  font-family: var(--font);
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.15s ease;
}
.ims-view-btn + .ims-view-btn { border-left: 1.5px solid var(--border); }
.ims-view-btn:hover { background: var(--bg3); }
.ims-view-btn.active { background: var(--accent); color: #fff; }

/* ── IMS freeze table: Item Code + Item Name frozen, rest scrolls ── */
.ims-freeze-table { border-collapse: separate; border-spacing: 0; }
.ims-freeze-table th, .ims-freeze-table td { white-space: nowrap; }
/* Fixed widths so frozen columns line up and dates stay compact */
.ims-freeze-table .sticky-col  { width: 96px;  min-width: 96px;  max-width: 96px; }
.ims-freeze-table .sticky-col2 { width: 200px; min-width: 200px; max-width: 200px;
  overflow: hidden; text-overflow: ellipsis; }
.ims-freeze-table .col-uom    { width: 54px;  min-width: 54px; }
.ims-freeze-table .col-num    { width: 84px;  min-width: 84px; text-align: right; }
.ims-freeze-table .col-status { width: 90px;  min-width: 90px; }
.ims-freeze-table .col-date   { width: 78px;  min-width: 78px; text-align: right; }
.ims-freeze-table .col-calc   { width: 72px;  min-width: 72px; text-align: right; background: var(--bg2); }
.ims-freeze-table .col-wide   { width: 140px; min-width: 140px; max-width: 140px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ims-inline-select {
  width: 100%;
  font-family: var(--font);
  font-size: 12px;
  padding: 2px 4px;
  border: 1px solid var(--border);
  border-radius: 5px;
  background: var(--bg);
  color: var(--text);
  cursor: pointer;
}
.ims-freeze-table th.col-calc { color: var(--accent2); }
.ims-freeze-table th.col-num, .ims-freeze-table th.col-date, .ims-freeze-table th.col-calc { text-align: right; }

/* Formula legend under the IMS table */
.ims-legend {
  margin-top: 12px;
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 8px 14px;
  font-size: 12.5px;
}
.ims-legend summary {
  cursor: pointer;
  font-weight: 600;
  color: var(--text);
  user-select: none;
}
.ims-legend-body { margin-top: 8px; display: grid; gap: 5px; color: var(--text2); line-height: 1.5; }
.ims-legend-body strong { color: var(--text); }

/* Stock colour legend bar (mirrors the sheet's row-1 legend) */
.ims-color-legend {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 4px 0;
  font-size: 12px;
  padding: 8px 12px;
  margin-bottom: 12px;
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: 8px;
}

.ims-freeze-table .sticky-col,
.ims-freeze-table .sticky-col2 {
  position: sticky;
  background: var(--bg);
  z-index: 2;
  box-shadow: 1px 0 0 var(--border);
}
.ims-freeze-table .sticky-col  { left: 0; }
.ims-freeze-table .sticky-col2 { left: 96px; }
.ims-freeze-table thead .sticky-col,
.ims-freeze-table thead .sticky-col2 { z-index: 3; background: var(--bg3); }
.ims-freeze-table tbody tr:hover .sticky-col,
.ims-freeze-table tbody tr:hover .sticky-col2 { background: var(--bg3); }
.ims-freeze-table th.closing-latest,
.ims-freeze-table td.closing-latest { background: var(--accent-light); }
.ims-freeze-table th.closing-latest { color: var(--accent2); }

@media (max-width: 700px) {
  .plant-tab { min-width: 0; padding: 12px 14px; }
  .plant-tab-icon { font-size: 22px; }
  .plant-tab-text strong { font-size: 14px; }
  .plant-tab-text small { font-size: 10px; }
  .ims-freeze-table .sticky-col2 { width: 130px; min-width: 130px; max-width: 130px; }
}

/* ============================================================
   ATIT ERP CHATBOT — v1.0
   ============================================================ */

/* ── FAB (Floating Action Button) ── */
#chat-fab {
  position: fixed;
  bottom: 28px;
  right: 28px;
  width: 56px;
  height: 56px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--accent), #1d4ed8);
  color: white;
  border: none;
  cursor: pointer;
  font-size: 22px;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 4px 20px rgba(37,99,235,0.4), 0 2px 8px rgba(0,0,0,0.15);
  z-index: 10000;
  transition: transform 0.2s ease, box-shadow 0.2s ease;
  line-height: 1;
}
#chat-fab:hover {
  transform: translateY(-2px) scale(1.05);
  box-shadow: 0 8px 28px rgba(37,99,235,0.5), 0 4px 12px rgba(0,0,0,0.2);
}
#chat-fab.chat-fab-open {
  background: linear-gradient(135deg, #5a6a8a, #1a2035);
  font-size: 18px;
}
#chat-unread-dot {
  position: absolute;
  top: 6px;
  right: 6px;
  width: 10px;
  height: 10px;
  background: var(--red);
  border-radius: 50%;
  border: 2px solid white;
}

/* ── Chat Window ── */
#chat-window {
  position: fixed;
  bottom: 96px;
  right: 28px;
  width: 380px;
  max-width: calc(100vw - 40px);
  height: 520px;
  max-height: calc(100vh - 120px);
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: 16px;
  box-shadow: 0 8px 40px rgba(30,50,100,0.18), 0 2px 10px rgba(30,50,100,0.1);
  z-index: 9999;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  animation: chatSlideUp 0.22s ease;
}
@keyframes chatSlideUp {
  from { opacity: 0; transform: translateY(16px) scale(0.97); }
  to   { opacity: 1; transform: translateY(0) scale(1); }
}

/* ── Header ── */
#chat-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 16px;
  background: linear-gradient(135deg, var(--accent), #1d4ed8);
  color: white;
  flex-shrink: 0;
}
.chat-header-info {
  display: flex;
  align-items: center;
  gap: 10px;
}
.chat-avatar-small {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  background: rgba(255,255,255,0.2);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 18px;
  flex-shrink: 0;
}
#chat-header strong {
  display: block;
  font-size: 14px;
  font-weight: 600;
  color: white;
}
.chat-status {
  font-size: 11px;
  color: rgba(255,255,255,0.8);
  display: flex;
  align-items: center;
  gap: 4px;
}
.chat-close-btn {
  background: rgba(255,255,255,0.15);
  border: 1px solid rgba(255,255,255,0.2);
  color: white;
  width: 28px;
  height: 28px;
  border-radius: 6px;
  cursor: pointer;
  font-size: 13px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.15s;
}
.chat-close-btn:hover { background: rgba(255,255,255,0.25); }

/* ── Messages Area ── */
#chat-messages {
  flex: 1;
  overflow-y: auto;
  padding: 16px 14px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  scroll-behavior: smooth;
}
#chat-messages::-webkit-scrollbar { width: 4px; }
#chat-messages::-webkit-scrollbar-track { background: transparent; }
#chat-messages::-webkit-scrollbar-thumb { background: var(--border2); border-radius: 4px; }

/* ── Message Bubbles ── */
.chat-msg { display: flex; max-width: 100%; }
.chat-msg.user { justify-content: flex-end; }
.chat-msg.bot  { justify-content: flex-start; }

.chat-bubble {
  max-width: 82%;
  padding: 10px 13px;
  border-radius: 12px;
  font-size: 13px;
  line-height: 1.55;
  word-break: break-word;
}
.chat-msg.user .chat-bubble {
  background: linear-gradient(135deg, var(--accent), #1d4ed8);
  color: white;
  border-bottom-right-radius: 3px;
}
.chat-msg.bot .chat-bubble {
  background: var(--bg3);
  color: var(--text);
  border: 1px solid var(--border);
  border-bottom-left-radius: 3px;
}
.chat-msg.bot .chat-bubble em {
  color: var(--accent);
  font-style: normal;
  font-weight: 500;
}

/* ── Typing Indicator ── */
.chat-typing {
  display: flex;
  align-items: center;
  gap: 5px;
  padding: 12px 16px !important;
}
.chat-typing span {
  display: block;
  width: 7px;
  height: 7px;
  background: var(--text3);
  border-radius: 50%;
  animation: chatTypingDot 1.2s infinite ease-in-out;
}
.chat-typing span:nth-child(2) { animation-delay: 0.2s; }
.chat-typing span:nth-child(3) { animation-delay: 0.4s; }
@keyframes chatTypingDot {
  0%, 80%, 100% { transform: scale(0.7); opacity: 0.4; }
  40% { transform: scale(1); opacity: 1; }
}

/* ── Quick Action Buttons ── */
#chat-quick-btns {
  padding: 0 14px 10px;
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  flex-shrink: 0;
}
#chat-quick-btns button {
  font-size: 11px;
  padding: 5px 10px;
  border: 1px solid var(--border2);
  background: var(--bg3);
  color: var(--accent);
  border-radius: 20px;
  cursor: pointer;
  font-family: var(--font);
  font-weight: 500;
  transition: background 0.15s, border-color 0.15s;
  white-space: nowrap;
}
#chat-quick-btns button:hover {
  background: var(--accent-light);
  border-color: var(--accent);
}

/* ── Input Area ── */
#chat-input-area {
  display: flex;
  align-items: flex-end;
  gap: 8px;
  padding: 10px 14px 14px;
  border-top: 1px solid var(--border);
  flex-shrink: 0;
  background: var(--bg2);
}
#chat-input {
  flex: 1;
  border: 1.5px solid var(--border2);
  border-radius: 10px;
  padding: 9px 12px;
  font-size: 13px;
  font-family: var(--font);
  color: var(--text);
  background: var(--bg3);
  resize: none;
  outline: none;
  line-height: 1.5;
  transition: border-color 0.15s;
  min-height: 38px;
  max-height: 120px;
}
#chat-input:focus {
  border-color: var(--accent);
  background: white;
}
#chat-input::placeholder { color: var(--text3); }
#chat-send-btn {
  width: 38px;
  height: 38px;
  border-radius: 10px;
  background: var(--accent);
  color: white;
  border: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: background 0.15s, transform 0.1s;
}
#chat-send-btn:hover { background: var(--accent2); transform: scale(1.05); }
#chat-send-btn:disabled { background: var(--text3); cursor: not-allowed; transform: none; }

/* ── Mobile responsive ── */
@media (max-width: 480px) {
  #chat-window {
    right: 12px;
    bottom: 88px;
    width: calc(100vw - 24px);
    height: calc(100vh - 110px);
    max-height: none;
  }
  #chat-fab {
    bottom: 20px;
    right: 16px;
    width: 50px;
    height: 50px;
    font-size: 20px;
  }
}
