/* 三井作造 曲線系統 — 日系簡約 × 暖石材木質調 */
* { box-sizing: border-box; margin: 0; padding: 0; }
:root {
  --bg: #f2ede4;          /* 暖紙色底 */
  --card: #fffdf8;        /* 米白卡片 */
  --line: #e6ddcd;        /* 淺砂線 */
  --ink: #3b352c;         /* 深棕墨 */
  --ink2: #8a8171;        /* 次要字 */
  --brand: #443c31;       /* 品牌深棕 */
  --brand-hi: #2e2822;
  --wood: #b39b78;        /* 木質 */
  --green: #6d7f5a;       /* 抹茶綠 */
}
body { font-family: -apple-system, "PingFang TC", "Hiragino Sans", "Noto Sans TC", "Microsoft JhengHei", sans-serif; background: var(--bg); color: var(--ink); letter-spacing: .02em; }
button { cursor: pointer; font-family: inherit; letter-spacing: .05em; }
input, select, textarea { font-family: inherit; font-size: 15px; padding: 9px 12px; border: 1px solid #d8cdb9; border-radius: 10px; background: #fffefb; color: var(--ink); }
input:focus, select:focus, textarea:focus { outline: 2px solid var(--wood); border-color: transparent; }

/* 頂欄：品牌 */
.topbar { background: var(--brand); color: #f4efe6; padding: 14px 24px; display: flex; align-items: center; gap: 16px; flex-wrap: wrap; }
.topbar h1 { font-size: 19px; font-weight: 700; letter-spacing: .35em; margin-right: 2px; }
.topbar .brand-en { font-size: 10px; letter-spacing: .22em; color: #bfb39d; margin-right: auto; line-height: 1.5; text-transform: uppercase; }
.topbar .who { font-size: 13px; color: #d8cfbd; letter-spacing: .08em; }
.topbar button { background: transparent; color: #e8e1d2; border: 1px solid #6b6152; border-radius: 999px; padding: 6px 16px; font-size: 13px; }
.topbar button:hover { background: rgba(255,255,255,.08); border-color: #9c8f78; }

/* 分頁：底線式 */
.tabs { display: flex; gap: 26px; background: var(--card); padding: 4px 28px 0; border-bottom: 1px solid var(--line); overflow-x: auto; }
.tabs button { border: none; background: none; padding: 14px 2px 12px; font-size: 15px; color: var(--ink2); white-space: nowrap; border-bottom: 2px solid transparent; letter-spacing: .12em; }
.tabs button:hover { color: var(--ink); }
.tabs button.on { color: var(--brand); font-weight: 700; border-bottom-color: var(--wood); }

.page { max-width: 1240px; margin: 28px auto; padding: 0 18px 70px; }
.warn-bar { background: #f2e6c8; color: #7a5f2a; padding: 10px 24px; font-size: 13.5px; letter-spacing: .06em; border-bottom: 1px solid #e6d5ac; }
.card { background: var(--card); border: 1px solid var(--line); border-radius: 16px; padding: 26px 28px; box-shadow: 0 2px 10px rgba(90,75,50,.05); margin-bottom: 20px; }
.card h2 { font-size: 17px; margin-bottom: 14px; letter-spacing: .18em; color: var(--brand); }
.card h2::before { content: ''; display: inline-block; width: 10px; height: 10px; background: var(--wood); border-radius: 2px; margin-right: 10px; transform: rotate(45deg) translateY(-1px); }
.hint { color: var(--ink2); font-size: 13px; line-height: 1.9; letter-spacing: .05em; }

table { width: 100%; border-collapse: collapse; font-size: 14px; }
th, td { padding: 11px 12px; text-align: left; border-bottom: 1px solid #efe8da; }
th { color: var(--ink2); font-weight: 600; font-size: 12.5px; letter-spacing: .15em; background: #f8f4ec; }
tr:hover td { background: #faf7f0; }

.badge { display: inline-block; padding: 3px 12px; border-radius: 999px; font-size: 12px; font-weight: 600; letter-spacing: .08em; }
.badge.open { background: #e7ecdc; color: #55663f; }
.badge.locked { background: #ede8dd; color: #948a77; }
.badge.pending { background: #f2e6c8; color: #8a6d33; }
.badge.approved { background: #e7ecdc; color: #55663f; }
.badge.rejected { background: #f0ddd5; color: #99513c; }

.btn { border: none; border-radius: 999px; padding: 9px 20px; font-size: 14px; background: var(--brand); color: #f4efe6; }
.btn:hover { background: var(--brand-hi); }
.btn.gray { background: #e9e2d3; color: #5c5445; }
.btn.gray:hover { background: #ddd4c1; }
.btn.green { background: var(--green); color: #f2f4ec; }
.btn.green:hover { background: #59683f; }
.btn.red { background: #a4553f; color: #f7ede8; }
.btn.red:hover { background: #8c4531; }
.btn.sm { padding: 6px 14px; font-size: 13px; }

/* 登入 */
.login-wrap { min-height: 100vh; display: flex; align-items: center; justify-content: center; background:
  radial-gradient(1200px 500px at 80% -10%, #e9e0cf 0%, transparent 60%),
  radial-gradient(900px 500px at -10% 110%, #e5dcc8 0%, transparent 55%), var(--bg); }
.login-box { background: var(--card); border: 1px solid var(--line); padding: 44px 40px 38px; border-radius: 20px; box-shadow: 0 18px 50px rgba(90,75,50,.14); width: 360px; }
.login-box .brand { text-align: center; margin-bottom: 26px; }
.login-box .brand .zh { font-size: 30px; font-weight: 800; letter-spacing: .4em; text-indent: .4em; color: var(--brand); }
.login-box .brand .en { font-size: 10px; letter-spacing: .3em; color: var(--wood); margin-top: 8px; text-transform: uppercase; }
.login-box .brand .divider { width: 1px; height: 22px; background: var(--wood); margin: 14px auto; }
.login-box .brand .sys { font-size: 15px; letter-spacing: .55em; text-indent: .55em; color: var(--ink); }
.login-box .sub { text-align: center; color: var(--ink2); font-size: 12px; margin-bottom: 24px; letter-spacing: .1em; line-height: 1.8; }
.login-box label { display: block; font-size: 12.5px; color: var(--ink2); margin: 14px 0 5px; letter-spacing: .2em; }
.login-box input { width: 100%; }
.login-box .btn { width: 100%; margin-top: 26px; padding: 12px; font-size: 15px; letter-spacing: .5em; text-indent: .5em; }

.row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.field label { display: block; font-size: 12.5px; color: var(--ink2); margin-bottom: 5px; letter-spacing: .15em; }

.chart-wrap { overflow-x: auto; }
.chart-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 16px; margin-top: 14px; }
@media (max-width: 1000px) { .chart-grid { grid-template-columns: repeat(2, 1fr); } }
@media (max-width: 640px) { .chart-grid { grid-template-columns: 1fr; } }
.chart-cell { border: 1px solid var(--line); background: #fffefb; border-radius: 14px; padding: 14px; }
.chart-cell h4 { font-size: 13.5px; margin-bottom: 10px; display: flex; align-items: center; gap: 8px; color: var(--ink); letter-spacing: .06em; }
.chart-cell .dot { width: 10px; height: 10px; border-radius: 50%; display: inline-block; }
.legend { display: flex; flex-wrap: wrap; gap: 8px 14px; margin: 14px 0; }
.legend label { display: flex; align-items: center; gap: 7px; font-size: 13.5px; cursor: pointer; padding: 5px 12px; border-radius: 999px; background: #f4efe4; letter-spacing: .05em; }
.legend label:hover { background: #ece5d5; }
.legend .dot { width: 11px; height: 11px; border-radius: 50%; display: inline-block; }
.legend-tree { flex-direction: column; align-items: flex-start; gap: 7px; }

/* 挑選面板（曲線清單） */
.pick-panel { background: #f8f4ec; border: 1px solid var(--line); border-radius: 14px; padding: 14px 16px 16px; margin: 14px 0 6px; }
.pick-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 12px; flex-wrap: wrap; }
.pick-head > span:first-child { font-size: 13px; color: var(--ink2); letter-spacing: .12em; }
.pick-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(215px, 1fr)); gap: 8px; }
.pick-chip { display: flex; align-items: center; gap: 9px; padding: 9px 12px; background: #fffefb; border: 1.5px solid #e2d9c7; border-radius: 12px; cursor: pointer; transition: border-color .12s, background .12s; min-width: 0; }
.pick-chip:hover { border-color: #cbbc9e; }
.pick-chip.on { border-color: var(--wood); background: #f6efe1; }
.pick-chip input { accent-color: #6d5f4b; flex-shrink: 0; }
.pick-chip .dot { width: 11px; height: 11px; border-radius: 50%; flex-shrink: 0; }
.pick-tx { display: flex; flex-direction: column; min-width: 0; }
.pick-t1 { font-size: 13.5px; font-weight: 600; letter-spacing: .03em; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.pick-t2 { font-size: 11.5px; color: #a09681; letter-spacing: .05em; }

.modal-bg { position: fixed; inset: 0; background: rgba(46,40,32,.5); display: flex; align-items: center; justify-content: center; z-index: 50; padding: 16px; }
.modal { background: var(--card); border-radius: 18px; padding: 28px; width: 430px; max-width: 100%; max-height: 90vh; overflow-y: auto; border: 1px solid var(--line); }
.modal h3 { margin-bottom: 18px; font-size: 16.5px; letter-spacing: .2em; color: var(--brand); }
.modal .field { margin-bottom: 14px; }
.modal input, .modal textarea, .modal select { width: 100%; }
.modal .actions { display: flex; gap: 10px; justify-content: flex-end; margin-top: 20px; }

#toast { position: fixed; bottom: 26px; left: 50%; transform: translateX(-50%); background: var(--brand); color: #f4efe6; padding: 11px 26px; border-radius: 999px; font-size: 14px; letter-spacing: .1em; opacity: 0; transition: opacity .25s; pointer-events: none; z-index: 99; box-shadow: 0 8px 24px rgba(46,40,32,.25); }
#toast.show { opacity: 1; }
#toast.bad { background: #8c4531; }

.mini-note { font-size: 12px; color: #a09681; letter-spacing: .03em; }
.num { font-variant-numeric: tabular-nums; }
.unassigned { color: #b4aa98; }
.ch-search { width: 220px; }

/* 本週輸入列（手機友善的卡片列） */
.in-list { margin-top: 14px; }
.in-row { display: flex; align-items: center; gap: 14px; padding: 14px 4px; border-bottom: 1px solid #efe8da; flex-wrap: wrap; }
.in-row:last-child { border-bottom: none; }
.in-info { flex: 1; min-width: 170px; }
.in-title { font-weight: 700; letter-spacing: .08em; font-size: 15px; }
.in-val { font-size: 14px; color: var(--ink2); white-space: nowrap; }
.in-act { display: flex; gap: 8px; align-items: center; }
.in-act input { width: 120px; }

/* 表格在小螢幕可橫向滑動 */
.card { overflow-x: auto; }
.card table { min-width: 620px; }

/* 手機版 */
@media (max-width: 640px) {
  .topbar { padding: 10px 14px; gap: 8px; }
  .topbar h1 { font-size: 16px; letter-spacing: .22em; }
  .topbar .brand-en { display: none; }
  .topbar .who { display: none; }
  .topbar button { padding: 5px 12px; font-size: 12.5px; }
  .tabs { padding: 0 12px; gap: 16px; }
  .tabs button { padding: 12px 2px 10px; font-size: 14px; }
  .page { margin: 14px auto; padding: 0 10px 60px; }
  .card { padding: 18px 16px; }
  .ch-search { width: 100%; }
  .in-row { gap: 10px; }
  .in-act { width: 100%; }
  .in-act input { flex: 1; width: auto; }
  #nf-panel { right: 8px; left: 8px; width: auto; top: 56px; }
  .login-box { padding: 34px 24px 30px; width: 100%; max-width: 360px; margin: 0 14px; }
}

/* 組織圖（樹狀，方塊＋連接線） */
.tree-wrap { overflow-x: auto; padding: 20px 4px; }
.tree ul { display: flex; justify-content: center; padding-top: 26px; position: relative; list-style: none; margin: 0; }
.tree > ul { padding-top: 0; }
.tree li { display: flex; flex-direction: column; align-items: center; padding: 26px 9px 0; position: relative; }
.tree > ul > li { padding-top: 0; }
.tree li::before, .tree li::after { content: ''; position: absolute; top: 0; right: 50%; border-top: 1.5px solid #cdbfa5; width: 50%; height: 26px; }
.tree li::after { right: auto; left: 50%; border-left: 1.5px solid #cdbfa5; }
.tree li:only-child::before, .tree li:only-child::after { display: none; }
.tree li:only-child { padding-top: 26px; }
.tree > ul > li:only-child { padding-top: 0; }
.tree li:first-child::before, .tree li:last-child::after { border-top: none; }
.tree li:last-child::before { border-right: 1.5px solid #cdbfa5; border-radius: 0 10px 0 0; }
.tree li:first-child::after { border-radius: 10px 0 0 0; }
.tree ul ul::before { content: ''; position: absolute; top: 0; left: 50%; border-left: 1.5px solid #cdbfa5; width: 0; height: 26px; }
.node { background: #fffefb; border: 1.5px solid #d8cdb9; border-radius: 14px; padding: 13px 16px; min-width: 138px; text-align: center; position: relative; z-index: 1; box-shadow: 0 2px 8px rgba(90,75,50,.06); }
.node.mine { border-color: var(--wood); box-shadow: 0 0 0 3px rgba(179,155,120,.18); }
.node-title { font-weight: 700; font-size: 15px; letter-spacing: .15em; color: var(--brand); }
.node-name { font-size: 13px; color: #6d6455; margin-top: 3px; letter-spacing: .08em; }
.node-curves { font-size: 11.5px; color: #a3987f; margin-top: 5px; letter-spacing: .05em; }
.node-btns { display: flex; gap: 4px; justify-content: center; margin-top: 10px; flex-wrap: wrap; }
.node-btn { border: 1px solid #ddd2bd; background: #f7f3e9; border-radius: 999px; font-size: 12px; padding: 3px 10px; color: #6d6455; letter-spacing: .05em; }
.node-btn:hover { background: #ede5d2; }
.node-btn.danger { color: #9a4f3f; }

.curve-h { font-size: 14.5px; margin: 16px 0 9px; color: #6d6455; letter-spacing: .12em; }
.curve-h::before { content: '─ '; color: var(--wood); }

/* 通知鈴鐺 */
#nf-btn { position: relative; font-size: 15px; }
.nf-badge { position: absolute; top: -7px; right: -7px; background: #a4553f; color: #fff; border-radius: 999px; font-size: 11px; min-width: 18px; height: 18px; line-height: 18px; padding: 0 5px; text-align: center; font-weight: 700; }
#nf-panel { position: fixed; top: 62px; right: 18px; width: 360px; max-width: calc(100vw - 24px); max-height: 70vh; overflow-y: auto; background: var(--card); border: 1px solid var(--line); border-radius: 16px; box-shadow: 0 16px 44px rgba(46,40,32,.22); z-index: 60; }
.nf-head { padding: 13px 18px; font-weight: 700; letter-spacing: .25em; color: var(--brand); border-bottom: 1px solid var(--line); font-size: 14px; }
.nf-item { display: flex; gap: 10px; padding: 13px 16px; border-bottom: 1px solid #f0e9db; cursor: pointer; align-items: flex-start; }
.nf-item:last-child { border-bottom: none; }
.nf-item:hover { background: #faf6ee; }
.nf-ic { font-size: 16px; line-height: 1.4; }
.nf-tx { flex: 1; font-size: 13.5px; line-height: 1.65; color: var(--ink); }
.nf-x { border: none; background: none; color: #a09681; font-size: 14px; padding: 2px 4px; }
.nf-x:hover { color: #6d6455; }
.curve-row { margin-bottom: 6px; }
.curve-row input { flex: 1; }
