:root {
  --hb-page: #f8fafc;
  --hb-ink: #0f172a;
  --hb-muted: #64748b;
  --hb-border: #e2e8f0;
  --hb-blue: #4f46e5;
  --warn: #b54708;
  --ok: #1a7f37;
  --danger: #b42318;
}

html, body, .page, .navbar, .nav-link, .page-title, .item-card, table {
  writing-mode: horizontal-tb;
  text-orientation: mixed;
}

body {
  background: var(--hb-page);
  color: var(--hb-ink);
}

.navbar-vertical {
  background-color: #ffffff;
  border-right: 1px solid #e2e8f0;
}

@media (min-width: 992px) {
  .navbar-vertical.navbar-expand-lg {
    width: 13rem;
  }
  .navbar-vertical.navbar-expand-lg ~ .page-wrapper {
    margin-left: 13rem !important;
  }
}

.dropdown-menu .dropdown-item {
  width: 100%;
  border: 0;
  background: transparent;
  text-align: left;
}

.page-body {
  background-color: #f8fafc;
  min-height: 100vh;
  min-height: 100dvh;
}

.app-content-container {
  width: 100%;
  min-width: 0;
}

.app-content-container > .container-xl,
.app-content-container .page-header .container-xl {
  max-width: none !important;
  width: 100% !important;
  padding-left: 24px;
  padding-right: 24px;
}

.navbar-nav .nav-link {
  color: rgb(71, 85, 105);
  font-weight: 500;
  border-radius: 6px;
  margin: 2px 8px;
  padding: 8px;
}

.navbar-nav .nav-link:hover {
  background-color: #f1f5f9;
  color: #0f172a;
}

.navbar-nav .nav-link.active,
.navbar-nav .nav-item.active > .nav-link {
  background-color: #e0e7ff;
  color: #4f46e5;
  font-weight: 600;
}

.navbar-brand {
  white-space: nowrap;
  flex-shrink: 0;
  margin-left: 0.5rem;
  margin-right: auto;
}
.navbar-brand > a {
  display: inline-flex;
  align-items: center;
}
.navbar-brand-image {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 2rem;
  height: 2rem;
  flex: 0 0 2rem;
  color: var(--tblr-primary);
  font-size: 1.75rem;
}
.navbar-brand-title {
  font-size: 20px;
  font-weight: 600;
  color: var(--tblr-primary);
  writing-mode: horizontal-tb;
  white-space: nowrap;
}
.nav-link-title {
  writing-mode: horizontal-tb;
  white-space: nowrap;
  font-weight: 500;
}

.navbar-vertical .navbar-nav {
  flex: 1 1 auto;
}


.card {
  border: 1px solid #e2e8f0;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.05);
  border-radius: 8px;
  background-color: #ffffff;
}

.btn-primary {
  background: linear-gradient(135deg, #4f46e5 0%, #6366f1 100%);
  border: none;
  box-shadow: 0 1px 2px rgba(79, 70, 229, 0.3);
}

.btn-primary:hover {
  background: linear-gradient(135deg, #4338ca 0%, #4f46e5 100%);
  box-shadow: 0 2px 4px rgba(79, 70, 229, 0.4);
}

.form-control,
.form-select {
  border: 1px solid #e2e8f0;
  border-radius: 6px;
}

.form-control:focus,
.form-select:focus {
  border-color: #6366f1;
  box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.1);
}

.filter-section-label {
  font-size: 12px;
  font-weight: 600;
  color: #64748b;
  margin-bottom: 10px;
}

.page-title {
  margin: 0;
  writing-mode: horizontal-tb;
  white-space: nowrap;
}

.login-page {
  display: flex;
  align-items: center;
  min-height: 100vh;
  min-height: 100dvh;
  padding-top: env(safe-area-inset-top, 0px);
  padding-bottom: env(safe-area-inset-bottom, 0px);
  padding-left: env(safe-area-inset-left, 0px);
  padding-right: env(safe-area-inset-right, 0px);
  box-sizing: border-box;
  background: #f8fafc;
}

.login-brand { margin-bottom: 1.25rem; }
.login-title { margin: 0 0 0.35rem; font-size: 1.75rem; line-height: 1.3; font-weight: 600; writing-mode: horizontal-tb; }
.login-subtitle { margin: 0; }
.login-heading { margin: 0 0 1.25rem; font-size: 1.25rem; line-height: 1.3; font-weight: 600; text-align: center; }

.service-status {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.4rem;
  margin-top: 1rem;
  font-size: 0.85rem;
  color: #6c7a91;
}
.service-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #adb5bd;
  flex-shrink: 0;
}
.service-status.online .service-dot { background: #2fb344; }
.service-status.offline .service-dot { background: #d63939; }
.service-status.checking .service-dot { background: #f76707; }
.service-status.offline { color: #d63939; }

.reimburse-body { padding-bottom: 28px; }

.toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: 10px 12px;
  align-items: end;
}
.toolbar .form-label {
  font-size: 12px;
  color: #64748b;
  font-weight: 600;
  margin: 0;
  min-width: 120px;
}
.toolbar .form-select,
.toolbar .form-control {
  min-width: 140px;
  background: #fff;
}

.drop {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  align-items: center;
  padding: 8px 0;
}
.drop-copy {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
  flex: 1;
}
.drop-copy span { color: #64748b; font-size: 12px; }
.drop.over { background: #eef2ff; border-radius: 8px; }
.camera-actions { display: flex; gap: 8px; flex-wrap: wrap; }
.only-mobile { display: none !important; }
.file-input {
  position: absolute;
  width: 1px;
  height: 1px;
  opacity: 0;
  overflow: hidden;
}
.upload-progress {
  margin-top: 8px;
  color: #64748b;
  font-size: 13px;
}

.batch-bar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px 12px;
}
.check-all, .check {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-weight: 400;
  margin: 0;
}

.layout {
  display: grid;
  grid-template-columns: 320px minmax(0, 1fr);
  gap: 16px;
  min-height: calc(100dvh - 360px);
}
.list.card,
.detail.card {
  min-height: 0;
  overflow: auto;
}
.list.card { padding: 0; }
.detail.card {
  padding: 12px;
  display: grid;
  grid-template-columns: minmax(240px, 42%) minmax(280px, 1fr);
  gap: 12px;
  overflow: hidden;
  align-items: stretch;
}
.item-card {
  padding: 12px 14px;
  border-bottom: 1px solid #e2e8f0;
  cursor: pointer;
  background: #fff;
  box-shadow: none;
  border-radius: 0;
  min-width: 0;
}
.item-card:hover { background: #f8fafc; }
.item-card.active { background: #eef2ff; }
.item-card .amt { font-size: 18px; font-weight: 700; writing-mode: horizontal-tb; }
.item-card .amt.pending { color: var(--warn); }
.item-card .amt.confirmed { color: var(--ok); }
.meta { color: #64748b; font-size: 12px; writing-mode: horizontal-tb; white-space: normal; word-break: break-word; }
.detail .empty { grid-column: 1 / -1; color: #64748b; padding: 48px 16px; text-align: center; }
.preview-pane {
  min-height: 0;
  overflow: auto;
  background: #111;
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
}
.preview {
  width: 100%;
  height: 100%;
  object-fit: contain;
  background: #111;
  border-radius: 8px;
}
form#review, #review {
  display: flex;
  flex-direction: column;
  gap: 8px;
  min-height: 0;
  overflow: auto;
}
.dialog label,
.modal-body label,
.reimburse-body #review label {
  display: flex;
  flex-direction: column;
  gap: 4px;
  font-weight: 600;
}
input.amount { font-size: 22px; font-weight: 700; color: var(--warn); }
.hint { font-weight: 400; color: #64748b; font-size: 12px; }
.actions { display: flex; gap: 8px; margin-top: 8px; flex-wrap: wrap; }
.sticky-actions {
  position: sticky;
  bottom: 0;
  background: linear-gradient(#fffc 70%, #fff);
  padding: 8px 0 2px;
  border-top: 1px solid #e2e8f0;
  z-index: 1;
}
.raw-box { font-weight: 400; }
.raw-box summary { cursor: pointer; color: #64748b; font-size: 12px; }
.raw { white-space: pre-wrap; background: #f8fafc; border-radius: 6px; padding: 8px; max-height: 180px; overflow: auto; font-size: 12px; color: #64748b; }
.badge { display: inline-block; padding: 0.375rem 0.75rem; font-weight: 500; border-radius: 6px; background: #eef2f6; font-size: 12px; }
.candidates { display: flex; flex-wrap: wrap; gap: 6px; }
.card-head { display: flex; justify-content: space-between; align-items: center; gap: 8px; }
.icon-del {
  background: transparent;
  color: var(--danger);
  border: 1px solid transparent;
  padding: 2px 8px;
  font-size: 12px;
}
.icon-del:hover { border-color: var(--danger); background: #fff5f5; }
.attach-box { display: flex; flex-direction: column; gap: 8px; }
.atts { display: flex; flex-direction: column; gap: 6px; }
.att { display: flex; justify-content: space-between; align-items: center; gap: 8px; padding: 6px 8px; background: #f8fafc; border-radius: 6px; }
.att a { color: #4f46e5; }
.dup {
  display: inline-block;
  margin-left: 6px;
  padding: 0 6px;
  border-radius: 999px;
  background: #fff4e5;
  color: var(--warn);
  font-size: 12px;
}

.modal {
  position: fixed !important;
  inset: 0;
  background: rgba(15, 23, 42, .35);
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 2000;
  padding: 16px;
  width: auto;
  height: auto;
  overflow: auto;
}
.modal:not([hidden]) { display: flex !important; }
.modal .modal-dialog { margin: 0; width: min(640px, 100%); }
.dialog, .modal-content {
  background: #fff;
  border-radius: 8px;
  box-shadow: 0 12px 40px rgba(15, 23, 42, .18);
}
.modal-title, .dialog h2 { margin: 0; font-size: 18px; }
.err { color: var(--danger); min-height: 1.2em; font-weight: 400; }
.user-create { display: grid; grid-template-columns: 1fr 1fr auto; gap: 8px; margin-bottom: 12px; }
.table-wrap {
  overflow-x: auto;
  max-height: 50vh;
  -webkit-overflow-scrolling: touch;
}
table.users {
  width: 100%;
  min-width: 520px;
  border-collapse: collapse;
}
table.users th, table.users td {
  text-align: left;
  padding: 8px;
  border-bottom: 1px solid #e2e8f0;
  writing-mode: horizontal-tb;
  white-space: nowrap;
}
.user-actions { display: flex; gap: 6px; flex-wrap: wrap; }

@media (max-width: 991.98px) {
  .only-mobile { display: inline-flex !important; }
  .layout, .detail.card { grid-template-columns: 1fr; }
  .list.card { max-height: 40vh; }
  .preview-pane, .preview { max-height: 42vh; }
  .app-content-container > .container-xl,
  .app-content-container .page-header .container-xl {
    padding-left: 16px;
    padding-right: 16px;
  }
  .user-create { grid-template-columns: 1fr; }
  .page-header .btn-list { display: flex; flex-wrap: wrap; gap: 8px; }
}

@media (max-width: 991.98px) {
  .navbar-vertical.navbar-expand-lg {
    position: fixed;
    inset: 0 0 auto;
    z-index: 1030;
    width: 100%;
    min-height: calc(56px + env(safe-area-inset-top, 0px));
    height: auto;
    padding-top: env(safe-area-inset-top, 0px);
  }
  .page {
    --mobile-header-height: 56px;
    padding-top: var(--mobile-header-height);
  }
  .navbar-vertical.navbar-expand-lg > .container-fluid {
    min-height: 56px;
    align-items: center;
    flex-wrap: nowrap;
  }
  .navbar-vertical.navbar-expand-lg .navbar-collapse {
    position: fixed !important;
    top: var(--mobile-header-height);
    bottom: 0;
    left: 0;
    z-index: 1031;
    display: block !important;
    width: min(82vw, 300px);
    height: calc(100dvh - var(--mobile-header-height)) !important;
    padding: 0.5rem 0;
    overflow-y: auto;
    background: #ffffff;
    box-shadow: 8px 0 24px rgba(15, 23, 42, 0.12);
    transform: translateX(-105%);
    visibility: hidden;
    transition: transform 0.2s ease, visibility 0.2s ease;
    overscroll-behavior: contain;
  }
  .navbar-vertical.navbar-expand-lg .navbar-collapse.show {
    transform: translateX(0);
    visibility: visible;
  }
  .navbar-vertical.navbar-expand-lg .navbar-collapse.collapsing {
    height: calc(100dvh - var(--mobile-header-height)) !important;
    display: block !important;
  }
  .navbar-vertical.navbar-expand-lg:has(.navbar-collapse.show)::after {
    content: '';
    position: fixed;
    inset: var(--mobile-header-height) 0 0 0;
    z-index: 1030;
    background: rgba(15, 23, 42, 0.18);
    pointer-events: auto;
  }
}

@media (max-width: 767.98px) {
  .page-wrapper,
  .page-body,
  .container-xl {
    min-width: 0;
    max-width: 100%;
  }

  .page-wrapper > .page-body > .container-xl,
  .page-body > .container-xl,
  .page-header > .container-xl,
  .app-content-container > .container-xl,
  .app-content-container .page-header .container-xl {
    padding-left: 12px;
    padding-right: 12px;
    box-sizing: border-box;
  }

  .page-header .row {
    align-items: flex-start !important;
  }
  .page-header .col-auto:has(.btn-list),
  .page-header .col-auto.ms-auto:has(.btn-list) {
    width: 100%;
    margin-left: 0 !important;
  }
  .page-header .btn-list {
    display: grid;
    grid-template-columns: minmax(0, 1fr);
    width: 100%;
  }
  .page-header .btn-list > .btn,
  .page-header .btn-list > a {
    width: 100%;
    justify-content: center;
  }

  .btn, .navbar-toggler, .navbar-nav .nav-link, label.btn, .dropdown-item {
    min-height: 44px;
  }
  .form-control, .form-select, input, select, textarea {
    min-height: 44px;
    font-size: 16px !important;
  }

  .toolbar {
    flex-direction: column;
    align-items: stretch;
  }
  .toolbar .form-label,
  .toolbar .form-select,
  .toolbar .form-control,
  .toolbar .btn {
    width: 100%;
    min-width: 0;
  }

  .item-card .amt,
  .item-card .meta,
  .page-title,
  .navbar-brand-title,
  .nav-link-title {
    writing-mode: horizontal-tb;
  }

  .table-wrap {
    position: relative;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    box-shadow: inset -18px 0 18px -18px rgba(15, 23, 42, 0.55);
  }
  .table-wrap::before {
    content: "左右滑动查看更多";
    display: block;
    margin-bottom: .5rem;
    color: #64748b;
    font-size: .75rem;
  }

  .login-page {
    align-items: stretch;
  }
  .login-wrap {
    display: flex;
    flex-direction: column;
    justify-content: center;
    width: 100%;
    max-width: 28rem;
    margin: 0 auto;
    padding: 1rem 1rem 1.5rem;
    min-height: 100%;
  }
  .login-title { font-size: 1.375rem; }
  .login-heading { margin-bottom: 1rem; font-size: 1.05rem; }
  .login-card { box-shadow: none; }
  .login-card .card-body { padding: 1.25rem 1rem; }
  .login-page .form-control {
    font-size: 16px;
    min-height: 44px;
  }
  .login-submit {
    min-height: 44px;
    font-size: 1rem;
  }
}
