:root {
  --navy: #12263a;
  --navy-2: #1b344d;
  --teal: #147d72;
  --teal-soft: #e8f4f1;
  --gold: #b48a42;
  --ink: #172331;
  --muted: #677583;
  --line: #dfe5e8;
  --paper: #ffffff;
  --canvas: #f3f6f6;
  --danger: #c74747;
  --warning: #d28a25;
  --success: #248660;
  --shadow: 0 14px 36px rgba(18, 38, 58, .10);
}

* { box-sizing: border-box; }
html, body { margin: 0; min-height: 100%; color: var(--ink); background: var(--canvas); font-family: "Microsoft YaHei", "PingFang SC", system-ui, sans-serif; }
button, input, select, textarea { font: inherit; }
button { cursor: pointer; }
.hidden { display: none !important; }

.login-view {
  min-height: 100vh;
  display: grid;
  grid-template-columns: 1.15fr .85fr;
  align-items: center;
  gap: 8vw;
  padding: 7vh 9vw;
  background:
    radial-gradient(circle at 12% 18%, rgba(180, 138, 66, .18), transparent 24%),
    linear-gradient(125deg, #10263a 0 51%, #edf2ef 51%);
}
.login-brand { display: flex; align-items: center; gap: 28px; color: #fff; }
.login-brand p { margin: 0 0 8px; color: #d3b77e; letter-spacing: 4px; font-weight: 700; }
.login-brand h1 { margin: 0; font-size: clamp(38px, 5vw, 70px); letter-spacing: 3px; }
.login-brand span { display: block; margin-top: 18px; color: #b9c6d0; font-size: 18px; }
.brand-seal { width: 112px; height: 112px; display: grid; place-items: center; flex: 0 0 auto; color: #f8ecd0; border: 2px solid #cfac68; box-shadow: inset 0 0 0 8px rgba(207,172,104,.12); font-family: serif; font-size: 58px; }
.brand-seal.small { width: 54px; height: 54px; font-size: 28px; box-shadow: inset 0 0 0 4px rgba(207,172,104,.12); }
.login-card { width: min(460px, 100%); padding: 42px; background: #fff; border-top: 6px solid var(--gold); box-shadow: 0 30px 70px rgba(18,38,58,.18); }
.login-card-head { margin-bottom: 30px; }
.eyebrow, .modal-panel header p { margin: 0 0 7px; color: var(--gold); font-size: 12px; font-weight: 800; letter-spacing: 2px; }
.login-card h2 { margin: 0; font-size: 30px; }
.login-card-head p { color: var(--muted); }
label { display: grid; gap: 8px; color: #3b4a57; font-size: 14px; font-weight: 700; }
.login-card label { margin-bottom: 20px; }
input, select, textarea {
  width: 100%;
  min-height: 42px;
  padding: 10px 12px;
  color: var(--ink);
  background: #fff;
  border: 1px solid #ccd5da;
  border-radius: 7px;
  outline: none;
}
textarea { min-height: 104px; resize: vertical; }
input:focus, select:focus, textarea:focus { border-color: var(--teal); box-shadow: 0 0 0 3px rgba(20,125,114,.12); }
.form-error { min-height: 20px; color: var(--danger); text-align: center; }

.primary, .danger, .ghost, .secondary {
  min-height: 40px;
  padding: 0 17px;
  border: 1px solid transparent;
  border-radius: 7px;
  font-weight: 700;
}
.primary { color: #fff; background: var(--teal); }
.primary:hover { background: #0f6a61; }
.danger { color: #fff; background: var(--danger); }
.secondary { color: var(--navy); background: #eaf0f4; border-color: #d4dde3; }
.ghost { color: #344553; background: #fff; border-color: #ccd5da; }
.ghost.light { color: #dbe5eb; background: transparent; border-color: rgba(255,255,255,.22); }
.wide { width: 100%; min-height: 48px; }

.app-shell { min-height: 100vh; display: grid; grid-template-columns: 248px minmax(0, 1fr); }
.sidebar { position: sticky; top: 0; height: 100vh; display: flex; flex-direction: column; color: #dbe5eb; background: var(--navy); }
.sidebar-brand { height: 92px; display: flex; align-items: center; gap: 13px; padding: 18px 20px; border-bottom: 1px solid rgba(255,255,255,.09); }
.sidebar-brand strong, .sidebar-brand span { display: block; }
.sidebar-brand strong { color: #fff; font-size: 18px; }
.sidebar-brand span { margin-top: 3px; color: #91a4b3; font-size: 12px; }
.main-nav { flex: 1; overflow-y: auto; padding: 14px 10px; }
.nav-group-title { padding: 15px 14px 7px; color: #6f8798; font-size: 11px; letter-spacing: 2px; }
.nav-item { width: 100%; display: flex; align-items: center; gap: 12px; margin: 3px 0; padding: 11px 13px; color: #b9c8d2; background: transparent; border: 0; border-radius: 7px; text-align: left; }
.nav-item:hover { color: #fff; background: rgba(255,255,255,.06); }
.nav-item.active { color: #fff; background: var(--teal); }
.nav-icon { width: 25px; text-align: center; font-size: 17px; }
.nav-badge { min-width: 22px; margin-left: auto; padding: 2px 6px; color: #fff; background: var(--danger); border-radius: 10px; font-size: 11px; text-align: center; }
.sidebar-foot { padding: 16px; border-top: 1px solid rgba(255,255,255,.09); }
.system-light { display: flex; align-items: center; gap: 8px; margin-bottom: 13px; color: #94a7b6; font-size: 12px; }
.system-light i { width: 8px; height: 8px; background: #4dc58d; border-radius: 50%; box-shadow: 0 0 0 4px rgba(77,197,141,.12); }

.main { min-width: 0; }
.topbar { height: 92px; display: flex; align-items: center; justify-content: space-between; gap: 20px; padding: 16px 30px; background: #fff; border-bottom: 1px solid var(--line); }
.topbar p { margin: 0 0 4px; color: var(--muted); font-size: 12px; }
.topbar h1 { margin: 0; font-size: 25px; }
.top-actions { display: flex; align-items: center; gap: 14px; }
.user-chip { display: flex; align-items: center; gap: 10px; padding-left: 14px; border-left: 1px solid var(--line); }
.user-chip > span { width: 38px; height: 38px; display: grid; place-items: center; color: #fff; background: var(--navy); border-radius: 50%; }
.user-chip strong, .user-chip small { display: block; }
.user-chip small { margin-top: 2px; color: var(--muted); }
.mobile-menu { display: none; background: none; border: 0; font-size: 24px; }
.content { min-height: calc(100vh - 92px); padding: 26px 30px 50px; }

.welcome-strip { display: flex; align-items: center; justify-content: space-between; gap: 20px; margin-bottom: 22px; padding: 22px 25px; color: #fff; background: linear-gradient(105deg, var(--navy), var(--navy-2)); border-left: 6px solid var(--gold); box-shadow: var(--shadow); }
.welcome-strip h2 { margin: 0 0 6px; font-size: 23px; }
.welcome-strip p { margin: 0; color: #b8c6d0; }
.date-block { color: #d8bf8b; font-weight: 700; white-space: nowrap; }
.stats-grid { display: grid; grid-template-columns: repeat(4, minmax(0,1fr)); gap: 16px; }
.stat-card { position: relative; overflow: hidden; padding: 20px; background: #fff; border: 1px solid var(--line); box-shadow: 0 6px 18px rgba(18,38,58,.05); }
.stat-card::before { content: ""; position: absolute; top: 0; left: 0; width: 4px; height: 100%; background: var(--teal); }
.stat-card.warning::before { background: var(--warning); }
.stat-card.danger-tone::before { background: var(--danger); }
.stat-card label { color: var(--muted); font-size: 13px; }
.stat-value { display: block; margin: 8px 0 3px; font-size: 34px; font-weight: 800; }
.stat-note { color: #87939d; font-size: 12px; }
.dashboard-grid { display: grid; grid-template-columns: 1.3fr .7fr; gap: 18px; margin-top: 18px; }
.panel { padding: 20px; background: #fff; border: 1px solid var(--line); box-shadow: 0 5px 16px rgba(18,38,58,.04); }
.panel-head { display: flex; align-items: center; justify-content: space-between; gap: 15px; margin-bottom: 16px; }
.panel-head h3 { margin: 0; font-size: 18px; }
.panel-head span { color: var(--muted); font-size: 12px; }
.trend-chart { height: 210px; display: flex; align-items: flex-end; gap: 14px; padding: 18px 8px 0; border-bottom: 1px solid var(--line); }
.trend-bar-wrap { flex: 1; display: grid; justify-items: center; gap: 7px; }
.trend-bar { width: min(38px, 70%); min-height: 5px; background: linear-gradient(#1d9286, #17645e); border-radius: 4px 4px 0 0; }
.trend-bar-wrap small { color: var(--muted); font-size: 11px; }
.pending-list { display: grid; gap: 9px; }
.pending-item { display: grid; grid-template-columns: auto 1fr auto; align-items: center; gap: 10px; padding: 11px; background: #f7f9f9; border-left: 3px solid var(--warning); }
.pending-item i { width: 28px; height: 28px; display: grid; place-items: center; color: #8a5e17; background: #f7e8c9; border-radius: 50%; font-style: normal; }
.pending-item strong, .pending-item small { display: block; }
.pending-item small { color: var(--muted); }

.toolbar { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 16px; padding: 14px; background: #fff; border: 1px solid var(--line); }
.filters, .toolbar-actions { display: flex; flex-wrap: wrap; gap: 9px; }
.search-box { min-width: 280px; }
.toolbar select { width: auto; min-width: 140px; }
.table-panel { overflow: hidden; background: #fff; border: 1px solid var(--line); }
.table-tip { padding: 10px 14px; color: #6a7883; background: #f6f8f8; border-bottom: 1px solid var(--line); font-size: 12px; }
.table-wrap { overflow: auto; }
table { width: 100%; border-collapse: collapse; white-space: nowrap; }
th { position: sticky; top: 0; z-index: 2; padding: 12px 13px; color: #566674; background: #f4f7f7; border-bottom: 1px solid var(--line); font-size: 12px; text-align: left; }
td { max-width: 270px; padding: 12px 13px; border-bottom: 1px solid #edf0f2; font-size: 13px; overflow: hidden; text-overflow: ellipsis; }
tbody tr:hover { background: #f8fbfa; }
tbody tr.dragging { opacity: .35; }
.drag-handle { color: #98a5ae; cursor: grab; font-size: 18px; }
.thumb { width: 52px; height: 42px; object-fit: cover; background: #edf1f2; border-radius: 5px; }
.status { display: inline-flex; align-items: center; padding: 4px 8px; border-radius: 12px; font-size: 11px; font-weight: 700; }
.status-pending, .status-draft, .status-processing { color: #8a5b14; background: #fff0d6; }
.status-approved, .status-published, .status-active, .status-resolved, .status-available { color: #176649; background: #dff3e9; }
.status-rejected, .status-disabled, .status-closed, .status-0 { color: #9e3939; background: #f9e1e1; }
.row-actions { display: flex; gap: 6px; }
.text-btn { padding: 4px 7px; color: var(--teal); background: transparent; border: 0; font-weight: 700; }
.text-btn.red { color: var(--danger); }
.pagination { display: flex; align-items: center; justify-content: flex-end; gap: 10px; padding: 13px; }
.pagination span { color: var(--muted); font-size: 12px; }
.empty { padding: 70px 20px; color: var(--muted); text-align: center; }
.empty b { display: block; margin-bottom: 8px; color: #3b4b58; font-size: 18px; }

.loading-state,
.error-state,
.empty-state {
  min-height: 360px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 18px;
  padding: 48px 24px;
  color: var(--muted);
  background: #fff;
  border: 1px solid var(--line);
  text-align: left;
}
.loading-state b,
.loading-state small,
.error-state b,
.empty-state b,
.empty-state p {
  display: block;
}
.loading-state b,
.error-state b,
.empty-state b {
  color: var(--ink);
  font-size: 19px;
}
.loading-state small { margin-top: 6px; color: var(--muted); }
.loading-spinner {
  width: 34px;
  height: 34px;
  flex: 0 0 auto;
  border: 4px solid #dce9e7;
  border-top-color: var(--teal);
  border-radius: 50%;
  animation: admin-spin .75s linear infinite;
}
.error-state {
  color: #8b4a4a;
  background: #fffafa;
  border-color: #efd7d7;
}
.error-state p { margin: 7px 0 16px; color: #8b6464; }
.error-state-icon,
.empty-state-icon {
  width: 48px;
  height: 48px;
  display: grid;
  place-items: center;
  flex: 0 0 auto;
  color: #fff;
  background: var(--danger);
  border-radius: 50%;
  font-size: 24px;
  font-weight: 800;
}
.empty-state {
  min-height: 300px;
  flex-direction: column;
  gap: 8px;
  text-align: center;
}
.empty-state-icon {
  margin-bottom: 5px;
  color: var(--teal);
  background: var(--teal-soft);
}
.empty-state p { margin: 0 0 13px; color: var(--muted); }
@keyframes admin-spin { to { transform: rotate(360deg); } }

.modal { position: fixed; inset: 0; z-index: 100; display: grid; place-items: center; padding: 25px; background: rgba(8,22,34,.58); }
.modal-panel { width: min(820px, 100%); max-height: calc(100vh - 50px); overflow: auto; background: #fff; box-shadow: 0 25px 70px rgba(0,0,0,.25); }
.modal-panel > header { position: sticky; top: 0; z-index: 3; display: flex; align-items: center; justify-content: space-between; padding: 19px 23px; background: #fff; border-top: 5px solid var(--gold); border-bottom: 1px solid var(--line); }
.modal-panel header h2 { margin: 0; }
.icon-btn { width: 38px; height: 38px; color: #63717c; background: #f1f4f5; border: 0; border-radius: 50%; font-size: 25px; }
.modal-body { display: grid; grid-template-columns: repeat(2, minmax(0,1fr)); gap: 18px; padding: 23px; }
.field-full { grid-column: 1 / -1; }
.help { color: var(--muted); font-size: 11px; font-weight: 400; }
.dropzone { min-height: 116px; display: grid; place-items: center; padding: 15px; color: var(--muted); background: #f7faf9; border: 2px dashed #bdcac9; border-radius: 8px; text-align: center; }
.dropzone.dragover { color: var(--teal); background: var(--teal-soft); border-color: var(--teal); }
.dropzone img { max-width: 140px; max-height: 90px; object-fit: cover; }
.field-label { display: block; margin-bottom: 8px; color: var(--ink); font-size: 14px; font-weight: 700; }
.spot-map-picker, .route-builder-field { padding: 15px; background: #f7faf9; border: 1px solid var(--line); border-radius: 10px; }
.picker-heading { display: flex; gap: 15px; align-items: center; justify-content: space-between; margin-bottom: 12px; }
.picker-heading div { display: flex; flex-direction: column; }
.picker-heading strong { color: var(--ink); font-size: 16px; }
.picker-heading small, .route-builder-map-wrap p { margin-top: 4px; color: var(--muted); }
.admin-picker-map { width: 100%; height: 340px; overflow: hidden; background: #eaf0ef; border: 1px solid #bdcac9; border-radius: 8px; }
.admin-map-loading { display: grid; min-height: 180px; place-items: center; color: var(--muted); }
.route-builder { margin-top: 10px; }
.route-builder-layout { display: grid; grid-template-columns: minmax(0,1.45fr) minmax(240px,.75fr); gap: 14px; }
.route-builder-map-wrap p { margin-bottom: 0; font-size: 12px; }
.route-builder-panel { display: flex; min-height: 340px; flex-direction: column; }
.route-builder-panel > input { margin-bottom: 9px; }
.route-spot-pool { display: flex; max-height: 300px; overflow: auto; gap: 7px; flex-direction: column; }
.route-spot-option { display: grid; grid-template-columns: 1fr auto; padding: 9px 11px; color: var(--ink); background: #fff; border: 1px solid var(--line); border-radius: 7px; text-align: left; }
.route-spot-option span { font-weight: 700; }
.route-spot-option small { color: var(--muted); grid-column: 1; }
.route-spot-option b { align-self: center; color: var(--teal); font-size: 12px; font-weight: 700; grid-column: 2; grid-row: 1 / 3; }
.route-spot-option.selected { background: var(--teal-soft); border-color: var(--teal); }
.route-selected-head { display: flex; margin: 18px 0 9px; align-items: center; justify-content: space-between; }
.route-selected-head span { color: var(--muted); font-size: 13px; }
.route-selected-list { display: grid; gap: 7px; }
.route-selected-item { display: grid; grid-template-columns: 34px 1fr auto; gap: 10px; padding: 10px; align-items: center; background: #fff; border: 1px solid var(--line); border-radius: 7px; cursor: grab; }
.route-selected-item > span { display: grid; width: 30px; height: 30px; place-items: center; color: #fff; font-weight: 800; background: var(--teal); border-radius: 50%; }
.route-selected-item > div { display: flex; min-width: 0; flex-direction: column; }
.route-selected-item small { color: var(--muted); }
.route-selected-item button { color: #b43f39; background: transparent; border: 0; }
.route-selected-item.dragging { opacity: .45; }
.route-empty { padding: 25px; color: var(--muted); background: #fff; border: 1px dashed var(--line); text-align: center; }
.route-count { color: var(--teal); font-weight: 800; }
.modal-panel footer { position: sticky; bottom: 0; display: flex; justify-content: flex-end; gap: 10px; padding: 15px 23px; background: #f8faf9; border-top: 1px solid var(--line); }

.confirm-backdrop { position: fixed; inset: 0; z-index: 120; display: grid; place-items: center; background: rgba(8,22,34,.58); }
.confirm-card { width: min(390px, calc(100% - 40px)); padding: 28px; background: #fff; text-align: center; box-shadow: var(--shadow); }
.confirm-icon { width: 48px; height: 48px; display: grid; place-items: center; margin: 0 auto 13px; color: #fff; background: var(--warning); border-radius: 50%; font-size: 25px; font-weight: 800; }
.confirm-card p { color: var(--muted); line-height: 1.7; }
.confirm-card > div:last-child { display: flex; justify-content: center; gap: 10px; }
.toast { position: fixed; top: 22px; left: 50%; z-index: 200; max-width: min(520px, calc(100% - 30px)); padding: 12px 20px; color: #fff; background: var(--navy); border-left: 4px solid var(--gold); box-shadow: var(--shadow); opacity: 0; pointer-events: none; transform: translate(-50%, -15px); transition: .2s ease; }
.toast.show { opacity: 1; transform: translate(-50%, 0); }
.toast.error { background: #782f2f; }

.ops-hero {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  margin-bottom: 18px;
  padding: 25px 28px;
  color: #fff;
  background: linear-gradient(110deg, #19334b, #234f67);
  border-left: 6px solid var(--warning);
  box-shadow: var(--shadow);
}
.ops-hero.is-online { border-left-color: #52cf96; }
.ops-hero h2 { margin: 5px 0 8px; font-size: 24px; }
.ops-hero p { margin: 0; color: #c0d0d9; }
.ops-kicker { color: #d9bd83; font-size: 11px; font-weight: 800; letter-spacing: 2px; }
.ops-actions { flex: 0 0 auto; }
.ops-actions .primary:disabled { cursor: not-allowed; opacity: .45; }
.ops-stats { margin-bottom: 18px; }
.stat-value small { color: var(--muted); font-size: 14px; }
.ops-grid { grid-template-columns: 1.4fr .6fr; }
.mono { font-family: Consolas, "SFMono-Regular", monospace; font-size: 12px; }
.log-table td { max-width: 340px; }
.log-detail { color: #596a77; }
.log-level {
  display: inline-flex;
  min-width: 54px;
  justify-content: center;
  padding: 4px 7px;
  color: #38566b;
  background: #eaf1f5;
  border-radius: 999px;
  font-size: 10px;
  font-weight: 800;
}
.log-warn { color: #885b17; background: #fff0d4; }
.log-error, .log-fatal { color: #9f3434; background: #fae0e0; }
.log-debug { color: #6e7780; background: #eef0f2; }
.alert-history { max-height: 430px; display: grid; gap: 9px; overflow: auto; }
.alert-item { padding: 13px; background: #f8faf9; border-left: 4px solid var(--warning); }
.alert-item.delivered { border-left-color: var(--success); }
.alert-item.failed { border-left-color: var(--danger); }
.alert-item b, .alert-item span, .alert-item small { display: block; }
.alert-item span { margin-top: 3px; color: var(--muted); font-size: 11px; }
.alert-item p { margin: 8px 0; color: #465866; font-size: 12px; line-height: 1.55; }
.alert-item small { color: var(--muted); }

@media (max-width: 1100px) {
  .stats-grid { grid-template-columns: repeat(2, minmax(0,1fr)); }
  .dashboard-grid { grid-template-columns: 1fr; }
  .ops-grid { grid-template-columns: 1fr; }
}
@media (max-width: 800px) {
  .route-builder-layout { grid-template-columns: 1fr; }
  .login-view { grid-template-columns: 1fr; padding: 35px 20px; background: linear-gradient(155deg, #10263a 0 38%, #edf2ef 38%); }
  .login-brand { align-items: flex-start; }
  .brand-seal { width: 72px; height: 72px; font-size: 38px; }
  .login-card { justify-self: center; padding: 28px; }
  .app-shell { grid-template-columns: 1fr; }
  .sidebar { position: fixed; left: -260px; z-index: 90; width: 248px; transition: left .2s ease; }
  .sidebar.open { left: 0; box-shadow: 20px 0 50px rgba(0,0,0,.2); }
  .mobile-menu { display: block; }
  .topbar { height: auto; min-height: 84px; padding: 14px 16px; }
  .topbar .ghost { display: none; }
  .content { padding: 18px 14px 40px; }
  .modal-body { grid-template-columns: 1fr; }
  .field-full { grid-column: auto; }
  .ops-hero { align-items: flex-start; flex-direction: column; }
}
@media (max-width: 540px) {
  .stats-grid { grid-template-columns: 1fr 1fr; gap: 9px; }
  .stat-card { padding: 15px; }
  .stat-value { font-size: 27px; }
  .welcome-strip { align-items: flex-start; flex-direction: column; }
  .user-chip div { display: none; }
  .search-box { min-width: 100%; }
  .filters { width: 100%; }
  .filters input, .filters select { flex: 1; }
}
