/* Home */
#view-home {
  margin: -12px 0 0;
  padding: 20px 20px 0;
  height: calc(100vh - 56px - 28px);
  overflow: hidden;
}
#view-home.is-visible { display: flex; flex-direction: column; }

.home-grid {
  flex: 1;
  min-height: 0;
  display: grid;
  grid-template-columns: repeat(48, 1fr);
  grid-template-rows: auto auto minmax(0, 1fr) auto;
  gap: 12px;
  overflow: hidden;
}

/* Hero greeting */
.home-hero-greet {
  grid-column: 1 / -1;
  grid-row: 1;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 18px 22px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
}
.home-hero-greet__title {
  display: block;
  font-size: 18px;
  font-weight: 700;
  color: var(--text);
  letter-spacing: -0.2px;
}
.home-hero-greet__sub {
  margin: 4px 0 0;
  font-size: 13px;
  color: var(--text-muted);
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
}
.home-hero-greet__hot { color: var(--accent); font-weight: 600; }
.home-hero-greet__dot { color: var(--border); }
.home-quick-actions { display: flex; gap: 8px; flex-shrink: 0; }
.home-quick-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 9px 14px;
  border-radius: 8px;
  border: 1px solid var(--accent);
  background: var(--accent);
  color: #fff;
  font-size: 13px;
  font-weight: 600;
  font-family: inherit;
  cursor: pointer;
  transition: background 0.15s, transform 0.15s, box-shadow 0.15s;
}
.home-quick-btn:hover { background: var(--accent-hover); transform: translateY(-1px); box-shadow: var(--shadow-card); }
.home-quick-btn--ghost { background: var(--surface); color: var(--accent); }
.home-quick-btn--ghost:hover { background: var(--accent-soft); }
.home-quick-btn__ico { font-size: 15px; line-height: 1; }

/* KPI cards */
.home-kpi-row { grid-column: 1 / -1; grid-row: 2; display: grid; grid-template-columns: repeat(4, 1fr); gap: 12px; }
@media (max-width: 1100px) { .home-kpi-row { grid-template-columns: repeat(2, 1fr); } }

.kpi-card { padding: 14px 16px; display: flex; flex-direction: column; gap: 2px; }
.kpi-card__head { display: flex; align-items: center; gap: 8px; }
.kpi-card__svg {
  width: 16px;
  height: 16px;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}
.kpi-card__ico {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  border-radius: 8px;
  font-size: 14px;
  background: var(--accent-soft);
  color: var(--accent);
  flex-shrink: 0;
}
html[data-brand="abl"] .kpi-card__ico {
  background: #ead9c4;
  color: #8b6f47;
}
.kpi-card .lbl { font-size: 14px; color: var(--text); font-weight: 700; }
.kpi-card .num { font-size: 26px; font-weight: 700; color: var(--text); line-height: 1.1; margin-top: 8px; }
.kpi-card .sub { font-size: 11px; color: var(--text-muted); margin-top: 4px; }
.kpi-card .trend { font-weight: 600; color: var(--text); }
.kpi-card .trend--up { color: var(--success); }
.kpi-card .trend--down { color: var(--danger); }
.kpi-card .trend--flat { color: var(--text-muted); }
.mini-bar {
  display: flex;
  align-items: flex-end;
  gap: 3px;
  height: 28px;
  margin-top: 6px;
}
.mini-bar span {
  flex: 1;
  border-radius: 2px;
  background: var(--border);
  min-width: 4px;
}
.mini-bar span.on { background: var(--accent); opacity: 0.55; }
html[data-brand="abl"] .mini-bar span.on { background: #b8956b; }

/* Common card head */
.home-card-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 12px;
}
.home-card-head strong { font-size: 14px; color: var(--text); }
.home-card-head__sub { font-size: 12px; color: var(--text-muted); margin: 0; }
.home-card-head__more { font-size: 12px; color: var(--accent); cursor: pointer; }

/* Priority list (row 3 좌측 18트랙 — KPI 2 중앙까지) */
.home-priority {
  grid-column: 1 / 19; grid-row: 3;
  padding: 14px 16px;
  display: flex; flex-direction: column;
  min-height: 0; overflow: hidden;
}
.home-priority-list {
  list-style: none; margin: 0; padding: 0;
  display: flex; flex-direction: column; gap: 6px;
  flex: 1; min-height: 0; overflow-y: auto;
}
.home-priority-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--surface);
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s, transform 0.15s;
}
.home-priority-item:hover {
  background: var(--accent-soft);
  border-color: var(--accent-border-subtle);
  transform: translateX(2px);
}
.home-priority-item.is-disabled { cursor: not-allowed; opacity: 0.65; }
.home-priority-item.is-disabled:hover {
  background: var(--surface);
  border-color: var(--border);
  transform: none;
}
.home-priority-item__ico {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: var(--accent-soft);
  color: var(--accent);
  flex-shrink: 0;
  font-size: 16px;
}
.home-priority-item--danger .home-priority-item__ico { background: rgba(240,68,82,0.12); color: var(--danger); }
.home-priority-item--warn .home-priority-item__ico { background: rgba(217,119,6,0.12); color: var(--viz-amber); }
.home-priority-item--info .home-priority-item__ico { background: rgba(13,148,136,0.12); color: var(--viz-teal); }
.home-priority-item__body { flex: 1; min-width: 0; }
.home-priority-item__name { margin: 0; font-size: 13px; font-weight: 600; color: var(--text); }
.home-priority-item__meta { font-weight: 400; color: var(--text-muted); }
.home-priority-item__reason { margin: 2px 0 0; font-size: 12px; color: var(--text-muted); }
.home-priority-item__chev { color: var(--text-muted); display: inline-flex; align-items: center; flex-shrink: 0; }
.home-priority-item__lock { display: inline-flex; align-items: center; flex-shrink: 0; opacity: 0.6; color: var(--text-muted); }
.home-priority-item__svg {
  width: 16px;
  height: 16px;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}
.home-priority-item__svg--sm { width: 14px; height: 14px; }

/* Schedule (row 3 중앙 18트랙 — priority와 동일 너비) */
.home-schedule {
  grid-column: 19 / 37; grid-row: 3;
  padding: 14px 16px;
  display: flex; flex-direction: column;
  min-height: 0; overflow: hidden;
}
.home-schedule-list { list-style: none; margin: 12px 0 0; padding: 0; display: flex; flex-direction: column; gap: 6px; }
.home-schedule-list li {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 12px;
  border-radius: 6px;
  background: var(--bg-app);
  font-size: 13px;
}
.home-schedule-list__time { font-weight: 700; color: var(--text); min-width: 42px; font-variant-numeric: tabular-nums; }
.home-schedule-list__text { color: var(--text); flex: 1; min-width: 0; }
.home-schedule-list__tag {
  font-size: 11px;
  font-weight: 600;
  padding: 3px 10px;
  border-radius: 999px;
  flex-shrink: 0;
  letter-spacing: -0.2px;
}
.home-schedule-list__tag--consult { background: var(--accent-soft); color: var(--accent); }
html[data-brand="abl"] .home-schedule-list__tag--consult { background: #ead9c4; color: #8b6f47; }
.home-schedule-list__tag--visit { background: rgba(13,148,136,0.12); color: var(--viz-teal); }
.home-schedule-list__tag--call { background: rgba(225,29,72,0.12); color: var(--viz-rose); }
.home-schedule-list__tag--due { background: rgba(217,119,6,0.12); color: var(--viz-amber); }
.home-schedule-badge {
  font-size: 11px;
  color: var(--text-muted);
  background: var(--bg-app);
  padding: 4px 12px;
  border-radius: 999px;
  font-weight: 500;
  white-space: nowrap;
}
.home-schedule-foot { margin: 10px 0 0; font-size: 12px; color: var(--text-muted); }

.week-nav { display: flex; align-items: center; gap: 6px; margin-top: 8px; }
.week-nav__btn {
  flex-shrink: 0; width: 26px; height: 26px; border-radius: 8px;
  border: 1px solid var(--border); background: var(--surface);
  cursor: pointer; color: var(--text-muted); font-size: 18px; line-height: 1;
  display: flex; align-items: center; justify-content: center; padding: 0;
}
.week-nav__btn:hover { background: var(--accent-soft); color: var(--accent); border-color: var(--accent); }
.week-strip { display: flex; gap: 4px; flex: 1; flex-wrap: nowrap; }
.day-pill {
  flex: 1; padding: 6px 0; border-radius: 8px;
  border: 1px solid var(--border); font-size: 11px; cursor: pointer;
  text-align: center; background: none; font-family: inherit; color: var(--text);
}
.day-pill.is-today { border-color: var(--accent); background: var(--accent-soft); color: var(--accent); font-weight: 600; }

/* Channel progress (row 4 좌측 27트랙 — schedule 중앙까지) */
.home-channel { grid-column: 1 / 28; grid-row: 4; padding: 14px 16px; }
.home-channel-progress { display: flex; flex-direction: column; gap: 14px; }
.home-channel-row__top {
  display: flex;
  justify-content: space-between;
  font-size: 12px;
  color: var(--text-muted);
  margin-bottom: 6px;
}
.home-channel-row__label { font-weight: 600; color: var(--text); font-size: 13px; }
.home-channel-row__num { font-variant-numeric: tabular-nums; }
.home-channel-row__pct { color: var(--accent); font-weight: 600; margin-left: 4px; }
.home-channel-row__track { height: 8px; background: var(--bg-app); border-radius: 999px; overflow: hidden; }
.home-channel-row__fill { height: 100%; border-radius: 999px; transition: width 0.4s ease; }
.home-channel-row__fill--ok { background: #5B9BF5; }
.home-channel-row__fill--warn { background: #EAB308; }
.home-channel-row__fill--danger { background: #F87171; }
html[data-brand="abl"] .home-channel-row__fill--ok { background: #b8956b; }
html[data-brand="abl"] .home-channel-row__fill--warn { background: #c79555; }
html[data-brand="abl"] .home-channel-row__fill--danger { background: #b91c1c; }

/* April summary (row 4 우측 21트랙) */
.home-april { grid-column: 28 / -1; grid-row: 4; padding: 14px 16px; }
.home-april-table { width: 100%; border-collapse: collapse; font-size: 13px; }
.home-april-table td { padding: 9px 0; border-bottom: 1px solid var(--border); }
.home-april-table tr:last-child td { border-bottom: none; }
.home-april-table .num-em { font-weight: 700; color: var(--accent); text-align: right; padding-right: 12px; font-variant-numeric: tabular-nums; }
.home-april-table .trend { text-align: right; font-size: 12px; font-weight: 600; }
.home-april-table .trend--up { color: var(--success); }
.home-april-table .trend--flat { color: var(--text-muted); }

/* Notice (row 3 우측 12트랙) */
.home-notice {
  grid-column: 37 / -1; grid-row: 3;
  padding: 14px 16px;
  display: flex; flex-direction: column;
  min-height: 0; overflow: hidden;
}
.notice-list { margin: 0; padding: 0; list-style: none; font-size: 13px; flex: 1; min-height: 0; overflow-y: auto; }
.notice-list li {
  padding: 9px 0;
  border-bottom: 1px solid var(--border);
  display: flex;
  justify-content: space-between;
  gap: 8px;
  align-items: center;
}
.notice-list li:last-child { border-bottom: none; }
.notice-list a { color: var(--accent); text-decoration: none; }
.notice-list__date { color: var(--text-muted); font-size: 12px; flex-shrink: 0; }

/* 반응형 */
@media (max-width: 960px) {
  #view-home { height: auto; overflow: visible; }
  .home-grid { grid-template-rows: auto; overflow: visible; }
  .home-priority, .home-schedule, .home-notice, .home-channel, .home-april {
    grid-column: 1 / -1; grid-row: auto; overflow: visible;
  }
  .home-priority-list, .notice-list { overflow: visible; }
  .home-hero-greet { flex-direction: column; align-items: flex-start; }
  .home-quick-actions { width: 100%; }
  .home-quick-btn { flex: 1; justify-content: center; }
}

/* === Legacy home layout (Insurance 토글 OFF) === */
#view-home.home-legacy { margin: -12px 0 0; padding: 20px 20px 0; height: auto; overflow: visible; }
#view-home.home-legacy.is-visible { display: block; }
.home-legacy .home-grid {
  display: grid;
  grid-template-columns: repeat(12, 1fr);
  grid-template-rows: none;
  gap: 10px;
  flex: none;
  min-height: auto;
  overflow: visible;
}
.home-legacy .home-kpi-row {
  grid-column: 1 / -1;
  grid-row: auto;
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 10px;
}
.home-legacy .home-hero-row {
  grid-column: 1 / -1;
  display: grid;
  grid-template-columns: 1fr 1.2fr;
  gap: 12px;
}
.home-legacy .home-hero-banner {
  min-height: 160px;
  border-radius: var(--radius);
  background: linear-gradient(135deg, #e8f3ff 0%, #fff 50%, #f0f4f8 100%);
  border: 1px solid var(--border);
  padding: 20px;
  display: flex; flex-direction: column; justify-content: center;
  background-image: url("https://images.unsplash.com/photo-1507525428034-b723cf961d3e?w=800&q=80");
  background-size: cover;
  background-position: center;
}
.home-legacy .home-hero-banner .hero-inner {
  background: rgba(255,255,255,.88);
  padding: 14px 16px;
  border-radius: 8px;
  max-width: 90%;
}
.home-legacy .home-mid-row {
  grid-column: 1 / -1;
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 10px;
}
@media (max-width: 1100px) {
  .home-legacy .home-mid-row { grid-template-columns: repeat(3, 1fr); }
  .home-legacy .home-hero-row { grid-template-columns: 1fr; }
}
@media (max-width: 640px) {
  .home-legacy .home-mid-row { grid-template-columns: repeat(2, 1fr); }
}
.home-legacy .home-mid-stat {
  padding: 10px;
  text-align: center;
  font-size: 11px;
  color: var(--text-muted);
}
.home-legacy .home-mid-stat strong {
  display: block;
  font-size: 16px;
  color: var(--text);
  margin-top: 3px;
}
.home-legacy .home-perf-table {
  grid-column: 1 / -1;
  overflow: auto;
}
.home-legacy .home-perf-table table {
  width: 100%;
  font-size: 13px;
  border-collapse: collapse;
}
.home-legacy .home-perf-table th,
.home-legacy .home-perf-table td {
  padding: 7px 12px;
  border-bottom: 1px solid var(--border);
  text-align: left;
}
.home-legacy .home-perf-table th {
  background: var(--bg-app);
  color: var(--text-muted);
  font-size: 12px;
}
.home-legacy .home-perf-table .num-em {
  font-weight: 700;
  color: var(--accent);
}
.home-legacy .home-schedule {
  grid-column: 1 / 8;
  grid-row: auto;
  padding: 12px;
  display: flex;
  flex-direction: column;
  max-height: 260px;
  overflow: hidden;
}
.home-legacy .home-notice {
  grid-column: 8 / -1;
  grid-row: auto;
  padding: 12px;
  display: flex;
  flex-direction: column;
  max-height: 260px;
  overflow: hidden;
}
.home-legacy .notice-list { overflow-y: auto; flex: 1; min-height: 0; }
.home-legacy .mini-bar span { background: var(--accent); opacity: 0.55; }
html[data-brand="abl"] .home-legacy .mini-bar span { background: #b8956b; }
