:root {
  --sidebar-bg: #1a2332;
  --sidebar-w: 220px;
  --sidebar-text: rgba(255, 255, 255, 0.55);
  --sidebar-active: #0891b2;
  --primary: #0891b2;
  --primary-hover: #0e7490;
  --main-bg: #f0f2f5;
  --card: #ffffff;
  --border: #e8e8e8;
  --text: #333333;
  --muted: #999999;
  --accent: #0891b2;
  --danger: #d97706;
  --ok: #52c41a;
  --warning: #faad14;
  --info: #1890ff;
  --shadow: 0 1px 4px rgba(0, 0, 0, 0.08);
  --radius: 8px;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: "PingFang SC", "Microsoft YaHei", system-ui, sans-serif;
  background: var(--main-bg);
  color: var(--text);
  min-height: 100vh;
}

.hidden {
  display: none !important;
}

.sub {
  color: var(--muted);
  font-size: 0.875rem;
}

/* ── 登录页 ── */
.login-screen {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--main-bg);
  padding: 24px 16px;
}

.login-box {
  width: 100%;
  max-width: 420px;
}

.login-brand {
  display: flex;
  align-items: center;
  gap: 14px;
  margin-bottom: 24px;
}

.login-logo {
  width: 48px;
  height: 48px;
  border-radius: 50%;
  background: var(--sidebar-active);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 20px;
  font-weight: 700;
  flex-shrink: 0;
}

.login-brand h1 {
  font-size: 1.25rem;
  font-weight: 600;
  margin: 0 0 4px;
  color: var(--text);
}

.login-brand .sub {
  margin: 0;
}

/* ── App Shell ── */
.app-shell {
  display: flex;
  min-height: 100vh;
}

.sidebar {
  width: var(--sidebar-w);
  background: var(--sidebar-bg);
  display: flex;
  flex-direction: column;
  flex-shrink: 0;
  position: fixed;
  top: 0;
  left: 0;
  bottom: 0;
  z-index: 100;
}

.sidebar-brand {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 20px 16px 16px;
}

.sidebar-logo {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: var(--sidebar-active);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 15px;
  font-weight: 700;
  flex-shrink: 0;
}

.sidebar-title {
  color: #fff;
  font-size: 14px;
  font-weight: 600;
  line-height: 1.3;
}

.sidebar-sub {
  color: var(--sidebar-text);
  font-size: 11px;
  margin-top: 2px;
}

.sidebar-nav {
  flex: 1;
  padding: 8px 12px;
  display: flex;
  flex-direction: column;
  gap: 4px;
  overflow-y: auto;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  padding: 10px 14px;
  border: none;
  border-radius: var(--radius);
  background: transparent;
  color: var(--sidebar-text);
  font-size: 14px;
  cursor: pointer;
  text-align: left;
  transition: background 0.15s, color 0.15s;
  font-family: inherit;
}

.nav-item:hover {
  color: rgba(255, 255, 255, 0.85);
  background: rgba(255, 255, 255, 0.06);
}

.nav-item.active {
  background: var(--sidebar-active);
  color: #fff;
}

.nav-icon {
  width: 18px;
  height: 18px;
  flex-shrink: 0;
}

.sidebar-footer {
  padding: 16px;
  border-top: 1px solid rgba(255, 255, 255, 0.08);
}

.sidebar-user {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 12px;
  width: 100%;
  padding: 6px 4px;
  border: none;
  border-radius: var(--radius);
  background: transparent;
  cursor: pointer;
  text-align: left;
  font-family: inherit;
  transition: background 0.15s;
}

.sidebar-user:hover {
  background: rgba(255, 255, 255, 0.06);
}

.sidebar-avatar {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.12);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 14px;
  flex-shrink: 0;
}

.sidebar-user-name {
  color: #fff;
  font-size: 13px;
  font-weight: 500;
}

.sidebar-user-role {
  color: var(--sidebar-text);
  font-size: 11px;
  margin-top: 2px;
}

.btn-sidebar-logout {
  width: 100%;
  padding: 8px;
  border: 1px solid rgba(255, 255, 255, 0.2);
  border-radius: var(--radius);
  background: transparent;
  color: rgba(255, 255, 255, 0.65);
  font-size: 13px;
  cursor: pointer;
  font-family: inherit;
  transition: background 0.15s;
}

.btn-sidebar-logout:hover {
  background: rgba(255, 255, 255, 0.06);
  color: #fff;
}

.main-wrap {
  flex: 1;
  margin-left: var(--sidebar-w);
  min-width: 0;
  display: flex;
  flex-direction: column;
}

.page-header {
  background: var(--card);
  padding: 16px 24px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}

.page-title {
  margin: 0;
  font-size: 1.125rem;
  font-weight: 600;
  color: var(--text);
}

.page-date {
  font-size: 13px;
  color: var(--muted);
}

.main-content {
  flex: 1;
  padding: 20px 24px 32px;
  overflow-y: auto;
}

/* ── 卡片 ── */
.card {
  background: var(--card);
  border-radius: var(--radius);
  padding: 20px;
  margin-bottom: 16px;
  box-shadow: var(--shadow);
}

.card-head {
  font-weight: 600;
  font-size: 15px;
  margin-bottom: 16px;
  color: var(--text);
}

.card-head-inline {
  font-weight: 600;
  font-size: 15px;
}

.card-desc {
  margin: -8px 0 12px;
}

/* ── 欢迎横幅 ── */
.welcome-banner {
  background: #ecfdf5;
  color: #065f46;
  padding: 12px 18px;
  border-radius: var(--radius);
  font-size: 14px;
  margin-bottom: 20px;
}

/* ── 统计卡片 ── */
.stat-cards {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 16px;
  margin-bottom: 20px;
}

.stat-card {
  background: var(--card);
  border-radius: var(--radius);
  padding: 20px;
  display: flex;
  align-items: center;
  gap: 16px;
  box-shadow: var(--shadow);
}

.stat-icon {
  width: 48px;
  height: 48px;
  border-radius: var(--radius);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.stat-icon svg {
  width: 24px;
  height: 24px;
}

.stat-icon--blue {
  background: #e6f4ff;
  color: #1890ff;
}

.stat-icon--green {
  background: #f6ffed;
  color: #52c41a;
}

.stat-icon--orange {
  background: #fff7e6;
  color: #fa8c16;
}

.stat-icon--purple {
  background: #f3e8ff;
  color: #9333ea;
}

.stat-value {
  font-size: 1.75rem;
  font-weight: 700;
  line-height: 1.2;
  color: var(--text);
}

.stat-label {
  font-size: 13px;
  color: var(--muted);
  margin-top: 4px;
}

/* ── 工作台中间区域 ── */
.dash-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
  margin-bottom: 16px;
}

.dash-grid .card {
  margin-bottom: 0;
}

.bar-list {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.bar-item {
  display: flex;
  align-items: center;
  gap: 12px;
}

.bar-label {
  width: 72px;
  font-size: 13px;
  color: var(--text);
  flex-shrink: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.bar-track {
  flex: 1;
  height: 8px;
  background: #f0f0f0;
  border-radius: 4px;
  overflow: hidden;
}

.bar-fill {
  height: 100%;
  border-radius: 4px;
  transition: width 0.3s;
}

.bar-fill--green { background: #52c41a; }
.bar-fill--blue { background: #1890ff; }
.bar-fill--orange { background: #faad14; }
.bar-fill--purple { background: #9333ea; }

.bar-count {
  width: 36px;
  text-align: right;
  font-size: 13px;
  color: var(--muted);
  flex-shrink: 0;
}

.tag-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.tag-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 12px;
  background: #fafafa;
  border: 1px solid var(--border);
  border-radius: 20px;
  font-size: 13px;
}

.tag-badge .tag-count {
  background: var(--sidebar-active);
  color: #fff;
  font-size: 11px;
  padding: 1px 7px;
  border-radius: 10px;
  font-weight: 500;
}

/* ── 数据表格 ── */
.table-wrap {
  overflow-x: auto;
}

.data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}

.data-table th {
  text-align: left;
  padding: 10px 12px;
  color: var(--muted);
  font-weight: 500;
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}

.data-table td {
  padding: 12px;
  border-bottom: 1px solid #f5f5f5;
  vertical-align: middle;
}

.data-table tbody tr:last-child td {
  border-bottom: none;
}

.data-table tbody tr:hover {
  background: #fafafa;
}

.badge {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 4px;
  font-size: 12px;
  font-weight: 500;
  color: #fff;
}

.badge--ok { background: #52c41a; }
.badge--info { background: #1890ff; }
.badge--warn { background: #faad14; }
.badge--muted { background: #d9d9d9; color: #666; }

.link-btn {
  background: none;
  border: none;
  color: var(--accent);
  cursor: pointer;
  font-size: 13px;
  padding: 0;
  font-family: inherit;
}

.link-btn:hover {
  text-decoration: underline;
}

/* ── 表单 ── */
.toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  align-items: center;
  margin-bottom: 16px;
}

input[type="password"],
input[type="text"],
input[type="tel"],
textarea {
  background: #fff;
  border: 1px solid #d9d9d9;
  color: var(--text);
  border-radius: 6px;
  padding: 8px 12px;
  font-size: 14px;
  width: 100%;
  transition: border-color 0.15s;
  font-family: inherit;
}

input:focus,
textarea:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 2px rgba(24, 144, 255, 0.1);
}

textarea {
  min-height: 80px;
  resize: vertical;
}

label {
  display: block;
  font-size: 13px;
  color: var(--muted);
  margin-bottom: 6px;
}

.field {
  margin-bottom: 14px;
}

.btn {
  border: none;
  border-radius: 6px;
  padding: 8px 16px;
  font-size: 14px;
  cursor: pointer;
  font-weight: 500;
  font-family: inherit;
  transition: opacity 0.15s;
}

.btn-primary {
  background: var(--primary);
  color: #fff;
}

.btn-primary:hover {
  opacity: 1;
  background: var(--primary-hover);
}

.btn-ghost {
  background: #fff;
  color: var(--text);
  border: 1px solid #d9d9d9;
}

.btn-ghost:hover {
  border-color: var(--accent);
  color: var(--accent);
}

.btn-danger {
  background: #fff;
  color: var(--danger);
  border: 1px solid #fcd34d;
}

.btn-danger:hover {
  background: #fffbeb;
}

.btn-block {
  width: 100%;
}

.grid-2 {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

.grid-3 {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  gap: 12px;
}

/* 渔船编辑表单：紧凑宽度，按内容类型定宽 */
.boat-form .form-row {
  display: flex;
  flex-wrap: wrap;
  gap: 12px 16px;
  margin-bottom: 4px;
}

.boat-form .field {
  margin-bottom: 10px;
}

.boat-form .form-row .field {
  margin-bottom: 0;
}

.boat-form input[type="text"],
.boat-form input[type="tel"],
.boat-form textarea {
  width: 100%;
}

.boat-form .field--xs { width: 88px; }
.boat-form .field--sm { width: 132px; }
.boat-form .field--md { width: 168px; }
.boat-form .field--lg { width: 280px; }
.boat-form .field--full {
  width: 100%;
  max-width: 420px;
}

.boat-form textarea {
  min-height: 72px;
}

.section-label {
  font-size: 12px;
  color: var(--muted);
  margin: 4px 0 10px;
  padding-bottom: 6px;
  border-bottom: 1px solid var(--border);
}

/* ── 列表 ── */
.list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.list-item {
  display: flex;
  gap: 12px;
  align-items: flex-start;
  padding: 10px 12px;
  border-radius: var(--radius);
  background: #fafafa;
  border: 1px solid transparent;
  cursor: pointer;
  transition: border-color 0.15s, background 0.15s;
}

.list-item:hover {
  background: #f0f5ff;
}

.list-item.active {
  border-color: var(--accent);
  background: #e6f4ff;
}

.thumb {
  width: 56px;
  height: 56px;
  border-radius: 6px;
  object-fit: cover;
  background: #eee;
  flex-shrink: 0;
}

.list-meta {
  flex: 1;
  min-width: 0;
}

.list-title {
  font-weight: 600;
  font-size: 14px;
  margin-bottom: 3px;
}

.list-sub {
  font-size: 12px;
  color: var(--muted);
}

/* ── 分栏布局 ── */
.split {
  display: grid;
  gap: 16px;
  align-items: stretch;
}

.split--two {
  grid-template-columns: minmax(240px, 300px) minmax(320px, 1fr);
}

.split--three {
  grid-template-columns: minmax(220px, 280px) minmax(300px, 1fr) minmax(220px, 280px);
}

.split-col {
  display: flex;
  flex-direction: column;
  min-height: 0;
}

.split-col--form {
  flex: 1 1 auto;
  min-height: 0;
  min-width: 0;
}

.split-col--qr {
  flex: 0 0 auto;
  min-width: 220px;
}

.split-col--qr .card--qr-side {
  position: sticky;
  top: 0;
  margin-bottom: 0;
}

.split-col--form .card {
  margin-bottom: 0;
}

.split-col--list .list-card {
  flex: 1 1 auto;
  display: flex;
  flex-direction: column;
  min-height: 0;
  margin-bottom: 0;
}

.list-card-head {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 8px;
  flex-shrink: 0;
  margin-bottom: 0;
}

.list-meta-count {
  font-size: 12px;
  margin: 0;
}

.list-scroll {
  flex: 1 1 auto;
  overflow-y: auto;
  overflow-x: hidden;
  min-height: 200px;
  padding-right: 4px;
  margin-top: 12px;
  -webkit-overflow-scrolling: touch;
}

.pager {
  flex-shrink: 0;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.pager--top {
  margin-top: 8px;
  margin-bottom: 10px;
  padding-bottom: 12px;
  border-bottom: 1px solid var(--border);
}

.pager-info {
  font-size: 12px;
  color: var(--muted);
}

.pager-btns {
  display: flex;
  gap: 8px;
  align-items: center;
}

.pager-btns .btn {
  padding: 6px 12px;
  font-size: 13px;
}

.pager-btns .btn:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

/* ── 二维码 ── */
.card--qr-side .qr-box {
  max-width: 100%;
}

.card--qr-side .card-desc {
  font-size: 12px;
  line-height: 1.5;
}

.qr-box {
  text-align: center;
  padding: 12px;
  background: #fff;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  max-width: 220px;
  margin: 0 auto;
}

.qr-box canvas,
.qr-box img {
  display: block;
  margin: 0 auto 8px;
  max-width: 100%;
  height: auto;
}

.qr-url {
  font-size: 11px;
  word-break: break-all;
  color: var(--muted);
  text-align: center;
  margin-top: 8px;
}

.card--qr-bulk {
  margin-bottom: 0;
}

.qr-bulk-toolbar {
  flex-wrap: wrap;
  margin-bottom: 8px;
}

.qr-bulk-progress {
  margin: 0 0 10px;
}

.qr-bulk-list {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(112px, 1fr));
  gap: 10px;
  margin-top: 4px;
}

.qr-bulk-item {
  background: #fafafa;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 10px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.qr-bulk-item .thumb-wrap {
  display: block;
  width: 100%;
  aspect-ratio: 1;
  max-height: 112px;
  margin: 0 auto;
  background: #fff;
  border-radius: 6px;
  overflow: hidden;
  cursor: zoom-in;
  border: 1px solid var(--border);
}

.qr-bulk-item .thumb-wrap img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  display: block;
}

.qr-bulk-filename {
  font-size: 12px;
  color: var(--muted);
  word-break: break-all;
  line-height: 1.35;
  min-height: 2.7em;
}

.qr-bulk-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.qr-bulk-actions .btn {
  padding: 4px 8px;
  font-size: 12px;
}

/* ── 图片上传 ── */
.upload-row {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  align-items: center;
}

.photo-gallery {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 10px;
}

.photo-tile {
  position: relative;
  width: 80px;
  height: 80px;
  border-radius: 6px;
  overflow: hidden;
  border: 1px solid var(--border);
  flex-shrink: 0;
}

.photo-thumb-btn {
  display: block;
  width: 100%;
  height: 100%;
  padding: 0;
  margin: 0;
  border: none;
  background: none;
  cursor: zoom-in;
  font: inherit;
}

.photo-tile img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
  pointer-events: none;
}

.photo-tile .rm {
  position: absolute;
  top: 2px;
  right: 2px;
  width: 20px;
  height: 20px;
  border: none;
  border-radius: 4px;
  background: rgba(0, 0, 0, 0.55);
  color: #fff;
  font-size: 13px;
  line-height: 1;
  cursor: pointer;
  padding: 0;
  z-index: 2;
}

.photo-tile .rm:hover {
  background: var(--danger);
}

/* ── 弹窗 & Toast ── */
.modal-overlay {
  position: fixed;
  inset: 0;
  z-index: 1000;
  background: rgba(0, 0, 0, 0.45);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
}

.modal-box {
  position: relative;
  background: #fff;
  border-radius: var(--radius);
  padding: 16px;
  max-width: min(420px, 100vw - 32px);
  max-height: calc(100vh - 40px);
  overflow: auto;
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.15);
}

.modal-box--form {
  width: min(380px, 100vw - 32px);
}

.modal-box--photo {
  max-width: min(920px, calc(100vw - 32px));
  width: 100%;
}

.modal-box--photo img {
  max-height: min(80vh, 720px);
}

.modal-title {
  font-size: 16px;
  font-weight: 600;
  margin: 0 0 16px;
  color: var(--text);
  padding-right: 28px;
}

.modal-actions {
  margin-top: 4px;
  margin-bottom: 0;
}

.modal-box--form .field input[type="password"] {
  width: 100%;
}

.modal-box img {
  display: block;
  width: 100%;
  height: auto;
  max-height: min(360px, 70vh);
  object-fit: contain;
}

.modal-caption {
  margin: 10px 0 0;
  text-align: center;
  font-size: 13px;
}

.modal-close {
  position: absolute;
  top: 6px;
  right: 8px;
  width: 32px;
  height: 32px;
  border: none;
  border-radius: 6px;
  background: rgba(0, 0, 0, 0.06);
  color: #333;
  font-size: 22px;
  line-height: 1;
  cursor: pointer;
}

.modal-close:hover {
  background: rgba(0, 0, 0, 0.12);
}

.toast {
  position: fixed;
  left: 50%;
  bottom: 24px;
  transform: translateX(-50%);
  background: rgba(0, 0, 0, 0.78);
  color: #fff;
  padding: 10px 20px;
  border-radius: 999px;
  font-size: 14px;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s;
  z-index: 2000;
}

.toast.show {
  opacity: 1;
}

code {
  background: #f5f5f5;
  padding: 1px 5px;
  border-radius: 3px;
  font-size: 12px;
}

/* ── 响应式 ── */
@media (max-width: 1100px) {
  .stat-cards {
    grid-template-columns: repeat(2, 1fr);
  }

  .dash-grid {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 900px) {
  .sidebar {
    width: 64px;
  }

  .sidebar-brand-text,
  .sidebar-user-name,
  .sidebar-user-role,
  .nav-item span,
  .btn-sidebar-logout {
    display: none;
  }

  .sidebar-brand {
    justify-content: center;
    padding: 16px 8px;
  }

  .nav-item {
    justify-content: center;
    padding: 12px;
  }

  .nav-item .nav-icon {
    margin: 0;
  }

  .sidebar-footer {
    padding: 12px 8px;
  }

  .sidebar-user {
    justify-content: center;
  }

  .main-wrap {
    margin-left: 64px;
  }

  .split--two,
  .split--three {
    grid-template-columns: 1fr;
  }

  .split-col--qr .card--qr-side {
    position: static;
  }

  .split-col--list .list-card {
    max-height: min(420px, 55vh);
  }
}

@media (max-width: 640px) {
  .grid-2,
  .grid-3 {
    grid-template-columns: 1fr;
  }

  .boat-form .field--xs,
  .boat-form .field--sm,
  .boat-form .field--md,
  .boat-form .field--lg,
  .boat-form .field--full {
    width: 100%;
    max-width: none;
  }

    grid-template-columns: 1fr 1fr;
  }

  .main-content {
    padding: 16px;
  }

  .page-header {
    padding: 12px 16px;
  }
}
