:root {
  --bg: #eaf7ff;
  --panel: rgba(255, 255, 255, 0.68);
  --panel-strong: #ffffff;
  --ink: #0b2436;
  --muted: #5b7283;
  --line: rgba(125, 185, 220, 0.34);
  --line-strong: rgba(14, 116, 144, 0.28);
  --gold: #38bdf8;
  --gold-dark: #0369a1;
  --green: #0f9f8f;
  --red: #e05252;
  --blue: #0284c7;
  --glass: rgba(255, 255, 255, 0.62);
  --shadow: 0 24px 70px rgba(2, 84, 128, 0.16);
  --radius: 14px;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background:
    radial-gradient(circle at 8% 8%, rgba(56, 189, 248, 0.28), transparent 30%),
    radial-gradient(circle at 92% 4%, rgba(20, 184, 166, 0.18), transparent 28%),
    linear-gradient(135deg, #f8fdff 0%, #eaf7ff 48%, #dff4ff 100%);
  color: var(--ink);
  font-family: "Noto Sans Thai", system-ui, sans-serif;
}

button,
input,
select,
textarea {
  font: inherit;
}

button {
  cursor: pointer;
}

.app-shell {
  display: grid;
  grid-template-columns: 280px minmax(0, 1fr);
  min-height: 100vh;
}

.sidebar {
  position: sticky;
  top: 0;
  display: flex;
  flex-direction: column;
  gap: 22px;
  height: 100vh;
  padding: 22px;
  background: linear-gradient(180deg, rgba(9, 57, 86, 0.82), rgba(5, 31, 48, 0.72));
  color: #f4fbff;
  border-right: 1px solid rgba(255, 255, 255, 0.24);
  box-shadow: 18px 0 54px rgba(2, 84, 128, 0.13);
  backdrop-filter: blur(22px);
  overflow-y: auto;
}

.brand,
.user-panel,
.metric,
.panel,
.product-card,
.cart-box,
.table-wrap,
.modal-like {
  border-radius: var(--radius);
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
}

.brand-mark {
  display: grid;
  place-items: center;
  width: 44px;
  height: 44px;
  background: linear-gradient(135deg, #ffffff, #7dd3fc);
  color: #075985;
  font-weight: 800;
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.58), 0 12px 26px rgba(14, 165, 233, 0.24);
}

.brand strong {
  display: block;
  font-size: 20px;
  line-height: 1.1;
}

.brand span,
.user-panel label,
.role-chip,
.eyebrow,
.hint,
.small,
td small {
  color: var(--muted);
  font-size: 13px;
}

.sidebar .brand span,
.sidebar .user-panel label {
  color: #c9ecff;
}

.nav {
  display: grid;
  gap: 6px;
}

.nav button {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 100%;
  min-height: 42px;
  padding: 9px 11px;
  border: 1px solid transparent;
  border-radius: var(--radius);
  background: transparent;
  color: #f4fbff;
  text-align: left;
}

.nav button.active,
.nav button:hover {
  border-color: rgba(186, 230, 253, 0.42);
  background: rgba(255, 255, 255, 0.16);
}

.nav kbd {
  min-width: 22px;
  padding: 2px 6px;
  border-radius: 99px;
  background: rgba(224, 242, 254, 0.18);
  color: #bae6fd;
  font-size: 11px;
  text-align: center;
}

.user-panel {
  display: grid;
  gap: 8px;
  margin-top: auto;
  padding: 14px;
  background: rgba(255, 255, 255, 0.14);
  border: 1px solid rgba(255, 255, 255, 0.18);
  backdrop-filter: blur(16px);
}

.user-panel select,
.field input,
.field select,
.field textarea,
.search {
  width: 100%;
  min-height: 42px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: rgba(255, 255, 255, 0.76);
  color: var(--ink);
  padding: 9px 11px;
  outline: none;
}

.user-panel select {
  border-color: rgba(224, 242, 254, 0.32);
  background: rgba(7, 89, 133, 0.42);
  color: #f4fbff;
}

.role-chip {
  color: #bae6fd;
}

.main {
  min-width: 0;
  padding: 26px;
}

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

.eyebrow {
  margin: 0 0 4px;
  color: var(--blue);
  font-weight: 700;
  letter-spacing: 0;
}

h1,
h2,
h3,
p {
  margin-top: 0;
}

h1 {
  margin-bottom: 0;
  font-size: clamp(28px, 4vw, 44px);
  line-height: 1.12;
}

h2 {
  margin-bottom: 14px;
  font-size: 22px;
}

h3 {
  margin-bottom: 8px;
  font-size: 17px;
}

.top-actions,
.row,
.tabs,
.button-row,
.summary-row {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.primary-btn,
.ghost-btn,
.danger-btn,
.mini-btn,
.icon-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 40px;
  border-radius: var(--radius);
  padding: 8px 13px;
  border: 1px solid transparent;
  font-weight: 700;
}

.primary-btn {
  background: linear-gradient(135deg, #0284c7, #0f766e);
  color: #f8fdff;
  box-shadow: 0 14px 28px rgba(2, 132, 199, 0.22);
}

.ghost-btn {
  border-color: var(--line-strong);
  background: rgba(255, 255, 255, 0.55);
  color: var(--ink);
  backdrop-filter: blur(12px);
}

.danger-btn {
  background: rgba(255, 244, 242, 0.84);
  color: var(--red);
  border-color: #f2cbc5;
}

.mini-btn,
.icon-btn {
  min-height: 34px;
  padding: 6px 10px;
  background: rgba(255, 255, 255, 0.72);
  border-color: var(--line);
  color: var(--ink);
}

.icon-btn {
  width: 36px;
  padding: 0;
}

.view {
  display: none;
}

.view.active {
  display: block;
}

.grid {
  display: grid;
  gap: 16px;
}

.grid.two {
  grid-template-columns: minmax(0, 1fr) minmax(320px, 0.45fr);
  align-items: start;
}

.grid.three {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

.grid.four {
  grid-template-columns: repeat(4, minmax(0, 1fr));
}

.module-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(210px, 1fr));
  gap: 12px;
}

.module-card {
  display: grid;
  gap: 8px;
  min-height: 118px;
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.72), rgba(224, 242, 254, 0.55));
  color: var(--ink);
  text-align: left;
  box-shadow: 0 12px 34px rgba(42, 32, 22, 0.1);
}

.module-card:hover {
  border-color: var(--gold);
  transform: translateY(-1px);
}

.module-card strong {
  font-size: 18px;
}

.module-card span {
  color: var(--muted);
  font-size: 13px;
  line-height: 1.5;
}

.panel,
.metric,
.product-card,
.cart-box,
.table-wrap,
.modal-like {
  border: 1px solid var(--line);
  background: var(--glass);
  box-shadow: var(--shadow);
  backdrop-filter: blur(22px) saturate(132%);
}

.panel,
.table-wrap,
.modal-like {
  padding: 18px;
}

.metric {
  padding: 16px;
}

.metric span {
  color: var(--muted);
  font-size: 13px;
}

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

.metric em {
  display: block;
  margin-top: 8px;
  color: var(--green);
  font-size: 13px;
  font-style: normal;
  font-weight: 700;
}

.field {
  display: grid;
  gap: 6px;
}

.field label {
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
}

.form-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
}

.form-grid .full {
  grid-column: 1 / -1;
}

.product-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(210px, 1fr));
  gap: 14px;
}

.product-card {
  overflow: hidden;
}

.product-image {
  display: block;
  width: 100%;
  aspect-ratio: 4 / 3;
  object-fit: cover;
  background: #e0f2fe;
}

.product-body {
  display: grid;
  gap: 9px;
  padding: 13px;
}

.price-line {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 10px;
}

.price {
  color: var(--blue);
  font-size: 22px;
  font-weight: 800;
}

.badge {
  display: inline-flex;
  align-items: center;
  min-height: 26px;
  padding: 3px 9px;
  border-radius: 999px;
  background: rgba(224, 242, 254, 0.82);
  color: #075985;
  font-size: 12px;
  font-weight: 800;
}

.badge.green {
  background: rgba(204, 251, 241, 0.72);
  color: var(--green);
}

.badge.blue {
  background: rgba(186, 230, 253, 0.88);
  color: #075985;
}

.badge.red {
  background: rgba(254, 226, 226, 0.8);
  color: var(--red);
}

.cart-box {
  position: sticky;
  top: 22px;
  padding: 16px;
}

.cart-list {
  display: grid;
  gap: 10px;
  margin: 12px 0;
}

.cart-item {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 8px;
  padding-bottom: 10px;
  border-bottom: 1px solid var(--line);
}

.qty {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.qty button {
  width: 28px;
  height: 28px;
  border: 1px solid var(--line);
  border-radius: 99px;
  background: rgba(255, 255, 255, 0.76);
}

.summary-row {
  justify-content: space-between;
  margin-top: 8px;
}

.summary-row.total {
  margin-top: 12px;
  padding-top: 12px;
  border-top: 1px solid var(--line-strong);
  font-size: 20px;
  font-weight: 800;
}

table {
  width: 100%;
  border-collapse: collapse;
}

th,
td {
  padding: 11px 10px;
  border-bottom: 1px solid var(--line);
  text-align: left;
  vertical-align: top;
}

th {
  color: var(--muted);
  font-size: 12px;
  text-transform: uppercase;
}

tr:last-child td {
  border-bottom: 0;
}

.table-wrap {
  overflow-x: auto;
}

.tabs {
  margin-bottom: 14px;
}

.tabs button {
  min-height: 38px;
  padding: 7px 12px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.68);
  color: var(--muted);
  font-weight: 800;
}

.tabs button.active {
  background: #0284c7;
  color: #f8fdff;
}

.bar-list {
  display: grid;
  gap: 12px;
}

.bar-item {
  display: grid;
  gap: 5px;
}

.bar-head {
  display: flex;
  justify-content: space-between;
  gap: 12px;
}

.bar-track {
  height: 10px;
  border-radius: 99px;
  background: rgba(186, 230, 253, 0.58);
  overflow: hidden;
}

.bar-fill {
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, #0284c7, #38bdf8, #14b8a6);
}

.analytics-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.2fr) minmax(320px, 0.8fr);
  gap: 16px;
}

.chart-panel {
  overflow: hidden;
}

.chart-head {
  display: flex;
  justify-content: space-between;
  gap: 14px;
  align-items: flex-start;
  margin-bottom: 8px;
}

.line-chart,
.donut-chart {
  width: 100%;
  display: block;
}

.line-chart text,
.donut-chart text {
  fill: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

.donut-wrap {
  display: grid;
  grid-template-columns: 170px minmax(0, 1fr);
  gap: 16px;
  align-items: center;
}

.donut-chart {
  transform: rotate(-90deg);
}

.donut-chart text {
  transform: rotate(90deg);
  transform-origin: 50px 50px;
}

.legend-list {
  display: grid;
  gap: 9px;
}

.legend-item {
  display: grid;
  grid-template-columns: 12px minmax(0, 1fr) auto;
  gap: 8px;
  align-items: center;
  color: var(--muted);
  font-size: 13px;
}

.legend-item span {
  width: 12px;
  height: 12px;
  border-radius: 99px;
}

.legend-item strong {
  color: var(--ink);
}

.legend-item em {
  font-style: normal;
  font-weight: 800;
  color: var(--blue);
}

.insight-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 12px;
  margin-top: 12px;
}

.insight-card {
  min-height: 118px;
  padding: 14px;
  border: 1px solid rgba(125, 185, 220, 0.34);
  border-radius: var(--radius);
  background: rgba(255, 255, 255, 0.48);
  box-shadow: 0 14px 34px rgba(2, 84, 128, 0.1);
  backdrop-filter: blur(18px);
}

.insight-card span {
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}

.insight-card strong {
  display: block;
  margin-top: 7px;
  color: var(--blue);
  font-size: 21px;
}

.insight-card p {
  margin: 5px 0 0;
  color: var(--muted);
  font-size: 13px;
}

.access-panel {
  display: grid;
  grid-template-columns: minmax(220px, 0.35fr) minmax(0, 1fr);
  gap: 16px;
  align-items: start;
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: rgba(255, 255, 255, 0.5);
  box-shadow: var(--shadow);
  backdrop-filter: blur(18px);
}

.access-panel h2 {
  margin-bottom: 4px;
}

.access-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(190px, 1fr));
  gap: 10px;
}

.access-item {
  min-height: 82px;
  padding: 12px;
  border: 1px solid rgba(125, 185, 220, 0.28);
  border-radius: var(--radius);
  background: rgba(255, 255, 255, 0.42);
}

.access-item span {
  display: block;
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}

.access-item strong {
  display: block;
  margin-top: 7px;
  color: var(--ink);
  font-size: 14px;
  line-height: 1.45;
}

.status-flow {
  display: flex;
  gap: 7px;
  flex-wrap: wrap;
}

.toast {
  position: fixed;
  right: 20px;
  bottom: 20px;
  z-index: 20;
  max-width: 360px;
  padding: 12px 14px;
  border: 1px solid rgba(23, 21, 19, 0.12);
  border-radius: var(--radius);
  background: rgba(8, 47, 73, 0.9);
  color: #f8fdff;
  backdrop-filter: blur(16px);
  box-shadow: var(--shadow);
  opacity: 0;
  transform: translateY(10px);
  pointer-events: none;
  transition: 0.2s ease;
}

.toast.show {
  opacity: 1;
  transform: translateY(0);
}

.empty {
  padding: 18px;
  border: 1px dashed var(--line-strong);
  border-radius: var(--radius);
  color: var(--muted);
  text-align: center;
}

@media (max-width: 1040px) {
  .app-shell {
    grid-template-columns: 1fr;
  }

  .sidebar {
    position: static;
    height: auto;
  }

  .nav {
    grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  }

  .user-panel {
    margin-top: 0;
  }

  .grid.two,
  .grid.three,
  .grid.four,
  .analytics-grid,
  .access-panel {
    grid-template-columns: 1fr;
  }

  .insight-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .cart-box {
    position: static;
  }
}

@media (max-width: 680px) {
  .main,
  .sidebar {
    padding: 16px;
  }

  .topbar {
    display: grid;
  }

  .top-actions,
  .button-row {
    width: 100%;
  }

  .top-actions button,
  .button-row button {
    flex: 1;
  }

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

  .donut-wrap,
  .insight-grid {
    grid-template-columns: 1fr;
  }

  th,
  td {
    padding: 9px 8px;
  }
}
