/* =========================================================================
   FRESHTech Project Management Portal — tokens + shared UI
   Tokens sourced from Asia Fruit Logistica Design System (colors_and_type.css).
   One stylesheet for the whole portal; new form modules add their styles here.
   ========================================================================= */

@font-face { font-family: "Lato"; src: url("../fonts/Lato-Regular.ttf") format("truetype"); font-weight: 400; font-style: normal; font-display: swap; }
@font-face { font-family: "Lato"; src: url("../fonts/Lato-Bold.ttf") format("truetype"); font-weight: 700; font-style: normal; font-display: swap; }
@font-face { font-family: "Lato"; src: url("../fonts/Lato-Black.ttf") format("truetype"); font-weight: 900; font-style: normal; font-display: swap; }

:root {
  /* FRESHTech sub-brand */
  --ft-green:       #188868;
  --ft-green-hover: #1FA07C;
  --ft-blue-light:  #0098E0;
  --ft-blue-mid:    #0070C0;
  --ft-blue-deep:   #0060B0;
  --ft-navy:        #202050;
  --ft-navy-mid:    #203060;
  --ft-navy-light:  #204060;
  --ft-tech-gradient:  linear-gradient(to bottom, #0098E0 0%, #0070C0 50%, #0060B0 100%);
  --ft-hero-gradient:  linear-gradient(135deg, #202050 0%, #203060 55%, #204060 100%);

  /* Surfaces + text */
  --bg-page: #f3f3f3;
  --bg-card: #ffffff;
  --bg-pale: #eef6f3;
  --fg1:     #3a2540;
  --fg2:     #777;
  --line:    #e5e2ea;

  --font-sans: "Lato", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
}

* { box-sizing: border-box; }
html, body {
  margin: 0; padding: 0;
  background: var(--bg-page); color: var(--fg1);
  font-family: var(--font-sans); font-size: 13px; line-height: 1.45;
  -webkit-font-smoothing: antialiased;
}

/* =========================================================================
   Hub shell (sidebar + main)
   ========================================================================= */
.hub { display: grid; grid-template-columns: 260px 1fr; min-height: 100vh; }
.hub-side { background: var(--ft-hero-gradient); color: #fff; padding: 20px 16px; }
.hub-side .wm { font-size: 22px; font-weight: 900; letter-spacing: -0.02em; }
.hub-side .wm .fresh { color: #4cc39a; }
.hub-side .wm .tech {
  background: var(--ft-tech-gradient);
  -webkit-background-clip: text; background-clip: text;
  color: transparent; font-style: italic;
}
.hub-side .sub { margin-top: 4px; font-size: 10px; letter-spacing: 0.09em; text-transform: uppercase; color: rgba(255,255,255,0.75); }
.hub-side h2 { margin: 24px 0 10px; font-size: 10px; font-weight: 700; letter-spacing: 0.1em; text-transform: uppercase; color: rgba(255,255,255,0.55); }
.hub-side .hint { margin-top: 22px; font-size: 10.5px; line-height: 1.5; color: rgba(255,255,255,0.55); }

.artefact-card {
  display: block; width: 100%; text-align: left;
  background: rgba(255,255,255,0.06); border: 1px solid rgba(255,255,255,0.12);
  border-radius: 12px; padding: 12px 14px; margin-bottom: 10px;
  color: #fff; cursor: pointer; font-family: var(--font-sans);
  transition: background 120ms ease, border-color 120ms ease;
}
.artefact-card:hover { background: rgba(255,255,255,0.12); }
.artefact-card.active { background: #fff; color: var(--ft-navy); border-color: #fff; }
.artefact-card .t { font-weight: 900; font-size: 13px; }
.artefact-card .m { font-size: 10.5px; opacity: 0.7; margin-top: 2px; }

.hub-main { padding: 24px; overflow-x: auto; }

/* =========================================================================
   Shared annotation UI
   ========================================================================= */
.note-tag { display: block; margin-top: 6px; padding: 4px 6px; background: #f4f1f8; border-left: 3px solid #888; color: var(--fg1); font-size: 10px; border-radius: 4px; word-break: break-word; }
.note-author { font-weight: 900; }
.note-editor { width: 100%; box-sizing: border-box; margin-top: 6px; font-family: var(--font-sans); font-size: 11px; border: 1px solid var(--ft-green); border-radius: 4px; padding: 5px; resize: vertical; }
.note-actions { margin-top: 5px; display: flex; gap: 6px; }
.note-actions button { font-family: var(--font-sans); font-size: 10px; font-weight: 700; border: none; border-radius: 999px; padding: 4px 12px; cursor: pointer; }
.btn-save { background: var(--ft-green); color: #fff; }
.btn-cancel { background: #e5e2ea; color: var(--fg1); }

/* identity overlay */
.name-overlay { position: fixed; inset: 0; background: rgba(32,32,80,0.62); display: flex; align-items: center; justify-content: center; z-index: 999; }
.name-overlay.hidden { display: none; }
.name-box { background: #fff; border-radius: 16px; padding: 24px 28px; width: 380px; box-shadow: 0 10px 40px rgba(0,0,0,0.32); }
.name-box .t { font-weight: 900; font-size: 16px; color: var(--ft-navy); margin-bottom: 4px; }
.name-box .s { font-size: 11px; color: #888; margin: 12px 0 6px; }
.name-box input { width: 100%; box-sizing: border-box; font-family: var(--font-sans); font-size: 14px; padding: 9px 12px; border: 1.5px solid #d8d4e0; border-radius: 8px; margin-bottom: 8px; }
.name-box input:focus { outline: none; border-color: var(--ft-green); }
.swatches { display: flex; gap: 8px; flex-wrap: wrap; }
.swatch { width: 26px; height: 26px; border-radius: 50%; cursor: pointer; border: 2px solid transparent; }
.swatch.sel { border-color: var(--ft-navy); box-shadow: 0 0 0 2px #fff inset; }
.known-names { display: flex; flex-wrap: wrap; gap: 6px; }
.known-name { font-family: var(--font-sans); font-size: 11px; font-weight: 700; padding: 4px 10px; border-radius: 999px; border: 1px solid #e5e2ea; background: #faf9fc; cursor: pointer; }
.name-box button.start { width: 100%; margin-top: 14px; font-family: var(--font-sans); background: var(--ft-green); color: #fff; border: none; border-radius: 999px; padding: 10px; font-size: 14px; font-weight: 700; cursor: pointer; }

/* annotator badge (bottom-right) */
.annotator-badge { position: fixed; right: 16px; bottom: 16px; z-index: 998; display: flex; align-items: center; gap: 8px; background: #fff; border: 1px solid #e5e2ea; border-radius: 999px; padding: 7px 14px; font-size: 12px; font-weight: 700; cursor: pointer; box-shadow: 0 4px 14px rgba(0,0,0,0.14); }
.annotator-badge .dot { width: 10px; height: 10px; border-radius: 50%; }
.annotator-badge.hidden { display: none; }

/* =========================================================================
   Checklist matrix (module: checklist)
   ========================================================================= */
table.matrix { width: 100%; border-collapse: separate; border-spacing: 0; font-size: 12px; background: #fff; border-radius: 10px; overflow: hidden; }
table.matrix thead th { background: var(--ft-navy); color: #fff; text-align: left; font-size: 10.5px; font-weight: 700; letter-spacing: 0.06em; text-transform: uppercase; padding: 8px 10px; border-right: 1px solid rgba(255,255,255,0.15); }
table.matrix thead th:first-child { border-radius: 10px 0 0 0; }
table.matrix thead th:last-child { border-radius: 0 10px 0 0; border-right: none; }
table.matrix tbody td { padding: 9px 10px; border-bottom: 1px solid #ece9f1; vertical-align: top; }
table.matrix tbody tr:nth-child(even) td { background: #faf9fc; }
table.matrix tbody tr:last-child td:first-child { border-radius: 0 0 0 10px; }
table.matrix tbody tr:last-child td:last-child { border-radius: 0 0 10px 0; }
table.matrix tbody tr { cursor: pointer; }
table.matrix tbody tr:hover td { background: #f6f6fa; }
table.matrix tbody tr.selected td { background: #eef6f3; }
table.matrix tbody tr.selected td:first-child { box-shadow: inset 3px 0 0 var(--ft-green); }
td.group .name { font-weight: 900; font-size: 12.5px; }
td.group .count { font-weight: 700; color: var(--ft-green); }
.prio { display: inline-block; font-weight: 900; font-size: 11px; width: 22px; height: 22px; line-height: 22px; text-align: center; border-radius: 6px; margin-bottom: 3px; }
.prio.h { background: var(--ft-navy); color: #fff; }
.prio.m { background: #fff; color: var(--ft-navy); border: 1.5px solid var(--ft-navy); }
td.prio-cell .why { font-size: 10.5px; color: var(--fg2); line-height: 1.3; }
td.action ul { list-style: none; margin: 0; padding: 0; }
td.action li { margin-bottom: 5px; display: flex; align-items: flex-start; }
td.action li:last-child { margin-bottom: 0; }
.chk { flex: 0 0 auto; width: 12px; height: 12px; border: 1.5px solid var(--ft-green); border-radius: 3px; margin: 1px 8px 0 0; background: #fff; }
td.loc, td.owner { font-size: 11px; line-height: 1.4; }
td.loc b, td.owner b { font-weight: 700; }
.tbc { color: #b33; font-weight: 700; }
.ai-strip { margin-top: 10px; background: var(--bg-pale); border-left: 4px solid var(--ft-green); border-radius: 8px; padding: 8px 14px; font-size: 11px; }
.ai-strip b { color: var(--ft-green); }

/* =========================================================================
   Swimlane calendar (module: calendar)
   ========================================================================= */
.cal-grid { display: grid; border: 1px solid var(--line); border-radius: 10px; overflow: hidden; background: #fff; }
.phase, .wh, .row { grid-column: 1 / -1; display: grid; }
.phase { background: #faf9fc; }
.phase .spacer { border-right: 1px solid var(--line); }
.phase .seg { text-align: center; font-weight: 900; font-size: 11px; letter-spacing: 0.06em; text-transform: uppercase; padding: 8px 4px; border-left: 1px solid var(--line); }
.seg.pre  { background: #eef4f7; color: var(--ft-blue-mid); }
.seg.on   { background: #eef6f3; color: var(--ft-green); }
.seg.post { background: #f0f0f5; color: var(--ft-navy); }
.wh { background: var(--ft-navy); color: #fff; }
.wh .lbl { padding: 6px 10px; font-size: 9.5px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.06em; border-right: 1px solid rgba(255,255,255,0.15); display: flex; align-items: center; }
.wh .t { padding: 6px 4px; text-align: center; font-size: 10px; font-weight: 700; border-left: 1px solid rgba(255,255,255,0.15); }
.wh .t span { display: block; font-weight: 400; font-size: 8.5px; color: rgba(255,255,255,0.6); }
.row { border-top: 1px solid var(--line); }
.row .lane { padding: 8px 10px; border-right: 1px solid var(--line); display: flex; flex-direction: column; justify-content: flex-start; }
.row .lane .g { font-weight: 900; font-size: 12px; }
.row .lane .gn { font-size: 10px; color: var(--fg2); }
.row .cell { padding: 8px 7px; border-left: 1px solid var(--line); font-size: 10.5px; line-height: 1.4; cursor: pointer; transition: background 120ms ease; }
.row .cell.empty { background: #fbfbfc; }
.row .cell .it { display: block; margin-bottom: 5px; }
.row .cell .it:last-child { margin-bottom: 0; }
.row .cell:hover { background: #f6f6fa; }
.row .cell.selected { outline: 2px solid var(--ft-green); outline-offset: -2px; background: #eef6f3; }
.g1 { color: var(--ft-blue-mid); } .g2 { color: var(--ft-green); } .g3 { color: var(--ft-navy); }
.row.g1 .cell { border-top: 3px solid var(--ft-blue-mid); }
.row.g2 .cell { border-top: 3px solid var(--ft-green); }
.row.g3 .cell { border-top: 3px solid var(--ft-navy); }
.legend { display: flex; gap: 14px; margin-top: 14px; font-size: 10.5px; flex-wrap: wrap; }
.legend .i { display: flex; align-items: center; gap: 6px; }
.dot { width: 10px; height: 10px; border-radius: 3px; display: inline-block; }
.d1 { background: var(--ft-blue-mid); } .d2 { background: var(--ft-green); } .d3 { background: var(--ft-navy); }

/* =========================================================================
   Generic multi-dim table (module: table)
   ========================================================================= */
table.ft-table { width: 100%; border-collapse: separate; border-spacing: 0; font-size: 12px; background: #fff; border: 1px solid var(--line); border-radius: 10px; overflow: hidden; }
table.ft-table thead th { background: var(--ft-navy); color: #fff; text-align: left; font-size: 10.5px; font-weight: 700; letter-spacing: 0.06em; text-transform: uppercase; padding: 8px 10px; border-right: 1px solid rgba(255,255,255,0.15); }
table.ft-table thead th:last-child { border-right: none; }
table.ft-table tbody td { padding: 9px 10px; border-bottom: 1px solid #ece9f1; vertical-align: top; cursor: pointer; transition: background 120ms ease; }
table.ft-table tbody tr:nth-child(even) td { background: #faf9fc; }
table.ft-table tbody td:hover { background: #f6f6fa; }
table.ft-table tbody td.selected { background: #eef6f3; box-shadow: inset 3px 0 0 var(--ft-green); }
.ft-caption { padding: 10px 12px; font-size: 11px; color: var(--fg2); background: #fff; border-top: 1px solid var(--line); }

/* =========================================================================
   Print
   ========================================================================= */
/* =========================================================================
   AI chat widget
   ========================================================================= */
.chat-toggle { position: fixed; left: 16px; bottom: 16px; z-index: 997; width: 52px; height: 52px; border-radius: 50%; background: var(--ft-green); color: #fff; border: none; font-size: 22px; cursor: pointer; box-shadow: 0 6px 16px rgba(0,0,0,0.25); display: flex; align-items: center; justify-content: center; }
.chat-toggle:hover { background: var(--ft-green-hover); }
.chat-panel { position: fixed; left: 16px; bottom: 80px; z-index: 997; width: 360px; max-width: calc(100vw - 32px); height: 480px; max-height: calc(100vh - 120px); background: #fff; border-radius: 16px; box-shadow: 0 10px 40px rgba(0,0,0,0.28); display: flex; flex-direction: column; overflow: hidden; }
.chat-panel.hidden { display: none; }
.chat-head { background: var(--ft-hero-gradient); color: #fff; padding: 12px 16px; }
.chat-head .t { font-weight: 900; font-size: 14px; }
.chat-head .ctx { margin-top: 3px; font-size: 10px; opacity: 0.8; }
.chat-msgs { flex: 1; overflow-y: auto; padding: 14px; display: flex; flex-direction: column; gap: 10px; background: var(--bg-page); }
.chat-msg { max-width: 85%; padding: 8px 12px; border-radius: 12px; font-size: 12.5px; line-height: 1.45; white-space: pre-wrap; word-break: break-word; }
.chat-msg.user { align-self: flex-end; background: var(--ft-green); color: #fff; border-bottom-right-radius: 4px; }
.chat-msg.assistant { align-self: flex-start; background: #fff; color: var(--fg1); border: 1px solid var(--line); border-bottom-left-radius: 4px; }
.chat-msg.system { align-self: flex-start; background: #f4f1f8; color: var(--fg2); font-size: 11px; }
.chat-input { display: flex; gap: 8px; padding: 10px; border-top: 1px solid var(--line); background: #fff; }
.chat-input textarea { flex: 1; resize: none; height: 40px; border: 1px solid #d8d4e0; border-radius: 10px; padding: 9px 12px; font-family: var(--font-sans); font-size: 13px; }
.chat-input textarea:focus { outline: none; border-color: var(--ft-green); }
.chat-input button { background: var(--ft-green); color: #fff; border: none; border-radius: 999px; padding: 0 18px; font-weight: 700; font-size: 13px; cursor: pointer; font-family: var(--font-sans); }
.chat-input button:hover { background: var(--ft-green-hover); }

/* =========================================================================
   Auth: login screen, user bar, admin panel
   ========================================================================= */
.hidden { display: none !important; }

.login-screen { position: fixed; inset: 0; background: var(--ft-hero-gradient); display: flex; align-items: center; justify-content: center; z-index: 1000; }
.login-box { background: #fff; border-radius: 18px; padding: 32px 36px; width: 340px; box-shadow: 0 20px 60px rgba(0,0,0,0.35); }
.login-box .wm { font-size: 26px; font-weight: 900; letter-spacing: -0.02em; }
.login-box .wm .fresh { color: var(--ft-green); }
.login-box .wm .tech { background: var(--ft-tech-gradient); -webkit-background-clip: text; background-clip: text; color: transparent; font-style: italic; }
.login-box .sub { margin: 4px 0 20px; font-size: 11px; letter-spacing: 0.09em; text-transform: uppercase; color: var(--fg2); }
.login-box input { width: 100%; box-sizing: border-box; font-family: var(--font-sans); font-size: 14px; padding: 10px 12px; border: 1.5px solid #d8d4e0; border-radius: 8px; margin-bottom: 10px; }
.login-box input:focus { outline: none; border-color: var(--ft-green); }
.login-error { color: #b33; font-size: 11.5px; min-height: 16px; margin-bottom: 6px; }
.login-box button.start { width: 100%; font-family: var(--font-sans); background: var(--ft-green); color: #fff; border: none; border-radius: 999px; padding: 11px; font-size: 14px; font-weight: 700; cursor: pointer; }
.login-box button.start:hover { background: var(--ft-green-hover); }

.user-bar { position: fixed; top: 12px; right: 16px; z-index: 996; display: flex; align-items: center; gap: 8px; background: #fff; border: 1px solid var(--line); border-radius: 999px; padding: 6px 12px; font-size: 12px; font-weight: 700; box-shadow: 0 4px 14px rgba(0,0,0,0.12); }
.user-bar .dot { width: 10px; height: 10px; border-radius: 50%; }
.user-bar button { font-family: var(--font-sans); font-size: 11px; font-weight: 700; border: none; border-radius: 999px; padding: 5px 12px; cursor: pointer; }
.user-bar #logoutBtn { background: #e5e2ea; color: var(--fg1); }
.user-bar #adminBtn { background: var(--ft-navy); color: #fff; }

.admin-panel { position: fixed; inset: 0; background: rgba(32,32,80,0.5); display: flex; align-items: center; justify-content: center; z-index: 1001; }
.admin-box { background: #fff; border-radius: 16px; width: 420px; max-width: calc(100vw - 32px); padding: 20px; box-shadow: 0 16px 50px rgba(0,0,0,0.3); }
.admin-head { display: flex; justify-content: space-between; align-items: center; font-weight: 900; font-size: 15px; color: var(--ft-navy); margin-bottom: 12px; }
.admin-list { max-height: 260px; overflow-y: auto; margin-bottom: 12px; }
.admin-row { display: flex; justify-content: space-between; align-items: center; padding: 8px 4px; border-bottom: 1px solid #f0eef4; font-size: 13px; }
.admin-row button { font-family: var(--font-sans); font-size: 10px; font-weight: 700; border: none; border-radius: 999px; padding: 4px 10px; cursor: pointer; background: #f4dada; color: #b33; }
.admin-add { display: flex; gap: 8px; }
.admin-add input { flex: 1; min-width: 0; font-family: var(--font-sans); font-size: 12px; padding: 8px 10px; border: 1.5px solid #d8d4e0; border-radius: 8px; }
.admin-add input:focus { outline: none; border-color: var(--ft-green); }
.admin-add button { font-family: var(--font-sans); font-size: 11px; font-weight: 700; border: none; border-radius: 999px; padding: 0 16px; cursor: pointer; }

/* =========================================================================
   Sidebar toggle + responsive
   ========================================================================= */
.sidebar-toggle { position: fixed; left: 14px; top: 14px; z-index: 995; width: 36px; height: 36px; border-radius: 9px; background: rgba(255,255,255,0.14); color: #fff; border: 1px solid rgba(255,255,255,0.22); font-size: 17px; line-height: 1; cursor: pointer; transition: background 120ms ease; }
.sidebar-toggle:hover { background: rgba(255,255,255,0.26); }
/* When collapsed the toggle floats over the white page — flip to a light chip */
body.sidebar-collapsed .sidebar-toggle { background: #fff; color: var(--ft-navy); border-color: var(--line); box-shadow: 0 2px 8px rgba(0,0,0,0.18); }
.hub-side { padding-top: 56px; overflow: hidden; }
.hub { transition: grid-template-columns 180ms ease; }
body.sidebar-collapsed .hub { grid-template-columns: 0px 1fr; }
/* 收起时 padding 必须归零 —— border-box 下负内容宽被钳到 0，padding 仍会渲染成一条 */
body.sidebar-collapsed .hub-side { padding-left: 0; padding-right: 0; }

.sidebar-backdrop { position: fixed; inset: 0; background: rgba(0,0,0,0.4); z-index: 985; display: none; }

/* Mobile top app bar + drawer close — hidden on desktop, activated ≤768px */
.topbar { display: none; }
.drawer-close { display: none; }

/* Tablet: force the wide forms to scroll instead of squashing */
@media (max-width: 1024px) {
  .cal-grid { min-width: 860px; }
  table.matrix { min-width: 720px; }
  table.ft-table { min-width: 560px; }
}

/* Phone: sticky top app bar + off-canvas drawer */
@media (max-width: 768px) {
  .hub { display: block; }

  /* sticky top bar carries the menu button + wordmark; content flows below */
  .topbar { display: flex; align-items: center; gap: 12px; position: sticky; top: 0; z-index: 994; height: 52px; padding: 0 14px; background: var(--ft-hero-gradient); box-shadow: 0 2px 10px rgba(0,0,0,0.18); }
  .topbar .wm { font-size: 18px; font-weight: 900; letter-spacing: -0.02em; color: #fff; }
  .topbar .wm .fresh { color: #4cc39a; }
  .topbar .wm .tech { background: var(--ft-tech-gradient); -webkit-background-clip: text; background-clip: text; color: transparent; font-style: italic; }
  .topbar-btn { flex: 0 0 auto; width: 38px; height: 38px; border-radius: 9px; background: rgba(255,255,255,0.16); color: #fff; border: none; font-size: 18px; line-height: 1; cursor: pointer; }
  .topbar-btn:active { background: rgba(255,255,255,0.3); }

  /* the desktop floating toggle is replaced by the topbar button */
  .sidebar-toggle { display: none; }

  /* off-canvas drawer (sits above the sticky top bar so its close button is reachable) */
  .hub-side { position: fixed; top: 0; left: 0; bottom: 0; width: 268px; z-index: 995; padding: 52px 16px 20px; transform: translateX(-100%); transition: transform 180ms ease; box-shadow: 4px 0 24px rgba(0,0,0,0.25); }
  body:not(.sidebar-collapsed) .hub-side { transform: translateX(0); }
  body:not(.sidebar-collapsed) .sidebar-backdrop { display: block; }
  .drawer-close { display: block; position: absolute; top: 12px; right: 12px; width: 34px; height: 34px; border-radius: 8px; background: rgba(255,255,255,0.14); color: #fff; border: none; font-size: 22px; line-height: 1; cursor: pointer; }
  .drawer-close:active { background: rgba(255,255,255,0.28); }

  /* larger touch targets in the drawer */
  .artefact-card { padding: 14px 16px; }

  .hub-main { padding: 16px 12px; }
  .login-box { width: calc(100vw - 40px); max-width: 340px; padding: 28px 24px; }
  .chat-panel { left: 8px; right: 8px; bottom: 76px; width: auto; }
  .admin-box { width: calc(100vw - 24px); }
  /* keep the user chip clear of the sticky top bar */
  .user-bar { top: 9px; right: 8px; z-index: 996; }
}

@media print {
  html, body { background: #fff; }
  .hub { display: block; }
  .hub-side, .topbar, .name-overlay, .annotator-badge, .note-editor, .note-actions, .chat-toggle, .chat-panel, .login-screen, .user-bar, .admin-panel, .sidebar-toggle, .sidebar-backdrop { display: none !important; }
  .hub-main { padding: 0; }
  * { -webkit-print-color-adjust: exact !important; print-color-adjust: exact !important; }
}
