/* ============================================================
   BI Team Planner — ใช้ MKS Design System ชุดเดียวกับ QC Dashboard
   สี/ฟอนต์ vendored มาจาก mksqc_dashboard/frontend/css/tokens/
   ============================================================ */
@import url('https://fonts.googleapis.com/css2?family=Open+Sans:wght@400;600;700&family=Carlito:wght@400;700&family=Sarabun:wght@400;600&display=swap');

:root {
  /* ---- MKS primary palette ---- */
  --mks-almost-black: #30302F;
  --mks-blue-grey:    #8A8F9D;
  --mks-ash-grey:     #78746D;
  --mks-orange:       #DF6F27;
  --mks-light-orange: #F0BA7D;
  --mks-fade-blue:    #D3D6E2;
  --mks-light-blue:   #A2BBD4;

  /* ---- neutrals ---- */
  --mks-white:    #FFFFFF;
  --mks-paper:    #F7F6F4;
  --mks-mist:     #EFEEEC;
  --mks-line:     #E2E1DE;
  --mks-grey-300: #CCCCCC;
  --mks-grey-500: #8A8F9D;
  --mks-grey-600: #78746D;
  --mks-ink-700:  #555452;
  --mks-ink-900:  #30302F;

  --mks-orange-hover: #C75F1E;
  --mks-orange-press: #B0531A;
  --mks-orange-soft:  #FBEADC;

  /* ---- semantic ---- */
  --text-strong: var(--mks-ink-900);
  --text-body:   var(--mks-ink-700);
  --text-muted:  var(--mks-grey-600);
  --text-light:  var(--mks-grey-500);
  --surface-page:  var(--mks-paper);
  --surface-card:  var(--mks-white);
  --surface-panel: var(--mks-mist);
  --surface-dark:  var(--mks-almost-black);
  --border-subtle: var(--mks-line);
  --border-strong: var(--mks-grey-300);
  --brand:       var(--mks-orange);
  --brand-soft:  var(--mks-orange-soft);
  --action:      var(--mks-orange);
  --action-hover: var(--mks-orange-hover);

  /* ---- status colours (kept semantic, warm-adjusted) ---- */
  --ok:      #2E7D5B;
  --ok-bg:   #E4F2EB;
  --warn:    #B7791F;
  --warn-bg: #FBF0DA;
  --bad:     #C0392B;
  --bad-bg:  #FBE7E4;
  --info:    #4A6FA5;
  --info-bg: #E7EDF6;

  /* ---- type ---- */
  --font-display: "Segoe UI", "Open Sans", system-ui, -apple-system, sans-serif;
  --font-body: "Calibri", "Carlito", "Segoe UI", "Sarabun", system-ui, sans-serif;
  --fs-micro: 11px;
  --fs-caption: 12px;
  --fs-body: 13px;
  --fs-lead: 15px;

  /* ---- shape / motion ---- */
  --radius-sm: 6px;
  --radius-md: 10px;
  --radius-lg: 16px;
  --radius-pill: 999px;
  --shadow-xs: 0 1px 2px rgba(48, 48, 47, .06);
  --shadow-sm: 0 1px 3px rgba(48, 48, 47, .08), 0 1px 2px rgba(48, 48, 47, .04);
  --shadow-md: 0 4px 12px rgba(48, 48, 47, .08), 0 2px 4px rgba(48, 48, 47, .05);
  --shadow-lg: 0 12px 28px rgba(48, 48, 47, .12);
  --ring: 0 0 0 3px rgba(223, 111, 39, .32);
  --t-fast: 120ms cubic-bezier(.4, 0, .2, 1);
}

* { box-sizing: border-box; margin: 0; padding: 0; }
html, body { height: 100%; }
body {
  font-family: var(--font-body);
  font-size: var(--fs-body);
  background: var(--surface-page);
  color: var(--text-body);
  -webkit-font-smoothing: antialiased;
}
html[lang="th"] body { font-family: "Sarabun", var(--font-body); }
button { font-family: inherit; cursor: pointer; border: none; background: none; color: inherit; }
input, textarea, select { font-family: inherit; }
.hidden { display: none !important; }
h1, h2, h3, .panel-title, .app-title, .modal-title, .login-title, .stat .val, .sum-value-big {
  font-family: var(--font-display); font-weight: 600; color: var(--text-strong);
}

/* ============ LOGIN ============ */
.login-screen {
  min-height: 100vh; background: var(--mks-almost-black);
  display: flex; align-items: center; justify-content: center; padding: 40px 20px;
  background-image: radial-gradient(circle at 20% 15%, rgba(223, 111, 39, .18), transparent 45%);
}
.login-card {
  background: var(--surface-card); border-radius: var(--radius-lg); padding: 40px;
  width: 100%; max-width: 400px; box-shadow: var(--shadow-lg);
}
.login-logo { width: 92px; margin-bottom: 20px; }
.login-kicker { font-size: var(--fs-micro); color: var(--brand); letter-spacing: .12em; font-weight: 700; text-transform: uppercase; }
.login-title { font-size: 22px; margin: 8px 0 6px; }
.login-sub { font-size: var(--fs-caption); color: var(--text-muted); margin-bottom: 22px; }
.login-err { color: var(--bad); background: var(--bad-bg); padding: 10px 12px; border-radius: var(--radius-sm); font-size: var(--fs-caption); margin-bottom: 12px; }
.login-ok { color: var(--ok); background: var(--ok-bg); padding: 10px 12px; border-radius: var(--radius-sm); font-size: var(--fs-caption); margin-bottom: 12px; }

/* ============ SHELL ============ */
.app-header {
  background: var(--surface-dark); color: var(--mks-white);
  padding: 10px 20px; display: flex; align-items: center; justify-content: space-between; gap: 12px;
}
.app-header-left { display: flex; align-items: center; gap: 12px; }
.logo-mark { width: 40px; height: 24px; display: block; }
.app-title { font-size: var(--fs-lead); color: var(--mks-white); letter-spacing: .01em; }
.app-subtitle { font-size: var(--fs-micro); color: rgba(255, 255, 255, .55); margin-top: 1px; }
.top-actions { display: flex; align-items: center; gap: 8px; }

.lang-seg { display: flex; border: 1px solid rgba(255, 255, 255, .22); border-radius: var(--radius-sm); overflow: hidden; }
.lang-btn {
  padding: 4px 10px; background: transparent; color: rgba(255, 255, 255, .7);
  font-family: var(--font-display); font-size: var(--fs-caption); font-weight: 600;
  transition: background var(--t-fast), color var(--t-fast);
}
.lang-btn:hover { background: rgba(255, 255, 255, .1); color: #fff; }
.lang-btn.active { background: var(--brand); color: #fff; }

.user-chip {
  display: flex; align-items: center; gap: 9px; padding: 5px 10px;
  border-radius: var(--radius-sm); background: rgba(255, 255, 255, .06);
  border: 1px solid rgba(255, 255, 255, .22); color: var(--mks-white);
}
.user-chip:hover { background: rgba(255, 255, 255, .14); }
.user-chip .avatar { width: 26px; height: 26px; border-radius: 50%; overflow: hidden; font-size: 11px; }
.user-chip .avatar img { width: 100%; height: 100%; object-fit: cover; }
.user-chip .name { font-size: var(--fs-caption); font-weight: 600; }
.user-chip .hint { font-size: 10px; color: rgba(255, 255, 255, .55); }
.user-menu { position: relative; }
.user-drop {
  position: absolute; right: 0; top: calc(100% + 6px); background: var(--surface-card);
  border: 1px solid var(--border-subtle); border-radius: var(--radius-md);
  box-shadow: var(--shadow-lg); min-width: 190px; z-index: 90; overflow: hidden;
}
.user-drop button {
  display: block; width: 100%; text-align: left; padding: 10px 14px;
  font-size: var(--fs-caption); color: var(--text-body);
}
.user-drop button:hover { background: var(--surface-panel); color: var(--text-strong); }

.tabs { display: flex; background: var(--surface-card); border-bottom: 1px solid var(--border-subtle); padding: 0 20px; overflow-x: auto; }
.tab {
  padding: 11px 15px; font-size: var(--fs-caption); color: var(--text-muted); white-space: nowrap;
  border-bottom: 2px solid transparent; display: flex; align-items: center; gap: 6px;
  font-family: var(--font-display); font-weight: 600;
}
.tab:hover { color: var(--text-strong); }
.tab.active { color: var(--brand); border-bottom-color: var(--brand); }
.tab .badge { background: var(--bad); color: #fff; font-size: 10px; padding: 1px 6px; border-radius: var(--radius-pill); }

.date-bar {
  background: var(--surface-card); border-bottom: 1px solid var(--border-subtle);
  padding: 9px 20px; display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; gap: 10px;
}
.date-nav { display: flex; align-items: center; gap: 10px; }
.date-nav-btn {
  width: 28px; height: 28px; border-radius: var(--radius-sm); background: var(--surface-panel);
  display: flex; align-items: center; justify-content: center; color: var(--text-muted);
  border: 1px solid var(--border-subtle);
}
.date-nav-btn:hover { background: var(--brand); border-color: var(--brand); color: #fff; }
.date-display { font-size: var(--fs-body); font-weight: 600; color: var(--text-strong); font-family: var(--font-display); min-width: 230px; }
.date-display .sub { font-size: var(--fs-micro); color: var(--text-muted); font-weight: 400; }
.today-chip { background: var(--brand-soft); color: var(--mks-orange-press); font-size: var(--fs-caption); padding: 5px 12px; border-radius: var(--radius-pill); font-weight: 600; }
.today-chip:hover { background: var(--brand); color: #fff; }

.view { padding: 18px 20px 60px; max-width: 1500px; margin: 0 auto; }

/* ============ PANELS / STATS ============ */
.panel { background: var(--surface-card); border: 1px solid var(--border-subtle); border-radius: var(--radius-md); margin-bottom: 16px; box-shadow: var(--shadow-xs); }
.panel-head { padding: 13px 18px; border-bottom: 1px solid var(--border-subtle); display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
.panel-title { font-size: var(--fs-lead); display: flex; align-items: center; gap: 7px; }
.panel-sub { font-size: var(--fs-caption); color: var(--text-muted); margin-top: 2px; }
.panel-body { padding: 16px 18px; }
.panel.alert { border-color: var(--bad); }
.panel.alert .panel-title { color: var(--bad); }

.stats-row { display: grid; grid-template-columns: repeat(auto-fit, minmax(130px, 1fr)); gap: 10px; margin-bottom: 16px; }
.stat { background: var(--surface-card); border: 1px solid var(--border-subtle); border-radius: var(--radius-md); padding: 13px 15px; }
.stat.accent { background: var(--surface-dark); border-color: var(--surface-dark); }
.stat.accent .val { color: var(--mks-white); }
.stat.accent .lbl { color: rgba(255, 255, 255, .6); }
.stat .val { font-size: 23px; line-height: 1.1; }
.stat .lbl { font-size: var(--fs-micro); color: var(--text-muted); margin-top: 3px; }

.summary-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: 12px; padding: 16px 18px; }
.sum-card { background: var(--surface-panel); border-radius: var(--radius-sm); padding: 14px; }
.sum-card.warn { background: var(--bad-bg); }
.sum-label { font-size: var(--fs-micro); color: var(--text-muted); text-transform: uppercase; letter-spacing: .06em; }
.sum-value-big { font-size: 26px; margin: 4px 0 2px; }
.sum-foot { font-size: var(--fs-micro); color: var(--text-light); }

/* ============ TASK CARD ============ */
.task-list { display: flex; flex-direction: column; gap: 8px; padding: 14px 18px; }
.task { border: 1px solid var(--border-subtle); border-left-width: 3px; border-radius: var(--radius-sm); background: var(--surface-card); }
.task.read-only { background: var(--surface-page); }
.border-todo { border-left-color: var(--mks-grey-300); }
.border-in_progress { border-left-color: var(--warn); }
.border-done { border-left-color: var(--ok); }
.border-blocked { border-left-color: var(--bad); }
.border-cancelled { border-left-color: var(--border-subtle); }
.task.overdue { border-left-color: var(--bad); background: #FEFAF9; }
.task-main { display: flex; align-items: flex-start; justify-content: space-between; gap: 10px; padding: 11px 13px; }
.task-body { flex: 1; min-width: 0; }
.task-meta { display: flex; flex-wrap: wrap; gap: 5px; margin-bottom: 6px; align-items: center; }
.task-title { font-size: var(--fs-body); font-weight: 600; color: var(--text-strong); font-family: var(--font-display); }
.task.status-done .task-title, .task.status-cancelled .task-title { text-decoration: line-through; color: var(--text-light); font-weight: 400; }
.task-detail { font-size: var(--fs-caption); color: var(--text-muted); margin-top: 4px; display: flex; align-items: center; gap: 5px; }
.task-notes { font-size: var(--fs-caption); color: var(--text-muted); margin-top: 6px; background: var(--surface-panel); padding: 8px 10px; border-radius: var(--radius-sm); display: flex; gap: 6px; }
.task-actions { display: flex; gap: 4px; flex-shrink: 0; align-items: center; }
.icon-btn {
  width: 27px; height: 27px; border-radius: var(--radius-sm); display: flex; align-items: center; justify-content: center;
  background: var(--surface-card); border: 1px solid var(--border-subtle); color: var(--text-muted);
  transition: background var(--t-fast), color var(--t-fast), border-color var(--t-fast);
}
.icon-btn:hover { background: var(--brand); border-color: var(--brand); color: #fff; }
.icon-btn.danger:hover { background: var(--bad); border-color: var(--bad); }
.icon-btn.ok { color: var(--ok); border-color: #BFE0D0; }
.icon-btn.ok:hover { background: var(--ok); border-color: var(--ok); color: #fff; }
.icon-btn.ok.on { background: var(--ok); border-color: var(--ok); color: #fff; }

/* ---- quick status: ปุ่มโชว์ตรงๆ กดครั้งเดียวเปลี่ยนสถานะ ---- */
.chip-status { font-family: var(--font-display); font-weight: 600; }
.status-seg {
  display: inline-flex; border: 1px solid var(--border-subtle);
  border-radius: var(--radius-sm); overflow: hidden; margin-right: 6px; background: var(--surface-card);
}
.seg-btn {
  width: 28px; height: 27px; display: flex; align-items: center; justify-content: center;
  color: var(--text-light); border-right: 1px solid var(--border-subtle);
  transition: background var(--t-fast), color var(--t-fast);
}
.seg-btn:last-child { border-right: none; }
.seg-btn:hover { background: var(--surface-panel); color: var(--text-strong); }
.seg-btn.on { color: #fff; }
.seg-btn.seg-todo.on { background: var(--mks-ash-grey); }
.seg-btn.seg-in_progress.on { background: var(--warn); }
.seg-btn.seg-blocked.on { background: var(--bad); }
.seg-btn.seg-done.on { background: var(--ok); }
.seg-btn.seg-in_progress:hover { color: var(--warn); }
.seg-btn.seg-blocked:hover { color: var(--bad); }
.seg-btn.seg-done:hover { color: var(--ok); }

/* ปุ่มขออนุญาตแจ้งเตือน */
.bell-btn {
  display: flex; align-items: center; gap: 6px; padding: 5px 10px; border-radius: var(--radius-sm);
  background: rgba(255, 255, 255, .06); border: 1px solid rgba(255, 255, 255, .22);
  color: rgba(255, 255, 255, .8); font-size: var(--fs-caption); font-weight: 600;
}
.bell-btn:hover { background: var(--brand); border-color: var(--brand); color: #fff; }
.bell-btn.on { border-color: var(--ok); color: #9FD9BF; }

.chip { font-size: var(--fs-micro); padding: 2px 8px; border-radius: var(--radius-pill); display: inline-flex; align-items: center; gap: 4px; }
.chip-time { background: var(--surface-panel); color: var(--text-muted); }
.chip-status.todo { background: var(--surface-panel); color: var(--text-muted); }
.chip-status.in_progress { background: var(--warn-bg); color: var(--warn); }
.chip-status.done { background: var(--ok-bg); color: var(--ok); }
.chip-status.blocked { background: var(--bad-bg); color: var(--bad); }
.chip-status.cancelled { background: var(--surface-panel); color: var(--text-light); }
.chip-priority { background: var(--bad-bg); color: var(--bad); }
.chip-due { background: var(--warn-bg); color: var(--warn); }
.chip-due.late { background: var(--bad-bg); color: var(--bad); font-weight: 700; }
.chip-tagged { background: var(--info-bg); color: var(--info); }
.chip-assigner { background: var(--brand-soft); color: var(--mks-orange-press); }
.chip-recur { background: var(--info-bg); color: var(--info); }

.task-expand { padding: 0 13px 12px; border-top: 1px solid var(--border-subtle); }

/* ============ AVATARS ============ */
.person-avatar { border-radius: 50%; overflow: hidden; display: flex; align-items: center; justify-content: center; color: #fff; font-weight: 600; flex-shrink: 0; font-family: var(--font-display); }
.person-avatar img { width: 100%; height: 100%; object-fit: cover; }

/* ============ TEAM BOARD ============ */
.team-board { display: grid; grid-template-columns: repeat(auto-fit, minmax(230px, 1fr)); gap: 12px; padding: 16px 18px; }
.person-col { background: var(--surface-page); border: 1px solid var(--border-subtle); border-radius: var(--radius-sm); display: flex; flex-direction: column; }
.person-header { padding: 11px; border-bottom: 1px solid var(--border-subtle); }
.person-top { display: flex; align-items: center; gap: 9px; }
.person-name { font-size: var(--fs-caption); font-weight: 600; color: var(--text-strong); font-family: var(--font-display); }
.person-role { font-size: 10px; color: var(--text-muted); }
.person-stats { display: flex; flex-wrap: wrap; gap: 4px; margin-top: 8px; }
.person-stat { font-size: 10px; padding: 1px 7px; border-radius: var(--radius-pill); background: var(--surface-panel); color: var(--text-muted); }
.person-stat.active { background: var(--warn-bg); color: var(--warn); }
.person-stat.done { background: var(--ok-bg); color: var(--ok); }
.person-stat.late { background: var(--bad-bg); color: var(--bad); }
.person-tasks { padding: 10px; display: flex; flex-direction: column; gap: 7px; flex: 1; min-height: 60px; }
.mini-task { border: 1px solid var(--border-subtle); border-left-width: 3px; border-radius: var(--radius-sm); padding: 8px 9px; background: var(--surface-card); cursor: pointer; }
.mini-task:hover { box-shadow: var(--shadow-sm); }
.mini-task.is-tagged { background: var(--surface-panel); }
.mini-task-top { display: flex; align-items: center; justify-content: space-between; gap: 6px; margin-bottom: 4px; }
.mini-time { font-size: 10px; color: var(--text-muted); }
.mini-status { font-size: 9px; padding: 1px 6px; border-radius: var(--radius-pill); background: var(--surface-panel); color: var(--text-muted); }
.mini-status.in_progress { background: var(--warn-bg); color: var(--warn); }
.mini-status.done { background: var(--ok-bg); color: var(--ok); }
.mini-status.blocked { background: var(--bad-bg); color: var(--bad); }
.mini-title { font-size: var(--fs-caption); color: var(--text-strong); line-height: 1.35; }
.mini-note { font-size: 10px; color: var(--text-light); margin-top: 3px; }
.assign-btn { margin: 0 10px 10px; padding: 8px; border: 1px dashed var(--border-strong); border-radius: var(--radius-sm); font-size: var(--fs-micro); color: var(--text-muted); }
.assign-btn:hover { border-color: var(--brand); color: var(--brand); background: var(--brand-soft); }
.empty-mini { font-size: var(--fs-micro); color: var(--text-light); text-align: center; padding: 14px 0; }

/* ============ UPCOMING ============ */
.upcoming-group { border-top: 1px solid var(--border-subtle); }
.upcoming-date-head { display: flex; align-items: center; justify-content: space-between; padding: 9px 18px; background: var(--surface-panel); }
.upcoming-date-main { font-size: var(--fs-caption); font-weight: 600; color: var(--text-strong); font-family: var(--font-display); }
.upcoming-date-sub { font-size: var(--fs-micro); color: var(--text-muted); }
.upcoming-jump { font-size: var(--fs-micro); color: var(--brand); font-weight: 600; }

/* ============ ROWS ============ */
.row-list { display: flex; flex-direction: column; }
.row-item { display: flex; align-items: center; gap: 12px; padding: 11px 18px; border-top: 1px solid var(--border-subtle); flex-wrap: wrap; }
.row-item:first-child { border-top: none; }
.row-main { display: flex; align-items: center; gap: 10px; flex: 1; min-width: 200px; }
.row-stats { display: flex; gap: 16px; align-items: center; }
.row-stat { text-align: center; min-width: 42px; }
.row-stat-num { font-size: 16px; font-weight: 600; color: var(--text-strong); font-family: var(--font-display); }
.row-stat-lbl { font-size: 10px; color: var(--text-muted); }
.bar { width: 70px; height: 5px; background: var(--surface-panel); border-radius: 3px; overflow: hidden; margin-top: 4px; }
.bar-fill { height: 100%; background: var(--brand); }

/* ============ FEED ============ */
.feed { display: flex; flex-direction: column; }
.feed-item { display: flex; gap: 10px; padding: 9px 18px; border-top: 1px solid var(--border-subtle); font-size: var(--fs-caption); }
.feed-item:first-child { border-top: none; }
.feed-text { color: var(--text-muted); flex: 1; }
.feed-text strong { color: var(--text-strong); font-weight: 600; }
.feed-time { font-size: var(--fs-micro); color: var(--text-light); white-space: nowrap; }

/* ============ FORMS ============ */
.form-row { margin-bottom: 13px; }
.form-label { display: block; font-size: var(--fs-caption); color: var(--text-muted); margin-bottom: 5px; font-weight: 600; }
.form-input {
  width: 100%; padding: 8px 11px; border: 1px solid var(--border-strong); border-radius: var(--radius-sm);
  font-size: var(--fs-body); outline: none; background: var(--surface-card); color: var(--text-strong);
}
.form-input:focus { border-color: var(--brand); box-shadow: var(--ring); }
.form-two-col { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.assignee-row { display: flex; flex-wrap: wrap; gap: 6px; }
.assignee-opt {
  display: flex; align-items: center; gap: 6px; padding: 4px 10px 4px 4px;
  border: 1px solid var(--border-strong); border-radius: var(--radius-pill); font-size: var(--fs-caption); color: var(--text-muted);
}
.assignee-opt.active { border-color: var(--brand); background: var(--brand-soft); color: var(--mks-orange-press); font-weight: 600; }
.assignee-opt.disabled { opacity: .4; cursor: not-allowed; }
.ao-avatar { width: 22px; height: 22px; border-radius: 50%; overflow: hidden; color: #fff; font-size: 10px; display: flex; align-items: center; justify-content: center; }
.ao-avatar img { width: 100%; height: 100%; object-fit: cover; }

.modal-overlay { position: fixed; inset: 0; background: rgba(48, 48, 47, .55); display: flex; align-items: flex-start; justify-content: center; padding: 24px 20px; z-index: 100; overflow-y: auto; }
.modal { background: var(--surface-card); border-radius: var(--radius-lg); padding: 24px; width: 100%; max-width: 620px; box-shadow: var(--shadow-lg); }
.modal-head { display: flex; align-items: flex-start; justify-content: space-between; margin-bottom: 18px; gap: 12px; }
.modal-kicker { font-size: 10px; color: var(--brand); letter-spacing: .12em; font-weight: 700; text-transform: uppercase; }
.modal-title { font-size: 18px; margin-top: 2px; }
.close-btn { width: 30px; height: 30px; border-radius: var(--radius-sm); background: var(--surface-panel); display: flex; align-items: center; justify-content: center; color: var(--text-muted); }
.close-btn:hover { background: var(--bad-bg); color: var(--bad); }
.modal-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 20px; }
.btn-primary { padding: 9px 18px; background: var(--action); color: #fff; border-radius: var(--radius-sm); font-size: var(--fs-caption); font-weight: 600; font-family: var(--font-display); }
.btn-primary:hover { background: var(--action-hover); }
.btn-primary:disabled { background: var(--border-strong); cursor: not-allowed; }
.btn-cancel { padding: 9px 18px; background: var(--surface-panel); color: var(--text-muted); border-radius: var(--radius-sm); font-size: var(--fs-caption); }
.btn-outline { padding: 7px 13px; border: 1px solid var(--border-strong); border-radius: var(--radius-sm); font-size: var(--fs-caption); color: var(--text-body); background: var(--surface-card); font-weight: 600; }
.btn-outline:hover { border-color: var(--brand); color: var(--brand); }
.btn-outline.on { border-color: var(--brand); background: var(--brand); color: #fff; }
.btn-danger { padding: 7px 13px; border-radius: var(--radius-sm); font-size: var(--fs-caption); background: var(--bad-bg); color: var(--bad); font-weight: 600; }

/* ============ COMMENTS / FILES ============ */
.comment { display: flex; gap: 9px; padding: 10px 0; border-top: 1px solid var(--border-subtle); }
.comment-body { flex: 1; }
.comment-head { display: flex; align-items: baseline; gap: 8px; }
.comment-author { font-size: var(--fs-caption); font-weight: 600; color: var(--text-strong); }
.comment-time { font-size: 10px; color: var(--text-light); }
.comment-text { font-size: var(--fs-body); color: var(--text-body); margin-top: 3px; white-space: pre-wrap; }
.file-item { display: flex; align-items: center; gap: 9px; padding: 8px 10px; background: var(--surface-panel); border-radius: var(--radius-sm); margin-bottom: 6px; font-size: var(--fs-caption); }
.file-name { flex: 1; color: var(--brand); cursor: pointer; font-weight: 600; }
.file-name:hover { text-decoration: underline; }
.file-size { color: var(--text-light); font-size: var(--fs-micro); }

/* ============ SOP ============ */
.sop-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 12px; padding: 16px 18px; }
.sop-card { border: 1px solid var(--border-subtle); border-radius: var(--radius-md); padding: 14px; background: var(--surface-card); display: flex; flex-direction: column; gap: 8px; transition: box-shadow var(--t-fast); }
.sop-card:hover { box-shadow: var(--shadow-md); }
.sop-cat { font-size: 10px; text-transform: uppercase; letter-spacing: .1em; color: var(--brand); font-weight: 700; }
.sop-title { font-size: var(--fs-lead); font-family: var(--font-display); font-weight: 600; color: var(--text-strong); line-height: 1.3; }
.sop-desc { font-size: var(--fs-caption); color: var(--text-muted); flex: 1; }
.sop-foot { display: flex; align-items: center; gap: 8px; justify-content: space-between; border-top: 1px solid var(--border-subtle); padding-top: 9px; }
.sop-meta { font-size: 10px; color: var(--text-light); }
.sop-body-text { white-space: pre-wrap; font-size: var(--fs-body); line-height: 1.7; color: var(--text-body); }
.sop-toolbar { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; padding: 12px 18px; border-bottom: 1px solid var(--border-subtle); }

/* ============ CHARTS ============ */
.chart-wrap { padding: 16px 18px; overflow-x: auto; }
.chart-legend { display: flex; gap: 14px; flex-wrap: wrap; font-size: var(--fs-micro); color: var(--text-muted); padding: 0 18px 12px; }
.legend-item { display: flex; align-items: center; gap: 5px; }
.legend-swatch { width: 10px; height: 10px; border-radius: 2px; }
svg.chart { display: block; min-width: 520px; }
svg.chart text { font-family: var(--font-display); fill: var(--text-muted); }
svg.chart .grid-line { stroke: var(--border-subtle); stroke-width: 1; }
svg.chart .axis-label { font-size: 10px; }
svg.chart .val-label { font-size: 10px; fill: var(--text-strong); font-weight: 600; }
.insight-list { padding: 14px 18px; display: flex; flex-direction: column; gap: 10px; }
.insight { display: flex; gap: 10px; font-size: var(--fs-body); color: var(--text-body); line-height: 1.55; }
.insight-icon { width: 22px; height: 22px; border-radius: 50%; flex: none; display: flex; align-items: center; justify-content: center; font-size: 11px; font-weight: 700; }
.insight.good .insight-icon { background: var(--ok-bg); color: var(--ok); }
.insight.warn .insight-icon { background: var(--warn-bg); color: var(--warn); }
.insight.bad .insight-icon { background: var(--bad-bg); color: var(--bad); }
.insight.info .insight-icon { background: var(--info-bg); color: var(--info); }
.insight b { color: var(--text-strong); font-weight: 600; }

/* ============ MISC ============ */
.empty { text-align: center; padding: 42px 20px; color: var(--text-light); }
.empty-title { font-size: var(--fs-body); color: var(--text-muted); margin-top: 10px; }
.empty-sub { font-size: var(--fs-caption); margin: 4px 0 14px; }
.toast {
  position: fixed; bottom: 24px; left: 50%; transform: translateX(-50%) translateY(80px);
  background: var(--surface-dark); color: #fff; padding: 11px 20px; border-radius: var(--radius-md);
  font-size: var(--fs-caption); opacity: 0; transition: .25s; z-index: 200; box-shadow: var(--shadow-lg);
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }
table.rpt { width: 100%; border-collapse: collapse; font-size: var(--fs-caption); }
table.rpt th, table.rpt td { padding: 8px 10px; border-bottom: 1px solid var(--border-subtle); text-align: left; }
table.rpt th { background: var(--surface-panel); color: var(--text-muted); font-weight: 600; font-size: var(--fs-micro); text-transform: uppercase; letter-spacing: .05em; }
table.rpt tbody tr:hover { background: var(--surface-page); }
table.rpt td.num, table.rpt th.num { text-align: right; }
.table-wrap { overflow-x: auto; padding: 16px 18px; }

@media (max-width: 640px) {
  .form-two-col { grid-template-columns: 1fr; }
  .view { padding: 14px 12px 50px; }
  .date-display { min-width: 0; }
  .app-subtitle { display: none; }
}
