@import url('https://fonts.googleapis.com/css2?family=IBM+Plex+Sans+Thai:wght@400;500;600;700&family=Inter:wght@400;500;600;700&family=JetBrains+Mono:wght@400;500;600;700&display=swap');

:root {
  --teal-50: #effaf7;
  --teal-100: #d5f1e8;
  --teal-200: #aee3d3;
  --teal-300: #7accb9;
  --teal-500: #1f9683;
  --teal-600: #0f766e;
  --teal-700: #0c5e58;
  --teal-800: #0a4a45;
  --teal-900: #07332f;
  --ink-900: #0d1417;
  --ink-800: #1a242a;
  --ink-700: #2c3a42;
  --ink-600: #455761;
  --ink-500: #67767f;
  --ink-400: #94a1a8;
  --ink-300: #c6cdd1;
  --ink-200: #e3e7ea;
  --ink-150: #eef1f3;
  --ink-100: #f5f7f8;
  --ink-50: #fafbfc;
  --white: #ffffff;
  --ok: #16a34a;
  --ok-bg: #dcfce7;
  --warn: #d97706;
  --warn-bg: #fef3c7;
  --danger: #dc2626;
  --danger-bg: #fee2e2;
  --info: #2563eb;
  --info-bg: #dbeafe;
  --purple: #7c3aed;
  --purple-bg: #ede9fe;
  --sidebar-width: 232px;
  --radius: 12px;
  --shadow-1: 0 1px 2px rgba(13, 20, 23, .04), 0 1px 1px rgba(13, 20, 23, .02);
  --shadow-2: 0 4px 12px rgba(13, 20, 23, .06), 0 1px 2px rgba(13, 20, 23, .04);
  --font-sans: "Inter", "IBM Plex Sans Thai", "Kanit", "Segoe UI", sans-serif;
  --font-mono: "JetBrains Mono", "SF Mono", ui-monospace, monospace;
}

* { box-sizing: border-box; }

html, body { min-height: 100%; }

body {
  margin: 0;
  background: var(--ink-100) !important;
  color: var(--ink-900);
  font-family: var(--font-sans);
  font-size: 14px;
  font-feature-settings: "cv11", "ss01";
  -webkit-font-smoothing: antialiased;
}

a { color: inherit; }
button, input, select, textarea { font-family: inherit; }

.mono { font-family: var(--font-mono); letter-spacing: -0.01em; }

.sidebar {
  position: fixed;
  inset: 0 auto 0 0;
  width: var(--sidebar-width);
  z-index: 300;
  display: flex;
  flex-direction: column;
  color: white;
  background: #1E4B42;
  border-right: 1px solid rgba(255, 255, 255, .08);
  box-shadow: 0 12px 36px rgba(7, 51, 47, .2);
}

.sb-brand {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 20px 18px 16px;
  color: white;
  text-decoration: none;
}

.sb-brand:hover {
  color: white;
  text-decoration: none;
}

.sb-brand-icon {
  width: 34px;
  height: 34px;
  display: grid;
  place-items: center;
  border-radius: 9px;
  background: rgba(255, 255, 255, .15);
  border: 1px solid rgba(255, 255, 255, .2);
  box-shadow: 0 4px 10px rgba(0, 0, 0, .18);
  font-size: 28px;
  font-weight: 400;
  line-height: 1;
}

.sb-brand-text {
  color: white;
  font-size: 16px;
  font-weight: 700;
  line-height: 1.1;
}

.sb-brand-sub {
  margin-top: 1px;
  color: rgba(255, 255, 255, .65);
  font-size: 11px;
  font-weight: 600;
}

.sb-nav {
  flex: 1;
  overflow-y: auto;
  padding: 4px 10px;
}

.sb-nav::-webkit-scrollbar { width: 6px; }
.sb-nav::-webkit-scrollbar-thumb { background: rgba(255, 255, 255, .18); border-radius: 999px; }

.sb-section {
  padding: 14px 10px 6px;
  color: rgba(255, 255, 255, .55);
  font-size: 10px;
  font-weight: 700;
  letter-spacing: .06em;
  text-transform: uppercase;
}

.sb-item {
  position: relative;
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 38px;
  margin-bottom: 2px;
  padding: 8px 10px;
  border-radius: 8px;
  color: rgba(255, 255, 255, .78);
  text-decoration: none;
  font-size: 14px;
  font-weight: 600;
  transition: background .15s, color .15s, transform .15s;
}

.sb-item:hover {
  color: white;
  background: rgba(255, 255, 255, .1);
  text-decoration: none;
}

.sb-item.active {
  color: white;
  background: rgba(255, 255, 255, .18);
}

.sb-item.active::before {
  content: "";
  position: absolute;
  left: -10px;
  top: 6px;
  bottom: 6px;
  width: 3px;
  border-radius: 0 3px 3px 0;
  background: #5eead4;
}

.si {
  width: 20px;
  height: 20px;
  display: grid;
  place-items: center;
  flex: 0 0 20px;
  color: rgba(255, 255, 255, .72);
}

.si svg {
  width: 19px;
  height: 19px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.sb-item.active .si { color: white; }
.sb-item-text { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.sb-category {
  min-height: 44px;
  margin-bottom: 7px;
  padding: 10px 12px;
  font-size: 15px;
}

.sb-badge {
  padding: 2px 7px;
  border-radius: 999px;
  background: rgba(255, 255, 255, .22);
  color: white;
  font-size: 11px;
  font-weight: 700;
  line-height: 1.4;
}

.sb-badge.warn {
  background: #fef3c7;
  color: #92400e;
}

.sb-user {
  display: flex;
  align-items: center;
  gap: 10px;
  margin: 10px;
  padding: 12px;
  border-radius: 12px;
  background: rgba(0, 0, 0, .18);
  border: 1px solid rgba(255, 255, 255, .08);
}

.sb-user-avatar {
  width: 36px;
  height: 36px;
  display: grid;
  place-items: center;
  flex: 0 0 36px;
  border-radius: 10px;
  background: linear-gradient(135deg, #fbbf24, #f59e0b);
  color: white;
  font-size: 13px;
  font-weight: 700;
}

.sb-user-meta { min-width: 0; flex: 1; }
.sb-user-name { overflow: hidden; color: white; font-size: 12px; font-weight: 700; text-overflow: ellipsis; white-space: nowrap; }
.sb-user-role { margin-top: 1px; color: rgba(255, 255, 255, .62); font-size: 10px; }
.sb-user-arrow { color: rgba(255, 255, 255, .55); font-size: 22px; line-height: 1; }

.sb-logout {
  width: 30px;
  height: 30px;
  display: grid;
  place-items: center;
  flex: 0 0 30px;
  border: 1px solid rgba(255, 255, 255, .1);
  border-radius: 9px;
  background: rgba(255, 255, 255, .06);
  color: rgba(255, 255, 255, .72);
  cursor: pointer;
}

.sb-logout:hover {
  background: rgba(255, 255, 255, .14);
  color: white;
}

.sb-logout svg {
  width: 17px;
  height: 17px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.9;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.readonly-disabled {
  cursor: not-allowed !important;
  opacity: .55 !important;
}

.mobile-menu-btn,
.sidebar-backdrop { display: none; }

.main-wrap {
  min-height: 100vh;
  margin-left: var(--sidebar-width);
  display: flex;
  flex-direction: column;
}

.subnav-tabs {
  position: sticky;
  top: 74px;
  z-index: 95;
  background: rgba(255, 255, 255, .96);
  border-bottom: 1px solid var(--ink-200);
  backdrop-filter: blur(10px);
}

.subnav-tabs-inner {
  display: flex;
  align-items: center;
  gap: 8px;
  max-width: 100%;
  min-height: 54px;
  padding: 8px 24px;
  overflow-x: auto;
  overflow-y: hidden;
  scrollbar-width: thin;
}

.subnav-tabs-inner::-webkit-scrollbar { height: 5px; }
.subnav-tabs-inner::-webkit-scrollbar-thumb { background: var(--ink-300); border-radius: 999px; }

.subnav-title {
  flex: 0 0 auto;
  margin-right: 4px;
  color: var(--ink-500);
  font-size: 12px;
  font-weight: 800;
  white-space: nowrap;
}

.subnav-tab {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  min-height: 36px;
  padding: 7px 12px;
  border: 1px solid var(--ink-200);
  border-radius: 999px;
  background: var(--white);
  color: var(--ink-600);
  text-decoration: none;
  font-size: 13px;
  font-weight: 700;
  white-space: nowrap;
  transition: background .15s, border-color .15s, color .15s;
}

.subnav-tab:hover {
  border-color: var(--teal-200);
  color: var(--teal-700);
  text-decoration: none;
}

.subnav-tab.active {
  border-color: var(--teal-600);
  background: var(--teal-600);
  color: white;
}

.subnav-icon {
  width: 16px;
  height: 16px;
  display: grid;
  place-items: center;
  flex: 0 0 16px;
}

.subnav-icon svg {
  width: 15px;
  height: 15px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.9;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.home-shortcut-btn {
  position: fixed;
  right: 18px;
  bottom: 18px;
  z-index: 210;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-height: 42px;
  padding: 9px 13px;
  border: 1px solid var(--ink-200);
  border-radius: 999px;
  background: white;
  color: var(--ink-800);
  box-shadow: var(--shadow-2);
  text-decoration: none;
  font-size: 13px;
  font-weight: 800;
}

.home-shortcut-btn:hover {
  color: var(--teal-700);
  text-decoration: none;
}

.home-shortcut-btn svg {
  width: 18px;
  height: 18px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.9;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.topbar,
.topbar-warehouse {
  min-height: 74px !important;
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 14px 24px !important;
  position: sticky;
  top: 0;
  z-index: 100;
  background: white !important;
  color: var(--ink-900) !important;
  border-bottom: 1px solid var(--ink-200);
  box-shadow: none !important;
}

.topbar-title {
  margin: 0;
  color: var(--ink-900) !important;
  font-size: 20px !important;
  font-weight: 800 !important;
  letter-spacing: 0 !important;
  line-height: 1.15;
}

.topbar-subtitle,
.topbar-time {
  color: var(--ink-500) !important;
  font-size: 12px;
  background: transparent !important;
  padding: 0 !important;
}

.topbar-spacer { flex: 1; }

.topbar-search {
  width: min(420px, 34vw);
  position: relative;
}

.topbar-search input {
  width: 100%;
  height: 40px;
  border: 1px solid var(--ink-200);
  border-radius: 10px;
  background: var(--ink-100);
  color: var(--ink-800);
  padding: 0 44px 0 38px;
  outline: none;
  font-size: 13px;
}

.topbar-search::before {
  content: "⌕";
  position: absolute;
  left: 14px;
  top: 50%;
  transform: translateY(-52%);
  color: var(--ink-400);
  font-size: 24px;
}

.topbar-kbd {
  position: absolute;
  right: 9px;
  top: 50%;
  transform: translateY(-50%);
  min-width: 24px;
  height: 20px;
  display: grid;
  place-items: center;
  border: 1px solid var(--ink-200);
  border-radius: 5px;
  background: white;
  color: var(--ink-500);
  font-family: var(--font-mono);
  font-size: 10px;
  font-weight: 700;
}

.topbar-user {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 5px 10px;
  border-radius: 10px;
  background: var(--ink-50) !important;
  border: 1px solid var(--ink-200) !important;
}

.topbar-user-avatar {
  width: 30px;
  height: 30px;
  display: grid;
  place-items: center;
  border-radius: 9px;
  background: #fbbf24 !important;
  color: white !important;
  font-size: 12px;
  font-weight: 800;
}

.topbar-user-name { color: var(--ink-700) !important; font-size: 13px !important; font-weight: 700; }

.page-content {
  flex: 1;
  padding: 20px 24px 32px;
}

.page-header { margin-bottom: 18px; }
.page-header h2 { margin: 0; color: var(--ink-900); font-size: 24px; font-weight: 800; letter-spacing: 0; }
.page-header p { margin: 4px 0 0; color: var(--ink-500); font-size: 13px; }

.content-card,
.content-card-po,
.section-card,
.card,
.stat-card,
.stat-card-po {
  background: white;
  border: 1px solid var(--ink-200) !important;
  border-radius: var(--radius) !important;
  box-shadow: var(--shadow-1) !important;
}

.content-card,
.content-card-po,
.section-card { padding: 18px; }

.stat-card,
.stat-card-po { padding: 16px; }
.stat-label { color: var(--ink-500); font-size: 12px; font-weight: 600; }
.stat-value { color: var(--ink-900); font-size: 26px; font-weight: 800; }

.btn,
.btn-clear,
.btn-export {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  min-height: 38px;
  border-radius: 10px !important;
  border: 1px solid var(--ink-200);
  background: white;
  color: var(--ink-700);
  font-size: 13px !important;
  font-weight: 700 !important;
  box-shadow: none !important;
}

.btn:hover,
.btn-clear:hover {
  background: var(--ink-100);
  color: var(--ink-900);
  border-color: var(--ink-300);
}

.btn-primary,
.btn-success {
  background: var(--teal-600) !important;
  border-color: var(--teal-600) !important;
  color: white !important;
}

.btn-primary:hover,
.btn-success:hover { background: var(--teal-700) !important; }

.filter-label {
  display: block;
  margin-bottom: 6px;
  color: var(--ink-500);
  font-size: 12px;
  font-weight: 700;
}

.filter-select,
.form-select,
.form-control {
  border: 1px solid var(--ink-200) !important;
  border-radius: 10px !important;
  background-color: white !important;
  color: var(--ink-800) !important;
  font-size: 13px !important;
  outline: none !important;
}

.filter-select:focus,
.form-select:focus,
.form-control:focus {
  border-color: var(--teal-500) !important;
  box-shadow: 0 0 0 3px rgba(31, 150, 131, .14) !important;
}

.table {
  color: var(--ink-800);
  font-size: 13px;
}

.table thead th {
  padding: 10px 14px !important;
  background: var(--ink-50) !important;
  color: var(--ink-500) !important;
  border-bottom: 1px solid var(--ink-200) !important;
  font-size: 11px !important;
  font-weight: 800 !important;
  letter-spacing: .04em;
  text-transform: uppercase;
}

.table tbody td {
  padding: 12px 14px !important;
  color: var(--ink-700);
  border-bottom: 1px solid var(--ink-150) !important;
  vertical-align: middle;
}

.table-hover tbody tr:hover td,
.clickable-row:hover td {
  background: var(--teal-50) !important;
}

.chip {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 3px 8px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 800;
  line-height: 1.4;
  white-space: nowrap;
}

.chip-ok { background: var(--ok-bg); color: #166534; }
.chip-warn { background: var(--warn-bg); color: #92400e; }
.chip-danger { background: var(--danger-bg); color: #991b1b; }
.chip-info { background: var(--info-bg); color: #1e40af; }
.chip-teal { background: var(--teal-100); color: var(--teal-800); }
.chip-purple { background: var(--purple-bg); color: #5b21b6; }
.chip-gray { background: var(--ink-150); color: var(--ink-700); }

.shortcut-tabs,
.sub-tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  margin-bottom: 18px;
  border-bottom: 1px solid var(--ink-200);
}

.shortcut-tab,
.sub-tab {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 10px 16px;
  margin-bottom: -1px;
  border: 1px solid transparent;
  border-bottom: none;
  border-radius: 10px 10px 0 0;
  background: transparent;
  color: var(--ink-500);
  text-decoration: none;
  font-size: 13px !important;
  font-weight: 800;
}

.shortcut-tab:hover,
.sub-tab:hover { color: var(--ink-900); background: var(--ink-50); text-decoration: none; }

.shortcut-tab.active,
.sub-tab.active {
  background: white;
  color: var(--teal-700);
  border-color: var(--ink-200);
  box-shadow: var(--shadow-1);
}

.chart-tab.active {
  background: var(--teal-600);
  color: white;
  border-color: var(--teal-600);
}

.progress-bar-bg {
  width: 76px;
  height: 5px;
  border-radius: 99px;
  background: var(--ink-150);
  overflow: hidden;
}

.progress-bar-fill {
  height: 100%;
  border-radius: inherit;
  background: var(--teal-500);
}

@media (max-width: 1024px) {
  :root { --sidebar-width: 72px; }
  .sidebar { width: var(--sidebar-width); }
  .sb-brand { justify-content: center; padding-left: 10px; padding-right: 10px; }
  .sb-brand > div:not(.sb-brand-icon),
  .sb-section,
  .sb-item-text,
  .sb-badge,
  .sb-user { display: none; }
  .sb-item { justify-content: center; padding: 10px; }
  .sb-item.active::before { left: -10px; }
  .topbar-search { display: none; }
}

@media (max-width: 760px) {
  :root { --sidebar-width: 232px; }
  .main-wrap { margin-left: 0; }
  .sidebar {
    transform: translateX(-102%);
    transition: transform .2s ease;
  }
  body.sidebar-open .sidebar { transform: translateX(0); }
  body.sidebar-open .sidebar-backdrop {
    display: block;
    position: fixed;
    inset: 0;
    z-index: 250;
    background: rgba(13, 20, 23, .45);
  }
  .mobile-menu-btn {
    position: fixed;
    left: 12px;
    top: 12px;
    z-index: 220;
    width: 42px;
    height: 42px;
    display: grid;
    place-items: center;
    border: 1px solid var(--ink-200);
    border-radius: 12px;
    background: white;
    color: var(--ink-800);
    box-shadow: var(--shadow-2);
  }
  .mobile-menu-btn svg {
    width: 21px;
    height: 21px;
    fill: none;
    stroke: currentColor;
    stroke-width: 1.8;
    stroke-linecap: round;
  }
  .topbar,
  .topbar-warehouse {
    min-height: 66px !important;
    padding-left: 66px !important;
    padding-right: 14px !important;
  }
  .subnav-tabs {
    top: 66px;
  }
  .subnav-tabs-inner {
    min-height: 50px;
    padding: 7px 14px 7px 66px;
  }
  .subnav-title {
    display: none;
  }
  .subnav-tab {
    min-height: 34px;
    padding: 7px 11px;
    font-size: 12px;
  }
  .home-shortcut-btn {
    right: 12px;
    bottom: 12px;
    min-height: 40px;
    padding: 8px 11px;
    font-size: 12px;
  }
  .topbar-title { font-size: 18px !important; }
  .topbar-time,
  .topbar-user-name { display: none; }
  .page-content { padding: 16px 14px 28px; }
}
