:root {
  --bg: #f5f5f7;
  --text: #1d1d1f;
  --muted: #86868b;
  --primary: #3182ce;
  --success: #34c759;
  --warning: #ff9500;
  --danger: #ff3b30;
  --accent: #af52de;
  --surface: rgba(255, 255, 255, 0.8);
  --surface-strong: rgba(255, 255, 255, 0.92);
  --border: rgba(60, 60, 67, 0.16);
  --border-soft: rgba(60, 60, 67, 0.1);
  --shadow-soft: 0 4px 16px rgba(0, 0, 0, 0.04);
  --shadow-hover: 0 10px 26px rgba(0, 0, 0, 0.08);
  --radius-card: 16px;
  --radius-input: 12px;
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  padding: 0;
}

body {
  min-height: 100vh;
  font-family: -apple-system, BlinkMacSystemFont, "SF Pro Display", "SF Pro Text", "Helvetica Neue", Arial, sans-serif;
  color: var(--text);
  background: var(--bg);
  letter-spacing: -0.01em;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

.page-shell {
  position: relative;
  isolation: isolate;
}

.bg-orb {
  position: fixed;
  z-index: -1;
  border-radius: 50%;
  filter: blur(76px);
  pointer-events: none;
}

.bg-orb-blue {
  width: 340px;
  height: 340px;
  top: -120px;
  left: -130px;
  opacity: 0.42;
  background: radial-gradient(circle, rgba(0, 122, 255, 0.4), rgba(0, 122, 255, 0));
}

.bg-orb-purple {
  width: 320px;
  height: 320px;
  top: -80px;
  right: -120px;
  opacity: 0.34;
  background: radial-gradient(circle, rgba(175, 82, 222, 0.36), rgba(175, 82, 222, 0));
}

.container {
  width: min(1080px, calc(100% - 16px));
  margin: 10px auto 20px;
  display: grid;
  gap: 12px;
}

.header-copy,
.page-header,
.controls-card,
.table-card {
  border-radius: var(--radius-card);
  border: 1px solid var(--border);
  background: var(--surface);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  box-shadow: var(--shadow-soft);
}

.page-header {
  padding: 14px;
}

.header-copy {
  padding: 14px;
}

.eyebrow {
  margin: 0 0 6px;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--primary);
}

h1 {
  margin: 0;
  font-size: clamp(26px, 7vw, 36px);
  line-height: 1.02;
  font-weight: 600;
  letter-spacing: -0.02em;
}

#admin-msg {
  margin: 8px 0 0;
  min-height: 20px;
  font-size: 13px;
  color: var(--muted);
}

.usage-summary {
  display: grid;
  gap: 8px;
}

.usage-item {
  border-radius: 14px;
  padding: 12px 14px;
  border: 1px solid rgba(60, 60, 67, 0.16);
  background: var(--surface-strong);
  box-shadow: var(--shadow-soft);
  transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.usage-item:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-hover);
}

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

.usage-value {
  margin-top: 6px;
  font-size: clamp(26px, 9vw, 34px);
  line-height: 1;
  font-weight: 700;
  letter-spacing: -0.03em;
  font-variant-numeric: tabular-nums;
}

.usage-unit {
  margin-top: 6px;
  font-size: 12px;
  color: var(--muted);
}

.usage-item.is-total {
  border-color: rgba(0, 122, 255, 0.24);
}

.usage-item.is-upload {
  border-color: rgba(175, 82, 222, 0.28);
}

.usage-item.is-booth {
  border-color: rgba(52, 199, 89, 0.28);
}

.controls-card {
  padding: 12px;
}

.admin-toolbar {
  display: grid;
  gap: 10px;
}

.bulk-action-row {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
}

.print-server-collapse {
  border: 1px solid var(--border-soft);
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.9);
  overflow: hidden;
}

.print-server-summary {
  list-style: none;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 10px 12px;
  cursor: pointer;
  user-select: none;
}

.print-server-summary::-webkit-details-marker {
  display: none;
}

.print-server-summary::after {
  content: "";
  width: 8px;
  height: 8px;
  border-right: 2px solid #5f6f8d;
  border-bottom: 2px solid #5f6f8d;
  transform: rotate(45deg);
  transition: transform 0.18s ease;
  margin-left: 4px;
}

.print-server-collapse[open] .print-server-summary::after {
  transform: rotate(225deg);
}

.print-server-summary-label {
  font-size: 13px;
  color: var(--muted);
  font-weight: 600;
}

.print-server-config {
  display: grid;
  gap: 8px;
  padding: 0 12px 12px;
  border-top: 1px solid var(--border-soft);
  background: transparent;
}

.print-server-config label {
  font-size: 13px;
  color: var(--muted);
  font-weight: 600;
}

.print-server-field-label {
  font-size: 13px;
  color: var(--muted);
  font-weight: 600;
  margin-top: 2px;
}

#printServerUrlText,
#printServerPrinterInput {
  height: 40px;
  width: 100%;
  border-radius: var(--radius-input);
  border: 1px solid var(--border);
  background: rgba(255, 255, 255, 0.95);
  color: var(--text);
  font: inherit;
  font-size: 14px;
  padding: 8px 12px;
}

#printServerPrinterInput:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(49, 130, 206, 0.16);
}

#printServerUrlText {
  display: flex;
  align-items: center;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  user-select: all;
}

#printServerUrlText.is-invalid {
  border-color: rgba(255, 59, 48, 0.45);
  background: rgba(255, 59, 48, 0.08);
  color: #b42318;
}

#printServerPrinterInput {
  appearance: none;
  -webkit-appearance: none;
  background-image: linear-gradient(45deg, transparent 50%, #5f6f8d 50%), linear-gradient(135deg, #5f6f8d 50%, transparent 50%);
  background-position: calc(100% - 18px) calc(50% + 1px), calc(100% - 12px) calc(50% + 1px);
  background-size: 6px 6px, 6px 6px;
  background-repeat: no-repeat;
  padding-right: 34px;
}

.admin-check-print-btn {
  min-height: 36px;
}

.print-status {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  width: fit-content;
  min-height: 24px;
  padding: 4px 10px;
  border-radius: 999px;
  border: 1px solid transparent;
  font-size: 12px;
  font-weight: 600;
  line-height: 1;
}

.print-status::before {
  content: '';
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: currentColor;
}

.print-status.is-ok {
  color: #18794e;
  background: rgba(52, 199, 89, 0.16);
  border-color: rgba(52, 199, 89, 0.3);
}

.print-status.is-down {
  color: #b42318;
  background: rgba(255, 59, 48, 0.14);
  border-color: rgba(255, 59, 48, 0.28);
}

.print-status.is-checking {
  color: #6b7280;
  background: rgba(107, 114, 128, 0.14);
  border-color: rgba(107, 114, 128, 0.2);
}

.print-status.is-unknown {
  color: #5f6f8d;
  background: rgba(95, 111, 141, 0.12);
  border-color: rgba(95, 111, 141, 0.2);
}

.admin-filter {
  display: grid;
  gap: 8px;
  padding: 10px;
  border-radius: 14px;
  border: 1px solid var(--border-soft);
  background: rgba(255, 255, 255, 0.85);
}

.admin-filter label {
  font-size: 13px;
  color: var(--muted);
  font-weight: 600;
}

#dateFilterInput,
#deletePasswordInput {
  height: 40px;
  width: 100%;
  border-radius: var(--radius-input);
  border: 1px solid var(--border);
  background: rgba(255, 255, 255, 0.95);
  color: var(--text);
  font: inherit;
  font-size: 14px;
  padding: 8px 12px;
}

#dateFilterInput:focus,
#deletePasswordInput:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(0, 122, 255, 0.12);
}

.btn-download {
  min-height: 40px;
  width: 100%;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  margin: 0;
  padding: 10px 14px;
  border: 1px solid transparent;
  border-radius: 999px;
  font: inherit;
  font-size: 14px;
  font-weight: 600;
  letter-spacing: -0.01em;
  text-decoration: none;
  cursor: pointer;
  transition: transform 0.18s ease, box-shadow 0.2s ease, filter 0.2s ease;
}

.btn-icon {
  width: 16px;
  height: 16px;
  display: block;
  flex: 0 0 auto;
  pointer-events: none;
  user-select: none;
}

.btn-label {
  display: inline-block;
  line-height: 1;
}

.btn-download:hover:not([disabled]) {
  transform: translateY(-2px);
  box-shadow: var(--shadow-hover);
}

.btn-download:active:not([disabled]) {
  transform: translateY(-1px) scale(0.99);
}

.btn-download[disabled] {
  opacity: 0.6;
  cursor: not-allowed;
  transform: none;
  box-shadow: none;
}

.btn-large {
  min-height: 42px;
}

.btn-sm {
  min-height: 34px;
  width: auto;
  min-width: 108px;
  padding: 8px 12px;
  font-size: 13px;
}

.btn-sm .btn-icon {
  width: 14px;
  height: 14px;
}

.btn-sm.btn-icon-only {
  min-width: 34px;
  width: 34px;
  padding: 0;
}

.btn-sm.btn-icon-only .btn-label {
  display: none;
}

.btn-sm.btn-icon-only .btn-icon {
  width: 15px;
  height: 15px;
}

.btn-ghost {
  color: var(--text);
  border-color: var(--border);
  background: rgba(255, 255, 255, 0.9);
}

.btn-image {
  color: #fff;
  border-color: rgba(49, 130, 206, 0.45);
  background: var(--primary);
}

.btn-image .btn-icon,
.btn-success .btn-icon,
.btn-danger .btn-icon {
  filter: brightness(0) saturate(100%) invert(1);
}

.btn-image:hover:not([disabled]) {
  filter: brightness(0.96);
}

.btn-success {
  color: #fff;
  border-color: rgba(52, 199, 89, 0.45);
  background: var(--success);
}

.btn-success:hover:not([disabled]) {
  filter: brightness(0.95);
}

.btn-danger {
  color: #fff;
  border-color: rgba(255, 59, 48, 0.5);
  background: var(--danger);
}

.btn-danger:hover:not([disabled]) {
  filter: brightness(0.95);
}

.admin-filter-clear {
  min-height: 36px;
}

.table-card {
  padding: 10px;
}

.table-scroll {
  overflow: auto;
  border-radius: calc(var(--radius-card) - 4px);
  border: 1px solid var(--border-soft);
  background: rgba(255, 255, 255, 0.95);
  -webkit-overflow-scrolling: touch;
  overscroll-behavior-x: contain;
}

.table-hint {
  margin: 8px 4px 0;
  color: var(--muted);
  font-size: 12px;
  letter-spacing: -0.01em;
}

.admin-table {
  width: 100%;
  min-width: 1100px;
  border-collapse: collapse;
  border-spacing: 0;
}

.admin-table thead {
  display: table-header-group;
}

.admin-th {
  position: sticky;
  top: 0;
  z-index: 1;
  text-align: left;
  padding: 12px 10px;
  font-size: 13px;
  font-weight: 600;
  color: #243145;
  background: rgba(0, 122, 255, 0.1);
  border-bottom: 1px solid rgba(0, 122, 255, 0.2);
}

.admin-th-check {
  width: 46px;
  text-align: center;
}

.admin-table tbody tr {
  transition: background-color 0.2s ease;
}

.admin-table tbody tr:hover {
  background: rgba(0, 122, 255, 0.05);
}

.admin-cell {
  display: table-cell;
  padding: 10px;
  border-bottom: 1px solid rgba(60, 60, 67, 0.1);
  vertical-align: middle;
  font-size: 14px;
  color: var(--text);
}

.admin-cell[data-label]::before {
  content: none;
}

.admin-cell-check {
  text-align: center;
  padding-bottom: 10px;
  border-bottom: 1px solid rgba(60, 60, 67, 0.1);
}

.admin-cell-check::before {
  content: none;
}

.admin-row-checkbox {
  width: 18px;
  height: 18px;
  accent-color: var(--primary);
  cursor: pointer;
}

.session-id-cell {
  font-family: ui-monospace, "SFMono-Regular", Menlo, Consolas, monospace;
  font-size: 13px;
  word-break: break-all;
}

.admin-cell .btn-download {
  width: auto;
  white-space: nowrap;
}

@media (max-width: 759px) {
  .container {
    width: calc(100% - 12px);
    margin: 8px auto 18px;
  }

  .page-header {
    padding: 14px;
    gap: 12px;
  }

  h1 {
    font-size: clamp(24px, 7vw, 30px);
  }

  .controls-card {
    padding: 10px;
  }

  .table-card {
    padding: 8px;
  }

  .table-scroll {
    border-radius: 12px;
  }

  .admin-table {
    min-width: 880px;
  }

  .admin-th {
    padding: 9px 8px;
    font-size: 12px;
    white-space: nowrap;
  }

  .admin-th-check {
    width: 38px;
  }

  .admin-cell {
    padding: 8px;
    font-size: 12px;
    white-space: nowrap;
  }

  .session-id-cell {
    max-width: 180px;
    overflow: hidden;
    text-overflow: ellipsis;
  }

  .btn-sm {
    min-height: 30px;
    min-width: 74px;
    padding: 6px 8px;
    font-size: 12px;
  }

  .btn-sm.btn-icon-only {
    min-width: 30px;
    width: 30px;
    padding: 0;
  }
}

@media (max-width: 430px) {
  .admin-table {
    min-width: 840px;
  }

  .btn-sm {
    min-width: 66px;
    padding: 6px 7px;
    font-size: 11px;
  }

  .btn-sm.btn-icon-only {
    min-width: 28px;
    width: 28px;
    padding: 0;
  }
}

.channel-pill,
.type-pill,
.shots-pill {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 24px;
  padding: 4px 10px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 600;
  line-height: 1;
  white-space: nowrap;
}

.channel-pill {
  border: 1px solid rgba(60, 60, 67, 0.16);
  background: rgba(60, 60, 67, 0.08);
  color: #3a3a3c;
}

.type-pill {
  border: 1px solid rgba(60, 60, 67, 0.14);
  background: rgba(60, 60, 67, 0.08);
  color: #324156;
  min-width: 36px;
  font-weight: 700;
}

.type-pill.is-u {
  color: #6f2dbd;
  border-color: rgba(175, 82, 222, 0.28);
  background: rgba(175, 82, 222, 0.14);
}

.type-pill.is-b {
  color: #18794e;
  border-color: rgba(52, 199, 89, 0.28);
  background: rgba(52, 199, 89, 0.14);
}

.channel-pill.is-promptpay {
  color: #0058b8;
  border-color: rgba(0, 122, 255, 0.25);
  background: rgba(0, 122, 255, 0.16);
}

.channel-pill.is-wechat {
  color: #1f8f43;
  border-color: rgba(52, 199, 89, 0.28);
  background: rgba(52, 199, 89, 0.16);
}

.channel-pill.is-cash {
  color: #a35b00;
  border-color: rgba(255, 149, 0, 0.3);
  background: rgba(255, 149, 0, 0.18);
}

.shots-pill {
  color: #29436a;
  border: 1px solid rgba(60, 60, 67, 0.14);
  background: rgba(60, 60, 67, 0.07);
}

.admin-sort-btn {
  border: none;
  padding: 0;
  font: inherit;
  font-size: 13px;
  font-weight: 600;
  color: #1f3a67;
  background: transparent;
  cursor: pointer;
}

.admin-sort-btn:hover {
  color: var(--primary);
}

.admin-modal {
  position: fixed;
  inset: 0;
  z-index: 1000;
}

.admin-modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(20, 20, 22, 0.28);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
}

.admin-modal-card {
  position: relative;
  margin: min(10vh, 80px) auto 0;
  width: min(520px, calc(100% - 20px));
  padding: 18px;
  border-radius: var(--radius-card);
  border: 1px solid var(--border);
  background: var(--surface-strong);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  box-shadow: 0 20px 52px rgba(0, 0, 0, 0.12);
  animation: modal-pop 0.18s ease-out;
}

@keyframes modal-pop {
  0% {
    opacity: 0;
    transform: translateY(8px) scale(0.98);
  }

  100% {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

h2 {
  margin: 0;
  font-size: 22px;
  font-weight: 600;
  color: var(--text);
}

.admin-modal-session {
  margin: 8px 0 12px;
  color: var(--muted);
  font-family: ui-monospace, "SFMono-Regular", Menlo, Consolas, monospace;
  font-size: 13px;
  word-break: break-all;
}

.admin-modal-label {
  display: block;
  margin-bottom: 8px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 600;
}

.admin-modal-error {
  min-height: 20px;
  margin: 8px 0 0;
  color: var(--danger);
  font-size: 13px;
}

.admin-modal-actions {
  margin-top: 14px;
  display: grid;
  gap: 10px;
}

@media (min-width: 760px) {
  .container {
    width: min(1080px, calc(100% - 24px));
    margin: 16px auto 28px;
    gap: 14px;
  }

  .page-header {
    padding: 16px;
  }

  .controls-card {
    padding: 14px;
  }

  .admin-toolbar {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 10px;
  }

  .admin-filter {
    display: flex;
    align-items: center;
    gap: 10px;
    width: auto;
    border-radius: 999px;
    padding: 8px 12px;
  }

  .print-server-config {
    display: grid;
    width: 100%;
    padding: 0 12px 12px;
  }

  .print-server-collapse {
    width: 100%;
  }

  .print-server-summary {
    padding: 10px 12px;
  }

  #printServerUrlText,
  #printServerPrinterInput {
    width: 260px;
    min-width: 220px;
  }

  #dateFilterInput {
    width: auto;
    min-width: 160px;
  }

  .btn-download {
    width: auto;
  }

  .admin-modal-actions {
    display: flex;
    justify-content: flex-end;
    flex-wrap: wrap;
  }

  .table-hint {
    display: none;
  }
}

@media (min-width: 920px) {
  .container {
    width: min(1080px, calc(100% - 32px));
    margin: 22px auto 34px;
    gap: 16px;
  }
}

/* Mobile-only layout */
.container {
  width: min(460px, calc(100% - 12px));
  margin: 8px auto 18px;
  gap: 10px;
}

.page-header,
.header-copy,
.controls-card,
.table-card {
  border-radius: 14px;
}

.page-header {
  padding: 14px;
}

.header-copy {
  padding: 12px 14px;
}

.usage-summary {
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 6px;
}

.usage-item {
  padding: 8px 8px;
}

.usage-label {
  font-size: 10px;
  line-height: 1.2;
}

.usage-value {
  margin-top: 4px;
  font-size: clamp(16px, 4.6vw, 22px);
}

.usage-unit {
  margin-top: 2px;
  font-size: 10px;
}

.controls-card {
  padding: 10px;
}

.admin-toolbar {
  display: grid;
  gap: 8px;
}

.print-server-config,
.admin-filter {
  border-radius: 12px;
  padding: 10px;
}

.admin-check-print-btn,
.admin-filter-clear,
.btn-download.btn-large,
.btn-download {
  width: 100%;
}

.bulk-action-row .btn-download {
  width: 100%;
}

.table-card {
  padding: 8px;
}

.table-scroll {
  overflow: visible;
  border: 0;
  box-shadow: none;
  background: transparent;
}

.admin-table {
  width: 100%;
  min-width: 0;
  border-collapse: separate;
  border-spacing: 0;
}

.admin-table thead {
  display: none;
}

.admin-table tbody {
  display: grid;
  gap: 10px;
}

.admin-table tbody tr {
  display: grid;
  gap: 6px;
  padding: 10px;
  border-radius: 12px;
  background: var(--surface-strong);
  box-shadow: inset 0 0 0 1px rgba(60, 60, 67, 0.1), var(--shadow-soft);
}

.admin-table tbody tr:hover {
  background: var(--surface-strong);
}

.admin-cell {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 3px 0;
  border-bottom: 0;
  font-size: 13px;
  white-space: normal;
}

.admin-cell[data-label]::before {
  content: attr(data-label);
  color: var(--muted);
  font-size: 12px;
  font-weight: 600;
  flex: 0 0 auto;
}

.admin-cell-check {
  justify-content: flex-start;
  gap: 10px;
  padding: 0 0 6px;
  margin-bottom: 2px;
  border-bottom: 1px solid rgba(60, 60, 67, 0.12);
}

.admin-cell-check::before {
  content: attr(data-label);
  color: var(--muted);
  font-size: 12px;
  font-weight: 600;
}

.admin-row-checkbox {
  width: 20px;
  height: 20px;
}

.session-id-cell {
  font-size: 12px;
  overflow-wrap: anywhere;
  word-break: break-word;
}

.admin-cell .btn-download {
  width: 32px;
  min-width: 32px;
  min-height: 32px;
  padding: 0;
}

.table-hint {
  display: none;
}
