/* =========================================================================
   아이성장발달 관제 — Component styles
   ========================================================================= */

/* ============ APP SHELL ============ */
.app { display: flex; min-height: 100vh; }

/* ===== SIDEBAR ===== */
.sidebar {
  width: var(--sidebar-w);
  flex: 0 0 var(--sidebar-w);
  background: var(--surface);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  position: sticky;
  top: 0;
  height: 100vh;
  z-index: 5;
}
.sb-logo {
  display: flex; align-items: center; gap: 12px;
  padding: 0 20px; height: var(--topbar-h);
  border-bottom: 1px solid var(--border);
}
.sb-logo-mark {
  width: 36px; height: 36px;
  background: linear-gradient(135deg, var(--primary), #f2a978);
  border-radius: 12px;
  display: flex; align-items: center; justify-content: center;
  color: #fff;
  box-shadow: 0 4px 10px rgba(232, 128, 79, .25);
}
.sb-logo-t { font-family: var(--font-heading); font-weight: 700; font-size: 14px; letter-spacing: -0.01em; }
.sb-logo-v { font-size: 11px; color: var(--text-muted); margin-top: 2px; }

.sb-class {
  margin: 16px 12px 4px;
  padding: 12px 14px;
  background: var(--surface-tint);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  display: flex; align-items: center; gap: 10px;
  cursor: pointer;
  transition: background 150ms;
}
.sb-class:hover { background: var(--surface-hover); }
.sb-class .glyph {
  width: 36px; height: 36px; border-radius: 10px;
  background: var(--primary-soft);
  display: flex; align-items: center; justify-content: center;
  font-size: 18px;
}
.sb-class .meta { flex: 1; min-width: 0; }
.sb-class .meta .name { font-weight: 600; font-size: 13px; color: var(--text-primary); }
.sb-class .meta .sub { font-size: 11px; color: var(--text-muted); margin-top: 1px; }
.sb-class .chev { color: var(--text-muted); }

.sb-nav { flex: 1; padding: 12px 12px; overflow-y: auto; }
.sb-section {
  padding: 16px 12px 6px;
  font-size: 10px;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  font-weight: 600;
}
.sb-item {
  display: flex; align-items: center; gap: 12px;
  padding: 9px 12px;
  border-radius: 10px;
  color: var(--text-secondary);
  font-size: 13px;
  font-weight: 500;
  margin-bottom: 2px;
  cursor: pointer;
  transition: background 150ms, color 150ms;
  position: relative;
}
.sb-item:hover { background: var(--surface-hover); color: var(--text-primary); }
.sb-item.active {
  background: var(--primary-soft);
  color: var(--primary);
}
.sb-item.active::before {
  content: '';
  position: absolute; left: -12px; top: 8px; bottom: 8px;
  width: 3px; border-radius: 0 3px 3px 0;
  background: var(--primary);
}
.sb-item svg { width: 18px; height: 18px; flex: 0 0 auto; }
.sb-item .count {
  margin-left: auto;
  font-size: 11px; font-weight: 600;
  background: var(--surface-hover);
  color: var(--text-secondary);
  padding: 1px 7px;
  border-radius: 999px;
}
.sb-item.active .count {
  background: rgba(232,128,79,.18);
  color: var(--primary);
}

.sb-foot {
  border-top: 1px solid var(--border);
  padding: 14px 16px;
  display: flex; align-items: center; gap: 12px;
}
.sb-avatar {
  width: 36px; height: 36px; border-radius: 999px;
  background: var(--primary-soft); color: var(--primary);
  display: flex; align-items: center; justify-content: center;
  font-weight: 700; font-size: 13px;
}
.sb-foot .name { font-size: 13px; font-weight: 600; }
.sb-foot .role { font-size: 11px; color: var(--text-muted); }

/* ===== MAIN ===== */
.main { flex: 1; min-width: 0; }
.topbar {
  position: sticky; top: 0; z-index: 4;
  height: var(--topbar-h);
  background: rgba(247, 243, 236, .88);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border);
  display: flex; align-items: center; justify-content: space-between;
  padding: 0 24px;
}
.crumbs { display: flex; align-items: center; gap: 8px; font-size: 13px; color: var(--text-muted); }
.crumbs .sep { color: var(--text-muted); }
.crumbs .cur { color: var(--text-primary); font-weight: 600; }

.tb-actions { display: flex; align-items: center; gap: 8px; }
.search {
  position: relative; width: 320px; max-width: 32vw;
}
.search svg {
  position: absolute; left: 12px; top: 50%; transform: translateY(-50%);
  width: 16px; height: 16px; color: var(--text-muted);
}
.search input {
  width: 100%;
  background: var(--surface);
  border: 1px solid var(--border);
  color: var(--text-primary);
  font-size: 13px;
  padding: 8px 12px 8px 36px;
  border-radius: 10px;
}
.search input:focus { outline: none; border-color: var(--primary); box-shadow: 0 0 0 3px var(--primary-ring); }

.btn-icon {
  width: 36px; height: 36px;
  border-radius: 10px;
  color: var(--text-secondary);
  display: inline-flex; align-items: center; justify-content: center;
  position: relative;
}
.btn-icon:hover { background: var(--surface-hover); color: var(--text-primary); }
.btn-icon .dot-alert {
  position: absolute; top: 8px; right: 8px;
  width: 8px; height: 8px;
  background: var(--danger);
  border-radius: 999px;
  border: 2px solid var(--surface);
}

/* ===== PAGE ===== */
.page {
  padding: 24px 28px 48px;
  max-width: var(--container-max);
}
.page-h {
  display: flex; justify-content: space-between; align-items: flex-start;
  gap: 24px;
  margin-bottom: 24px;
  flex-wrap: wrap;
}
.page-h .l { min-width: 0; }
.page-h h1 { display: flex; align-items: center; gap: 12px; }
.page-h .desc { color: var(--text-secondary); font-size: 13px; margin-top: 6px; max-width: 640px; }
.page-h .r { display: flex; gap: 8px; align-items: center; flex-shrink: 0; }

/* ===== CARDS ===== */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 20px;
}
.card.flat { box-shadow: var(--shadow-sm); }
.card-h {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 16px;
}
.card-t {
  font-family: var(--font-heading);
  font-weight: 600;
  font-size: 15px;
  display: flex; align-items: center; gap: 8px;
}
.card-t .ico {
  width: 28px; height: 28px;
  border-radius: 8px;
  background: var(--primary-soft); color: var(--primary);
  display: flex; align-items: center; justify-content: center;
}
.card-t .ico svg { width: 16px; height: 16px; }
.card-sub { font-size: 12px; color: var(--text-muted); }

/* ===== GRIDS ===== */
.grid-2 { display: grid; grid-template-columns: repeat(2, 1fr); gap: 16px; }
.grid-3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 16px; }
.grid-4 { display: grid; grid-template-columns: repeat(4, 1fr); gap: 16px; }
.grid-12 { display: grid; grid-template-columns: repeat(12, 1fr); gap: 16px; }
@media (max-width: 1180px) {
  .grid-4 { grid-template-columns: repeat(2, 1fr); }
  .grid-3 { grid-template-columns: 1fr; }
}

/* ===== KPI ===== */
.kpi { display: flex; flex-direction: column; gap: 6px; }
.kpi-h { display: flex; align-items: center; justify-content: space-between; }
.kpi-ico {
  width: 36px; height: 36px;
  border-radius: 10px;
  display: flex; align-items: center; justify-content: center;
}
.kpi-ico svg { width: 18px; height: 18px; }
.kpi-lbl { color: var(--text-secondary); font-size: 13px; font-weight: 500; }
.kpi-val { font-family: var(--font-heading); font-size: 28px; font-weight: 700; line-height: 1.1; color: var(--text-primary); }
.kpi-sub { color: var(--text-muted); font-size: 11px; display: flex; align-items: center; gap: 4px; }
.kpi-trend { font-size: 11px; font-weight: 600; padding: 2px 6px; border-radius: 6px; }
.kpi-trend.up { background: rgba(95,179,126,.14); color: var(--success); }
.kpi-trend.down { background: rgba(217,105,97,.14); color: var(--danger); }
.kpi-trend.flat { background: var(--surface-hover); color: var(--text-secondary); }

/* ===== BUTTONS ===== */
.btn {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 8px 14px;
  border-radius: 10px;
  font-weight: 600; font-size: 13px;
  transition: all 150ms var(--ease);
  border: 1px solid transparent;
}
.btn svg { width: 16px; height: 16px; }
.btn-primary { background: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-hover); }
.btn-secondary { background: var(--surface); border-color: var(--border); color: var(--text-primary); }
.btn-secondary:hover { background: var(--surface-hover); }
.btn-ghost { color: var(--text-secondary); }
.btn-ghost:hover { background: var(--surface-hover); color: var(--text-primary); }
.btn-danger { background: rgba(217,105,97,.10); color: var(--danger); }
.btn-danger:hover { background: rgba(217,105,97,.18); }
.btn-soft { background: var(--primary-soft); color: var(--primary); }
.btn-soft:hover { background: rgba(232,128,79,.18); }
.btn-sm { padding: 5px 10px; font-size: 12px; }

/* ===== BADGES ===== */
.badge {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 3px 10px;
  border-radius: 999px;
  font-size: 11px; font-weight: 600;
}
.dot { width: 6px; height: 6px; border-radius: 999px; flex: 0 0 auto; }
.badge-good   { background: rgba(95,179,126,.14); color: #3f8757; }
.badge-watch  { background: rgba(232,168,56,.16); color: #a67318; }
.badge-care   { background: rgba(217,105,97,.14); color: #a64c46; }
.badge-rest   { background: rgba(163,154,140,.18); color: var(--text-secondary); }
.badge-new    { background: rgba(181,139,209,.16); color: #7c5fa1; }
.badge-info   { background: rgba(111,168,214,.16); color: #4982b3; }

.pulse { animation: pulseDim 2s infinite; }
@keyframes pulseDim { 0%, 100% { opacity: 1; } 50% { opacity: .35; } }

/* ===== CHIPS ===== */
.chips { display: flex; gap: 6px; flex-wrap: wrap; }
.chip {
  padding: 6px 12px;
  border-radius: 10px;
  font-size: 13px; font-weight: 500;
  color: var(--text-secondary);
  background: transparent;
  border: 1px solid transparent;
  transition: all 150ms;
}
.chip:hover { background: var(--surface-hover); }
.chip.active {
  background: var(--primary-soft);
  color: var(--primary);
  border-color: rgba(232,128,79,.25);
}
.chip-tone {
  padding: 6px 12px;
  border-radius: 999px;
  background: var(--surface-tint);
  border: 1px solid var(--border);
  font-size: 12px;
  color: var(--text-secondary);
}
.chip-tone.on {
  background: var(--primary);
  color: #fff;
  border-color: var(--primary);
}

/* ===== TABLE ===== */
.table-card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-lg); overflow: hidden; }
table { width: 100%; border-collapse: collapse; }
th {
  text-align: left;
  padding: 12px 16px;
  font-size: 11px;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: .05em;
  font-weight: 600;
  border-bottom: 1px solid var(--border);
  background: var(--surface-tint);
}
td {
  padding: 14px 16px;
  border-bottom: 1px solid var(--border);
  font-size: 13px;
  color: var(--text-secondary);
}
tr:last-child td { border-bottom: 0; }
tr.row-h:hover td { background: var(--surface-hover); }
.n { color: var(--text-primary); font-weight: 600; }
.id { font-family: var(--font-mono); font-size: 11px; color: var(--text-muted); }

/* ===== INPUTS ===== */
label { display: block; font-size: 13px; color: var(--text-secondary); margin-bottom: 6px; font-weight: 500; }
.input, .select, textarea.input {
  width: 100%;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 9px 12px;
  color: var(--text-primary);
  font-size: 14px;
  transition: border-color 150ms, box-shadow 150ms;
}
.input:focus, .select:focus, textarea.input:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px var(--primary-ring);
}
textarea.input { resize: vertical; min-height: 80px; }

/* ===== MODAL ===== */
.modal-backdrop {
  position: fixed; inset: 0;
  background: rgba(43,39,34,.32);
  z-index: 80;
  display: flex; align-items: center; justify-content: center;
  padding: 24px;
  animation: fadeIn 150ms ease-out;
}
.modal {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-xl);
  max-width: 560px;
  width: 100%;
  max-height: 90vh;
  display: flex; flex-direction: column;
  animation: popIn 180ms cubic-bezier(.18,.89,.32,1.28);
}
.modal.lg { max-width: 720px; }
.modal-h {
  display: flex; align-items: center; justify-content: space-between;
  padding: 18px 22px;
  border-bottom: 1px solid var(--border);
}
.modal-h h3 { margin: 0; font-size: 16px; font-weight: 600; }
.modal-b { padding: 20px 22px; overflow: auto; flex: 1; }
.modal-f { padding: 14px 22px; border-top: 1px solid var(--border); display: flex; gap: 10px; justify-content: flex-end; }
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }
@keyframes popIn { from { opacity: 0; transform: translateY(8px) scale(.98); } to { opacity: 1; transform: none; } }

/* ===== TOAST ===== */
.toast {
  position: fixed; top: 80px; right: 24px;
  z-index: 100;
  display: flex; flex-direction: column; gap: 8px;
  max-width: 360px;
}
.toast-item {
  display: flex; align-items: flex-start; gap: 12px;
  padding: 12px 14px;
  border-radius: var(--radius-lg);
  background: var(--surface);
  border: 1px solid var(--border);
  box-shadow: var(--shadow-lg);
  font-size: 13px;
  animation: slideIn 200ms ease-out;
}
.toast-item.success { background: #f0f8f3; border-color: rgba(95,179,126,.3); }
.toast-item.warning { background: #fdf6e8; border-color: rgba(232,168,56,.3); }
.toast-item.error   { background: #fdf0ee; border-color: rgba(217,105,97,.3); }
@keyframes slideIn { from { transform: translateX(16px); opacity: 0; } to { transform: none; opacity: 1; } }

/* ===== CHILD AVATAR ===== */
.avatar {
  width: 44px; height: 44px;
  border-radius: 999px;
  background: var(--primary-soft);
  color: var(--primary);
  display: inline-flex; align-items: center; justify-content: center;
  font-weight: 700;
  flex: 0 0 auto;
  position: relative;
  font-size: 14px;
}
.avatar.lg { width: 60px; height: 60px; font-size: 18px; }
.avatar.sm { width: 28px; height: 28px; font-size: 11px; }
.avatar .badge-corner {
  position: absolute; bottom: -2px; right: -2px;
  width: 14px; height: 14px;
  border-radius: 999px;
  background: var(--success);
  border: 2px solid var(--surface);
}
.avatar .badge-corner.watch { background: var(--warning); }
.avatar .badge-corner.care { background: var(--danger); }
.avatar .badge-corner.rest { background: var(--text-muted); }

/* avatar color variants — child name initial colors */
.av-1 { background: rgba(232,128,79,.18); color: #c46a3e; }
.av-2 { background: rgba(95,179,126,.18); color: #3f8757; }
.av-3 { background: rgba(240,198,86,.22); color: #946a0c; }
.av-4 { background: rgba(181,139,209,.22); color: #7c5fa1; }
.av-5 { background: rgba(111,183,201,.22); color: #3e8398; }
.av-6 { background: rgba(222,138,138,.22); color: #a64c46; }
.av-7 { background: rgba(136,196,168,.25); color: #4a8068; }
.av-8 { background: rgba(242,169,120,.22); color: #b46732; }

/* ===== CHILD CARD ===== */
.child-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 16px;
  transition: all 150ms;
  cursor: pointer;
  display: flex; flex-direction: column; gap: 12px;
}
.child-card:hover {
  border-color: var(--border-light);
  box-shadow: var(--shadow);
  transform: translateY(-1px);
}
.child-card .top { display: flex; align-items: flex-start; gap: 12px; }
.child-card .info { flex: 1; min-width: 0; }
.child-card .name { font-weight: 600; font-size: 14px; color: var(--text-primary); }
.child-card .meta { font-size: 11px; color: var(--text-muted); margin-top: 2px; }
.child-card .stats {
  display: grid; grid-template-columns: repeat(3, 1fr);
  gap: 4px;
  padding-top: 10px;
  border-top: 1px dashed var(--border);
}
.child-card .stat .k { font-size: 10px; color: var(--text-muted); text-transform: uppercase; letter-spacing: .04em; font-weight: 600; }
.child-card .stat .v { font-family: var(--font-heading); font-weight: 700; font-size: 14px; color: var(--text-primary); margin-top: 2px; }
.child-card .stat .v .unit { color: var(--text-muted); font-size: 10px; font-weight: 500; margin-left: 2px; }
.child-card .bottom { display: flex; align-items: center; justify-content: space-between; gap: 8px; }

/* ===== STATUS DOT ===== */
.s-dot { width: 8px; height: 8px; border-radius: 999px; display: inline-block; flex: 0 0 auto; }
.s-good { background: var(--success); }
.s-watch { background: var(--warning); }
.s-care { background: var(--danger); }
.s-rest { background: var(--text-muted); }
.s-new { background: #b58bd1; }

/* ===== ALERT ROWS ===== */
.alert-row {
  display: flex; align-items: flex-start; gap: 12px;
  padding: 12px 14px;
  border-radius: 12px;
  border: 1px solid var(--border);
  background: var(--surface-tint);
  transition: background 150ms;
  cursor: pointer;
}
.alert-row:hover { background: var(--surface-hover); }
.alert-row.care { background: rgba(217,105,97,.06); border-color: rgba(217,105,97,.25); }
.alert-row.watch { background: rgba(232,168,56,.07); border-color: rgba(232,168,56,.25); }
.alert-row.info { background: rgba(111,168,214,.07); border-color: rgba(111,168,214,.25); }
.alert-row .ico {
  width: 36px; height: 36px;
  border-radius: 10px;
  display: flex; align-items: center; justify-content: center;
  flex: 0 0 auto;
}
.alert-row.care .ico { background: rgba(217,105,97,.15); color: var(--danger); }
.alert-row.watch .ico { background: rgba(232,168,56,.18); color: var(--warning); }
.alert-row.info .ico { background: rgba(111,168,214,.16); color: var(--info); }
.alert-row .body { flex: 1; min-width: 0; }
.alert-row .title { font-weight: 600; color: var(--text-primary); font-size: 13px; }
.alert-row .sub { font-size: 12px; color: var(--text-secondary); margin-top: 2px; }
.alert-row .time { font-size: 11px; color: var(--text-muted); white-space: nowrap; }

/* ===== EMPTY / DIVIDER ===== */
.divider-soft { height: 1px; background: var(--border); margin: 16px 0; }

/* ===== PROGRESS ===== */
.progress {
  height: 6px; width: 100%;
  background: var(--surface-hover);
  border-radius: 999px;
  overflow: hidden;
}
.progress > span {
  display: block; height: 100%;
  background: var(--primary);
  border-radius: 999px;
  transition: width 300ms var(--ease);
}
.progress.success > span { background: var(--success); }
.progress.warning > span { background: var(--warning); }
.progress.danger  > span { background: var(--danger); }

/* ===== CHECKBOX ===== */
.chk {
  display: inline-flex; align-items: center; justify-content: center;
  width: 18px; height: 18px;
  border: 1.5px solid var(--border-light);
  border-radius: 6px;
  background: var(--surface);
  cursor: pointer;
  transition: all 150ms;
  flex: 0 0 auto;
}
.chk.on {
  background: var(--success);
  border-color: var(--success);
  color: #fff;
}
.chk svg { width: 12px; height: 12px; opacity: 0; }
.chk.on svg { opacity: 1; }

/* ===== TIMELINE ===== */
.timeline { position: relative; padding-left: 28px; }
.timeline::before {
  content: '';
  position: absolute; left: 9px; top: 6px; bottom: 6px;
  width: 2px;
  background: var(--border);
}
.tl-item { position: relative; padding-bottom: 18px; }
.tl-item::before {
  content: '';
  position: absolute; left: -23px; top: 6px;
  width: 12px; height: 12px;
  border-radius: 999px;
  background: var(--surface);
  border: 2px solid var(--primary);
}
.tl-item.dim::before { border-color: var(--border-light); }
.tl-item .time { font-size: 11px; color: var(--text-muted); font-family: var(--font-mono); }
.tl-item .title { font-weight: 600; color: var(--text-primary); font-size: 13px; margin-top: 2px; }
.tl-item .sub { font-size: 12px; color: var(--text-secondary); margin-top: 2px; }

/* ===== MOOD CHIP ===== */
.mood {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 4px 10px;
  border-radius: 999px;
  font-size: 12px; font-weight: 600;
  background: var(--surface-tint);
}
.mood .emoji { font-size: 13px; line-height: 1; }
.mood.happy   { background: rgba(240,198,86,.18); color: #946a0c; }
.mood.calm    { background: rgba(136,196,168,.22); color: #4a8068; }
.mood.tired   { background: rgba(182,174,192,.28); color: #6b6680; }
.mood.upset   { background: rgba(222,138,138,.22); color: #a64c46; }
.mood.curious { background: rgba(242,169,120,.22); color: #b46732; }
