/* ============================================================
   NYCU Medicine Curriculum Map — v2
   Self-contained, no external assets. System font stack.
   ============================================================ */
:root {
  --brand:        #0a5c7a;
  --brand-600:    #08506b;
  --brand-700:    #063f54;
  --brand-050:    #e8f4f9;
  --brand-100:    #cfe8f1;
  --accent:       #e08a3c;
  --accent-050:   #fdf1e6;
  --ink:          #16262f;
  --ink-2:        #40525c;
  --muted:        #6c7f89;
  --line:         #dbe6ec;
  --line-2:       #eaf1f5;
  --bg:           #f4f8fb;
  --surface:      #ffffff;
  --surface-2:    #f7fafc;
  --ok:           #1f9d6b;
  --warn:         #c9770d;
  --danger:       #d24d4d;
  --shadow-sm:    0 1px 2px rgba(16,42,54,.06), 0 1px 3px rgba(16,42,54,.05);
  --shadow-md:    0 4px 12px rgba(16,42,54,.09), 0 2px 4px rgba(16,42,54,.05);
  --shadow-lg:    0 16px 48px rgba(16,42,54,.18);
  --radius:       12px;
  --radius-sm:    8px;
  --grade-1:      #2d7dd2;
  --grade-2:      #17a398;
  --grade-3:      #7b4fb5;
  --grade-4:      #c0499a;
  --grade-5:      #d67d1a;
  --grade-6:      #4a8a3a;
  --font: "Segoe UI", "PingFang TC", "Microsoft JhengHei", "Noto Sans TC", -apple-system, BlinkMacSystemFont, Roboto, Helvetica, Arial, sans-serif;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font-family: var(--font);
  color: var(--ink);
  background: var(--bg);
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}
h1, h2, h3, h4 { margin: 0; font-weight: 700; letter-spacing: -.01em; }
button { font-family: inherit; cursor: pointer; }
input, select, textarea, button { font-family: inherit; font-size: inherit; }

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex; align-items: center; gap: 7px;
  border: 1px solid var(--line); background: var(--surface); color: var(--ink-2);
  padding: 8px 14px; border-radius: var(--radius-sm); font-weight: 600; font-size: 14px;
  transition: background .15s, border-color .15s, box-shadow .15s, color .15s;
  white-space: nowrap;
}
.btn:hover { background: var(--surface-2); border-color: var(--brand-100); color: var(--brand); }
.btn:active { transform: translateY(.5px); }
.btn-sm { padding: 6px 11px; font-size: 13px; }
.btn-primary { background: var(--brand); border-color: var(--brand); color: #fff; }
.btn-primary:hover { background: var(--brand-600); border-color: var(--brand-600); color: #fff; }
.btn-warn { color: var(--warn); border-color: #f0d9b8; background: #fff8ee; }
.btn-warn:hover { background: #fdeed6; border-color: var(--warn); color: var(--warn); }
.btn-danger { color: var(--danger); border-color: #f0c9c9; background: #fdf1f1; }
.btn-danger:hover { background: #fadede; border-color: var(--danger); color: var(--danger); }
.btn-ghost { background: transparent; border-color: transparent; }
.btn-ghost:hover { background: rgba(255,255,255,.16); color: #fff; border-color: transparent; }
.btn-lang { background: rgba(255,255,255,.14); border-color: rgba(255,255,255,.28); color: #fff; font-size: 13px; }
.btn-lang:hover { background: rgba(255,255,255,.26); color: #fff; border-color: rgba(255,255,255,.5); }
.link-btn { background: none; border: none; color: var(--brand); font-weight: 600; font-size: 13px; padding: 2px 4px; }
.link-btn:hover { text-decoration: underline; }
.icon-btn { background: none; border: none; font-size: 18px; color: var(--muted); width: 34px; height: 34px; border-radius: 8px; display: inline-flex; align-items: center; justify-content: center; }
.icon-btn:hover { background: var(--surface-2); color: var(--ink); }

/* ---------- Header ---------- */
.app-header {
  background: linear-gradient(120deg, var(--brand-700), var(--brand) 60%, #0d6c8e);
  color: #fff; position: sticky; top: 0; z-index: 40;
  box-shadow: var(--shadow-md);
}
.header-inner { max-width: 1440px; margin: 0 auto; padding: 12px 22px; display: flex; align-items: center; gap: 16px; }
.brand { display: flex; align-items: center; gap: 13px; min-width: 0; }
.brand-mark { flex: none; display: flex; align-items: center; justify-content: center; width: 52px; height: 52px; background: #fff; border-radius: 50%; box-shadow: 0 2px 8px rgba(0,0,0,.18); }
.brand-mark img { width: 46px; height: 46px; object-fit: contain; display: block; }
.brand-text { min-width: 0; }
.brand-text h1 { font-size: 20px; line-height: 1.2; }
.brand-sub { margin: 1px 0 0; font-size: 12.5px; opacity: .82; font-weight: 500; }
.header-actions { margin-left: auto; display: flex; align-items: center; gap: 8px; }
/* Header action buttons sit on the dark header — force light colour so they're visible */
.header-actions .btn-ghost { color: #eaf6fb; border-color: rgba(255,255,255,.22); background: rgba(255,255,255,.08); }
.header-actions .btn-ghost:hover { color: #fff; background: rgba(255,255,255,.22); border-color: rgba(255,255,255,.45); }

/* ---------- Edit bar ---------- */
.edit-bar {
  background: #fff8ee; border-bottom: 1px solid #f0dcbf; color: var(--warn);
  position: sticky; top: 64px; z-index: 39;
}
.edit-bar { display: flex; align-items: center; gap: 14px; padding: 8px 22px; max-width: 1440px; margin: 0 auto; flex-wrap: wrap; }
.edit-bar-label { display: inline-flex; align-items: center; gap: 7px; font-weight: 700; font-size: 13.5px; }
.edit-bar-label .dot { width: 9px; height: 9px; border-radius: 50%; background: var(--warn); box-shadow: 0 0 0 3px rgba(201,119,13,.2); animation: pulse 1.8s infinite; }
@keyframes pulse { 50% { box-shadow: 0 0 0 5px rgba(201,119,13,.05); } }
.edit-bar-hint { font-size: 12.5px; color: #9a7327; }
.edit-bar-actions { margin-left: auto; display: flex; gap: 7px; flex-wrap: wrap; }

/* ---------- Controls ---------- */
.controls { background: var(--surface); border-bottom: 1px solid var(--line); position: sticky; top: 64px; z-index: 30; }
.edit-active .controls { top: 106px; }
.controls-inner { max-width: 1440px; margin: 0 auto; padding: 12px 22px; display: flex; align-items: center; gap: 14px; flex-wrap: wrap; }
.search-wrap { position: relative; flex: 1 1 340px; min-width: 240px; }
.search-icon { position: absolute; left: 13px; top: 50%; transform: translateY(-50%); color: var(--muted); pointer-events: none; }
#search {
  width: 100%; padding: 11px 40px 11px 40px; border: 1px solid var(--line); border-radius: 10px;
  background: var(--surface-2); color: var(--ink); font-size: 15px; transition: border-color .15s, box-shadow .15s, background .15s;
}
#search:focus { outline: none; border-color: var(--brand); background: #fff; box-shadow: 0 0 0 3px var(--brand-050); }
.search-kbd { position: absolute; right: 12px; top: 50%; transform: translateY(-50%); font-size: 12px; color: var(--muted); background: #fff; border: 1px solid var(--line); border-radius: 5px; padding: 1px 7px; font-family: inherit; }
.control-buttons { display: flex; align-items: center; gap: 8px; }
.filter-count { background: var(--accent); color: #fff; border-radius: 999px; font-size: 11px; min-width: 18px; height: 18px; display: inline-flex; align-items: center; justify-content: center; padding: 0 5px; font-weight: 700; }
.seg { display: inline-flex; border: 1px solid var(--line); border-radius: 8px; overflow: hidden; background: var(--surface-2); }
.seg-btn { border: none; background: transparent; padding: 8px 11px; color: var(--muted); display: inline-flex; }
.seg-btn.is-active { background: var(--brand); color: #fff; }
.select-sort { padding: 8px 12px; border: 1px solid var(--line); border-radius: 8px; background: var(--surface-2); color: var(--ink-2); font-weight: 600; font-size: 13.5px; }
.select-sort:focus { outline: none; border-color: var(--brand); }

/* ---------- Layout ---------- */
.layout { max-width: 1440px; margin: 0 auto; padding: 20px 22px 40px; display: grid; grid-template-columns: 256px 1fr; gap: 22px; align-items: start; }
.filters { position: sticky; top: 132px; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow-sm); overflow: hidden; }
.edit-active .filters { top: 174px; }
.filters-head { display: flex; align-items: center; justify-content: space-between; padding: 14px 16px; border-bottom: 1px solid var(--line-2); }
.filters-head h2 { font-size: 15px; }
.filter-scroll { max-height: calc(100vh - 230px); overflow-y: auto; padding: 6px 16px 16px; }
.filter-group { padding: 12px 0; border-bottom: 1px solid var(--line-2); }
.filter-group:last-child { border-bottom: none; }
.filter-group h3 { font-size: 12px; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); margin-bottom: 10px; font-weight: 700; }
.chip-row { display: flex; flex-wrap: wrap; gap: 7px; }
.chip {
  display: inline-flex; align-items: center; gap: 6px; padding: 5px 11px; border-radius: 999px;
  border: 1px solid var(--line); background: var(--surface); color: var(--ink-2); font-size: 13px; font-weight: 600;
  transition: all .13s;
}
.chip:hover { border-color: var(--brand-100); background: var(--brand-050); }
.chip.is-on { background: var(--brand); border-color: var(--brand); color: #fff; }
.chip .chip-dot { width: 9px; height: 9px; border-radius: 50%; flex: none; }
.chip.is-on .chip-dot { box-shadow: 0 0 0 2px rgba(255,255,255,.5); }
.chip-count { font-size: 11px; opacity: .7; font-weight: 600; }
.dept-select { width: 100%; padding: 8px 10px; border: 1px solid var(--line); border-radius: 8px; background: var(--surface-2); color: var(--ink-2); font-size: 13.5px; }
.dept-select:focus { outline: none; border-color: var(--brand); }

/* ---------- Results ---------- */
.results { min-width: 0; }
.results-head { display: flex; align-items: center; gap: 12px; margin-bottom: 14px; flex-wrap: wrap; min-height: 26px; }
.results-count { font-size: 14px; color: var(--muted); font-weight: 600; }
.results-count b { color: var(--ink); }
.active-chips { display: flex; flex-wrap: wrap; gap: 6px; }
.active-chip { display: inline-flex; align-items: center; gap: 5px; background: var(--brand-050); color: var(--brand-600); border: 1px solid var(--brand-100); border-radius: 999px; padding: 3px 6px 3px 10px; font-size: 12.5px; font-weight: 600; }
.active-chip button { background: none; border: none; color: var(--brand); font-size: 14px; line-height: 1; padding: 0 2px; opacity: .7; }
.active-chip button:hover { opacity: 1; }

.course-container { display: block; }
.grade-section { margin-bottom: 26px; }
.grade-section-head { display: flex; align-items: center; gap: 10px; margin: 4px 0 14px; }
.grade-badge-lg { font-size: 13px; font-weight: 700; color: #fff; padding: 4px 12px; border-radius: 999px; }
.grade-section-head .cnt { font-size: 13px; color: var(--muted); font-weight: 600; }
.grade-section-head .rule { flex: 1; height: 1px; background: var(--line); }

/* Course card */
.course-card {
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 15px 16px; box-shadow: var(--shadow-sm); cursor: pointer; position: relative;
  transition: transform .14s, box-shadow .14s, border-color .14s; overflow: hidden;
}
.course-card:hover { transform: translateY(-2px); box-shadow: var(--shadow-md); border-color: var(--brand-100); }
.course-card::before { content: ""; position: absolute; left: 0; top: 0; bottom: 0; width: 4px; background: var(--gc, var(--brand)); }
.cc-top { display: flex; align-items: flex-start; justify-content: space-between; gap: 10px; margin-bottom: 8px; }
.cc-name { font-size: 15.5px; font-weight: 700; color: var(--ink); line-height: 1.35; }
.cc-name-alt { display: block; font-size: 12px; font-weight: 500; color: var(--muted); margin-top: 2px; line-height: 1.3; }
.cc-tags { display: flex; gap: 6px; flex: none; flex-wrap: wrap; justify-content: flex-end; }
.tag { font-size: 11px; font-weight: 700; padding: 2px 8px; border-radius: 6px; white-space: nowrap; }
.tag-req { background: var(--brand-050); color: var(--brand-600); }
.tag-elec { background: var(--accent-050); color: var(--accent); }
.tag-grade { color: #fff; }
.cc-meta { display: flex; flex-direction: column; gap: 3px; margin-bottom: 11px; }
.cc-meta-row { display: flex; align-items: center; gap: 7px; font-size: 13px; color: var(--ink-2); }
.cc-meta-row svg { color: var(--muted); flex: none; }
.cc-meta-row span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.cc-foot { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding-top: 10px; border-top: 1px solid var(--line-2); }
.cc-domains { display: flex; gap: 4px; }
.dom-pip { width: 20px; height: 20px; border-radius: 6px; font-size: 10.5px; font-weight: 700; display: inline-flex; align-items: center; justify-content: center; color: #fff; }
.cc-credit { font-size: 12.5px; color: var(--muted); font-weight: 600; }
.edit-badge { position: absolute; top: 8px; right: 8px; background: var(--warn); color: #fff; border: none; border-radius: 6px; width: 26px; height: 26px; display: none; align-items: center; justify-content: center; box-shadow: var(--shadow-sm); }
.edit-active .course-card .edit-badge { display: inline-flex; }
.edit-active .course-card .cc-tags { margin-right: 30px; }

/* List view */
.course-container.list { display: flex; flex-direction: column; gap: 8px; }
.course-container.list .grade-section { margin-bottom: 18px; }
.course-container.list .course-cards { display: flex; flex-direction: column; gap: 8px; }
.course-container.list .course-card { display: grid; grid-template-columns: 1fr auto; align-items: center; gap: 12px; padding: 12px 16px; }
.course-container.list .course-card:hover { transform: none; }
.course-container.list .cc-meta { flex-direction: row; flex-wrap: wrap; gap: 4px 16px; margin-bottom: 0; margin-top: 4px; }
.course-container.list .cc-foot { border: none; padding: 0; flex-direction: column; align-items: flex-end; }
.course-container.list .cc-top { margin-bottom: 2px; }

/* ---------- Empty ---------- */
.empty { text-align: center; padding: 70px 20px; color: var(--muted); }
.empty svg { color: var(--line); margin-bottom: 10px; }
.empty p { font-size: 15px; margin: 0 0 16px; }

/* ---------- Drawer (course detail) ---------- */
.drawer-scrim { position: fixed; inset: 0; background: rgba(16,42,54,.42); z-index: 50; backdrop-filter: blur(2px); animation: fade .2s; }
@keyframes fade { from { opacity: 0; } }
.drawer {
  position: fixed; top: 0; right: 0; bottom: 0; width: min(680px, 94vw); background: var(--bg);
  z-index: 51; box-shadow: var(--shadow-lg); display: flex; flex-direction: column; animation: slideIn .26s cubic-bezier(.2,.8,.2,1);
}
@keyframes slideIn { from { transform: translateX(40px); opacity: .4; } }
.drawer-body { overflow-y: auto; height: 100%; }
.d-hero { background: linear-gradient(135deg, var(--gc, var(--brand)), var(--brand-700)); color: #fff; padding: 22px 26px 20px; position: sticky; top: 0; z-index: 2; }
.d-hero-top { display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; }
.d-crumb { font-size: 12.5px; opacity: .85; font-weight: 600; letter-spacing: .02em; margin-bottom: 8px; display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.d-close { background: rgba(255,255,255,.16); border: none; color: #fff; width: 34px; height: 34px; border-radius: 9px; font-size: 17px; flex: none; }
.d-close:hover { background: rgba(255,255,255,.3); }
.d-title { font-size: 22px; line-height: 1.25; margin-bottom: 6px; }
.d-subtitle { font-size: 14.5px; font-weight: 500; opacity: .85; margin-bottom: 12px; }
.d-hero-tags { display: flex; gap: 8px; flex-wrap: wrap; }
.d-hero-tags .tag { background: rgba(255,255,255,.18); color: #fff; font-size: 12px; padding: 4px 11px; }
.d-hero .edit-btn-hero { background: rgba(255,255,255,.16); border: none; color: #fff; border-radius: 8px; padding: 7px 12px; font-weight: 600; font-size: 13px; display: inline-flex; gap: 6px; align-items: center; }
.d-hero .edit-btn-hero:hover { background: rgba(255,255,255,.3); }

.d-section { padding: 20px 26px; }
.d-info-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 1px; background: var(--line-2); border: 1px solid var(--line-2); border-radius: var(--radius); overflow: hidden; margin-bottom: 20px; }
.d-info-cell { background: var(--surface); padding: 11px 14px; }
.d-info-cell .k { font-size: 11.5px; color: var(--muted); font-weight: 700; text-transform: uppercase; letter-spacing: .03em; margin-bottom: 3px; }
.d-info-cell .v { font-size: 14px; color: var(--ink); font-weight: 600; }
.d-block { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px 18px; margin-bottom: 14px; box-shadow: var(--shadow-sm); }
.d-block h3 { font-size: 13px; text-transform: uppercase; letter-spacing: .04em; color: var(--brand); margin-bottom: 9px; display: flex; align-items: center; gap: 8px; }
.d-block h3::before { content: ""; width: 3px; height: 14px; background: var(--accent); border-radius: 2px; }
.d-block .body-text { font-size: 14.5px; color: var(--ink-2); white-space: pre-wrap; line-height: 1.7; }
.d-block.empty-block { display: none; }

/* Competence viz */
.comp-wrap { display: grid; grid-template-columns: 220px 1fr; gap: 20px; align-items: start; }
.radar-box { display: flex; flex-direction: column; align-items: center; gap: 8px; }
.radar-legend { font-size: 11.5px; color: var(--muted); text-align: center; }
.comp-domains { display: flex; flex-direction: column; gap: 14px; }
.comp-domain-h { font-size: 13.5px; font-weight: 700; color: var(--ink); display: flex; align-items: center; gap: 8px; margin-bottom: 7px; }
.comp-domain-h .num { width: 22px; height: 22px; border-radius: 6px; color: #fff; font-size: 12px; display: inline-flex; align-items: center; justify-content: center; font-weight: 700; flex: none; }
.comp-sub { margin-bottom: 8px; }
.comp-sub-top { display: flex; justify-content: space-between; align-items: baseline; gap: 10px; margin-bottom: 4px; }
.comp-sub-label { font-size: 13px; color: var(--ink-2); }
.comp-sub-level { font-size: 11.5px; font-weight: 700; flex: none; }
.comp-bar { height: 7px; background: var(--line-2); border-radius: 4px; overflow: hidden; }
.comp-bar-fill { height: 100%; border-radius: 4px; transition: width .3s; }
.lvl-3 { color: var(--ok); } .lvl-3-bg { background: var(--ok); }
.lvl-2 { color: var(--brand); } .lvl-2-bg { background: var(--brand); }
.lvl-1 { color: var(--warn); } .lvl-1-bg { background: var(--accent); }
.lvl-0 { color: var(--muted); } .lvl-0-bg { background: var(--line); }

/* ---------- Modals ---------- */
.modal-scrim { position: fixed; inset: 0; background: rgba(16,42,54,.42); z-index: 60; display: flex; align-items: center; justify-content: center; padding: 20px; backdrop-filter: blur(2px); animation: fade .2s; }
.modal { background: var(--surface); border-radius: 16px; box-shadow: var(--shadow-lg); width: min(560px, 100%); max-height: 90vh; display: flex; flex-direction: column; animation: popIn .22s cubic-bezier(.2,.8,.2,1); }
.modal-lg { width: min(820px, 100%); }
@keyframes popIn { from { transform: scale(.96) translateY(8px); opacity: .4; } }
.modal-head { display: flex; align-items: center; justify-content: space-between; padding: 18px 22px; border-bottom: 1px solid var(--line-2); }
.modal-head h2 { font-size: 17px; }
.modal-body { padding: 20px 22px; overflow-y: auto; }
.modal-foot { display: flex; align-items: center; gap: 10px; padding: 14px 22px; border-top: 1px solid var(--line-2); }
.modal-foot .spacer { flex: 1; }

/* Stats */
.stat-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(120px, 1fr)); gap: 12px; margin-bottom: 22px; }
.stat-card { background: var(--surface-2); border: 1px solid var(--line-2); border-radius: var(--radius); padding: 14px 16px; }
.stat-card .num { font-size: 26px; font-weight: 800; color: var(--brand); line-height: 1; }
.stat-card .lbl { font-size: 12.5px; color: var(--muted); margin-top: 5px; font-weight: 600; }
.bar-chart { margin-bottom: 20px; }
.bar-chart h3 { font-size: 13px; color: var(--muted); text-transform: uppercase; letter-spacing: .04em; margin-bottom: 12px; }
.bar-row { display: grid; grid-template-columns: 120px 1fr 44px; align-items: center; gap: 10px; margin-bottom: 7px; font-size: 13px; }
.bar-row .bl { color: var(--ink-2); font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.bar-track { background: var(--line-2); border-radius: 5px; height: 20px; overflow: hidden; }
.bar-fill { height: 100%; border-radius: 5px; background: var(--brand); display: flex; align-items: center; }
.bar-row .bv { text-align: right; color: var(--muted); font-weight: 700; }

/* ---------- Plan feature ---------- */
.plan-count-badge { background: var(--accent); color: #fff; border-radius: 999px; font-size: 11px; min-width: 17px; height: 17px; display: inline-flex; align-items: center; justify-content: center; padding: 0 5px; font-weight: 700; }
.cc-foot-right { display: flex; align-items: center; gap: 8px; }
.plan-toggle { background: none; border: none; color: var(--muted); padding: 3px; border-radius: 6px; display: inline-flex; opacity: .5; transition: opacity .15s, color .15s, background .15s; cursor: pointer; }
.course-card:hover .plan-toggle { opacity: 1; }
.plan-toggle:hover { color: var(--brand); background: var(--brand-050); }
.plan-toggle.is-in { color: var(--brand); opacity: 1; }
.plan-toggle.is-in svg { fill: var(--brand); }
.plan-btn-hero { background: rgba(255,255,255,.16); border: none; color: #fff; border-radius: 8px; padding: 7px 12px; font-weight: 600; font-size: 13px; display: inline-flex; gap: 6px; align-items: center; cursor: pointer; }
.plan-btn-hero:hover { background: rgba(255,255,255,.3); }
.plan-btn-hero.is-in { background: #fff; color: var(--brand); }
.plan-btn-hero.is-in svg { fill: var(--brand); }
.plan-empty { text-align: center; color: var(--muted); padding: 44px 20px; font-size: 15px; line-height: 1.6; }
.plan-stat-grid { margin-bottom: 18px; }
.plan-grade { margin-bottom: 16px; }
.plan-grade-head { display: flex; align-items: center; gap: 10px; margin-bottom: 8px; }
.plan-grade-head .cnt { font-size: 12.5px; color: var(--muted); font-weight: 600; }
.plan-row { display: grid; grid-template-columns: 1fr auto auto auto; align-items: center; gap: 12px; padding: 8px 12px; border: 1px solid var(--line-2); border-radius: 8px; margin-bottom: 6px; background: var(--surface); }
.plan-row-name { font-size: 14px; font-weight: 600; color: var(--ink); min-width: 0; }
.plan-row-en { display: block; font-size: 11.5px; color: var(--muted); font-weight: 500; }
.plan-row-credit { font-size: 13px; color: var(--ink-2); font-weight: 600; white-space: nowrap; }
.plan-row .tag { white-space: nowrap; }
.plan-row-rm { background: none; border: none; color: var(--muted); font-size: 15px; width: 26px; height: 26px; border-radius: 6px; cursor: pointer; }
.plan-row-rm:hover { background: #fdf1f1; color: var(--danger); }

/* ---------- Dashboard heatmap & gaps ---------- */
.dash-block { margin-bottom: 24px; }
.dash-block h3 { font-size: 13px; color: var(--muted); text-transform: uppercase; letter-spacing: .04em; margin-bottom: 6px; }
.dash-desc { font-size: 12.5px; color: var(--muted); margin: 0 0 12px; line-height: 1.55; }
.heatmap-wrap { overflow-x: auto; }
.heatmap { border-collapse: collapse; width: 100%; min-width: 480px; }
.heatmap th, .heatmap td { border: 1px solid var(--line-2); padding: 7px 6px; text-align: center; font-size: 13px; }
.heatmap tr:first-child th { background: var(--surface-2); font-weight: 700; color: var(--ink-2); }
.heatmap .hm-rowh { text-align: left; font-weight: 600; color: var(--ink-2); white-space: nowrap; background: var(--surface-2); font-size: 12.5px; }
.heatmap .hm-dot { display: inline-block; width: 9px; height: 9px; border-radius: 50%; margin-right: 6px; vertical-align: middle; }
.hm-cell { font-weight: 700; font-variant-numeric: tabular-nums; }
.hm-total { font-weight: 800; color: var(--brand); background: var(--surface-2); }
.hm-corner { color: var(--muted) !important; }
.gap-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 6px; }
.gap-list li { font-size: 13.5px; color: var(--ink-2); display: flex; align-items: center; gap: 8px; }
.gap-list li b { color: var(--warn); }
.gap-dot { width: 9px; height: 9px; border-radius: 50%; flex: none; }

/* Edit form */
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.form-field { display: flex; flex-direction: column; gap: 5px; }
.form-field.full { grid-column: 1 / -1; }
.form-field label { font-size: 12.5px; font-weight: 700; color: var(--ink-2); }
.form-field input, .form-field select, .form-field textarea {
  padding: 9px 11px; border: 1px solid var(--line); border-radius: 8px; background: var(--surface); color: var(--ink); font-size: 14px; width: 100%;
}
.form-field input:focus, .form-field select:focus, .form-field textarea:focus { outline: none; border-color: var(--brand); box-shadow: 0 0 0 3px var(--brand-050); }
.form-field textarea { resize: vertical; min-height: 68px; line-height: 1.6; }
.form-sec-title { grid-column: 1/-1; font-size: 12px; text-transform: uppercase; letter-spacing: .05em; color: var(--brand); font-weight: 700; margin: 8px 0 -2px; padding-top: 10px; border-top: 1px solid var(--line-2); }
.comp-edit-row { display: grid; grid-template-columns: 1fr auto; gap: 10px; align-items: center; padding: 6px 0; border-bottom: 1px solid var(--line-2); }
.comp-edit-row .cl { font-size: 13px; color: var(--ink-2); }
.comp-edit-row .cl b { color: var(--ink); }
.weight-seg { display: inline-flex; border: 1px solid var(--line); border-radius: 7px; overflow: hidden; }
.weight-seg button { border: none; background: var(--surface); color: var(--muted); width: 30px; height: 30px; font-weight: 700; font-size: 13px; border-right: 1px solid var(--line-2); }
.weight-seg button:last-child { border-right: none; }
.weight-seg button.on { background: var(--brand); color: #fff; }
.prog-check { display: flex; gap: 14px; flex-wrap: wrap; }
.prog-check label { display: inline-flex; align-items: center; gap: 6px; font-size: 13px; font-weight: 600; color: var(--ink-2); }

/* ---------- Toast ---------- */
.toast { position: fixed; bottom: 24px; left: 50%; transform: translateX(-50%); background: var(--ink); color: #fff; padding: 11px 20px; border-radius: 10px; font-size: 14px; font-weight: 600; z-index: 90; box-shadow: var(--shadow-lg); animation: toastIn .25s; }
@keyframes toastIn { from { transform: translate(-50%, 12px); opacity: 0; } }

/* ---------- Footer ---------- */
.app-footer { text-align: center; padding: 22px; color: var(--muted); font-size: 13px; border-top: 1px solid var(--line); background: var(--surface); display: flex; align-items: center; justify-content: center; gap: 8px; flex-wrap: wrap; }
.foot-sep { opacity: .5; }

/* ---------- Responsive ---------- */
.filter-backdrop { display: none; }
@media (max-width: 900px) {
  .layout { grid-template-columns: 1fr; }
  .filters {
    position: fixed; top: 0; left: 0; bottom: 0; width: 300px; max-width: 88vw; border-radius: 0; z-index: 55;
    transform: translateX(-100%); transition: transform .25s; box-shadow: var(--shadow-lg);
  }
  .filters.open { transform: translateX(0); }
  .filter-scroll { max-height: none; height: calc(100vh - 56px); }
  .filter-backdrop.show { display: block; position: fixed; inset: 0; background: rgba(16,42,54,.4); z-index: 54; }
  .brand-text h1 { font-size: 17px; }
  .brand-sub { display: none; }
  .header-actions .btn span { display: none; }
  .header-actions .btn-lang span, .header-actions .btn-lang { display: inline-flex; }
  .edit-bar-hint { display: none; }
  .edit-active .controls, .controls { top: 60px; }
  .edit-active .filters { top: 0; }
}
@media (max-width: 560px) {
  .header-inner, .controls-inner, .layout, .edit-bar { padding-left: 14px; padding-right: 14px; }
  .comp-wrap { grid-template-columns: 1fr; }
  .radar-box { margin: 0 auto; }
  .form-grid { grid-template-columns: 1fr; }
  .d-title { font-size: 19px; }
  .control-buttons { width: 100%; justify-content: space-between; }
}

/* scrollbars */
.filter-scroll::-webkit-scrollbar, .drawer-body::-webkit-scrollbar, .modal-body::-webkit-scrollbar { width: 9px; }
.filter-scroll::-webkit-scrollbar-thumb, .drawer-body::-webkit-scrollbar-thumb, .modal-body::-webkit-scrollbar-thumb { background: var(--line); border-radius: 6px; border: 2px solid transparent; background-clip: content-box; }
.filter-scroll::-webkit-scrollbar-thumb:hover, .drawer-body::-webkit-scrollbar-thumb:hover { background: var(--muted); background-clip: content-box; }

[hidden] { display: none !important; }
