* { box-sizing: border-box; }
body { margin: 0; font-family: -apple-system, "Segoe UI", "Malgun Gothic", sans-serif; background: #f0f2f5; color: #222; }
body.center { display: flex; align-items: center; justify-content: center; min-height: 100vh; }
a { color: #3b5bdb; text-decoration: none; }
.muted { color: #777; font-size: 13px; }
.error { color: #c33; font-size: 13px; }
.note { color: #b36b00; font-size: 12px; margin-bottom: 4px; }
.center { text-align: center; }

.toolbar { background: #fff; border-bottom: 1px solid #ddd; padding: 8px 16px; display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.toolbar h1 { font-size: 17px; margin: 0 8px 0 0; }
.toolbar .label { color: #666; font-size: 13px; }
.toolbar .spacer, .spacer { flex: 1; }
button, select, input { font: inherit; font-size: 13px; }
button { padding: 5px 11px; border: 1px solid #ccc; border-radius: 6px; background: #fafafa; cursor: pointer; }
button:hover { background: #eee; }
button.primary { background: #3b5bdb; color: #fff; border-color: #3b5bdb; }
select, input[type=text], input[type=email], input[type=password], input:not([type]) { padding: 5px 8px; border: 1px solid #ccc; border-radius: 6px; }
#add-buttons { display: inline-flex; gap: 4px; }
.status { font-size: 12px; color: #888; }

main { padding: 16px; }
.card { background: #fff; border: 1px solid #ddd; border-radius: 10px; padding: 20px; }
.card.login { width: 360px; display: flex; flex-direction: column; gap: 10px; }
.card.login input { width: 100%; }
.admin { display: grid; gap: 16px; max-width: 1100px; }
.admin table { width: 100%; border-collapse: collapse; font-size: 13px; margin-top: 10px; }
.admin th, .admin td { padding: 6px 8px; border-bottom: 1px solid #eee; text-align: left; }
#invite { display: flex; gap: 6px; }

/* 위젯 */
.grid-stack-item-content { background: #fff; border: 1px solid #ddd; border-radius: 8px; box-shadow: 0 1px 3px rgba(0,0,0,.06); display: flex; flex-direction: column; overflow: hidden; }
.widget-header { display: flex; align-items: center; gap: 8px; padding: 6px 10px; border-bottom: 1px solid #eee; font-size: 13px; font-weight: 600; cursor: move; user-select: none; }
.grid-stack-static .widget-header { cursor: default; }
.widget-header .title { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.widget-header .type-badge { font-size: 10px; font-weight: normal; color: #666; background: #eef; padding: 1px 6px; border-radius: 10px; }
.widget-header button { border: none; background: transparent; color: #999; padding: 0 4px; }
.widget-header button:hover { color: #3b5bdb; background: transparent; }
.widget-header .btn-delete:hover { color: #d33; }
.widget-header input[type=range] { width: 70px; }
.widget-body { flex: 1; min-height: 0; padding: 8px; position: relative; display: flex; flex-direction: column; }
.widget-body canvas { flex: 1; min-height: 0; width: 100% !important; }
.widget-body.grid { overflow: auto; padding: 0; display: block; }
.widget-body table { width: 100%; border-collapse: collapse; font-size: 13px; }
.widget-body th, .widget-body td { padding: 6px 10px; border-bottom: 1px solid #eee; text-align: left; }
.widget-body th { background: #f7f7f9; position: sticky; top: 0; }
.widget-body td.num { text-align: right; font-variant-numeric: tabular-nums; }
.widget-body.text { overflow: auto; display: block; }
.text-editor { width: 100%; height: 100%; outline: none; white-space: pre-wrap; word-break: break-word; line-height: 1.5; }
.widget-body.image { align-items: center; justify-content: center; background: #fafafa; }
.widget-body.image img { max-width: 100%; max-height: 100%; object-fit: contain; }

/* 위젯 상세 전체 화면 페이지 */
.detail-page .toolbar h1 { font-size: 16px; }
.detail-main { padding: 16px; height: calc(100vh - 52px); }
.detail-body { height: 100%; background: #fff; border: 1px solid #ddd; border-radius: 10px; padding: 16px; overflow: auto; }
.detail-body canvas { max-height: 60vh; }
.detail-body .kpis { display: flex; gap: 16px; margin-bottom: 16px; flex-wrap: wrap; }
.detail-body .kpi { background: #f7f7f9; border-radius: 8px; padding: 12px 16px; min-width: 140px; }
.detail-body .kpi b { display: block; font-size: 24px; }
.detail-body .kpi span { color: #666; font-size: 12px; }
.detail-body table { width: 100%; border-collapse: collapse; font-size: 13px; margin-top: 12px; }
.detail-body th, .detail-body td { padding: 6px 10px; border-bottom: 1px solid #eee; text-align: left; }
.detail-body td.num { text-align: right; }

/* 위젯 미리보기 페이지 */
.preview-main { display: grid; grid-template-columns: minmax(320px, 1fr) 2fr; gap: 20px; padding: 16px; }
.preview-col h2 { font-size: 14px; color: #666; margin: 0 0 8px; }
.preview-box { max-width: 100%; }
.preview-detail { background: #fff; border: 1px solid #ddd; border-radius: 10px; overflow: hidden; }
.preview-detail .toolbar { border-bottom: 1px solid #eee; min-height: 40px; }
.preview-detail .detail-body { border: none; border-radius: 0; height: auto; min-height: 400px; }
@media (max-width: 1000px) { .preview-main { grid-template-columns: 1fr; } }
