:root {
  --ink: #17243f;
  --muted: #69738a;
  --line: #e4e9f1;
  --surface: #ffffff;
  --canvas: #f4f7fb;
  --navy: #10284d;
  --blue: #2f6feb;
  --green: #198754;
  --amber: #d58a00;
  --violet: #7557d3;
  font-family: Inter, "Noto Sans TC", "Microsoft JhengHei", system-ui, sans-serif;
  color: var(--ink);
  background: var(--canvas);
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
body { margin: 0; min-width: 320px; min-height: 100vh; }
button, input, select { font: inherit; }
button { cursor: pointer; }
.panel + .panel { margin-top: 24px; }
.file-name-cell { min-width: 220px; max-width: 360px; overflow-wrap: anywhere; }
.table-action { white-space: nowrap; }

.app-shell { min-height: 100vh; display: grid; grid-template-columns: 252px 1fr; }
.sidebar {
  position: sticky; top: 0; height: 100vh; padding: 30px 20px 22px;
  display: flex; flex-direction: column; color: #fff;
  background:
    radial-gradient(circle at 8% 90%, rgba(54, 111, 207, .32), transparent 34%),
    linear-gradient(160deg, #132d56, #09182f 72%);
}
.brand { display: flex; gap: 13px; align-items: center; color: #fff; text-decoration: none; padding: 0 9px; }
.brand-mark {
  display: inline-grid; place-items: center; flex: 0 0 auto; width: 42px; height: 42px;
  border-radius: 12px; background: linear-gradient(135deg, #407de9, #2cb9b2);
  box-shadow: 0 7px 22px rgba(51, 122, 230, .32); font-weight: 800;
}
.brand strong, .brand small, .user-chip strong, .user-chip small { display: block; }
.brand strong { letter-spacing: .06em; }
.brand small { margin-top: 3px; color: #aebbd1; font-size: 12px; }
nav { margin-top: 48px; display: grid; gap: 9px; }
.nav-item {
  width: 100%; padding: 13px 15px; border: 0; border-radius: 11px; color: #aebbd1;
  text-align: left; background: transparent; transition: .2s ease;
}
.nav-item span, .nav-item small { display: block; }
.nav-item span { color: inherit; font-weight: 700; }
.nav-item small { margin-top: 3px; font-size: 11px; opacity: .72; }
.nav-item:hover, .nav-item.active { color: #fff; background: rgba(255,255,255,.1); }
.sidebar-foot {
  margin-top: auto; display: grid; grid-template-columns: 10px 1fr; gap: 0 9px;
  align-items: center; padding: 16px 10px 0; border-top: 1px solid rgba(255,255,255,.12);
  color: #d6deec; font-size: 13px;
}
.sidebar-foot small { grid-column: 2; margin-top: 4px; color: #7e8ca6; }
.status-dot { width: 8px; height: 8px; border-radius: 50%; background: #44d89e; box-shadow: 0 0 0 4px rgba(68,216,158,.12); }

main { min-width: 0; }
.topbar {
  min-height: 92px; padding: 20px 42px; display: flex; justify-content: space-between; align-items: center;
  background: rgba(255,255,255,.9); border-bottom: 1px solid var(--line); backdrop-filter: blur(12px);
}
h1, h2, h3, p { margin-top: 0; }
h1 { margin-bottom: 0; font-size: 22px; }
.eyebrow { margin-bottom: 6px; color: #71809b; font-size: 11px; font-weight: 800; letter-spacing: .15em; text-transform: uppercase; }
.topbar-actions { display: flex; align-items: center; gap: 14px; }
.icon-button, .text-button {
  border: 1px solid var(--line); border-radius: 10px; background: #fff; color: var(--ink);
}
.icon-button { width: 38px; height: 38px; font-size: 20px; }
.text-button { padding: 8px 12px; }
.user-chip { display: flex; align-items: center; gap: 10px; min-width: 150px; }
.user-chip strong { font-size: 13px; }
.user-chip small { margin-top: 3px; color: var(--muted); font-size: 11px; }
.avatar { display: grid; place-items: center; width: 36px; height: 36px; border-radius: 50%; color: #fff; background: var(--navy); font-weight: 800; }

.content { padding: 34px 42px 48px; }
.hero {
  min-height: 170px; padding: 34px 36px; display: flex; align-items: center; justify-content: space-between; gap: 32px;
  border-radius: 20px; overflow: hidden; color: #fff;
  background:
    radial-gradient(circle at 84% 22%, rgba(98,190,210,.5), transparent 23%),
    linear-gradient(118deg, #163764, #1d5180 60%, #287d8d);
  box-shadow: 0 18px 38px rgba(24, 65, 111, .16);
}
.hero .eyebrow { color: #a9d4e5; }
.hero h2 { margin-bottom: 9px; max-width: 640px; font-size: clamp(24px, 3vw, 35px); line-height: 1.2; }
.hero p:last-child { margin-bottom: 0; max-width: 680px; color: #ccdeeb; }
.primary-button, .secondary-button {
  border: 0; border-radius: 10px; padding: 12px 18px; font-weight: 800; transition: .18s ease;
}
.primary-button { color: #fff; background: var(--blue); box-shadow: 0 8px 18px rgba(47,111,235,.25); }
.hero .primary-button { color: var(--navy); background: #fff; box-shadow: 0 8px 25px rgba(0,0,0,.12); }
.primary-button:hover { transform: translateY(-1px); filter: brightness(1.04); }
.secondary-button { color: var(--ink); background: #eef2f7; }
.wide { width: 100%; margin-top: 7px; }

.metric-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 17px; margin: 22px 0; }
.metric-card {
  padding: 22px; display: flex; gap: 15px; align-items: center; background: var(--surface);
  border: 1px solid var(--line); border-radius: 15px; box-shadow: 0 7px 20px rgba(35,56,92,.04);
}
.metric-icon { display: grid; place-items: center; width: 43px; height: 43px; border-radius: 12px; font-weight: 900; }
.metric-icon.blue { color: var(--blue); background: #eaf1ff; }
.metric-icon.amber { color: var(--amber); background: #fff4d9; }
.metric-icon.green { color: var(--green); background: #e4f6ed; }
.metric-icon.violet { color: var(--violet); background: #f0ebff; }
.metric-card small, .metric-card strong { display: block; }
.metric-card small { color: var(--muted); font-size: 12px; }
.metric-card strong { margin-top: 2px; font-size: 26px; }

.panel { background: var(--surface); border: 1px solid var(--line); border-radius: 16px; overflow: hidden; }
.panel-head { padding: 22px 24px; display: flex; align-items: center; justify-content: space-between; gap: 20px; }
.panel-head h3 { margin-bottom: 0; font-size: 19px; }
.filters { display: flex; gap: 10px; }
.search-field { min-width: 250px; display: flex; align-items: center; gap: 8px; padding: 0 12px; border: 1px solid var(--line); border-radius: 9px; }
.search-field input { width: 100%; border: 0; outline: 0; padding: 9px 0; }
select, .form-grid input, .auth-modal input {
  min-height: 40px; border: 1px solid #d8deea; border-radius: 9px; padding: 8px 11px; background: #fff; outline: 0;
}
select:focus, input:focus { border-color: #6d9df4; box-shadow: 0 0 0 3px rgba(47,111,235,.1); }
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
th, td { padding: 14px 24px; border-top: 1px solid var(--line); text-align: left; white-space: nowrap; font-size: 13px; }
th { color: #7c879c; background: #fafbfd; font-size: 11px; letter-spacing: .04em; }
td.case-title { max-width: 400px; overflow: hidden; text-overflow: ellipsis; font-weight: 700; }
tbody tr[data-id] { cursor: pointer; }
tbody tr[data-id]:hover { background: #f5f8ff; }
.status-pill { display: inline-flex; padding: 5px 9px; border-radius: 20px; font-size: 11px; font-weight: 800; background: #edf2f8; }
.status-pill.draft { color: #5c6678; }
.status-pill.announced, .status-pill.opening { color: #1761bd; background: #e8f2ff; }
.status-pill.awarded, .status-pill.contracting, .status-pill.performing { color: #956000; background: #fff1cd; }
.status-pill.acceptance, .status-pill.closed { color: #19734c; background: #e2f5ea; }
.status-pill.cancelled { color: #a93242; background: #fde8eb; }
.empty-state { padding: 45px; color: var(--muted); text-align: center; }

.modal { width: min(680px, calc(100vw - 28px)); padding: 0; border: 0; border-radius: 18px; box-shadow: 0 30px 90px rgba(8,25,48,.28); }
.modal::backdrop { background: rgba(7,19,39,.57); backdrop-filter: blur(4px); }
.modal form { padding: 30px; }
.modal-head { display: flex; justify-content: space-between; align-items: flex-start; margin-bottom: 20px; }
.modal h2 { margin-bottom: 5px; }
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.form-grid label, .auth-modal label { display: grid; gap: 7px; color: #45516a; font-size: 12px; font-weight: 800; }
.span-2 { grid-column: span 2; }
.modal-actions { display: flex; justify-content: flex-end; gap: 10px; margin-top: 24px; }
.detail-modal { width: min(920px, calc(100vw - 28px)); }
.detail-modal form { max-height: min(88vh, 900px); overflow-y: auto; }
.detail-section { margin-top: 28px; padding-top: 24px; border-top: 1px solid var(--line); }
.detail-section-head { display: flex; align-items: center; justify-content: space-between; gap: 14px; }
.detail-section-head h3 { margin: 2px 0 0; }
.compact-actions { display: flex; gap: 8px; }
.attachment-list { margin-top: 14px; border: 1px solid var(--line); border-radius: 10px; overflow: hidden; }
.attachment-item { display: flex; align-items: center; justify-content: space-between; gap: 16px; padding: 12px 14px; }
.attachment-item + .attachment-item { border-top: 1px solid var(--line); }
.attachment-item strong, .attachment-item small { display: block; overflow-wrap: anywhere; }
.attachment-item small { margin-top: 3px; color: var(--muted); }
.upload-row { display: grid; grid-template-columns: 1.4fr 1fr auto; gap: 10px; margin-top: 12px; align-items: center; }
.upload-row input { min-width: 0; min-height: 40px; border: 1px solid #d8deea; border-radius: 9px; padding: 8px 11px; }
.auth-modal { width: min(420px, calc(100vw - 28px)); text-align: center; }
.auth-modal form { padding: 40px; }
.auth-modal .modal-brand { display: flex; justify-content: center; margin-bottom: 20px; }
.auth-modal .brand-mark { width: 52px; height: 52px; color: #fff; font-size: 20px; }
.auth-modal label { margin-top: 14px; text-align: left; }
.muted { color: var(--muted); }
.login-hint {
  margin: 14px 0 0;
  padding: 10px 12px;
  border-left: 3px solid var(--blue);
  color: #536078;
  background: #f1f6ff;
  font-size: 12px;
  line-height: 1.55;
  text-align: left;
}
.auth-modal .text-button.wide {
  margin-top: 10px;
  box-shadow: none;
}
.form-error { min-height: 20px; margin: 10px 0 0; color: #b12d3e; font-size: 12px; }
.toast {
  position: fixed; right: 24px; bottom: 24px; z-index: 10; padding: 12px 18px; border-radius: 10px;
  color: #fff; background: #17243f; box-shadow: 0 12px 30px rgba(0,0,0,.2);
  opacity: 0; transform: translateY(12px); pointer-events: none; transition: .2s ease;
}
.toast.show { opacity: 1; transform: translateY(0); }

@media (max-width: 980px) {
  .app-shell { grid-template-columns: 82px 1fr; }
  .sidebar { padding-inline: 14px; }
  .brand > span:last-child, .nav-item small, .nav-item span, .sidebar-foot span:not(.status-dot), .sidebar-foot small { display: none; }
  .brand { justify-content: center; padding: 0; }
  .nav-item { height: 46px; padding: 0; }
  .nav-item::after { content: "•"; display: grid; place-items: center; height: 100%; font-size: 24px; }
  .sidebar-foot { display: flex; justify-content: center; }
  .metric-grid { grid-template-columns: 1fr 1fr; }
}

@media (max-width: 680px) {
  .app-shell { display: block; }
  .sidebar { display: none; }
  .topbar, .content { padding-left: 18px; padding-right: 18px; }
  .topbar h1 { font-size: 17px; }
  .topbar .eyebrow, .user-chip span:last-child { display: none; }
  .hero { align-items: flex-start; flex-direction: column; }
  .metric-grid { grid-template-columns: 1fr 1fr; }
  .panel-head, .filters { align-items: stretch; flex-direction: column; }
  .search-field { min-width: 0; }
  .form-grid { grid-template-columns: 1fr; }
  .span-2 { grid-column: auto; }
  .detail-section-head, .attachment-item { align-items: stretch; flex-direction: column; }
  .compact-actions { flex-wrap: wrap; }
  .upload-row { grid-template-columns: 1fr; }
}
