:root {
  --bg: #f6f5f8; --panel: #fff; --ink: #1f1d24; --muted: #6e6a78; --line: #e6e3ec; --soft: #f1eef6;
  --brand: #5b3f8f; --brand-ink: #fff; --brand-soft: #efe9f8;
  --ok: #1f7a4d; --ok-soft: #e4f4ec; --warn: #9a6200; --warn-soft: #fdf1dc; --bad: #b42335; --bad-soft: #fbe7ea;
  --info: #24589e; --info-soft: #e5eefa;
  --radius: 10px; --shadow: 0 1px 2px rgba(20, 10, 40, .06), 0 4px 16px rgba(20, 10, 40, .05);
  font-family: -apple-system, BlinkMacSystemFont, "PingFang TC", "Noto Sans TC", "Microsoft JhengHei", "Segoe UI", sans-serif;
  color: var(--ink); background: var(--bg); font-size: 14px; line-height: 1.5;
}
* { box-sizing: border-box; }
body { margin: 0; }
a { color: var(--brand); }
button, input, select, textarea { font: inherit; color: inherit; }
.boot { padding: 80px; text-align: center; color: var(--muted); }

/* layout */
.shell { display: grid; grid-template-columns: 220px 1fr; min-height: 100vh; }
.side { background: #231a33; color: #e9e4f2; padding: 18px 12px; position: sticky; top: 0; height: 100vh; overflow-y: auto; }
.logo { display: flex; align-items: center; gap: 10px; padding: 4px 8px 18px; font-weight: 700; letter-spacing: .02em; }
.logo b { background: var(--brand); width: 30px; height: 30px; border-radius: 8px; display: grid; place-items: center; color: #fff; }
.logo small { display: block; font-weight: 400; color: #a99fbd; font-size: 12px; }
.nav-group { margin: 14px 0 4px; padding: 0 10px; font-size: 12px; color: #9a90ae; letter-spacing: .05em; }
.nav a { display: flex; justify-content: space-between; align-items: center; padding: 7px 10px; border-radius: 8px; color: #e9e4f2; text-decoration: none; }
.nav a:hover { background: rgba(255, 255, 255, .07); }
.nav a.on { background: var(--brand); color: #fff; }
.nav .cnt { font-size: 11px; color: #b8aecb; }
.nav a.on .cnt { color: #e8dcff; }
.side-foot { margin-top: 24px; padding: 12px 10px; border-top: 1px solid rgba(255, 255, 255, .1); font-size: 12px; color: #a99fbd; }
.side-foot button { background: none; border: 1px solid rgba(255, 255, 255, .2); color: #e9e4f2; border-radius: 6px; padding: 3px 10px; cursor: pointer; margin-top: 6px; }
.main { padding: 22px 28px 60px; min-width: 0; }
.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 12px; margin-bottom: 16px; flex-wrap: wrap; }
.page-head h1 { font-size: 22px; margin: 0; }
.page-head p { margin: 4px 0 0; color: var(--muted); }
.menu-btn { display: none; }

/* controls */
.btn { border: 1px solid var(--line); background: var(--panel); padding: 7px 14px; border-radius: 8px; cursor: pointer; white-space: nowrap; }
.btn:hover { border-color: #cfc8dc; }
.btn.primary { background: var(--brand); color: var(--brand-ink); border-color: var(--brand); }
.btn.primary:hover { filter: brightness(1.08); }
.btn.danger { color: var(--bad); }
.btn.sm { padding: 4px 10px; font-size: 13px; }
.btn:disabled { opacity: .5; cursor: default; }
.toolbar { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; margin-bottom: 12px; }
.toolbar .grow { flex: 1; }
.inp, .sel { border: 1px solid var(--line); background: var(--panel); border-radius: 8px; padding: 7px 10px; min-width: 0; }
.inp:focus, .sel:focus, textarea:focus { outline: 2px solid var(--brand-soft); border-color: var(--brand); }
.search { width: 240px; }
.chk { display: inline-flex; gap: 6px; align-items: center; color: var(--muted); font-size: 13px; cursor: pointer; }

/* cards */
.card { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); }
.card-pad { padding: 16px 18px; }
.card h3 { margin: 0 0 12px; font-size: 15px; }
.grid { display: grid; gap: 14px; }
.kpis { grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); margin-bottom: 14px; }
.kpi { padding: 14px 16px; }
.kpi .l { color: var(--muted); font-size: 13px; }
.kpi .v { font-size: 21px; white-space: nowrap; font-weight: 700; margin-top: 2px; font-variant-numeric: tabular-nums; }
.kpi .s { color: var(--muted); font-size: 12px; }
.two { grid-template-columns: 1.4fr 1fr; }
@media (max-width: 1100px) { .two { grid-template-columns: 1fr; } }

/* table */
.tbl-wrap { overflow: auto; background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); max-height: calc(100vh - 210px); }
table.tbl { border-collapse: separate; border-spacing: 0; width: 100%; font-size: 13px; }
.tbl th { position: sticky; top: 0; background: #faf9fc; text-align: left; font-weight: 600; color: var(--muted); padding: 9px 10px; border-bottom: 1px solid var(--line); white-space: nowrap; cursor: pointer; user-select: none; z-index: 1; }
.tbl th.sorted { color: var(--brand); }
.tbl td { padding: 8px 10px; border-bottom: 1px solid #f0edf4; vertical-align: top; white-space: nowrap; }
.tbl td .clip { white-space: pre-line; min-width: 120px; max-width: 260px; }
.tbl tr:hover td { background: #fbfaff; }
.tbl tr.click { cursor: pointer; }
.tbl td.num, .tbl th.num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.tbl td .clip { display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.tbl tfoot td { position: sticky; bottom: 0; background: #faf9fc; font-weight: 600; border-top: 1px solid var(--line); }
.more { text-align: center; padding: 10px; }
.empty { padding: 40px; text-align: center; color: var(--muted); }

/* tags */
.tag { display: inline-block; padding: 1px 8px; border-radius: 999px; font-size: 12px; background: var(--soft); color: #4a4555; white-space: nowrap; }
.tag.ok { background: var(--ok-soft); color: var(--ok); }
.tag.warn { background: var(--warn-soft); color: var(--warn); }
.tag.bad { background: var(--bad-soft); color: var(--bad); }
.tag.info { background: var(--info-soft); color: var(--info); }
.tag.brand { background: var(--brand-soft); color: var(--brand); }
.muted { color: var(--muted); }
.lock { color: var(--muted); font-size: 12px; }

/* kanban */
.board { display: flex; gap: 10px; overflow-x: auto; padding-bottom: 10px; align-items: flex-start; }
.col { flex: 0 0 248px; background: #eeebf3; border-radius: var(--radius); padding: 8px; max-height: calc(100vh - 200px); display: flex; flex-direction: column; }
.col.drop { outline: 2px dashed var(--brand); }
.col-head { display: flex; justify-content: space-between; padding: 4px 6px 8px; font-weight: 600; }
.col-head .muted { font-weight: 400; font-size: 12px; }
.col-body { overflow-y: auto; display: flex; flex-direction: column; gap: 7px; min-height: 40px; }
.kcard { background: var(--panel); border: 1px solid var(--line); border-radius: 8px; padding: 9px 10px; cursor: pointer; font-size: 13px; }
.kcard:hover { border-color: #c9bfe0; }
.kcard .t { font-weight: 600; margin-bottom: 3px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.kcard .m { color: var(--muted); font-size: 12px; display: flex; gap: 6px; flex-wrap: wrap; }
.kcard .due { color: var(--bad); }
.kcard.dragging { opacity: .4; }

/* drawer */
.drawer { position: fixed; inset: 0; pointer-events: none; z-index: 50; }
.drawer.open { pointer-events: auto; }
.drawer-bg { position: absolute; inset: 0; background: rgba(20, 12, 35, .3); opacity: 0; transition: opacity .15s; }
.drawer.open .drawer-bg { opacity: 1; }
.drawer-panel { position: absolute; right: 0; top: 0; bottom: 0; width: min(720px, 100vw); background: var(--bg); transform: translateX(100%); transition: transform .18s ease; display: flex; flex-direction: column; }
.drawer.open .drawer-panel { box-shadow: -8px 0 30px rgba(0, 0, 0, .12); }
.drawer.open .drawer-panel { transform: none; }
.d-head { padding: 16px 20px; background: var(--panel); border-bottom: 1px solid var(--line); display: flex; justify-content: space-between; align-items: center; gap: 10px; }
.d-head h2 { margin: 0; font-size: 17px; }
.d-body { padding: 16px 20px; overflow-y: auto; flex: 1; }
.d-foot { padding: 12px 20px; background: var(--panel); border-top: 1px solid var(--line); display: flex; gap: 8px; justify-content: space-between; }
.sec { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px 16px; margin-bottom: 12px; }
.sec h4 { margin: 0 0 10px; font-size: 13px; color: var(--muted); letter-spacing: .03em; }
.form { display: grid; grid-template-columns: 1fr 1fr; gap: 10px 14px; }
.f { display: flex; flex-direction: column; gap: 4px; min-width: 0; }
.f.wide { grid-column: 1 / -1; }
.f label { font-size: 12px; color: var(--muted); }
.f label .req { color: var(--bad); }
.f .hint { font-size: 11px; color: var(--muted); }
.f textarea { border: 1px solid var(--line); border-radius: 8px; padding: 7px 10px; min-height: 64px; resize: vertical; background: #fff; }
.f .row { display: flex; gap: 6px; align-items: center; }
.f .row .inp { flex: 1; }
.rates { width: 100%; border-collapse: collapse; }
.rates td { padding: 3px 4px 3px 0; }
.rates .inp { width: 100%; }
.rel { margin-top: 4px; }
.rel table { width: 100%; font-size: 13px; border-collapse: collapse; }
.rel td { padding: 6px 4px; border-top: 1px solid #f0edf4; }
.log { font-size: 12px; color: var(--muted); }
.log div { padding: 4px 0; border-top: 1px dashed var(--line); }

/* charts */
.bars { display: flex; align-items: flex-end; gap: 6px; height: 190px; padding-top: 10px; }
.bar { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: flex-end; height: 100%; min-width: 0; }
.bar .stack { width: 70%; max-width: 38px; display: flex; flex-direction: column-reverse; border-radius: 4px 4px 0 0; overflow: hidden; }
.bar .seg { width: 100%; }
.bar .x { font-size: 11px; color: var(--muted); margin-top: 4px; }
.bar .vv { font-size: 10px; color: var(--muted); margin-bottom: 2px; white-space: nowrap; }
.legend { display: flex; gap: 14px; font-size: 12px; color: var(--muted); }
.legend i { display: inline-block; width: 10px; height: 10px; border-radius: 2px; margin-right: 5px; vertical-align: -1px; }
.prog { height: 10px; background: var(--soft); border-radius: 999px; overflow: hidden; }
.prog > div { height: 100%; background: var(--brand); }
.prog.over > div { background: var(--bad); }
.blist { display: flex; flex-direction: column; gap: 14px; }
.blist .top { display: flex; justify-content: space-between; margin-bottom: 4px; font-size: 13px; }
.mini td { padding: 6px 4px; border-bottom: 1px solid #f0edf4; font-size: 13px; }
.mini { width: 100%; border-collapse: collapse; }

/* login */
.login { min-height: 100vh; display: grid; place-items: center; padding: 20px; }
.login .card { width: 380px; max-width: 100%; padding: 32px; text-align: center; }
.login h1 { font-size: 20px; margin: 10px 0 4px; }
.login p { color: var(--muted); margin: 0 0 22px; }
.login .err { color: var(--bad); margin-top: 14px; font-size: 13px; }
.gbtn { display: flex; justify-content: center; min-height: 44px; }

.toast { position: fixed; bottom: 22px; left: 50%; transform: translateX(-50%) translateY(20px); background: #231a33; color: #fff; padding: 9px 18px; border-radius: 8px; opacity: 0; transition: .2s; pointer-events: none; z-index: 80; }
.toast.show { opacity: 1; transform: translateX(-50%); }
.toast.err { background: var(--bad); }

@media (max-width: 860px) {
  .shell { grid-template-columns: 1fr; }
  .side { position: fixed; z-index: 40; width: 240px; transform: translateX(-100%); transition: transform .18s; }
  .side.open { transform: none; }
  .main { padding: 16px; }
  .menu-btn { display: inline-block; }
  .form { grid-template-columns: 1fr; }
  .search { width: 100%; }
}
