/* Shipping_Status_Inquiry：淺色卡片版面，RWD（手機／平板／電腦）。不使用外部字型與 CDN。 */
:root {
  --navy: #0B2D5B;
  --navy-d: #082245;
  --orange: #D35400;
  --bg: #F1F4F8;
  --card: #FFFFFF;
  --ink: #1f2933;
  --muted: #5d6b7c;
  --line: #d9e0e8;
  --ok: #1f7a3d;
  --ok-bg: #e6f4ea;
  --err: #a12a2a;
  --err-bg: #fbeaea;
  --warn: #8a5a00;
  --warn-bg: #fff3d6;
  --radius: 12px;
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; background: var(--bg); color: var(--ink); min-height: 100vh;
  display: flex; flex-direction: column;
  font: 14px/1.5 "Microsoft JhengHei", "PingFang TC", "Noto Sans TC", "Noto Sans SC", "Microsoft YaHei", system-ui, -apple-system, "Segoe UI", sans-serif;
}
a { color: var(--navy); }
h1 { font-size: 1.35rem; margin: 0 0 8px; color: var(--navy); }
h2 { font-size: 1.1rem; margin: 0 0 8px; color: var(--navy); }
.muted { color: var(--muted); }
.small { font-size: .9rem; }
.center { text-align: center; }
.nowrap { white-space: nowrap; }

/* ---------- 頁首 ---------- */
.topbar {
  display: flex; flex-wrap: wrap; align-items: center; gap: 6px 16px;
  padding: 6px 8px; background: var(--card); border-bottom: 3px solid var(--navy);
}
.brand { display: flex; align-items: center; gap: 12px; text-decoration: none; color: var(--navy); }
.brand img { display: block; height: 32px; width: auto; }
.brand-text { display: flex; flex-direction: column; line-height: 1.2; }
.brand-text strong { font-size: 1.05rem; }
.brand-text small { color: #3f4c5e; font-size: 1.1rem; font-weight: 600; letter-spacing: .05em; }
.nav { display: flex; flex-wrap: wrap; gap: 4px; flex: 1; }
.nav a {
  padding: 5px 10px; border-radius: 8px; text-decoration: none; color: var(--ink); font-weight: 600;
}
.nav a:hover { background: var(--bg); }
.nav a.on { background: var(--navy); color: #fff; }
.topright { display: flex; align-items: center; gap: 12px; margin-left: auto; flex-wrap: wrap; }
.who { display: flex; flex-direction: column; line-height: 1.25; font-size: .9rem; text-align: right; }
.who small { color: var(--muted); font-size: .75rem; }
.lang-switch { display: inline-flex; border: 1px solid var(--line); border-radius: 8px; overflow: hidden; }
.lang-switch button {
  border: 0; background: var(--card); color: var(--ink); padding: 6px 12px; font: inherit; font-size: .85rem; cursor: pointer;
}
.lang-switch button.on { background: var(--navy); color: #fff; }

/* ---------- 版面 ---------- */
.container { width: 100%; max-width: none; margin: 0; padding: 12px 8px; flex: 1; }
.footer { text-align: center; color: var(--muted); font-size: .8rem; padding: 16px 20px 24px; }
.card {
  background: var(--card); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 14px; box-shadow: 0 1px 3px rgba(11, 45, 91, .06);
}
.card.narrow { max-width: 520px; }
.grid { display: grid; gap: 12px; }
.grid.cards { grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); margin-top: 16px; }
.grid.two { grid-template-columns: repeat(auto-fit, minmax(320px, 1fr)); align-items: start; }
.stat-label { color: var(--muted); font-size: .9rem; }
.stat-value { font-size: 1.6rem; font-weight: 700; color: var(--navy); line-height: 1.2; }
.stat-note { color: var(--muted); font-size: .8rem; }
.page-head { display: flex; justify-content: space-between; align-items: center; gap: 8px; flex-wrap: wrap; margin-bottom: 8px; }
.kv { display: grid; grid-template-columns: max-content 1fr; gap: 8px 16px; margin: 0; }
.kv dt { color: var(--muted); }
.kv dd { margin: 0; word-break: break-all; }

/* ---------- 登入頁 ---------- */
.auth-page { background: linear-gradient(180deg, #E4EBF4 0%, var(--bg) 60%); }
.auth-lang { display: flex; justify-content: flex-end; padding: 14px 20px 0; }
.auth-wrap { flex: 1; display: flex; align-items: center; justify-content: center; padding: 16px; }
.auth-card { width: 100%; max-width: 420px; padding: 28px 28px 22px; }
.auth-logo { display: block; width: 220px; max-width: 70%; height: auto; margin: 0 auto 6px; }
.auth-title { text-align: center; font-size: 1.3rem; margin: 0; }

/* ---------- 表單 ---------- */
.field { margin-bottom: 10px; }
label { display: block; font-weight: 600; margin-bottom: 3px; }
input[type=text], input[type=email], input[type=password], input[type=number], select {
  width: 100%; min-height: 36px; padding: 4px 10px; font: inherit; color: var(--ink);
  border: 1.5px solid var(--line); border-radius: 10px; background: #fff;
}
input.num { width: 84px; min-height: 36px; padding: 4px 8px; }
input:focus-visible, button:focus-visible, select:focus-visible, a:focus-visible { outline: 3px solid #f2b886; outline-offset: 1px; }
.hint { font-size: .85rem; color: var(--muted); margin: 4px 0 14px; }
.pw-wrap { position: relative; }
.pw-wrap input { padding-right: 84px; }
.pw-toggle {
  position: absolute; right: 6px; top: 50%; transform: translateY(-50%);
  min-height: 34px; padding: 2px 12px; font: inherit; font-size: .8rem;
  border: 1px solid var(--line); border-radius: 8px; background: var(--bg); color: var(--navy); cursor: pointer;
}
.pw-toggle .s-hide, .pw-toggle.on .s-show { display: none; }
.pw-toggle.on .s-hide { display: inline; }
.btn {
  display: inline-block; min-height: 34px; padding: 5px 14px; font: inherit; font-weight: 600;
  border: 1.5px solid var(--navy); border-radius: 10px; background: #fff; color: var(--navy);
  cursor: pointer; text-decoration: none; text-align: center;
}
.btn:hover { background: var(--bg); }
.btn-primary { background: var(--navy); color: #fff; }
.btn-primary:hover { background: var(--navy-d); }
.btn-ghost { min-height: 30px; padding: 4px 14px; border-color: var(--line); }
.btn-sm { min-height: 28px; padding: 2px 8px; font-size: .85rem; }
.btn-block { display: block; width: 100%; }
.btn-link { background: none; border: 0; color: var(--navy); text-decoration: underline; cursor: pointer; font: inherit; margin-top: 10px; }
form.inline { display: inline-flex; align-items: center; gap: 6px; margin: 2px 0; }

.alert { padding: 12px 14px; border-radius: 10px; margin-bottom: 16px; font-size: .95rem; }
.alert-error { background: var(--err-bg); color: var(--err); border: 1px solid #e7bcbc; }
.alert-ok { background: var(--ok-bg); color: var(--ok); border: 1px solid #b7dcc2; }

/* ---------- 表格 ---------- */
.table-wrap { overflow-x: auto; padding: 0; }
.table { width: 100%; border-collapse: collapse; font-size: .93rem; }
.table th { background: var(--navy); color: #fff; text-align: left; padding: 6px 8px; white-space: nowrap; }
.table td { padding: 5px 8px; border-bottom: 1px solid var(--line); vertical-align: middle; }
.table tbody tr:nth-child(even) { background: #F1F4F8; }
.table tr.inactive td { color: var(--muted); }
.table .actions { min-width: 220px; }
.badge { display: inline-block; padding: 1px 10px; border-radius: 999px; font-size: .78rem; font-weight: 600; margin-right: 4px; }
.badge.ok { background: var(--ok-bg); color: var(--ok); }
.badge.off { background: #e8ebef; color: var(--muted); }
.badge.warn { background: var(--warn-bg); color: var(--warn); }

/* ---------- 平板／手機：導覽列獨立一排 ---------- */
@media (max-width: 1100px) {
  .nav { order: 3; flex-basis: 100%; overflow-x: auto; flex-wrap: nowrap; }
  .nav a { white-space: nowrap; }
}
@media (max-width: 720px) {
  body { font-size: 14px; }
  .topbar { padding: 8px 8px; }
  .brand { width: 100%; min-width: 0; gap: 8px; }
  .brand img { height: 30px; }
  .brand-text { min-width: 0; }
  .brand-text strong { font-size: .95rem; overflow-wrap: anywhere; }
  .topright { margin-left: 0; width: 100%; justify-content: space-between; }
  .container { padding: 10px 6px; }
  .card { padding: 16px; }
  .kv { grid-template-columns: 1fr; gap: 2px; }
  .kv dd { margin-bottom: 8px; }
}

/* ---------- Phase 1：船班總表、櫃況明細、記錄頁 ---------- */
h2.spaced { margin-top: 28px; }
.actions-row { display: flex; gap: 8px; flex-wrap: wrap; }
.filters { margin-bottom: 10px; }
.filter-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(130px, 1fr)); gap: 0 10px; }
.filter-grid .field { margin-bottom: 6px; }
.filter-grid label { font-size: .85rem; margin-bottom: 3px; }
.filter-grid input, .filter-grid select { min-height: 32px; padding: 2px 8px; }
.filter-bar { display: flex; flex-wrap: wrap; align-items: center; gap: 10px 14px; }
.check { display: inline-flex; align-items: center; gap: 6px; font-weight: 400; margin: 0 14px 6px 0; }
.check input { width: auto; min-height: 0; }
.seg { display: inline-flex; border: 1.5px solid var(--navy); border-radius: 10px; overflow: hidden; }
.seg button { border: 0; background: #fff; color: var(--navy); padding: 5px 12px; font: inherit; cursor: pointer; }
.seg button.on { background: var(--navy); color: #fff; }
.cols-picker { margin-bottom: 10px; }
.cols-picker summary { cursor: pointer; font-weight: 600; color: var(--navy); }
.cols-picker fieldset { border: 1px solid var(--line); border-radius: 10px; margin: 10px 0; padding: 6px 12px 2px; }
.cols-picker legend { font-weight: 600; color: var(--muted); padding: 0 6px; }
.table.sticky thead th { position: sticky; top: 0; z-index: 2; }
.table .rowno { width: 1%; white-space: nowrap; color: var(--muted); }
.table td.pre, .pre { white-space: pre-wrap; }
.table a.sort { color: #fff; text-decoration: none; }
.table.sticky td { white-space: nowrap; }
.table.sticky td .cv { display: inline-block; max-width: 16em; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; vertical-align: bottom; }
.cv.dg { color: #26384f; }
.st { display: inline-block; padding: 1px 10px; border-radius: 999px; font-size: .78rem; font-weight: 600; background: #e8ebef; color: #3F4C5E; white-space: nowrap; }
.st-at_sea { background: #e3eefb; color: #174a8b; }
.st-discharged, .st-on_rail { background: #e8e6fa; color: #3a2f8f; }
.st-arrived, .st-picked_up { background: #fff3d6; color: #8a5a00; }
.st-returned { background: var(--ok-bg); color: var(--ok); }
.badge.bl { background: #fbeaea; color: var(--err); }
.mm { color: #b26a00; cursor: help; }
.cmt { position: relative; display: inline-block; cursor: pointer; outline: none; font-size: .85em; }
.cmt-pop {
  display: none; position: absolute; z-index: 10; left: 0; top: 1.6em; min-width: 220px; max-width: 360px;
  padding: 8px 10px; background: #fff; color: var(--ink); border: 1px solid var(--line); border-radius: 8px;
  box-shadow: 0 4px 14px rgba(11, 45, 91, .18); white-space: pre-wrap; font-size: .85rem; font-weight: 400;
}
.cmt:hover .cmt-pop, .cmt:focus .cmt-pop, .cmt:focus-within .cmt-pop { display: block; }
.cmt-item { display: block; margin-bottom: 4px; }
.pager { display: flex; flex-wrap: wrap; gap: 6px; justify-content: center; margin: 16px 0; }
.pager a, .pager span { min-width: 38px; padding: 6px 10px; text-align: center; border: 1px solid var(--line); border-radius: 8px; background: #fff; text-decoration: none; color: var(--navy); }
.pager span.on { background: var(--navy); color: #fff; border-color: var(--navy); }
.tabs { display: flex; flex-wrap: wrap; gap: 6px; margin: 6px 0 14px; border-bottom: 1px solid var(--line); }
.tabs a { padding: 8px 14px; text-decoration: none; color: var(--ink); border-radius: 8px 8px 0 0; font-weight: 600; }
.tabs a.on { background: #fff; color: var(--navy); border: 1px solid var(--line); border-bottom-color: #fff; margin-bottom: -1px; }
.form-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 0 16px; }
.kv.wide { grid-template-columns: max-content 1fr; }
.kv.sub { margin-top: 12px; padding-top: 12px; border-top: 1px dashed var(--line); }
.card + .card { margin-top: 10px; }
.edit-row td { background: #fafbfd; padding-top: 2px; padding-bottom: 6px; }
.edit-row summary { cursor: pointer; color: var(--navy); font-size: .88rem; }
input[type=date] { width: 100%; min-height: 32px; padding: 2px 8px; font: inherit; border: 1.5px solid var(--line); border-radius: 10px; }
input[type=file] { width: 100%; padding: 8px 0; font: inherit; }
input[type=search] { width: 100%; min-height: 32px; padding: 2px 8px; font: inherit; border: 1.5px solid var(--line); border-radius: 10px; }
@media (max-width: 720px) { .filter-grid { grid-template-columns: 1fr 1fr; } }

/* ---------- Phase 2：設定、郵件交換 ---------- */
textarea { width: 100%; padding: 8px 12px; font: inherit; border: 1.5px solid var(--line); border-radius: 10px; background: #fff; }
.job { padding: 14px 0; border-top: 1px dashed var(--line); }
.job:first-of-type { border-top: 0; }
.job h3 { margin: 0 0 4px; font-size: 1.05rem; color: var(--navy); }
fieldset.days { border: 0; padding: 0; margin: 4px 0 10px; }
fieldset.days legend { font-weight: 600; margin-bottom: 4px; }
.inline-add { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin-top: 12px; }
.inline-add input, .inline-add select { width: auto; min-height: 38px; padding: 4px 10px; }
td input[type=text], td select { min-height: 34px; padding: 2px 8px; width: 100%; }
.matched { font-weight: 600; }
.badge.warn, .badge.ok, .badge.off { white-space: nowrap; }

/* 查詢條件、欄位選擇收合時變窄 */
.card.filters, .card.cols-picker { padding: 6px 12px; margin-bottom: 8px; }
.card.filters .filter-box > summary, .cols-picker > summary { margin: 0; line-height: 1.4; }
.card.filters .filter-box[open] > summary, .cols-picker[open] > summary { margin-bottom: 8px; }
.per-page input { width: 70px; min-height: 30px; padding: 2px 6px; margin-left: 4px; }
/* 總表：標題列固定，只有內容上下捲動；左右捲動時標題列跟著動 */
.table-wrap.fill { overflow: auto; }
.table-wrap.fill .table thead th { position: sticky; top: 0; z-index: 2; }
/* 收合時兩張卡片並排一列；展開的那張佔滿整列 */
.toolbars { display: flex; flex-wrap: wrap; gap: 8px; align-items: flex-start; margin-bottom: 8px; }
.toolbars > .card { flex: 1 1 260px; margin: 0; }
.toolbars .tb-title { margin: 0; font-size: 1.2rem; white-space: nowrap; align-self: center; }
.toolbars .actions-row { align-self: center; margin-left: auto; }
.toolbars > .card:has(details[open]), .toolbars > details[open] { flex-basis: 100%; }
/* 列更緊湊，一個畫面看到更多筆 */
.table.sticky td { padding: 3px 8px; line-height: 1.3; }
.table.sticky th { padding: 5px 8px; }
.pager { margin: 6px 0; }
.pager a, .pager span { padding: 3px 9px; min-width: 32px; }
.nav { flex-wrap: nowrap; }
.nav a { white-space: nowrap; padding: 5px 9px; }
/* 日期欄位與起、迄放在同一列 */
.filter-grid .date-group { grid-column: span 3; display: grid; grid-template-columns: 1.2fr 1fr 1fr; gap: 0 10px; }
@media (max-width: 720px) { .filter-grid .date-group { grid-column: 1 / -1; } }
/* 查詢條件可收合 */
.filter-box > summary { cursor: pointer; font-weight: 600; color: var(--navy); margin-bottom: 6px; }
.filter-box:not([open]) > summary { margin-bottom: 0; }

/* 欄位選擇：群組與每 5 個一小群，皆可全選 */
.pick-tools { display: flex; gap: 6px; margin: 8px 0; }
.pick-sub { display: flex; flex-wrap: wrap; align-items: center; gap: 2px 14px; padding: 4px 0; border-top: 1px dashed var(--line); }
.pick-sub:first-of-type { border-top: 0; }
.pick-subhead { color: var(--muted); font-weight: 400; margin-right: 8px; }
.pick-group legend .check { margin: 0; }

/* 導覽列「管理」選單與唯讀連線橫幅（Phase 7） */
.nav-menu { position: relative; }
.nav-menu > summary { list-style: none; cursor: pointer; padding: 5px 9px; border-radius: 8px; font-weight: 600; color: var(--ink); white-space: nowrap; }
.nav-menu > summary::-webkit-details-marker { display: none; }
.nav-menu > summary::after { content: " \25BE"; font-size: .8em; }
.nav-menu > summary:hover { background: var(--bg); }
.nav-menu.on > summary { background: var(--navy); color: #fff; }
.nav-pop { position: absolute; z-index: 30; left: 0; top: 110%; min-width: 180px; background: #fff; border: 1px solid var(--line); border-radius: 10px; box-shadow: 0 6px 18px rgba(11, 45, 91, .18); padding: 6px; display: flex; flex-direction: column; }
.nav-pop a { padding: 7px 12px; border-radius: 6px; text-decoration: none; color: var(--ink); white-space: nowrap; }
.nav-pop a:hover { background: var(--bg); }
.zone-banner { margin-bottom: 8px; }

/* 登入頁：中英文並列；中文系統名稱放大（Phase 7 後續） */
.auth-tagline { text-align: center; margin: 4px 0 14px; font-size: 1.2rem; font-weight: 600; letter-spacing: .06em; color: #3f4c5e; }
.auth-tagline .bi-en { display: block; font-size: .85rem; font-weight: 400; letter-spacing: 0; color: var(--muted); }
.bi-en { font-weight: 400; color: var(--muted); font-size: .9em; }
.btn .bi-en { color: inherit; opacity: .85; }
.pw-toggle .bi-zh, .pw-toggle .bi-en { display: block; line-height: 1.1; text-align: center; }
.pw-toggle .bi-en { font-size: .7em; }

/* 密碼相關頁面：長句的英文換行顯示在中文下面 */
.auth-card h2 .bi-en, .auth-card p .bi-en, .auth-card .alert .bi-en { display: block; margin-top: 2px; }
.auth-card h2 { font-size: 1.2rem; margin: 6px 0 8px; }
.auth-card .btn-link .bi-en, .auth-card .btn .bi-en { display: inline; }
.auth-card .hint { font-size: .85rem; }

/* 一個畫面多看幾筆（Phase 7 後續）：頁碼與版權併成一列、查詢條件展開時排成緊湊的一列、列與頁首再縮一點 */
.fit-page .footer { display: none; }
.bottom-bar { display: flex; align-items: center; gap: 12px; margin: 2px 0 0; }
.bottom-bar .pager { margin: 0; flex: 1; }
.bottom-bar .pager a, .bottom-bar .pager span { padding: 1px 8px; min-width: 28px; font-size: .9rem; }
.bottom-bar .copy { color: var(--muted); font-size: .75rem; white-space: nowrap; margin-left: auto; }
.bottom-bar:not(:has(.pager)) .copy { margin-left: auto; }
.topbar { padding-top: 4px; padding-bottom: 4px; }
.container { padding-top: 8px; padding-bottom: 6px; }
.table.sticky td { padding-top: 2px; padding-bottom: 2px; }
.card.filters .filter-body { display: flex; flex-wrap: wrap; align-items: flex-end; gap: 0 10px; }
.card.filters .filter-grid, .card.filters .filter-bar { display: contents; }
.card.filters .filter-grid .field { flex: 1 1 120px; max-width: 210px; margin-bottom: 6px; }
.card.filters .filter-grid .date-group { flex: 3 1 380px; max-width: 640px; margin-bottom: 0; }
.card.filters .filter-grid .date-group .field { max-width: none; }
.card.filters .check, .card.filters .seg, .card.filters .btn, .card.filters .per-page { margin-bottom: 6px; }
@media (max-width: 720px) { .bottom-bar { flex-direction: column; gap: 2px; } .bottom-bar .copy { margin-left: 0; } }
