:root {
  font-family: "Microsoft YaHei", "PingFang SC", Arial, sans-serif;
  font-size: 13px;
  color: #333;
  background: #f2f2f2;
}

* { box-sizing: border-box; }
body { margin: 0; min-width: 320px; }
button, input, select, textarea { font: inherit; }
button { cursor: pointer; }

.topbar {
  height: 50px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: #23262e;
  color: #fff;
  position: sticky;
  top: 0;
  z-index: 30;
}
.header-left, .header-right { height: 100%; display: flex; align-items: center; }
.brand {
  width: 200px;
  padding: 0 18px;
  font-size: 18px;
  font-weight: 600;
  line-height: 50px;
  white-space: nowrap;
}
.brand span { margin-left: 10px; color: #b1b3b9; font-size: 12px; font-weight: 400; }
.menu-toggle {
  width: 50px;
  height: 50px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 4px;
  border: 0;
  background: transparent;
}
.menu-toggle:hover, .header-right button:hover { background: #393d49; }
.menu-toggle span { display: block; width: 17px; height: 2px; background: #c2c3c7; }
.header-right { gap: 0; color: #c2c3c7; }
.header-right #connection-state { padding: 0 16px; }
.header-right button {
  height: 50px;
  min-width: 68px;
  border: 0;
  color: #c2c3c7;
  background: transparent;
}

.login-view { min-height: calc(100vh - 50px); display: grid; place-items: center; padding: 20px; }
.login-box { width: min(400px, 100%); background: #fff; border: 1px solid #e6e6e6; border-top: 3px solid #009688; padding: 30px; }
.login-box h1 { margin: 0 0 28px; font-size: 20px; font-weight: 500; text-align: center; }
.login-box form { display: grid; gap: 12px; }
.login-box label { color: #555; }
.login-box input, .login-box button { width: 100%; }

.admin-layout { min-height: calc(100vh - 50px); display: grid; grid-template-columns: 200px minmax(0, 1fr); }
.sidebar {
  min-width: 0;
  height: calc(100vh - 50px);
  position: sticky;
  top: 50px;
  overflow-y: auto;
  overflow-x: hidden;
  background: #20222a;
}
.sidebar nav { padding: 12px 0 22px; }
.nav-group { padding: 18px 18px 7px; color: #7f838e; font-size: 12px; white-space: nowrap; }
.sidebar nav button {
  display: flex;
  align-items: center;
  width: 100%;
  height: 41px;
  padding: 0 16px;
  border: 0;
  border-left: 4px solid transparent;
  background: transparent;
  color: #c2c2c2;
  text-align: left;
  white-space: nowrap;
  font-size: 13px;
}
.sidebar nav button:hover { background: #2f333e; color: #fff; }
.sidebar nav button.active { background: #009688; border-left-color: #55c8b8; color: #fff; }
.nav-mark { display: block; width: 7px; height: 7px; margin-right: 14px; border: 1px solid currentColor; border-radius: 1px; opacity: .8; }
.sidebar-scrim { display: none; }
.sidebar-collapsed .admin-layout { grid-template-columns: 0 minmax(0, 1fr); }
.sidebar-collapsed .sidebar { visibility: hidden; }

.main-content { min-width: 0; padding: 18px 20px 36px; }
.workspace-heading { margin-bottom: 18px; }
.breadcrumb { color: #888; font-size: 12px; line-height: 20px; }
.breadcrumb span { margin: 0 6px; }
.breadcrumb strong { color: #666; font-weight: 400; }
.workspace-heading h1 { margin: 8px 0 0; font-size: 20px; font-weight: 500; line-height: 28px; }

.card, .panel, .dashboard-panel {
  background: #fff;
  border: 1px solid #e6e6e6;
  border-radius: 2px;
}
.card { padding: 18px; }
.section-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  min-height: 36px;
  margin-bottom: 16px;
}
.section-head h2 { margin: 0; font-size: 15px; font-weight: 500; }
.section-head > div, .toolbar-actions { display: flex; align-items: center; gap: 8px; }
.hint { margin: 0; color: #888; font-size: 12px; line-height: 1.7; }
.hint + .form-grid { margin-top: 18px; }
.form-grid + .hint { padding-top: 16px; border-top: 1px solid #eee; }

button:not(.menu-toggle):not(.sidebar-scrim):not(.stat-card):not([data-subtab]):not([data-tab]):not(#logout-button) {
  min-height: 34px;
  padding: 6px 15px;
  border: 1px solid #009688;
  border-radius: 2px;
  background: #009688;
  color: #fff;
  white-space: nowrap;
}
button:not(.menu-toggle):not(.sidebar-scrim):not(.stat-card):not([data-subtab]):not([data-tab]):not(#logout-button):hover { background: #008579; }
button.secondary { background: #fff; color: #555; border-color: #d2d2d2; }
button.secondary:hover { background: #f7f7f7; }
button:disabled { opacity: .55; cursor: not-allowed; }

input, select, textarea {
  min-height: 36px;
  width: 100%;
  padding: 7px 10px;
  border: 1px solid #d2d2d2;
  border-radius: 2px;
  outline: none;
  background: #fff;
  color: #333;
}
input:focus, select:focus, textarea:focus { border-color: #5fb9aa; }
textarea { min-height: 80px; resize: vertical; }
.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); column-gap: 28px; row-gap: 15px; max-width: 1100px; }
.form-grid label, .review-form label { display: grid; grid-template-columns: 132px minmax(0, 1fr); align-items: center; gap: 10px; color: #555; min-width: 0; }
.form-grid .wide { grid-column: 1 / -1; }
.form-grid .wide textarea { max-width: 800px; }
.form-actions { display: flex; gap: 10px; padding-left: 142px; }
.settings-secondary-head { margin-top: 24px; padding-top: 18px; border-top: 1px solid #eee; }
.inline-filter { display: flex; align-items: center; gap: 8px; color: #666; white-space: nowrap; }
.inline-filter select { width: min(330px, 33vw); }
.list-filter { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.list-filter input { width: min(300px, 32vw); }
.list-filter select { width: 120px; }
.list-footer { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-top: 14px; color: #666; }
.list-footer > div { display: flex; align-items: center; gap: 10px; }
.scope-bar { display: flex; align-items: center; gap: 12px; margin-bottom: 12px; color: #666; }

.subtabs { height: 44px; display: flex; align-items: stretch; gap: 0; border-bottom: 1px solid #e6e6e6; padding-left: 10px; }
.subtabs button { min-width: 96px; padding: 0 18px; border: 0; border-bottom: 2px solid transparent; background: transparent; color: #666; }
.subtabs button:hover { color: #009688; }
.subtabs button.active { border-bottom-color: #009688; color: #009688; }
.subtab-pane { padding: 18px; }

.table-wrap { max-width: 100%; overflow-x: auto; }
table { border-collapse: collapse; width: 100%; min-width: 760px; table-layout: auto; }
th, td { border: 1px solid #e6e6e6; padding: 9px 11px; text-align: left; vertical-align: middle; line-height: 1.5; }
th { background: #f2f2f2; font-weight: 500; color: #555; white-space: nowrap; }
td { overflow-wrap: anywhere; }
tbody tr:hover { background: #fafafa; }
td button { min-height: 28px !important; padding: 3px 9px !important; margin: 0 5px 4px 0; font-size: 12px; }
.cell-subline { color: #888; font-size: 12px; }
.shipment-price { font-weight: 600; white-space: nowrap; }

.review-form { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px 28px; margin-top: 20px; padding: 18px; background: #fafafa; border: 1px solid #e6e6e6; }
.review-form h3, .review-form button { grid-column: 1 / -1; }
.review-form h3 { margin: 0; font-size: 15px; font-weight: 500; }
.review-form label:has(textarea) { grid-column: 1 / -1; }
.review-form label textarea { max-width: 800px; }
.review-form button { justify-self: start; margin-left: 142px; }

.dashboard-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 16px; margin-bottom: 18px; }
.dashboard-note { margin: 0 0 16px; padding: 10px 14px; border: 1px solid #e6dcc4; background: #fffaf0; color: #6d5b37; line-height: 1.6; }
.stat-card { display: flex; flex-direction: column; align-items: flex-start; min-width: 0; min-height: 150px; padding: 17px 20px; border: 1px solid #e6e6e6; border-top: 2px solid #009688; border-radius: 2px; background: #fff; color: #666; text-align: left; }
.stat-card:hover { border-color: #b8dcd6; background: #fcfffe; }
.stat-label { font-size: 13px; }
.stat-card strong { margin: 12px 0 8px; color: #009688; font-size: 28px; line-height: 1; font-weight: 500; }
.stat-link { margin-top: auto; color: #888; font-size: 12px; }
.dashboard-panel { padding: 18px; }
.dashboard-totals { margin-top: 18px; }
.dashboard-totals dl { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 0; margin: 0; border-top: 1px solid #eee; border-left: 1px solid #eee; }
.dashboard-totals dl > div { padding: 12px 14px; border-right: 1px solid #eee; border-bottom: 1px solid #eee; }
.dashboard-totals dt { color: #777; }
.dashboard-totals dd { margin: 5px 0 0; font-size: 18px; }
.quick-actions { display: flex; gap: 10px; flex-wrap: wrap; }

#message { position: fixed; z-index: 60; right: 20px; top: 62px; max-width: min(440px, calc(100vw - 40px)); margin: 0; padding: 10px 16px; border: 1px solid #cde9e4; border-left: 3px solid #009688; background: #fff; color: #356b62; box-shadow: 0 4px 16px #00000012; }
#message.error { border-color: #f3d4d1; border-left-color: #c84a40; color: #9d312a; }
dialog { width: min(920px, calc(100vw - 32px)); max-height: 86vh; padding: 18px; border: 1px solid #ddd; border-radius: 2px; }
dialog::backdrop { background: #0008; }
#shipment-dialog { width: min(680px, calc(100vw - 32px)); overflow-y: auto; }
#user-dialog { width: min(900px, calc(100vw - 32px)); overflow-y: auto; }
#user-detail-content { max-height: calc(86vh - 100px); overflow-y: auto; }
.user-fields { display: grid; grid-template-columns: 130px minmax(0, 1fr); margin: 0; }
.user-fields dt, .user-fields dd { min-width: 0; margin: 0; padding: 9px 0; border-bottom: 1px solid #eee; line-height: 1.5; overflow-wrap: anywhere; }
.user-fields dt { color: #777; }
.user-photo-action { margin: 14px 0; }
.user-recent { margin-top: 18px; }
.user-recent h3 { margin: 0 0 8px; font-size: 14px; font-weight: 500; }
.user-recent p { color: #888; margin: 8px 0; }
.user-recent-row { padding: 8px 0; border-top: 1px solid #eee; line-height: 1.5; overflow-wrap: anywhere; }
#shipment-details { display: grid; grid-template-columns: 110px minmax(0, 1fr); margin: 0; }
#shipment-details dt, #shipment-details dd { min-width: 0; margin: 0; padding: 10px 0; border-bottom: 1px solid #eee; line-height: 1.5; overflow-wrap: anywhere; }
#shipment-details dt { color: #777; }
#photo-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 12px; overflow-y: auto; }
#photo-grid figure { margin: 0; }
#photo-grid img { width: 100%; max-height: 500px; object-fit: contain; background: #f5f5f5; }
#photo-grid figcaption { padding: 6px 0; color: #777; font-size: 12px; overflow-wrap: anywhere; }

@media (max-width: 1100px) {
  .dashboard-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .dashboard-totals dl { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .form-grid { grid-template-columns: 1fr; }
  .form-grid .wide { grid-column: 1; }
}
@media (max-width: 800px) {
  .brand { width: 172px; }
  .admin-layout, .sidebar-collapsed .admin-layout { display: block; }
  .sidebar, .sidebar-collapsed .sidebar {
    position: fixed;
    z-index: 25;
    top: 50px;
    left: 0;
    width: 200px;
    height: calc(100vh - 50px);
    transform: translateX(-100%);
    transition: transform .18s ease;
    visibility: visible;
  }
  .sidebar-open .sidebar { transform: translateX(0); }
  .sidebar-open .sidebar-scrim { display: block; position: fixed; z-index: 24; inset: 50px 0 0; width: 100%; border: 0; background: #0007; }
  .main-content { padding: 14px 12px 28px; }
  .section-head { align-items: flex-start; flex-direction: column; }
  .section-head > div, .toolbar-actions { flex-wrap: wrap; }
  .inline-filter select { width: min(330px, 60vw); }
  .list-filter { width: 100%; }
  .list-filter input { width: min(300px, 60vw); }
}
@media (max-width: 560px) {
  .header-right #connection-state { display: none; }
  .dashboard-grid { gap: 10px; }
  .stat-card { min-height: 130px; padding: 14px; }
  .stat-card strong { font-size: 24px; }
  .card, .subtab-pane, .dashboard-panel { padding: 14px; }
  .form-grid label, .review-form label { grid-template-columns: 1fr; gap: 6px; }
  .form-actions, .review-form button { padding-left: 0; margin-left: 0; }
  .review-form { grid-template-columns: 1fr; }
  .review-form h3, .review-form button, .review-form label:has(textarea) { grid-column: 1; }
  .list-footer { align-items: flex-start; flex-direction: column; }
  .user-fields { grid-template-columns: 100px minmax(0, 1fr); }
}
