@import url('./tokens.css');
* {
  box-sizing: border-box;
}
body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: 'IBM Plex Sans Thai', system-ui, sans-serif;
  font-size: 14px;
  line-height: 1.6;
  font-variant-numeric: tabular-nums;
}
button,
input,
select,
textarea {
  font: inherit;
}
button,
.button {
  border: 0;
  border-radius: 9px;
  background: var(--blue);
  color: #fff;
  padding: 10px 17px;
  cursor: pointer;
  font-weight: 600;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  text-decoration: none;
  min-height: 42px;
}
button:hover,
.button:hover {
  filter: brightness(0.94);
}
button:disabled {
  opacity: 0.45;
  cursor: wait;
}
.secondary {
  color: var(--ink);
  background: #fff;
  border: 1px solid var(--line);
}
.danger {
  background: var(--red);
}
.quiet {
  background: transparent;
  color: var(--blue);
  padding: 5px 9px;
  min-height: 32px;
}
.orange {
  background: var(--orange);
}
button:focus-visible,
a:focus-visible {
  outline: 3px solid #93c5fd;
  outline-offset: 3px;
}
a {
  color: var(--blue);
}
input,
select,
textarea {
  border: 1px solid #cbd5e1;
  border-radius: 8px;
  background: white;
  padding: 10px 12px;
  color: var(--ink);
  width: 100%;
  min-height: 44px;
}
input:focus,
select:focus,
textarea:focus {
  outline: 2px solid #bfdbfe;
  border-color: var(--blue);
}
textarea {
  min-height: 84px;
  resize: vertical;
}
input[type='checkbox'] {
  width: 18px;
  min-height: 18px;
  accent-color: var(--blue);
}
label {
  display: block;
  font-weight: 500;
  color: #334155;
}
.field {
  display: grid;
  gap: 5px;
}
.hint,
.muted {
  color: var(--muted);
  font-size: 13px;
}
.small {
  font-size: 12px;
}
h1,
h2,
h3,
p {
  margin-top: 0;
}
h1 {
  font-size: 28px;
  line-height: 1.3;
  margin-bottom: 6px;
  letter-spacing: -0.6px;
}
h2 {
  font-size: 19px;
  margin-bottom: 16px;
}
h3 {
  font-size: 16px;
  margin-bottom: 12px;
}
.layout {
  display: grid;
  grid-template-columns: 230px 1fr;
  min-height: 100vh;
}
.sidebar {
  position: sticky;
  top: 0;
  height: 100vh;
  background: #fff;
  border-right: 1px solid var(--line);
  padding: 27px 18px;
  display: flex;
  flex-direction: column;
  gap: 24px;
}
.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  color: var(--ink);
  text-decoration: none;
  line-height: 1.3;
}
.brand-mark {
  width: 42px;
  height: 42px;
  border-radius: 12px;
  display: grid;
  place-items: center;
  background: var(--blue);
  color: #fff;
  font-size: 26px;
  font-weight: 700;
  flex-shrink: 0;
}
.brand strong {
  font-size: 19px;
  letter-spacing: -0.4px;
}
.brand small {
  display: block;
  color: var(--muted);
  font-size: 11px;
  margin-top: 4px;
}
.nav {
  display: grid;
  gap: 4px;
  overflow: auto;
}
.nav a {
  display: flex;
  align-items: center;
  gap: 11px;
  text-decoration: none;
  color: #526078;
  padding: 10px 13px;
  border-radius: 9px;
  font-weight: 500;
}
.nav a.active {
  background: var(--blue-soft);
  color: var(--blue);
}
.nav svg {
  width: 19px;
  height: 19px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.7;
  flex-shrink: 0;
}
.sidebar-bottom {
  margin-top: auto;
  border-top: 1px solid var(--line);
  padding-top: 17px;
  display: grid;
  gap: 8px;
}
.main {
  min-width: 0;
}
.topbar {
  padding: 18px 36px;
  border-bottom: 1px solid var(--line);
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: #ffffffb3;
}
.topbar .dot {
  display: inline-block;
  width: 7px;
  height: 7px;
  background: var(--green);
  border-radius: 50%;
  margin-right: 7px;
}
.content {
  padding: 32px 36px;
  max-width: 1560px;
  margin: auto;
}
.page-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 16px;
  margin-bottom: 25px;
}
.page-head p {
  margin: 0;
  color: var(--muted);
}
.actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
}
.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 24px;
  margin-bottom: 20px;
  box-shadow: 0 3px 10px #16376503;
}
.stats {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 16px;
  margin-bottom: 24px;
}
.stat {
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 13px;
  padding: 21px 23px;
  position: relative;
  overflow: hidden;
}
.stat:first-child {
  background: var(--blue);
  color: #fff;
  border-color: var(--blue);
}
.stat .value {
  font-size: 30px;
  font-weight: 600;
  letter-spacing: -1px;
  line-height: 1.35;
  margin: 7px 0;
}
.stat .label {
  opacity: 0.8;
  font-size: 13px;
}
.stat .caption {
  font-size: 12px;
  opacity: 0.7;
}
.grid2 {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 20px;
}
.form-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
}
.span2 {
  grid-column: 1/-1;
}
.stack {
  display: grid;
  gap: 14px;
}
.table-wrap {
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: #fff;
}
table {
  border-collapse: collapse;
  width: 100%;
  text-align: left;
  white-space: nowrap;
}
th {
  background: #f8fafc;
  color: #64748b;
  font-weight: 500;
  font-size: 12px;
  padding: 13px 17px;
  border-bottom: 1px solid var(--line);
}
td {
  padding: 14px 17px;
  border-bottom: 1px solid #f1f5f9;
  font-size: 13px;
}
tbody tr:last-child td {
  border-bottom: 0;
}
tbody tr:hover {
  background: #fafcff;
}
.numeric {
  text-align: right;
}
.wrap {
  white-space: normal;
  min-width: 160px;
}
.badge {
  display: inline-flex;
  padding: 3px 10px;
  border-radius: 20px;
  font-size: 11px;
  font-weight: 600;
  background: #eef2f7;
  color: #526078;
}
.badge.active,
.badge.delivered,
.badge.posted,
.badge.approved,
.badge.converted {
  background: #e6f6ef;
  color: #087c55;
}
.badge.pending,
.badge.submitted,
.badge.contacted {
  background: #fff1d6;
  color: #996215;
}
.badge.closed {
  background: #e9eeff;
  color: #395bc6;
}
.badge.cancelled,
.badge.rejected,
.badge.reversed {
  background: #fee9e7;
  color: #b83732;
}
.toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  align-items: end;
  margin-bottom: 18px;
}
.toolbar .field {
  min-width: 150px;
}
.toolbar .search {
  flex: 1;
  min-width: 200px;
  max-width: 360px;
}
.empty {
  text-align: center;
  padding: 45px 20px;
  color: var(--muted);
  white-space: normal;
}
.empty strong {
  display: block;
  color: #475569;
  font-size: 16px;
  margin-bottom: 5px;
}
.pagination {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding-top: 16px;
  color: var(--muted);
}
.error {
  color: #b42318;
  background: #fff1ef;
  padding: 12px 15px;
  border-radius: 8px;
  white-space: pre-wrap;
}
.notice {
  background: var(--blue-soft);
  color: #2457a0;
  padding: 12px 15px;
  border-radius: 8px;
}
.warning {
  background: #fff4dd;
  color: #8a5e13;
}
.loading-screen {
  display: grid;
  place-items: center;
  min-height: 70vh;
  color: var(--muted);
}
.login-page {
  min-height: 100vh;
  display: grid;
  grid-template-columns: 1fr 1fr;
}
.login-art {
  padding: 12%;
  background: linear-gradient(140deg, #164fc9, #2563eb 65%, #5d9df8);
  color: #fff;
  display: flex;
  flex-direction: column;
  justify-content: center;
}
.login-art h1 {
  font-size: 47px;
  max-width: 480px;
  line-height: 1.4;
  margin: 35px 0 20px;
}
.login-art p {
  opacity: 0.8;
  max-width: 420px;
  font-size: 16px;
}
.login-art .brand {
  color: #fff;
}
.login-art .brand-mark {
  background: #ffffff26;
}
.login-form {
  display: grid;
  align-content: center;
  max-width: 450px;
  padding: 50px;
  margin: auto;
  width: 100%;
}
.login-form form {
  display: grid;
  gap: 18px;
}
.login-form h2 {
  font-size: 27px;
  margin-bottom: 5px;
}
dialog {
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 0;
  width: min(780px, calc(100% - 28px));
  max-height: 90vh;
  color: var(--ink);
  box-shadow: 0 25px 100px #15386a30;
}
dialog::backdrop {
  background: #12223d70;
  backdrop-filter: blur(2px);
}
.dialog-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 20px 24px;
  border-bottom: 1px solid var(--line);
}
.dialog-head h2 {
  margin: 0;
}
.dialog-body {
  padding: 24px;
  overflow: auto;
}
.dialog-footer {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  padding: 16px 24px;
  border-top: 1px solid var(--line);
  background: #f8fafc;
}
.dialog-error {
  margin-bottom: 14px;
}
.line-row {
  display: grid;
  grid-template-columns: minmax(160px, 2fr) 1fr 1fr 34px;
  gap: 8px;
  align-items: end;
  margin-bottom: 10px;
}
.line-row .quiet {
  margin-bottom: 5px;
}
.line-labels {
  display: grid;
  grid-template-columns: 2fr 1fr 1fr 34px;
  gap: 8px;
  font-size: 12px;
  color: var(--muted);
  margin-bottom: 5px;
}
.total-line {
  display: flex;
  justify-content: space-between;
  gap: 14px;
  padding: 10px 0;
  border-bottom: 1px solid var(--line);
}
.total-line strong {
  font-size: 18px;
}
.total-line:last-child {
  border: 0;
}
.tabs {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  margin-bottom: 18px;
}
.list-item {
  padding: 12px 0;
  border-bottom: 1px solid var(--line);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}
.list-item:last-child {
  border: 0;
}
.bar {
  height: 8px;
  background: #eef2f7;
  border-radius: 10px;
  overflow: hidden;
  margin-top: 7px;
}
.bar > span {
  display: block;
  height: 100%;
  background: var(--blue);
  border-radius: 10px;
}
.slip {
  max-width: 100%;
  max-height: 65vh;
  object-fit: contain;
  display: block;
  margin: auto;
}
#toast {
  position: fixed;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 100;
  background: #123663;
  color: white;
  padding: 12px 22px;
  border-radius: 10px;
  box-shadow: 0 8px 25px #0002;
  display: none;
  max-width: 90vw;
}
.checkbox {
  display: flex;
  align-items: center;
  gap: 9px;
  font-weight: 400;
}
.days {
  display: flex;
  flex-wrap: wrap;
  gap: 15px;
}
.connection-gate {
  position: fixed;
  inset: 0;
  z-index: 9999;
  background: var(--bg);
  display: grid;
  place-items: center;
  padding: 24px;
}
.gate-card {
  max-width: 380px;
  width: 100%;
  text-align: center;
}
.gate-card .brand-mark {
  margin: 0 auto 24px;
  width: 64px;
  height: 64px;
  font-size: 38px;
}
.gate-card h1 {
  font-size: 23px;
}
.gate-card p {
  color: var(--muted);
}
.gate-card button {
  width: 100%;
  margin-top: 20px;
}
.driver #driver-app {
  max-width: 600px;
  margin: auto;
  padding: 20px 16px 100px;
}
.driver-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 24px;
}
.driver h1 {
  font-size: 25px;
}
.driver .card {
  padding: 20px;
}
.driver .stats {
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
}
.driver .stat {
  padding: 17px;
}
.driver .stat .value {
  font-size: 25px;
}
.driver .button,
.driver button {
  min-height: 46px;
}
.driver .task-card {
  cursor: pointer;
}
.driver .task-card h2 {
  margin: 10px 0 3px;
}
.stop-card {
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 13px;
  margin-bottom: 12px;
  padding: 18px;
}
.stop-card .stop-head {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  align-items: start;
}
.stop-card h3 {
  font-size: 17px;
  margin: 0 0 6px;
}
.stop-card .actions {
  margin-top: 14px;
}
.driver .bottom-actions {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  max-width: 600px;
  margin: auto;
  background: #fff;
  border-top: 1px solid var(--line);
  padding: 12px 16px calc(12px + env(safe-area-inset-bottom));
  display: flex;
  gap: 10px;
  z-index: 10;
}
.driver .bottom-actions > * {
  flex: 1;
}
.driver .form-grid {
  grid-template-columns: 1fr;
}
.driver .span2 {
  grid-column: auto;
}
.driver .line-row {
  grid-template-columns: minmax(110px, 2fr) 1fr 1fr 24px;
  gap: 5px;
}
.driver dialog .dialog-body {
  padding: 18px;
}
.driver .line-row input,
.driver .line-row select {
  padding: 8px 5px;
  font-size: 13px;
}
.driver .line-row button {
  padding: 0;
  min-height: 40px;
}
.selected-stops {
  max-height: 330px;
  overflow: auto;
}
.check-list {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}
.print-only {
  display: none;
}
[hidden] {
  display: none !important;
}
@media (max-width: 1100px) {
  .stats {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
  .content {
    padding: 24px;
  }
  .topbar {
    padding: 16px 24px;
  }
  .grid2 {
    grid-template-columns: 1fr;
  }
}
@media (max-width: 760px) {
  .layout {
    grid-template-columns: 1fr;
  }
  .sidebar {
    position: relative;
    height: auto;
    padding: 14px 16px;
    gap: 14px;
    border-right: 0;
    border-bottom: 1px solid var(--line);
  }
  .sidebar .brand small,
  .sidebar-bottom {
    display: none;
  }
  .nav {
    display: flex;
    gap: 5px;
    overflow: auto;
    white-space: nowrap;
  }
  .nav a {
    padding: 7px 11px;
  }
  .nav svg {
    display: none;
  }
  .topbar {
    padding: 12px 16px;
  }
  .content {
    padding: 22px 16px;
  }
  .page-head {
    align-items: start;
  }
  h1 {
    font-size: 24px;
  }
  .form-grid {
    grid-template-columns: 1fr;
  }
  .span2 {
    grid-column: auto;
  }
  .login-page {
    grid-template-columns: 1fr;
  }
  .login-art {
    padding: 28px;
  }
  .login-art h1,
  .login-art p {
    display: none;
  }
  .login-form {
    padding: 32px;
  }
  .card {
    padding: 18px;
  }
  .stats {
    gap: 10px;
  }
  .stat {
    padding: 16px;
  }
  .stat .value {
    font-size: 26px;
  }
  .line-row {
    grid-template-columns: 1.5fr 1fr 1fr 24px;
  }
  .line-labels {
    display: none;
  }
  .dialog-body {
    padding: 18px;
  }
  .check-list {
    grid-template-columns: 1fr;
  }
}
@media print {
  body {
    background: white;
  }
  .sidebar,
  .topbar,
  .toolbar,
  .page-head .actions,
  button,
  .pagination,
  #toast {
    display: none !important;
  }
  .layout {
    display: block;
  }
  .content {
    padding: 0;
  }
  .card,
  .table-wrap {
    box-shadow: none;
    break-inside: avoid;
  }
  .print-only {
    display: block;
  }
  .stats {
    grid-template-columns: repeat(4, 1fr);
  }
  .stat:first-child {
    background: white;
    color: black;
  }
  .table-wrap {
    overflow: visible;
  }
  th,
  td {
    padding: 7px;
    font-size: 11px;
  }
}

.mobile-only {
  display: none;
}
@media (max-width: 760px) {
  .mobile-only {
    display: inline-flex;
  }
}
