/* ==========================================================================
   U客舱 Web App —— 颜色与尺寸严格对齐原 Android 工程
   颜色来源 res/values/colors.xml；尺寸来源各 layout 的 dp/sp（Web 上 1dp≈1px）
   ========================================================================== */

:root {
  --bg: #f5f7fa;
  --blue: #1565c0;
  --blue-dark: #0d47a1;
  --card-bg: #ffffff;
  --label-color: #1565c0;
  --orange: #e65100;
  --text-primary: #212121;
  --text-secondary: #616161;
  --divider: #e0e0e0;
  --toolbar-h: 56px;
  --nav-h: 58px;
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }

html, body {
  margin: 0;
  padding: 0;
  height: 100%;
  background: var(--bg);
  color: var(--text-primary);
  font-family: -apple-system, BlinkMacSystemFont, "PingFang SC", "Helvetica Neue",
               "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
  -webkit-text-size-adjust: 100%;
  overscroll-behavior-y: none;
}

body { overflow: hidden; }

#app {
  position: fixed;
  inset: 0;
  display: flex;
  flex-direction: column;
}

/* ---------------------------------- 顶部栏 --------------------------------- */
.toolbar {
  flex: none;
  display: flex;
  align-items: center;
  gap: 4px;
  height: calc(var(--toolbar-h) + var(--safe-top));
  padding: var(--safe-top) 4px 0 4px;
  background: var(--blue);
  color: #fff;
  box-shadow: 0 2px 6px rgba(0, 0, 0, .18);
  z-index: 30;
}

.tb-title {
  flex: 1;
  min-width: 0;
  font-size: 20px;
  font-weight: 600;
  letter-spacing: .5px;
  padding-left: 12px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.tb-btn {
  flex: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 4px;
  height: 40px;
  min-width: 40px;
  padding: 0 8px;
  border: 0;
  border-radius: 20px;
  background: transparent;
  color: #fff;
  font-size: 14px;
  font-family: inherit;
  cursor: pointer;
}
.tb-btn:active { background: rgba(255, 255, 255, .22); }
.tb-action { padding: 0 10px; }

/* ---------------------------------- 内容区 --------------------------------- */
#host {
  flex: 1;
  min-height: 0;
  position: relative;
  overflow: hidden;
}

.scroll-area {
  position: absolute;
  inset: 0;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  background: var(--bg);
  padding: 16px 16px calc(24px + var(--safe-bottom));
}

/* ---------------------------------- 底部导航 -------------------------------- */
.bottom-nav {
  flex: none;
  display: flex;
  height: calc(var(--nav-h) + var(--safe-bottom));
  padding-bottom: var(--safe-bottom);
  background: #fff;
  border-top: 1px solid var(--divider);
  z-index: 30;
}

.nav-item {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  border: 0;
  background: transparent;
  color: var(--text-secondary);
  font-size: 11px;
  font-family: inherit;
  padding: 6px 0;
  cursor: pointer;
}
.nav-item.is-active { color: var(--blue); }
.nav-item svg { display: block; }

/* ---------------------------------- 通用文本 -------------------------------- */
.page-title { font-size: 20px; font-weight: 700; color: var(--text-primary); }
.page-title.blue { color: var(--label-color); }
.page-sub { font-size: 13px; color: var(--text-secondary); margin-top: 4px; line-height: 1.5; }
.title-bar { width: 48px; height: 3px; background: var(--label-color); border-radius: 2px; margin: 12px 0; }
.hint { font-size: 12px; color: var(--text-secondary); line-height: 1.6; }
.bold-label { font-size: 13px; font-weight: 700; color: var(--label-color); }

.card {
  background: var(--card-bg);
  border-radius: 8px;
  box-shadow: 0 1px 3px rgba(0, 0, 0, .12);
  padding: 12px;
  margin-top: 12px;
}
.card.stroke-orange { border: 1px solid var(--orange); }
.card.stroke-blue { border: 1px solid var(--blue); }
.card-h { font-size: 14px; font-weight: 700; color: var(--label-color); }
.card-b { font-size: 12px; color: var(--text-secondary); margin-top: 6px; line-height: 1.7; }

/* 说明卡片正文（原版 res/values/strings.xml 的 12sp + lineSpacingExtra 3dp 文本）
   white-space: pre-line 用于还原原文里的显式换行（每条要求一行） */
.notice { font-size: 12px; color: var(--text-secondary); line-height: 1.5; margin-top: 6px; white-space: pre-line; }

/* 计数行（原版 tvCount / tv_count，12sp text_secondary，marginTop 12dp） */
.count-line { font-size: 12px; color: var(--text-secondary); margin-top: 12px; }

/* ---------------------------------- 搜索框 --------------------------------- */
.search-wrap {
  position: relative;
  display: flex;
  align-items: center;
  background: #fff;
  border: 1px solid #bdbdbd;
  border-radius: 6px;
  height: 48px;
  padding: 0 10px;
}
.search-wrap svg { flex: none; color: var(--text-secondary); }
.search-prefix {
  flex: none;
  font-size: 16px;
  font-weight: 700;
  color: var(--blue);
  letter-spacing: 1px;
  padding: 0 4px 0 2px;
  user-select: none;
}
.search-wrap input {
  flex: 1;
  min-width: 0;
  border: 0;
  outline: 0;
  background: transparent;
  font-size: 15px;
  font-family: inherit;
  color: var(--text-primary);
  padding: 0 4px;
  text-transform: uppercase;
}
.search-wrap input::placeholder { text-transform: none; color: #9e9e9e; }

/* ---------------------------------- 列表卡片 -------------------------------- */
.grid-3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin-top: 4px; }

.tile {
  position: relative;
  min-height: 56px;
  background: var(--card-bg);
  border-radius: 6px;
  box-shadow: 0 1px 2px rgba(0, 0, 0, .12);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 8px;
}
.tile-name { font-size: 13px; color: var(--text-primary); text-align: center; word-break: break-all; }

.badge {
  position: absolute;
  right: 6px;
  bottom: 6px;
  font-size: 9px;
  line-height: 1.4;
  color: #fff;
  border-radius: 4px;
  padding: 1px 4px;
}
.badge.orange { background: var(--orange); }
.badge.blue { background: var(--blue); }

.empty {
  font-size: 14px;
  color: var(--text-secondary);
  text-align: center;
  padding: 48px 24px;
  line-height: 1.7;
}

/* 配餐计划列表 */
.flight-card {
  background: #fff;
  border: 1px solid var(--blue);
  border-radius: 10px;
  box-shadow: 0 2px 6px rgba(0, 0, 0, .14);
  padding: 12px;
  margin: 6px 0;
}
.flight-no { font-size: 18px; font-weight: 700; color: var(--blue-dark); }
.flight-route { font-size: 14px; color: var(--text-secondary); margin-top: 2px; }
.flight-divider { height: 1px; background: var(--divider); margin: 8px 0; }

.field-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px 12px; }
.field { min-width: 0; }
.field-label { font-size: 12px; color: var(--label-color); }
.field-value { font-size: 14px; color: var(--text-primary); margin-top: 2px; word-break: break-word; }

/* ---------------------------------- 作业指导 -------------------------------- */
.city-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px 12px; margin-top: 16px; }
.city-btn {
  height: 46px;
  border: 0;
  border-radius: 22px;
  background: var(--blue);
  color: #fff;
  font-size: 15px;
  font-family: inherit;
  box-shadow: 0 1px 3px rgba(0, 0, 0, .2);
  cursor: pointer;
}
.city-btn:active { background: var(--blue-dark); }

.pdf-pages { display: flex; flex-direction: column; gap: 8px; }
.pdf-pages canvas {
  display: block;
  width: 100%;
  height: auto;
  background: #fff;
  border: 1px solid var(--divider);
  border-radius: 4px;
}
.page-slot { position: relative; }
/* 未渲染页的占位：由内联 aspect-ratio 撑起高度，与真实页面比例一致，避免滚动跳动 */
.page-slot .ph { width: 100%; display: flex; align-items: center; justify-content: center;
  font-size: 12px; color: var(--text-secondary); background: #fff; border: 1px solid var(--divider); border-radius: 4px; }

/* ---------------------------------- 遮罩/弹窗 ------------------------------- */
.mask {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, .45);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  z-index: 100;
}
.mask[hidden] { display: none; }

.progress-box {
  background: #fff;
  border-radius: 10px;
  padding: 22px 26px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
  min-width: 170px;
}
.spinner {
  width: 34px; height: 34px;
  border: 3px solid #cfe0f3;
  border-top-color: var(--blue);
  border-radius: 50%;
  animation: spin .9s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }
.progress-text { font-size: 14px; color: var(--text-primary); }

.dialog {
  width: 100%;
  max-width: 420px;
  max-height: 78vh;
  display: flex;
  flex-direction: column;
  background: #fff;
  border-radius: 12px;
  padding: 20px 20px 8px;
}
.dialog-title { font-size: 17px; font-weight: 700; color: var(--text-primary); }
.dialog-body {
  margin-top: 10px;
  font-size: 13px;
  line-height: 1.6;
  color: var(--text-secondary);
  overflow-y: auto;
  white-space: pre-wrap;
  word-break: break-word;
  font-family: ui-monospace, Menlo, Consolas, monospace;
}
.dialog-actions { display: flex; justify-content: flex-end; padding: 8px 0; }

.text-btn {
  border: 0; background: transparent; color: var(--blue);
  font-size: 15px; font-weight: 600; font-family: inherit;
  padding: 10px 14px; border-radius: 8px; cursor: pointer;
}
.text-btn:active { background: #eef4fc; }

.filled-btn {
  border: 0; background: var(--blue); color: #fff;
  font-size: 15px; font-weight: 600; font-family: inherit;
  padding: 10px 20px; border-radius: 22px; cursor: pointer;
}
.filled-btn:active { background: var(--blue-dark); }

/* ---------------------------------- Toast --------------------------------- */
.toast {
  position: fixed;
  left: 50%;
  bottom: calc(var(--nav-h) + var(--safe-bottom) + 24px);
  transform: translateX(-50%);
  max-width: 84vw;
  background: rgba(33, 33, 33, .92);
  color: #fff;
  font-size: 14px;
  line-height: 1.5;
  padding: 12px 18px;
  border-radius: 24px;
  z-index: 200;
  text-align: center;
  animation: toastIn .18s ease-out;
}
.toast[hidden] { display: none; }
@keyframes toastIn { from { opacity: 0; transform: translate(-50%, 8px); } }

/* ------------------------------- 主屏安装引导 ------------------------------- */
#installMask { align-items: flex-end; padding: 0; }

.sheet {
  width: 100%;
  background: #fff;
  border-radius: 18px 18px 0 0;
  padding: 10px 20px calc(20px + var(--safe-bottom));
  animation: sheetUp .24s ease-out;
}
@keyframes sheetUp { from { transform: translateY(100%); } }
.sheet-handle { width: 40px; height: 4px; border-radius: 2px; background: #d5d5d5; margin: 0 auto 14px; }
.sheet-title { font-size: 19px; font-weight: 700; color: var(--text-primary); }
.sheet-sub { font-size: 13px; color: var(--text-secondary); margin-top: 6px; line-height: 1.6; }

.steps { list-style: none; margin: 16px 0 0; padding: 0; }
.steps li { display: flex; gap: 12px; align-items: flex-start; margin-bottom: 14px; font-size: 14px; line-height: 1.6; color: var(--text-primary); }
.steps li strong { color: var(--blue); }
.step-ic {
  flex: none;
  width: 22px; height: 22px;
  border-radius: 50%;
  background: var(--blue);
  color: #fff;
  font-size: 12px;
  font-weight: 700;
  display: flex; align-items: center; justify-content: center;
  margin-top: 1px;
}
.inline-share { vertical-align: -3px; color: var(--blue); }

.sheet-note {
  font-size: 12px;
  color: var(--text-secondary);
  background: #f1f5fb;
  border-radius: 8px;
  padding: 10px 12px;
  line-height: 1.6;
}
.sheet-actions { display: flex; justify-content: flex-end; align-items: center; gap: 6px; margin-top: 16px; }

/* ---------------------------------- 登录页 --------------------------------- */
.login-screen {
  position: fixed;
  inset: 0;
  z-index: 300;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 24px;
  background: linear-gradient(160deg, #1565c0, #0d47a1);
}
.login-card {
  width: 100%;
  max-width: 360px;
  background: #fff;
  border-radius: 16px;
  padding: 28px 22px 22px;
  box-shadow: 0 12px 40px rgba(0, 0, 0, .3);
}
.login-logo { font-size: 30px; font-weight: 800; color: var(--blue); text-align: center; letter-spacing: 2px; }
.login-sub { font-size: 14px; color: var(--text-secondary); text-align: center; margin: 6px 0 22px; }
.login-field { margin-bottom: 16px; }
.login-label { font-size: 13px; color: var(--text-primary); font-weight: 600; margin-bottom: 6px; }
.login-input-wrap {
  display: flex;
  align-items: center;
  border: 1px solid #bdbdbd;
  border-radius: 8px;
  height: 46px;
  padding: 0 12px;
  background: #fff;
}
.login-prefix { font-size: 16px; font-weight: 700; color: var(--blue); letter-spacing: 1px; margin-right: 2px; user-select: none; }
.login-input-wrap input {
  flex: 1;
  min-width: 0;
  border: 0;
  outline: 0;
  background: transparent;
  font-size: 16px;
  font-family: inherit;
  color: var(--text-primary);
}
.login-field > input {
  width: 100%;
  box-sizing: border-box;
  border: 1px solid #bdbdbd;
  border-radius: 8px;
  height: 46px;
  padding: 0 12px;
  background: #fff;
  font-size: 16px;
  font-family: inherit;
  color: var(--text-primary);
  outline: 0;
}
.login-field > input:focus, .login-input-wrap:focus-within { border-color: var(--blue); }
.login-err { font-size: 12px; color: #d32f2f; margin-top: 4px; min-height: 16px; }
.login-btn {
  width: 100%;
  height: 48px;
  margin-top: 4px;
  border: 0;
  border-radius: 24px;
  background: var(--blue);
  color: #fff;
  font-size: 16px;
  font-weight: 700;
  font-family: inherit;
  cursor: pointer;
}
.login-btn:active { background: var(--blue-dark); }
.login-foot { margin-top: 22px; font-size: 12px; color: rgba(255, 255, 255, .85); text-align: center; }

/* ---------------------------------- 全页底层水印 --------------------------------- */
/* 固定覆盖内容区、不可交互、低透明度；层级低于顶部栏/底部导航(30)，高于内容(auto)。 */
#watermark {
  position: fixed;
  inset: 0;
  z-index: 25;
  pointer-events: none;
  overflow: hidden;
  background-repeat: repeat;
}
