:root {
    --ink: #18221d;
    --muted: #68736d;
    --paper: #f4f1e9;
    --surface: #fffefa;
    --line: #deddd5;
    --forest: #174f3a;
    --forest-soft: #e1eee7;
    --terracotta: #b34e35;
    --amber: #b87a1c;
    --amber-soft: #fff0cd;
    --danger-soft: #f8dfd8;
    --success: #2d6a4f;
    --shadow: 0 24px 70px rgba(25, 43, 34, .12);
    font-family: Inter, "Noto Sans TC", "PingFang TC", "Microsoft JhengHei", sans-serif;
    color: var(--ink);
    background: var(--paper);
  }

  * { box-sizing: border-box; }
  body { margin: 0; min-height: 100vh; background: var(--paper); color: var(--ink); }
  button, input, select { font: inherit; }
  button, select { cursor: pointer; }
  [hidden] { display: none !important; }

  .eyebrow {
    margin: 0 0 7px;
    color: var(--forest);
    font-size: 11px;
    font-weight: 800;
    letter-spacing: .14em;
  }

  .login-shell {
    min-height: 100vh;
    display: grid;
    place-items: center;
    padding: 28px;
    background:
      radial-gradient(circle at 18% 24%, rgba(23,79,58,.12), transparent 28%),
      radial-gradient(circle at 80% 78%, rgba(179,78,53,.1), transparent 25%),
      linear-gradient(135deg, #ebe9df 0%, #f8f5ed 48%, #e7ede8 100%);
  }

  .login-card {
    width: min(100%, 440px);
    padding: 44px;
    border: 1px solid rgba(23,79,58,.15);
    border-radius: 28px;
    background: rgba(255,254,250,.94);
    box-shadow: var(--shadow);
  }

  .brand-mark, .mini-mark {
    display: grid;
    place-items: center;
    color: white;
    background: var(--forest);
    border-radius: 16px;
    font-family: Georgia, serif;
    font-weight: 700;
  }
  .brand-mark { width: 58px; height: 58px; margin-bottom: 28px; font-size: 27px; }
  .mini-mark { width: 40px; height: 40px; border-radius: 12px; font-size: 18px; flex: 0 0 auto; }
  .login-card h1 { margin: 0; font-family: Georgia, "Noto Serif TC", serif; font-size: 40px; letter-spacing: -.03em; }
  .login-copy { margin: 13px 0 30px; color: var(--muted); line-height: 1.7; }
  .login-form label { display: block; margin-bottom: 9px; font-size: 14px; font-weight: 700; }
  .password-wrap { position: relative; }
  .password-wrap input {
    width: 100%; height: 54px; padding: 0 68px 0 16px;
    border: 1px solid var(--line); border-radius: 13px; outline: none; background: #fff;
  }
  .password-wrap input:focus { border-color: var(--forest); box-shadow: 0 0 0 4px rgba(23,79,58,.1); }
  .text-button { position: absolute; inset: 7px 7px 7px auto; border: 0; background: transparent; color: var(--forest); font-size: 13px; font-weight: 700; }
  .primary-button {
    width: 100%; height: 54px; display: flex; align-items: center; justify-content: space-between;
    padding: 0 20px; border: 0; border-radius: 13px; background: var(--forest); color: white; font-weight: 800;
    transition: transform .15s ease, background .15s ease;
  }
  .primary-button:hover { transform: translateY(-1px); background: #103f2e; }
  .primary-button:disabled { cursor: wait; opacity: .65; transform: none; }
  .form-error { min-height: 23px; margin: 8px 0; color: var(--terracotta); font-size: 13px; }
  .security-note { margin: 22px 0 0; color: var(--muted); font-size: 12px; text-align: center; }
  .security-note span { color: var(--success); font-size: 9px; }

  .app-shell { min-height: 100vh; }
  .topbar {
    position: sticky; top: 0; z-index: 20; height: 72px; display: flex; align-items: center; justify-content: space-between;
    padding: 0 28px; border-bottom: 1px solid var(--line); background: rgba(255,254,250,.92); backdrop-filter: blur(14px);
  }
  .topbar-brand, .topbar-actions { display: flex; align-items: center; gap: 12px; }
  .topbar-brand .eyebrow { margin-bottom: 2px; font-size: 8px; }
  .topbar-brand strong { font-family: Georgia, "Noto Serif TC", serif; font-size: 19px; }
  .last-updated { color: var(--muted); font-size: 12px; }
  .icon-button, .quiet-button {
    border: 1px solid var(--line); background: var(--surface); color: var(--ink); border-radius: 10px; height: 38px;
  }
  .icon-button { width: 38px; font-size: 20px; }
  .quiet-button { padding: 0 15px; font-size: 13px; font-weight: 700; }

  .page-grid { display: grid; grid-template-columns: 220px minmax(0, 1fr); min-height: calc(100vh - 72px); }
  .sidebar { padding: 28px 18px; border-right: 1px solid var(--line); background: #efede5; }
  .sidebar nav { display: grid; gap: 7px; }
  .nav-item {
    width: 100%; display: flex; justify-content: space-between; align-items: center; padding: 12px 14px;
    border: 0; border-radius: 10px; color: var(--muted); background: transparent; text-align: left;
  }
  .nav-item b { min-width: 25px; padding: 3px 7px; border-radius: 20px; background: rgba(24,34,29,.07); font-size: 11px; text-align: center; }
  .nav-item.active { color: white; background: var(--forest); font-weight: 800; }
  .nav-item.active b { background: rgba(255,255,255,.16); }
  .sync-card { margin-top: 28px; padding: 16px; display: flex; gap: 10px; border-top: 1px solid var(--line); color: var(--muted); }
  .sync-card strong, .sync-card small { display: block; font-size: 11px; }
  .sync-card small { margin-top: 4px; }
  .pulse-dot { width: 8px; height: 8px; margin-top: 3px; border-radius: 50%; background: var(--success); box-shadow: 0 0 0 5px rgba(45,106,79,.12); }

  .content { width: 100%; max-width: 1420px; margin: 0 auto; padding: 42px clamp(22px, 4vw, 58px) 64px; }
  .hero { display: flex; justify-content: space-between; gap: 28px; align-items: end; margin-bottom: 30px; }
  .hero h1 { margin: 0; font-family: Georgia, "Noto Serif TC", serif; font-size: clamp(34px, 4vw, 52px); letter-spacing: -.04em; }
  .hero p:not(.eyebrow) { margin: 12px 0 0; color: var(--muted); line-height: 1.7; }
  .hero-date { flex: 0 0 auto; color: var(--muted); font-size: 13px; }

  .metrics { display: grid; grid-template-columns: repeat(4, 1fr); gap: 14px; margin-bottom: 22px; }
  .metric-card { padding: 20px; border: 1px solid var(--line); border-radius: 16px; background: var(--surface); box-shadow: 0 8px 25px rgba(25,43,34,.04); }
  .metric-card span, .metric-card small { display: block; color: var(--muted); font-size: 12px; }
  .metric-card strong { display: block; margin: 7px 0 5px; font-family: Georgia, serif; font-size: 35px; }
  .metric-card.danger strong { color: var(--terracotta); }
  .metric-card.warning strong { color: var(--amber); }
  .metric-card.success strong { color: var(--success); }

  .workspace-card, .forecast-card { border: 1px solid var(--line); border-radius: 20px; background: var(--surface); box-shadow: 0 10px 34px rgba(25,43,34,.05); }
  .workspace-card { overflow: hidden; }
  .section-heading { display: flex; align-items: center; justify-content: space-between; gap: 16px; padding: 24px 26px 18px; }
  .section-heading h2 { margin: 0; font-family: Georgia, "Noto Serif TC", serif; font-size: 24px; }
  .count-pill, .forecast-badge { padding: 7px 11px; border-radius: 20px; background: var(--forest-soft); color: var(--forest); font-size: 11px; font-weight: 800; }
  .toolbar { display: grid; grid-template-columns: 1fr 160px 170px; gap: 10px; padding: 0 26px 20px; border-bottom: 1px solid var(--line); }
  .search-box { display: flex; align-items: center; gap: 10px; height: 43px; padding: 0 13px; border: 1px solid var(--line); border-radius: 10px; background: #fff; }
  .search-box input { width: 100%; border: 0; outline: none; background: transparent; }
  .toolbar select, .status-editor select { border: 1px solid var(--line); border-radius: 10px; padding: 0 12px; background: #fff; color: var(--ink); }

  .announcement-list { min-height: 140px; }
  .announcement-row {
    display: grid; grid-template-columns: 110px minmax(0, 1fr) 135px 115px; gap: 18px; align-items: center;
    width: 100%; padding: 19px 26px; border: 0; border-bottom: 1px solid var(--line); background: transparent; color: inherit; text-align: left;
    transition: background .15s ease;
  }
  .announcement-row:last-child { border-bottom: 0; }
  .announcement-row:hover { background: #f7f6f0; }
  .row-id { color: var(--muted); font-size: 11px; font-weight: 800; }
  .row-main { min-width: 0; }
  .row-main h3 { margin: 0 0 8px; font-size: 15px; line-height: 1.45; }
  .row-main p { margin: 0; overflow: hidden; color: var(--muted); font-size: 12px; line-height: 1.5; text-overflow: ellipsis; white-space: nowrap; }
  .row-tags { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px; }
  .tag { padding: 4px 7px; border-radius: 6px; background: #eeece4; color: var(--muted); font-size: 10px; font-weight: 700; }
  .row-deadline { color: var(--muted); font-size: 11px; line-height: 1.45; }
  .row-deadline strong { display: block; color: var(--ink); font-size: 12px; }
  .status-chip { justify-self: end; padding: 7px 9px; border-radius: 8px; background: #eeece4; color: var(--muted); font-size: 10px; font-weight: 800; }
  .status-chip.overdue { background: var(--danger-soft); color: var(--terracotta); }
  .status-chip.soon { background: var(--amber-soft); color: #8a5910; }
  .status-chip.done { background: var(--forest-soft); color: var(--success); }

  .empty-state { min-height: 210px; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 8px; color: var(--muted); }
  .empty-state strong { color: var(--ink); }
  .empty-icon { width: 44px; height: 44px; display: grid; place-items: center; border-radius: 50%; background: var(--forest-soft); color: var(--success); }
  .spinner { width: 28px; height: 28px; border: 3px solid var(--line); border-top-color: var(--forest); border-radius: 50%; animation: spin .75s linear infinite; }
  @keyframes spin { to { transform: rotate(360deg); } }

  .forecast-card { margin-top: 22px; padding-bottom: 24px; }
  .forecast-intro { margin: -4px 26px 20px; color: var(--muted); font-size: 12px; line-height: 1.6; }
  .signal-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px; padding: 0 26px; }
  .signal-card { padding: 15px; border-left: 3px solid var(--amber); background: #faf5e9; border-radius: 5px 12px 12px 5px; }
  .signal-card span { display: block; margin-bottom: 6px; color: var(--amber); font-size: 10px; font-weight: 800; }
  .signal-card strong { font-size: 13px; line-height: 1.5; }
  .signal-empty { grid-column: 1 / -1; color: var(--muted); font-size: 13px; }

  .drawer-backdrop { position: fixed; inset: 0; z-index: 40; background: rgba(18,28,23,.34); backdrop-filter: blur(2px); }
  .detail-drawer {
    position: fixed; inset: 0 0 0 auto; z-index: 50; width: min(620px, 100%); display: flex; flex-direction: column;
    background: var(--surface); box-shadow: -22px 0 65px rgba(18,28,23,.18); transform: translateX(102%); transition: transform .23s ease;
  }
  .detail-drawer.open { transform: translateX(0); }
  .drawer-header { display: flex; justify-content: space-between; gap: 20px; align-items: flex-start; padding: 26px; border-bottom: 1px solid var(--line); }
  .drawer-header h2 { margin: 0; font-family: Georgia, "Noto Serif TC", serif; font-size: 23px; line-height: 1.35; }
  .drawer-body { overflow-y: auto; padding: 25px 26px 42px; }
  .detail-meta { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; margin: 0 0 20px; }
  .detail-meta div { padding: 12px; border-radius: 10px; background: #f2f0e9; }
  .detail-meta dt { color: var(--muted); font-size: 10px; }
  .detail-meta dd { margin: 5px 0 0; font-size: 12px; line-height: 1.45; }
  .status-editor { display: grid; grid-template-columns: 90px 160px 1fr; align-items: center; gap: 10px; padding: 15px; border: 1px solid var(--line); border-radius: 12px; }
  .status-editor label { font-size: 12px; font-weight: 800; }
  .status-editor select { height: 38px; }
  .status-editor small { color: var(--muted); font-size: 10px; }
  .detail-section { margin-top: 25px; }
  .detail-section h3 { margin: 0 0 12px; font-size: 13px; }
  .detail-content { color: #334039; font-size: 14px; line-height: 1.85; white-space: pre-wrap; word-break: break-word; }
  .attachment-list { display: grid; gap: 8px; }
  .attachment-link { display: block; padding: 12px; border: 1px solid var(--line); border-radius: 9px; color: var(--forest); text-decoration: none; font-size: 12px; font-weight: 800; }
  .source-button { display: inline-flex; margin-top: 28px; padding: 12px 16px; border-radius: 10px; background: var(--forest); color: white; text-decoration: none; font-size: 12px; font-weight: 800; }

  .toast { position: fixed; left: 50%; bottom: 24px; z-index: 100; max-width: calc(100% - 32px); padding: 12px 16px; border-radius: 10px; background: #17221d; color: white; box-shadow: var(--shadow); font-size: 13px; opacity: 0; pointer-events: none; transform: translate(-50%, 12px); transition: .2s ease; }
  .toast.show { opacity: 1; transform: translate(-50%, 0); }
  .toast.error { background: #8d3523; }

  @media (max-width: 1000px) {
    .page-grid { grid-template-columns: 1fr; }
    .sidebar { position: sticky; top: 72px; z-index: 15; padding: 9px 16px; border-right: 0; border-bottom: 1px solid var(--line); overflow-x: auto; }
    .sidebar nav { display: flex; min-width: max-content; }
    .nav-item { width: auto; gap: 9px; padding: 9px 12px; }
    .sync-card { display: none; }
    .metrics { grid-template-columns: repeat(2, 1fr); }
  }

  @media (max-width: 720px) {
    .login-card { padding: 32px 24px; }
    .topbar { padding: 0 16px; }
    .last-updated { display: none; }
    .content { padding: 30px 15px 46px; }
    .hero { align-items: flex-start; }
    .hero-date { display: none; }
    .hero h1 { font-size: 36px; }
    .metrics { gap: 9px; }
    .metric-card { padding: 15px; }
    .metric-card strong { font-size: 28px; }
    .toolbar { grid-template-columns: 1fr 1fr; padding: 0 16px 16px; }
    .search-box { grid-column: 1 / -1; }
    .section-heading { padding: 20px 16px 16px; }
    .announcement-row { grid-template-columns: 1fr auto; gap: 10px; padding: 16px; }
    .row-id { grid-column: 1; }
    .row-main { grid-column: 1 / -1; grid-row: 2; }
    .row-deadline { grid-column: 1; grid-row: 3; }
    .status-chip { grid-column: 2; grid-row: 1; }
    .signal-grid { grid-template-columns: 1fr; padding: 0 16px; }
    .forecast-intro { margin-inline: 16px; }
    .detail-meta { grid-template-columns: 1fr; }
    .status-editor { grid-template-columns: 1fr; }
  }
