html {
  -webkit-text-size-adjust: 100%;
}

body {
  margin: 0;
  color: #0f172a;
  -webkit-font-smoothing: antialiased;
  font-family: "PingFang SC", "Hiragino Sans GB", "Noto Sans SC", "Microsoft YaHei", sans-serif;
  background-color: #f4f8fc;
  background-image:
    radial-gradient(circle at top left, rgba(96, 165, 250, 0.12), transparent 26%),
    linear-gradient(180deg, #f9fbff 0%, #f4f8fc 45%, #eff4f9 100%);
}

.page-topbar {
  padding: 0 0 0.25rem;
}

.page-topbar-meta {
  display: flex;
  position: relative;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  min-height: 2.5rem;
}

.page-topbar-pill {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 2.25rem;
  padding: 0.375rem 0.875rem;
  border: 1px solid rgba(255, 255, 255, 0.62);
  border-radius: 9999px;
  background: rgba(255, 255, 255, 0.34);
  -webkit-backdrop-filter: blur(16px) saturate(160%);
  backdrop-filter: blur(16px) saturate(160%);
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.72),
    0 8px 22px rgba(148, 163, 184, 0.12);
}

.page-topbar-userpill {
  max-width: calc(100% - 6.5rem);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 0.9375rem;
  font-weight: 600;
  letter-spacing: -0.02em;
  color: #0f172a;
}

.page-topbar-logout {
  margin-left: auto;
  color: #dc2626;
  font-size: 0.875rem;
  font-weight: 600;
  line-height: 1.2;
  cursor: pointer;
}

.page-topbar-logout:hover {
  background: rgba(254, 242, 242, 0.48);
  border-color: rgba(254, 202, 202, 0.88);
  color: #b91c1c;
}

.page-topbar-brand {
  display: flex;
  align-items: center;
  justify-content: center;
  margin-top: 0.125rem;
}

.page-topbar-brand-inline {
  position: absolute;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%);
  margin-top: 0;
  pointer-events: none;
}

.page-topbar-brand-image {
  width: min(100%, 168px);
  height: auto;
  display: block;
  object-fit: contain;
}

.inventory-page-topbar {
  padding-top: 0;
  padding-bottom: 0.125rem;
}

.inventory-page-topbar-meta {
  min-height: 2.5rem;
}

.inventory-page-topbar-brand {
  margin-top: 0.125rem;
  margin-bottom: 0;
  background: transparent;
  box-shadow: none;
}

.inventory-page-topbar-brand-image {
  width: min(100%, 172px);
  background: transparent;
  box-shadow: none;
  vertical-align: top;
}

.inventory-page-topbar-brand-inline {
  top: 110%;
}

.inventory-page-main {
  margin-top: 4.5rem;
}

.records-page-topbar-brand-inline,
.customers-page-topbar-brand-inline {
  top: 110%;
}

.records-page-topbar-brand-image,
.customers-page-topbar-brand-image {
  width: min(100%, 172px);
  background: transparent;
  box-shadow: none;
  vertical-align: top;
}

.records-page-main,
.customers-page-main {
  margin-top: 4.5rem;
}

.login-page-shell {
  max-width: 28rem;
}

.login-card {
  overflow: hidden;
}

.login-logo-wrap {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0.5rem 0 0.25rem;
}

.login-logo {
  width: min(100%, 220px);
  height: auto;
  display: block;
  object-fit: contain;
}

body.modal-open {
  position: fixed;
  width: 100%;
  overflow: hidden;
}

* {
  box-sizing: border-box;
}

::placeholder {
  color: rgb(148 163 184);
}

input,
select,
textarea,
button {
  font-size: 16px;
  touch-action: manipulation;
  font-family: inherit;
}

input[type="date"] {
  min-height: 48px;
  line-height: 1.25;
}

input[type="date"]::-webkit-date-and-time-value {
  text-align: left;
}

input[type="date"]::-webkit-calendar-picker-indicator {
  opacity: 0.75;
}

.page-shell {
  width: 100%;
  max-width: 80rem;
  margin: 0 auto;
  min-height: 100vh;
  padding:
    calc(12px + env(safe-area-inset-top))
    1rem
    calc(104px + env(safe-area-inset-bottom));
}

@media (min-width: 640px) {
  .page-shell {
    padding-left: 1.5rem;
    padding-right: 1.5rem;
  }
}

@media (min-width: 1024px) {
  .page-shell {
    padding-left: 2rem;
    padding-right: 2rem;
  }
}

.app-card {
  border: 1px solid rgba(226, 232, 240, 0.8);
  border-radius: 1.5rem;
  background: #ffffff;
  box-shadow: 0 12px 32px rgba(15, 23, 42, 0.06);
}

.glass-card {
  border-color: rgba(255, 255, 255, 0.6);
  background: rgba(255, 255, 255, 0.52);
  -webkit-backdrop-filter: blur(18px) saturate(150%);
  backdrop-filter: blur(18px) saturate(150%);
  box-shadow:
    0 12px 30px rgba(15, 23, 42, 0.06),
    inset 0 1px 0 rgba(255, 255, 255, 0.72);
}

.app-input {
  width: 100%;
  min-height: 48px;
  padding: 0.75rem 1rem;
  border: 1px solid #e2e8f0;
  border-radius: 1rem;
  background: #f8fafc;
  color: #0f172a;
  outline: none;
  transition: border-color 0.2s ease, box-shadow 0.2s ease, background-color 0.2s ease;
}

.app-input:focus,
.app-select:focus,
.app-date:focus,
.app-textarea:focus {
  border-color: #60a5fa;
  box-shadow: 0 0 0 4px rgba(191, 219, 254, 0.55);
  background: #ffffff;
}

.app-select {
  width: 100%;
  min-height: 48px;
  padding: 0.75rem 2.5rem 0.75rem 1rem;
  border: 1px solid #e2e8f0;
  border-radius: 1rem;
  background-color: #f8fafc;
  color: #0f172a;
  outline: none;
  background-image:
    linear-gradient(45deg, transparent 50%, rgb(100 116 139) 50%),
    linear-gradient(135deg, rgb(100 116 139) 50%, transparent 50%);
  background-position:
    calc(100% - 22px) calc(50% - 3px),
    calc(100% - 16px) calc(50% - 3px);
  background-size: 6px 6px, 6px 6px;
  background-repeat: no-repeat;
  -webkit-appearance: none;
  appearance: none;
}

.app-date {
  width: 100%;
  min-height: 48px;
  padding: 0.75rem 1rem;
  border: 1px solid #e2e8f0;
  border-radius: 1rem;
  background: #f8fafc;
  color: #0f172a;
  outline: none;
  -webkit-appearance: none;
  appearance: none;
}

.app-textarea {
  width: 100%;
  min-height: 104px;
  padding: 0.75rem 1rem;
  border: 1px solid #e2e8f0;
  border-radius: 1rem;
  background: #f8fafc;
  color: #0f172a;
  resize: none;
  outline: none;
}

.app-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 44px;
  padding: 0.625rem 1rem;
  border-radius: 1rem;
  border: 1px solid transparent;
  font-size: 0.875rem;
  font-weight: 500;
  line-height: 1.2;
  white-space: nowrap;
  text-decoration: none;
  cursor: pointer;
  transition: background-color 0.2s ease, border-color 0.2s ease, color 0.2s ease, transform 0.12s ease;
}

.app-btn:active {
  transform: scale(0.99);
}

.app-btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.app-btn-primary {
  background: #60a5fa;
  border-color: #60a5fa;
  color: #ffffff;
}

.app-btn-primary:hover {
  background: #3b82f6;
  border-color: #3b82f6;
}

.app-btn-secondary {
  background: #ffffff;
  border-color: #e2e8f0;
  color: #334155;
}

.app-btn-secondary:hover {
  background: #f8fafc;
}

.bill-status-action-btn {
  background: transparent !important;
  border-color: transparent !important;
  color: #2563eb !important;
  box-shadow: none !important;
}

.bill-status-action-btn:hover {
  background: rgba(239, 246, 255, 0.75) !important;
  border-color: transparent !important;
  color: #1d4ed8 !important;
}

.customer-detail-header-row {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: flex-start;
  min-height: 44px;
}

.customer-detail-title-wrap {
  position: absolute;
  left: 50%;
  transform: translateX(-50%);
  width: calc(100% - 132px);
  text-align: center;
  pointer-events: none;
}

.customer-detail-back-btn {
  position: relative;
  z-index: 1;
  min-width: 72px;
  background: transparent !important;
  border-color: #dbeafe !important;
  color: #0f172a !important;
  box-shadow: none !important;
}

.customer-detail-back-btn:hover {
  background: rgba(248, 250, 252, 0.9) !important;
  border-color: #cbd5e1 !important;
  color: #0f172a !important;
}

.customer-detail-header-spacer {
  width: 72px;
  flex: 0 0 72px;
}

.app-btn-danger {
  background: #ffffff;
  border-color: #fecaca;
  color: #dc2626;
}

.app-btn-danger:hover {
  background: #fef2f2;
}

.add-bill-item-btn {
  background: #16a34a;
  border-color: #16a34a;
  color: #ffffff;
}

.add-bill-item-btn:hover {
  background: #15803d;
  border-color: #15803d;
}

.green-action-btn {
  background: #16a34a;
  border-color: #16a34a;
  color: #ffffff;
}

.green-action-btn:hover {
  background: #15803d;
  border-color: #15803d;
}

.app-btn-close {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 36px;
  padding: 0.375rem 0.75rem;
  border: 1px solid #e2e8f0;
  border-radius: 0.75rem;
  background: #ffffff;
  color: #475569;
  font-size: 0.875rem;
  font-weight: 500;
  white-space: nowrap;
  cursor: pointer;
}

.tab-btn {
  min-height: 44px;
  padding: 0.625rem 0.75rem;
  border-radius: 1rem;
  border: 1px solid #e2e8f0;
  font-size: 0.875rem;
  font-weight: 500;
  transition: background-color 0.2s ease, border-color 0.2s ease, color 0.2s ease;
}

.tab-btn-active {
  background: #60a5fa;
  border-color: #60a5fa;
  color: #ffffff;
}

.tab-btn-idle {
  background: #f8fafc;
  border-color: #e2e8f0;
  color: #475569;
}

.info-pill {
  display: inline-flex;
  align-items: center;
  border: 1px solid #e2e8f0;
  border-radius: 9999px;
  background: #f8fafc;
  padding: 0.25rem 0.75rem;
  font-size: 0.75rem;
  font-weight: 500;
  color: #475569;
}

.status-chip {
  display: inline-flex;
  align-items: center;
  border-radius: 9999px;
  padding: 0.25rem 0.75rem;
  font-size: 0.75rem;
  font-weight: 500;
}

.status-chip-pending {
  background: #fef3c7;
  color: #b45309;
}

.status-chip-settled {
  background: #d1fae5;
  color: #047857;
}

.metric-card,
.summary-box,
.line-item-card,
.bill-system-box {
  border: 1px solid #e2e8f0;
  border-radius: 1rem;
  background: rgba(248, 250, 252, 0.92);
}

.metric-card {
  padding: 0.75rem 1rem;
}

.metric-label {
  margin: 0;
  font-size: 11px;
  font-weight: 500;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: #94a3b8;
}

.metric-value {
  margin: 0.375rem 0 0;
  font-size: 1.25rem;
  font-weight: 600;
  letter-spacing: -0.02em;
  color: #0f172a;
}

.metric-caption {
  margin: 0.125rem 0 0;
  font-size: 0.75rem;
  color: #64748b;
}

.table-wrap {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}

.table-shell {
  overflow: hidden;
}

.data-table {
  width: 100%;
  min-width: 760px;
  border-collapse: collapse;
  font-size: 0.875rem;
}

.data-table th {
  padding: 0.75rem 1rem;
  border-bottom: 1px solid #e2e8f0;
  background: #f8fafc;
  text-align: left;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: #64748b;
}

.data-table td {
  padding: 0.75rem 1rem;
  border-bottom: 1px solid #f1f5f9;
  vertical-align: top;
  color: #475569;
}

.mobile-card {
  padding: 1rem;
}

.inventory-summary-stock {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 3.5rem;
  padding: 0.25rem 0.75rem;
  border-radius: 9999px;
  background: #f8fafc;
  color: #475569;
  font-size: 0.75rem;
  font-weight: 600;
  white-space: nowrap;
}

.inventory-mobile-table-wrap {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}

.inventory-mobile-table {
  width: 100%;
  min-width: 560px;
  border-collapse: collapse;
  font-size: 0.875rem;
}

.inventory-mobile-table th {
  padding: 0.75rem 0.75rem 0.625rem;
  border-bottom: 1px solid #e2e8f0;
  text-align: left;
  font-size: 0.75rem;
  font-weight: 600;
  letter-spacing: 0.04em;
  color: #64748b;
  white-space: nowrap;
}

.inventory-mobile-table td {
  padding: 0.875rem 0.75rem;
  color: #475569;
  vertical-align: middle;
  white-space: nowrap;
}

.inventory-mobile-row-bordered td {
  border-bottom: 1px solid #eef2f7;
}

.inventory-mobile-name-cell {
  font-weight: 600;
  color: #0f172a;
}

.inventory-mobile-action-cell {
  display: flex;
  gap: 0.5rem;
  justify-content: flex-end;
}

.records-mobile-table-wrap {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}

.records-mobile-table {
  width: 100%;
  min-width: 640px;
  border-collapse: collapse;
  font-size: 0.875rem;
}

.records-mobile-table th {
  padding: 0.75rem 0.75rem 0.625rem;
  border-bottom: 1px solid #e2e8f0;
  text-align: left;
  font-size: 0.75rem;
  font-weight: 600;
  letter-spacing: 0.04em;
  color: #64748b;
  white-space: nowrap;
}

.records-mobile-table td {
  padding: 0.875rem 0.75rem;
  color: #475569;
  vertical-align: middle;
  white-space: nowrap;
}

.records-mobile-row-bordered td {
  border-bottom: 1px solid #eef2f7;
}

.records-mobile-name-cell {
  font-weight: 600;
  color: #0f172a;
}

.records-source-chip {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 4.5rem;
  padding: 0.25rem 0.75rem;
  border-radius: 9999px;
  background: #f8fafc;
  color: #475569;
  font-size: 0.75rem;
  font-weight: 600;
  white-space: nowrap;
}


.chat-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  width: 100%;
  min-height: 68px;
  padding: 0.875rem 1rem;
  border: 1px solid transparent;
  border-radius: 1rem;
  background: transparent;
  text-align: left;
  transition: background-color 0.18s ease, border-color 0.18s ease;
}

.chat-item:active {
  background: #eff6ff;
  border-color: #dbeafe;
}

.customer-swipe-row {
  position: relative;
  overflow: hidden;
  border-radius: 1rem;
}

.customer-swipe-actions {
  position: absolute;
  top: 0;
  right: 0;
  bottom: 0;
  display: flex;
  justify-content: flex-end;
}

.customer-swipe-content {
  position: relative;
  z-index: 1;
  background: #ffffff;
  transition: transform 0.2s ease;
  will-change: transform;
}

.customer-swipe-delete {
  width: 88px;
  border: 0;
  border-radius: 0 1rem 1rem 0;
  background: #ef4444;
  color: #ffffff;
  font-size: 0.875rem;
  font-weight: 600;
  cursor: pointer;
}

.customer-swipe-delete:active {
  background: #dc2626;
}

.summary-box,
.bill-system-box {
  padding: 0.75rem 1rem;
}

.line-item-card {
  padding: 0.875rem;
}

.bill-final-box {
  padding: 0.75rem 1rem;
  border: 1px solid #dbeafe;
  border-radius: 1rem;
  background: #eff6ff;
}

.empty-state {
  padding: 2.5rem 1.25rem;
  text-align: center;
}

.empty-state-icon {
  width: 3rem;
  height: 3rem;
  margin: 0 auto;
  border-radius: 1rem;
  background: #f1f5f9;
  color: #64748b;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.125rem;
  font-weight: 500;
}

.modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 50;
  display: none;
  padding: 1rem;
  background: rgba(15, 23, 42, 0.22);
  -webkit-backdrop-filter: blur(10px) saturate(135%);
  backdrop-filter: blur(10px) saturate(135%);
  overscroll-behavior: contain;
}

.modal-backdrop.show {
  display: block;
}

.modal-shell {
  display: flex;
  min-height: 100%;
  align-items: center;
  justify-content: center;
  padding: 1rem 0;
}

.inventory-feedback-modal-shell {
  align-items: center;
}

.modal-panel {
  width: 100%;
  max-width: 42rem;
  max-height: calc(100dvh - 2rem - env(safe-area-inset-bottom));
  display: flex;
  flex-direction: column;
  overflow: hidden;
  border: 1px solid rgba(255, 255, 255, 0.7);
  border-radius: 28px;
  background: rgba(255, 255, 255, 0.78);
  -webkit-backdrop-filter: blur(22px) saturate(155%);
  backdrop-filter: blur(22px) saturate(155%);
  padding: 1.25rem;
  box-shadow:
    0 18px 42px rgba(15, 23, 42, 0.12),
    inset 0 1px 0 rgba(255, 255, 255, 0.8);
}

@media (min-width: 640px) {
  .modal-shell {
    padding: 1.5rem 0;
  }

  .modal-panel {
    padding: 1.5rem;
  }
}

.modal-body {
  flex: 1 1 auto;
  min-height: 0;
  margin-top: 1rem;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  overscroll-behavior: contain;
  padding-bottom: calc(1rem + env(safe-area-inset-bottom));
}

.modal-actions {
  position: sticky;
  bottom: calc(-1rem - env(safe-area-inset-bottom));
  z-index: 1;
  display: flex;
  gap: 0.75rem;
  margin: 0;
  padding: 0.875rem 0 calc(0.25rem + env(safe-area-inset-bottom));
  border-top: 1px solid transparent;
  border-radius: 0;
  background: transparent;
  -webkit-backdrop-filter: none;
  backdrop-filter: none;
  box-shadow: none;
}

.modal-actions > * {
  flex: 1 1 0;
}

#billModal .modal-actions {
  position: static;
  bottom: auto;
  padding-top: 1rem;
}

@media (min-width: 640px) {
  .modal-actions {
    bottom: calc(-1rem - env(safe-area-inset-bottom));
  }
}

.bottom-nav {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 40;
  padding: 0.75rem 1rem calc(0.75rem + env(safe-area-inset-bottom));
}

.bottom-nav-inner {
  width: 100%;
  max-width: 32rem;
  margin: 0 auto;
  position: relative;
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 0.5rem;
  padding: 0.5rem;
  border: 1px solid rgba(255, 255, 255, 0.52);
  border-radius: 1.5rem;
  background: rgba(255, 255, 255, 0.46);
  -webkit-backdrop-filter: blur(22px) saturate(165%);
  backdrop-filter: blur(22px) saturate(165%);
  box-shadow:
    0 16px 34px rgba(15, 23, 42, 0.1),
    inset 0 1px 0 rgba(255, 255, 255, 0.65);
}

.bottom-nav-indicator {
  position: absolute;
  top: 0.45rem;
  left: 0;
  height: calc(100% - 0.9rem);
  border-radius: 1rem;
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.82), rgba(255, 255, 255, 0.62));
  border: 1px solid rgba(255, 255, 255, 0.72);
  box-shadow:
    0 8px 18px rgba(148, 163, 184, 0.18),
    inset 0 1px 0 rgba(255, 255, 255, 0.85);
  transform: translate3d(0, 0, 0);
  will-change: transform, width;
  pointer-events: none;
  z-index: 0;
}

.bottom-nav-indicator-animate {
  transition: transform 0.28s cubic-bezier(0.22, 1, 0.36, 1), width 0.28s cubic-bezier(0.22, 1, 0.36, 1);
}

.bottom-nav-link {
  position: relative;
  z-index: 1;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 44px;
  padding: 0.625rem 0.75rem;
  border-radius: 1rem;
  background: transparent !important;
  text-decoration: none;
  font-size: 0.875rem;
  font-weight: 600;
  color: rgba(71, 85, 105, 0.9);
  transition: color 0.22s ease;
}

.bottom-nav-link:active {
  color: #0f172a;
}

.bottom-nav-link-active {
  background: transparent !important;
  color: #0f172a !important;
  box-shadow: none !important;
}

.notice-box {
  margin-top: 0.75rem;
  border-radius: 1rem;
  border: 1px solid transparent;
  padding: 0.75rem 1rem;
  font-size: 0.875rem;
}

.notice-box.hidden {
  display: none;
}

.notice-success {
  border-color: #a7f3d0;
  background: #ecfdf5;
  color: #047857;
}

.notice-error {
  border-color: #fecaca;
  background: #fef2f2;
  color: #b91c1c;
}

.home-links {
  display: grid;
  gap: 0.75rem;
  margin-top: 1rem;
}

@media (min-width: 640px) {
  .home-links {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }
}
