* { box-sizing: border-box; }

body {
    margin: 0;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Apple SD Gothic Neo',
                 'Malgun Gothic', sans-serif;
    background: #f5f6fa;
    color: #222;
    line-height: 1.5;
}

a { color: #2c5282; text-decoration: none; }
a:hover { text-decoration: underline; }

.container { max-width: 1100px; margin: 0 auto; padding: 0 20px; }

/* 상단 바 */
.topbar { background: #1a365d; color: #fff; border-bottom: 3px solid #2b6cb0; }
.topbar a { color: #fff; }
.topbar-inner {
    display: flex; justify-content: space-between; align-items: center;
    padding: 14px 20px; flex-wrap: wrap; gap: 10px;
}
.brand { font-size: 1.2rem; font-weight: 700; }
.nav { display: flex; align-items: center; gap: 16px; flex-wrap: wrap; }
.nav a { font-size: 0.95rem; }
.user-tag {
    background: rgba(255,255,255,0.15); padding: 4px 10px;
    border-radius: 12px; font-size: 0.85rem;
}
.admin-link {
    background: #d69e2e; padding: 4px 12px; border-radius: 6px;
    font-weight: 600; font-size: 0.9rem;
}
.admin-link:hover { background: #b7791f; text-decoration: none; }
.admin-badge {
    background: #d69e2e; color: #fff; padding: 1px 6px;
    border-radius: 4px; font-size: 0.7rem; margin-left: 4px;
}

.main { padding: 24px 20px 60px; min-height: calc(100vh - 140px); }

.footer {
    background: #2d3748; color: #cbd5e0; text-align: center;
    padding: 16px 0; font-size: 0.85rem;
}

/* Flash */
.flashes { margin-bottom: 16px; }
.flash {
    padding: 12px 16px; border-radius: 8px;
    margin-bottom: 8px; font-size: 0.95rem;
}
.flash-success { background: #d4edda; color: #155724; border: 1px solid #c3e6cb; }
.flash-error   { background: #f8d7da; color: #721c24; border: 1px solid #f5c6cb; }

/* Card */
.card {
    background: #fff; border-radius: 12px; padding: 24px;
    box-shadow: 0 1px 3px rgba(0,0,0,0.06); margin-bottom: 20px;
}
.card h2, .card h3 { margin-top: 0; }

.alert-card { background: #fffaf0; border-left: 4px solid #d69e2e; }
.notice-card { background: #ebf8ff; border-left: 4px solid #2b6cb0; }

/* Form */
.form-card { max-width: 480px; margin: 40px auto; }
.form { display: flex; flex-direction: column; gap: 14px; }
.form label, .form .field { display: flex; flex-direction: column; gap: 6px; font-size: 0.9rem; color: #4a5568; }
.form .field-label { font-size: 0.9rem; color: #4a5568; }
.form input, .form textarea, .form select {
    padding: 10px 12px; border: 1px solid #cbd5e0; border-radius: 8px;
    font-size: 1rem; font-family: inherit;
}
.form textarea { resize: vertical; min-height: 80px; }
.form input:disabled { background: #edf2f7; color: #718096; }
.form input:focus, .form textarea:focus, .form select:focus {
    outline: 2px solid #4299e1; border-color: #4299e1;
}
.form-bottom { text-align: center; margin-top: 16px; font-size: 0.9rem; color: #718096; }

.checkbox-row {
    flex-direction: row !important;
    align-items: center;
    gap: 8px !important;
}
.checkbox-row input[type="checkbox"] { width: auto; }

.dong-ho-row { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.dong-ho-row input, .dong-ho-row select {
    flex: 1;
    min-width: 60px;
    text-align: center;
    padding: 10px 8px;
    border: 1px solid #cbd5e0;
    border-radius: 8px;
    font-size: 1rem;
    font-family: inherit;
    background: #fff;
}
.dong-ho-row .suffix { color: #4a5568; font-size: 0.95rem; padding-right: 4px; }

.code-input {
    font-size: 1.5rem !important;
    letter-spacing: 0.4em;
    text-align: center;
    font-family: 'Menlo', 'Consolas', monospace;
}

.divider { border: none; border-top: 1px solid #e2e8f0; margin: 8px 0; }

.btn-row { display: flex; gap: 8px; flex-wrap: wrap; }

/* Buttons */
.btn {
    display: inline-block; padding: 8px 14px; border-radius: 8px;
    border: none; cursor: pointer; font-size: 0.9rem;
    font-family: inherit; font-weight: 500;
    transition: opacity 0.15s, background 0.15s;
    text-decoration: none;
}
.btn:hover { opacity: 0.9; text-decoration: none; }
.btn:disabled { opacity: 0.4; cursor: not-allowed; }
.btn-primary  { background: #2b6cb0; color: #fff; }
.btn-danger   { background: #c53030; color: #fff; }
.btn-ghost    { background: #edf2f7; color: #2d3748; border: 1px solid #cbd5e0; }
.btn-ghost:hover { background: #e2e8f0; }
.btn-sm       { padding: 5px 10px; font-size: 0.8rem; }
.btn-block    { width: 100%; padding: 12px; font-size: 1rem; }

.topbar .btn-ghost { background: transparent; color: #fff; border: 1px solid rgba(255,255,255,0.4); }

/* Dashboard */
.dashboard-header {
    display: flex; align-items: center; flex-wrap: wrap;
    gap: 12px; margin-bottom: 16px;
}
.dashboard-header h2 { margin: 0; }
.badge {
    background: #2b6cb0; color: #fff; padding: 4px 10px;
    border-radius: 12px; font-size: 0.8rem;
}

.household-card { border-left: 4px solid #2b6cb0; }
.household-header {
    display: flex; justify-content: space-between; align-items: center;
    flex-wrap: wrap; gap: 10px; margin-bottom: 12px;
}
.household-header h3 { margin: 0; }
.quota {
    background: #ebf8ff; padding: 8px 14px; border-radius: 10px;
    font-size: 0.9rem; display: flex; gap: 14px; align-items: center;
}
.quota-ok   { color: #2b6cb0; font-weight: 600; }
.quota-full { color: #c53030; font-weight: 600; }

.tag-mine {
    display: inline-block; background: #38a169; color: #fff;
    padding: 1px 6px; border-radius: 4px;
    font-size: 0.7rem; margin-left: 4px; vertical-align: middle;
}
.row-past-text td { color: #a0aec0; }
.hint { font-size: 0.8rem; margin-top: 8px; }

/* 예약표 */
.schedule-card { padding: 20px; }
.schedule-wrap { overflow-x: auto; }
.schedule {
    width: 100%; border-collapse: collapse;
    margin: 12px 0; min-width: 480px;
}
.schedule th, .schedule td {
    border: 1px solid #e2e8f0; padding: 8px;
    text-align: center; vertical-align: middle;
}
.schedule th { background: #edf2f7; font-size: 0.9rem; font-weight: 600; }
.schedule .time-col {
    font-weight: 600; background: #f7fafc; white-space: nowrap;
    font-size: 0.85rem; width: 130px;
}
.cell { height: 50px; min-width: 110px; }
.cell-open      { background: #fff; }
.cell-taken     { background: #fed7d7; color: #742a2a; }
.cell-mine      { background: #c6f6d5; color: #22543d; }
.cell-household { background: #bee3f8; color: #2c5282; }
.cell-label { font-size: 0.85rem; font-weight: 600; }
.cell-sub   { font-size: 0.7rem; color: #4a5568; margin-top: 2px; }
.row-past td { background: #f1f3f5 !important; color: #a0aec0; }
.row-past .cell-mine, .row-past .cell-taken, .row-past .cell-household { opacity: 0.55; }

/* 범례 */
.legend {
    list-style: none; padding: 0; margin: 12px 0 0;
    display: flex; flex-wrap: wrap; gap: 16px;
    font-size: 0.85rem; color: #4a5568;
}
.legend li { display: flex; align-items: center; gap: 6px; }
.legend-box {
    display: inline-block; width: 18px; height: 18px;
    border: 1px solid #cbd5e0; border-radius: 3px;
}
.row-past-box { background: #f1f3f5; }

/* List tables */
.list-table { width: 100%; border-collapse: collapse; margin-top: 10px; }
.list-table th, .list-table td {
    border-bottom: 1px solid #e2e8f0; padding: 10px;
    text-align: left; font-size: 0.95rem;
}
.list-table th { background: #f7fafc; }
.row-cancelled td { color: #a0aec0; }
.row-cancelled .status { text-decoration: none; }

.status {
    padding: 2px 8px; border-radius: 10px;
    font-size: 0.8rem; font-weight: 600;
    display: inline-block;
}
.status-cancelled { background: #e2e8f0; color: #4a5568; }
.status-done      { background: #bee3f8; color: #2c5282; }
.status-admin     { background: #faf089; color: #744210; }
.status-user      { background: #c6f6d5; color: #22543d; }

.muted { color: #718096; font-size: 0.9rem; }

/* ===== 관리자 페이지 ===== */
.admin-page { }
.admin-header { margin-bottom: 16px; }
.admin-header h2 { margin: 0; }

.admin-tabs {
    display: flex; gap: 0; flex-wrap: wrap;
    margin-bottom: 20px;
    border-bottom: 2px solid #cbd5e0;
}
.admin-tabs a {
    padding: 10px 18px;
    color: #4a5568;
    border-bottom: 2px solid transparent;
    margin-bottom: -2px;
    font-weight: 500;
    font-size: 0.95rem;
}
.admin-tabs a:hover { color: #2b6cb0; text-decoration: none; }
.admin-tabs a.active {
    color: #2b6cb0;
    border-bottom-color: #2b6cb0;
    font-weight: 600;
}

.stat-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 14px;
    margin-bottom: 20px;
}
.stat-card {
    background: #fff; border-radius: 12px;
    padding: 18px 20px;
    box-shadow: 0 1px 3px rgba(0,0,0,0.06);
    border-left: 4px solid #2b6cb0;
}
.stat-label { font-size: 0.85rem; color: #718096; margin-bottom: 6px; }
.stat-value { font-size: 1.8rem; font-weight: 700; color: #2d3748; }
.stat-value small { font-size: 0.95rem; color: #718096; font-weight: 400; }
.stat-sub { font-size: 0.75rem; color: #a0aec0; margin-top: 4px; }

/* ===== 리포트 ===== */
.report-subtabs {
    display: flex;
    gap: 0;
    flex-wrap: wrap;
    margin-bottom: 16px;
    background: #fff;
    border-radius: 10px;
    padding: 4px;
    box-shadow: 0 1px 3px rgba(0,0,0,0.06);
}
.report-subtabs a {
    padding: 8px 14px;
    color: #4a5568;
    border-radius: 6px;
    font-size: 0.9rem;
    font-weight: 500;
}
.report-subtabs a:hover { background: #edf2f7; text-decoration: none; }
.report-subtabs a.active {
    background: #2b6cb0;
    color: #fff;
}
.report-subtabs a.active:hover { background: #2c5282; }

/* TOP 5 랭크 카드 */
.rank-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    gap: 16px;
    margin-bottom: 20px;
}
.rank-card h3 { font-size: 1rem; }
.rank-card h3 small { font-size: 0.75rem; font-weight: 400; }
.rank-list {
    list-style: decimal inside;
    padding: 0;
    margin: 8px 0 0;
}
.rank-list li {
    padding: 8px 0;
    border-bottom: 1px solid #e2e8f0;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 6px;
    flex-wrap: wrap;
    font-size: 0.9rem;
}
.rank-list li:last-child { border-bottom: none; }
.rank-list .muted {
    font-size: 0.75rem;
    flex-basis: 100%;
    margin-left: 18px;
}
.rank-count {
    background: #ebf8ff;
    color: #2b6cb0;
    padding: 3px 10px;
    border-radius: 12px;
    font-size: 0.8rem;
    font-weight: 600;
    white-space: nowrap;
}

/* 막대 차트 */
.bar-chart {
    display: flex;
    flex-direction: column;
    gap: 4px;
    margin: 12px 0;
    font-size: 0.85rem;
}
.bar-row {
    display: flex;
    align-items: center;
    gap: 10px;
}
.bar-label {
    min-width: 90px;
    color: #4a5568;
    font-size: 0.8rem;
    text-align: right;
}
.bar-track {
    flex: 1;
    background: #f1f3f5;
    height: 22px;
    border-radius: 4px;
    position: relative;
    overflow: hidden;
}
.bar {
    height: 100%;
    border-radius: 4px;
    display: flex;
    align-items: center;
    justify-content: flex-end;
    transition: width 0.2s ease;
    min-width: 2px;
}
.bar-active { background: #2b6cb0; }
.bar-value {
    color: #fff;
    font-weight: 600;
    font-size: 0.8rem;
    padding: 0 8px;
    white-space: nowrap;
}
.bar-aux {
    min-width: 70px;
    color: #c53030;
    font-size: 0.75rem;
}

/* 히트맵 */
.heatmap-wrap {
    overflow-x: auto;
    margin: 12px -4px;
}
.heatmap-table {
    border-collapse: collapse;
    font-size: 0.7rem;
    margin: 0 4px;
}
.heatmap-table th, .heatmap-table td {
    border: 1px solid #e2e8f0;
    padding: 0;
    text-align: center;
    min-width: 26px;
    height: 24px;
    color: #2d3748;
}
.heatmap-table th {
    background: #f7fafc;
    font-weight: 600;
    padding: 4px 6px;
    white-space: nowrap;
}
.heatmap-table .day-label {
    background: #f7fafc;
    font-weight: 600;
    padding: 0 8px;
    min-width: 36px;
    text-align: center;
}
.heatmap-table .corner {
    background: #edf2f7;
    color: #4a5568;
    font-size: 0.7rem;
}
.heatmap-table .heatmap-cell {
    font-weight: 600;
    color: #1a365d;
}
.heatmap-table .total-col {
    background: #edf2f7;
    font-weight: 700;
    color: #2b6cb0;
    padding: 0 8px;
}
.heatmap-table .total-row {
    background: #edf2f7;
    font-weight: 600;
}
.heatmap-legend {
    margin-top: 12px;
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 0.8rem;
    color: #4a5568;
}
.legend-gradient {
    display: inline-block;
    width: 180px;
    height: 14px;
    border-radius: 4px;
    background: linear-gradient(to right, rgba(43,108,176,0.1), rgba(43,108,176,1));
    border: 1px solid #e2e8f0;
}

/* 취소율 강조 */
.cancel-high {
    color: #c53030;
    font-weight: 700;
}

/* ===== 타석 운영 관리 ===== */
.booth-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
    gap: 16px;
    margin-top: 12px;
}
.booth-card {
    background: #f7fafc;
    border: 2px solid #e2e8f0;
    border-radius: 10px;
    padding: 16px;
}
.booth-card.booth-closed {
    background: #fff5f5;
    border-color: #fed7d7;
}
.booth-head {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 8px;
}
.booth-head h4 { margin: 0; font-size: 1.1rem; }
.booth-card .form-inline {
    display: flex;
    flex-direction: column;
    gap: 4px;
    margin: 8px 0;
    font-size: 0.85rem;
    color: #4a5568;
}
.booth-card .form-inline input {
    padding: 6px 10px;
    border: 1px solid #cbd5e0;
    border-radius: 6px;
    font-size: 0.9rem;
    font-family: inherit;
}

/* 입주민 화면에서 운영중지 타석 표시 */
.booth-closed-badge {
    display: inline-block;
    background: #fed7d7;
    color: #742a2a;
    padding: 1px 6px;
    border-radius: 4px;
    font-size: 0.7rem;
    font-weight: 600;
    margin-top: 2px;
}

/* ===== PWA 설치 안내 ===== */
.install-page {
    max-width: 600px;
    margin: 0 auto;
}
.install-hero {
    text-align: center;
    padding: 24px 0;
}
.install-icon {
    width: 96px;
    height: 96px;
    border-radius: 22px;
    box-shadow: 0 4px 12px rgba(0,0,0,0.15);
    margin-bottom: 12px;
}
.install-hero h2 { margin: 0 0 8px; }
.install-tabs {
    display: flex;
    gap: 0;
    background: #f1f3f5;
    border-radius: 10px;
    padding: 4px;
    margin: 16px 0;
}
.install-tab-btn {
    flex: 1;
    background: transparent;
    border: none;
    padding: 10px;
    font-size: 0.95rem;
    cursor: pointer;
    color: #4a5568;
    border-radius: 6px;
    font-family: inherit;
}
.install-tab-btn.active {
    background: #fff;
    color: #2b6cb0;
    font-weight: 600;
    box-shadow: 0 1px 3px rgba(0,0,0,0.06);
}
.install-tab-content {
    display: none;
    background: #fff;
    border-radius: 10px;
    padding: 20px;
    box-shadow: 0 1px 3px rgba(0,0,0,0.06);
}
.install-tab-content.active { display: block; }
.install-steps {
    padding-left: 24px;
    line-height: 1.8;
}
.install-steps li { margin-bottom: 14px; }
.icon-box {
    display: inline-block;
    background: #edf2f7;
    border-radius: 4px;
    padding: 2px 8px;
    font-weight: 600;
}
.install-faq {
    margin-top: 28px;
}
.install-faq h3 {
    border-bottom: 2px solid #e2e8f0;
    padding-bottom: 8px;
}
.install-faq details {
    background: #fff;
    border-radius: 8px;
    margin-bottom: 8px;
    padding: 12px 16px;
    box-shadow: 0 1px 3px rgba(0,0,0,0.04);
}
.install-faq summary {
    cursor: pointer;
    font-weight: 500;
    color: #2d3748;
}
.install-faq summary:hover { color: #2b6cb0; }
.install-faq p {
    margin: 10px 0 0;
    color: #4a5568;
    line-height: 1.7;
}

@media (max-width: 600px) {
    .heatmap-table { font-size: 0.6rem; }
    .heatmap-table th, .heatmap-table td { min-width: 22px; height: 20px; }
    .bar-label { min-width: 60px; }
    .rank-grid { grid-template-columns: 1fr; }
}

.page-toolbar {
    display: flex; justify-content: space-between;
    align-items: center; flex-wrap: wrap; gap: 10px;
    margin-bottom: 12px;
}
.page-toolbar h3 { margin: 0; }
.search-form {
    display: flex; gap: 6px; align-items: center;
}
.search-form input {
    padding: 6px 10px; border: 1px solid #cbd5e0;
    border-radius: 6px; font-size: 0.9rem;
}

.filter-form {
    display: flex; flex-wrap: wrap; gap: 12px;
    align-items: end;
}
.filter-form label { display: flex; flex-direction: column; gap: 4px; font-size: 0.85rem; color: #4a5568; }
.filter-form input, .filter-form select {
    padding: 8px 10px; border: 1px solid #cbd5e0;
    border-radius: 6px; font-size: 0.9rem; font-family: inherit;
}

/* 공지사항 리스트 */
.notice-list { display: flex; flex-direction: column; gap: 14px; }
.notice-item {
    border: 1px solid #e2e8f0; border-radius: 8px;
    padding: 14px;
}
.notice-item.inactive { opacity: 0.6; background: #f7fafc; }
.notice-item.has-divider { border-bottom: 1px solid #e2e8f0; }
.notice-head {
    display: flex; justify-content: space-between;
    align-items: flex-start; gap: 10px; flex-wrap: wrap;
    margin-bottom: 6px;
}
.notice-head h4 { margin: 0; font-size: 1.05rem; }
.notice-actions { display: flex; gap: 6px; flex-wrap: wrap; }
.notice-content {
    white-space: pre-wrap;
    color: #2d3748;
    margin: 6px 0;
    font-size: 0.95rem;
}
.notice-meta { font-size: 0.8rem; margin-top: 6px; }

/* notice-card (입주민용) */
.notice-card .notice-item {
    border: none;
    padding: 8px 0;
}
.notice-card .notice-item.has-divider {
    border-bottom: 1px dashed #bee3f8;
}

@media (max-width: 600px) {
    .topbar-inner { flex-direction: column; align-items: flex-start; }
    .nav { gap: 10px; }
    .quota { flex-direction: column; gap: 4px; align-items: flex-start; }
    .household-header { flex-direction: column; align-items: flex-start; }
    .admin-tabs a { padding: 8px 12px; font-size: 0.85rem; }
}
