:root {
  --navy: #143c66;
  --blue: #2563eb;
  --ink: #0f172a;
  --muted: #64748b;
  --line: #e2e8f0;
  --bg: #f6f8fb;
}
* { box-sizing: border-box; }
body {
  margin: 0;
  font-family: "Sarabun", system-ui, sans-serif;
  color: var(--ink);
  background: var(--bg);
}
.app-shell { min-height: 100vh; display: grid; grid-template-columns: 260px 1fr; }
.sidebar {
  background: #0f2f50;
  color: #fff;
  padding: 24px 18px;
  position: sticky;
  top: 0;
  height: 100vh;
}
.brand { display: flex; align-items: center; gap: 10px; font-weight: 700; color: inherit; }
.brand-logo {
  width: 38px;
  height: 38px;
  object-fit: cover;
  border-radius: 50%;
  border: 2px solid #d8eee5;
  background: #2f211e;
  flex: 0 0 auto;
}
.brand-mark {
  display: inline-grid;
  place-items: center;
  width: 46px;
  height: 34px;
  border-radius: 8px;
  background: #fff;
  color: var(--navy);
  font-size: 14px;
  letter-spacing: 0;
}
.brand-login { color: var(--ink); justify-content: center; margin-bottom: 18px; }
.shop-logo {
  display: block;
  width: 92px;
  height: 92px;
  object-fit: cover;
  border-radius: 50%;
  border: 4px solid #d8eee5;
  background: #2f211e;
  box-shadow: 0 12px 28px rgba(47, 33, 30, .14);
}
.shop-logo-card {
  margin: 0 auto 14px;
}
.shop-logo-row {
  display: flex;
  align-items: center;
  gap: 14px;
}
.shop-logo-row .shop-logo {
  width: 74px;
  height: 74px;
  flex: 0 0 auto;
}
.sidebar nav { display: grid; gap: 6px; margin-top: 28px; }
.sidebar a {
  color: #dbeafe;
  text-decoration: none;
  padding: 11px 12px;
  border-radius: 8px;
  display: flex;
  gap: 10px;
  align-items: center;
}
.sidebar a:hover { background: rgba(255,255,255,.12); color: #fff; }
.nav-icon {
  display: inline-grid;
  place-items: center;
  width: 22px;
  height: 22px;
  flex: 0 0 22px;
  border: 1px solid rgba(219, 234, 254, .55);
  border-radius: 6px;
  color: #fff;
  font-size: 11px;
  font-weight: 700;
  line-height: 1;
}
.main { min-width: 0; }
.topbar {
  min-height: 82px;
  background: #fff;
  border-bottom: 1px solid var(--line);
  padding: 16px 28px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 16px;
}
.topbar h1 { font-size: 24px; margin: 0; font-weight: 700; }
.content { padding: 24px 28px; }
.user-chip { border: 1px solid var(--line); border-radius: 999px; padding: 8px 12px; background: #fff; }
.panel, .stat-card, .login-card, .track-card, .tracking-card, .empty-state {
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: 0 8px 24px rgba(15, 23, 42, .05);
}
.panel { padding: 20px; }
.panel h2 { font-size: 18px; font-weight: 700; margin: 0 0 16px; }
.stat-grid { display: grid; grid-template-columns: repeat(6, minmax(0, 1fr)); gap: 14px; }
.stat-card { padding: 18px; display: grid; gap: 6px; min-height: 120px; }
.stat-symbol {
  display: inline-grid;
  place-items: center;
  width: 42px;
  height: 28px;
  border: 1px solid currentColor;
  border-radius: 7px;
  font-size: 11px;
  font-weight: 700;
  line-height: 1;
}
.stat-card span { color: var(--muted); }
.stat-card .stat-symbol.text-primary { color: #2563eb; }
.stat-card .stat-symbol.text-info { color: #0891b2; }
.stat-card .stat-symbol.text-warning { color: #d97706; }
.stat-card .stat-symbol.text-success { color: #059669; }
.stat-card .stat-symbol.text-danger { color: #dc2626; }
.stat-card .stat-symbol.text-secondary { color: #64748b; }
.stat-card strong { font-size: 28px; line-height: 1; }
.bar-chart { display: grid; gap: 10px; }
.bar-row { display: grid; grid-template-columns: 110px 1fr 38px; gap: 10px; align-items: center; }
.bar-row div { background: #e2e8f0; height: 12px; border-radius: 999px; overflow: hidden; }
.bar-row b { display: block; height: 100%; background: var(--blue); border-radius: 999px; }
.login-page, .public-wrap {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
  background: linear-gradient(160deg, #eef6ff 0%, #ffffff 45%, #f4f8fb 100%);
}
.public-list-page {
  min-height: 100vh;
  padding: 28px;
  background: linear-gradient(160deg, #eef6ff 0%, #ffffff 45%, #f4f8fb 100%);
}
.public-list-panel {
  width: min(100%, 1040px);
  margin: 0 auto;
  padding: 24px;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: 0 8px 24px rgba(15, 23, 42, .05);
}
.public-list-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-end;
  gap: 18px;
  margin-bottom: 18px;
}
.public-list-header h1 {
  font-size: 28px;
  font-weight: 700;
  margin: 18px 0 4px;
}
.public-list-header p {
  color: var(--muted);
  margin: 0;
}
.daily-date-form {
  min-width: min(100%, 360px);
}
.tracking-link {
  color: var(--blue);
  font-weight: 700;
  text-decoration: none;
}
.tracking-link:hover { text-decoration: underline; }
.public-list-actions {
  display: flex;
  justify-content: flex-end;
  margin-top: 16px;
}
.login-card, .track-card, .tracking-card, .empty-state { width: min(100%, 440px); padding: 28px; }
.login-card h1, .track-card h1 { text-align: center; font-size: 26px; font-weight: 700; margin-bottom: 22px; }
.dropzone {
  min-height: 240px;
  border: 2px dashed #93c5fd;
  border-radius: 8px;
  display: grid;
  place-items: center;
  text-align: center;
  padding: 24px;
  cursor: pointer;
  background: #f8fbff;
}
.dropzone i { font-size: 44px; color: var(--blue); }
.dropzone span { color: var(--muted); }
.preview-box img { max-width: 100%; border-radius: 8px; border: 1px solid var(--line); transform: rotate(var(--rotation, 0deg)); }
.slip-panel img, .slip-panel iframe { width: 100%; min-height: 520px; object-fit: contain; border: 1px solid var(--line); border-radius: 8px; background: #f8fafc; }
.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px; }
.span-2 { grid-column: 1 / -1; }
.raw-text { max-height: 260px; overflow: auto; padding: 16px; white-space: pre-wrap; }
.ocr-items-table th {
  background: #f8fafc;
  color: var(--muted);
  font-size: 14px;
}
.ocr-items-table td {
  vertical-align: top;
}
.candidate-box {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  padding: 12px;
  border: 1px solid #bfdbfe;
  background: #eff6ff;
  border-radius: 8px;
}
.candidate-box span { color: var(--muted); font-size: 14px; }
.filter-row { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)) auto auto; gap: 10px; }
.shipments-filter { grid-template-columns: minmax(170px, 1fr) minmax(170px, 1fr) minmax(150px, .75fr) minmax(170px, .85fr) auto auto; }
.post-message-filter { grid-template-columns: minmax(180px, 260px) auto; justify-content: start; }
.post-message-text {
  min-height: 190px;
  resize: vertical;
  white-space: pre-wrap;
  line-height: 1.8;
  font-size: 18px;
}
.shipments-table .action-view { min-width: 52px; font-weight: 600; }
.detail-grid, .public-detail { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px; }
.detail-grid div, .public-detail div { padding: 12px; background: #f8fafc; border: 1px solid var(--line); border-radius: 8px; }
.detail-grid span, .public-detail span { display: block; color: var(--muted); font-size: 13px; }
.timeline { display: grid; gap: 16px; }
.timeline-item { display: grid; grid-template-columns: 34px 1fr; gap: 12px; position: relative; }
.timeline-item i { width: 34px; height: 34px; border-radius: 999px; display: grid; place-items: center; background: #dbeafe; color: var(--blue); }
.timeline-item strong { display: block; }
.timeline-item span { color: var(--muted); font-size: 13px; }
.timeline-item p { margin: 4px 0 0; }
.status-form { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-top: 18px; }
.status-form button { grid-column: 1 / -1; }
.qr { width: 180px; height: 180px; }
.tracking-page { align-items: start; padding-top: 40px; }
.tracking-card { width: min(100%, 720px); }
.tracking-card h1 { font-size: 30px; margin: 14px 0 0; }
.empty-state { text-align: center; }
.empty-state h1 { font-size: 34px; font-weight: 700; }
@media (max-width: 980px) {
  .app-shell { grid-template-columns: 1fr; }
  .sidebar { position: static; height: auto; }
  .sidebar nav { grid-template-columns: repeat(2, 1fr); }
  .stat-grid { grid-template-columns: repeat(2, 1fr); }
  .topbar { align-items: flex-start; }
  .filter-row, .form-grid, .detail-grid, .public-detail, .status-form { grid-template-columns: 1fr; }
  .span-2 { grid-column: auto; }
  .public-list-header { display: block; }
  .shop-logo-row { justify-content: center; }
  .daily-date-form { margin-top: 16px; }
}
@media (max-width: 560px) {
  .topbar { flex-direction: column; }
  .content { padding: 16px; }
  .sidebar nav { grid-template-columns: 1fr; }
  .stat-grid { grid-template-columns: 1fr; }
}
