/* =====================================================
   재난심리지원 현황 공유 시스템 - Main Stylesheet
   ===================================================== */

/* ── Reset & Base ── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --primary:       #1e6fb5;
  --primary-dark:  #145a96;
  --primary-light: #e8f2fc;
  --secondary:     #3fada8;
  --danger:        #e05252;
  --warning:       #f5a623;
  --success:       #38a169;
  --text:          #2d3748;
  --text-muted:    #718096;
  --border:        #e2e8f0;
  --bg:            #f7f9fc;
  --card-bg:       #ffffff;
  --nav-height:    60px;
  --sidebar-w:     220px;
  --sidebar-collapsed: 0px;
  --radius:        10px;
  --shadow:        0 1px 4px rgba(0,0,0,.08), 0 4px 16px rgba(0,0,0,.06);
  --shadow-sm:     0 1px 3px rgba(0,0,0,.08);

  /* Level colors */
  --level-1: #48bb78;
  --level-2: #ecc94b;
  --level-3: #ed8936;
  --level-4: #e53e3e;
}

html { font-size: 14px; }
body {
  font-family: 'Noto Sans KR', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.6;
  min-height: 100vh;
}

a { text-decoration: none; color: inherit; }
input, select, textarea, button { font-family: inherit; font-size: inherit; }
img { max-width: 100%; }

/* ── Scrollbar ── */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: #f1f5f9; }
::-webkit-scrollbar-thumb { background: #cbd5e0; border-radius: 4px; }
::-webkit-scrollbar-thumb:hover { background: #a0aec0; }

/* =====================================================
   LOGIN OVERLAY
   ===================================================== */
.login-overlay {
  position: fixed; inset: 0; z-index: 9999;
  background: linear-gradient(135deg, #1e3c72 0%, #1e6fb5 50%, #3fada8 100%);
  display: flex; align-items: center; justify-content: center;
  padding: 20px;
}

.login-box {
  background: #fff;
  border-radius: 20px;
  padding: 48px 40px;
  width: 100%; max-width: 440px;
  box-shadow: 0 20px 60px rgba(0,0,0,.3);
  text-align: center;
}

.login-logo {
  width: 72px; height: 72px; border-radius: 18px;
  background: linear-gradient(135deg, var(--primary) 0%, var(--secondary) 100%);
  display: flex; align-items: center; justify-content: center;
  margin: 0 auto 20px;
  font-size: 36px; color: #fff;
  box-shadow: 0 8px 20px rgba(30,111,181,.4);
}

.login-box h2 { font-size: 1.5rem; font-weight: 700; color: var(--text); margin-bottom: 6px; }
.login-subtitle { color: var(--text-muted); margin-bottom: 32px; font-size: .9rem; }

.login-form { text-align: left; }
.login-form .form-group { margin-bottom: 16px; }
.login-form label { display: block; font-weight: 500; margin-bottom: 6px; font-size: .85rem; }
.login-form input,
.login-form select {
  width: 100%; padding: 11px 14px; border: 1.5px solid var(--border);
  border-radius: 8px; background: #f8fafc; transition: border-color .2s;
}
.login-form input:focus,
.login-form select:focus { outline: none; border-color: var(--primary); background: #fff; }

.btn-login {
  width: 100%; padding: 13px; margin-top: 8px;
  background: linear-gradient(135deg, var(--primary), var(--secondary));
  color: #fff; border: none; border-radius: 10px;
  font-size: 1rem; font-weight: 600; cursor: pointer;
  transition: opacity .2s, transform .1s;
}
.btn-login:hover { opacity: .92; }
.btn-login:active { transform: scale(.98); }

.login-error { color: var(--danger); font-size: .85rem; margin-top: 10px; text-align: center; }
.login-hint {
  margin-top: 24px; padding: 12px 16px;
  background: var(--primary-light); border-radius: 8px;
  font-size: .82rem; color: var(--primary);
}

/* =====================================================
   APP LAYOUT
   ===================================================== */
.app-container { display: flex; flex-direction: column; min-height: 100vh; }

/* ── Top Nav ── */
.top-nav {
  position: fixed; top: 0; left: 0; right: 0; z-index: 1000;
  height: var(--nav-height); background: #fff;
  border-bottom: 1px solid var(--border);
  display: flex; align-items: center; padding: 0 20px;
  gap: 16px;
  box-shadow: var(--shadow-sm);
}

.nav-left { display: flex; align-items: center; gap: 12px; min-width: var(--sidebar-w); }
.nav-brand { display: flex; align-items: center; gap: 8px; font-size: 1rem; font-weight: 700; color: var(--primary); }
.nav-brand i { font-size: 1.3rem; }

.nav-center { flex: 1; display: flex; justify-content: center; gap: 8px; flex-wrap: wrap; }
.nav-right { display: flex; align-items: center; gap: 8px; }
.nav-user { font-size: .85rem; font-weight: 500; color: var(--text-muted); }

.sidebar-toggle {
  background: none; border: none; cursor: pointer;
  width: 36px; height: 36px; border-radius: 8px;
  display: flex; align-items: center; justify-content: center;
  color: var(--text-muted); transition: background .2s;
  font-size: 1.1rem;
}
.sidebar-toggle:hover { background: var(--bg); color: var(--text); }

/* ── Layout ── */
.layout {
  display: flex;
  margin-top: var(--nav-height);
  min-height: calc(100vh - var(--nav-height));
}

/* ── Sidebar ── */
.sidebar {
  width: var(--sidebar-w);
  background: #fff;
  border-right: 1px solid var(--border);
  position: fixed;
  top: var(--nav-height); bottom: 0; left: 0;
  overflow-y: auto; overflow-x: hidden;
  z-index: 900;
  transition: width .25s ease, transform .25s ease;
  display: flex; flex-direction: column;
}

.sidebar.collapsed { width: 0; transform: translateX(-100%); }

.sidebar-menu { list-style: none; padding: 12px 0; flex: 1; }

.sidebar-menu li a {
  display: flex; align-items: center; gap: 10px;
  padding: 12px 18px; border-radius: 0;
  color: var(--text-muted); transition: all .15s;
  font-size: .9rem; white-space: nowrap;
  min-height: 44px; /* 모바일 터치 영역 최소 44px */
}
.sidebar-menu li a:hover { background: var(--bg); color: var(--text); }
.sidebar-menu li a.active {
  background: var(--primary-light); color: var(--primary); font-weight: 600;
  border-right: 3px solid var(--primary);
}
.sidebar-menu li a i { width: 18px; text-align: center; font-size: .95rem; }

.menu-divider {
  padding: 16px 18px 4px !important;
  font-size: .75rem; font-weight: 600;
  color: var(--text-muted); text-transform: uppercase; letter-spacing: .05em;
  list-style: none;
}
.menu-divider span { display: block; }

.sidebar-footer {
  padding: 16px;
  border-top: 1px solid var(--border);
}

.connection-status {
  display: flex; align-items: center; gap: 6px;
  font-size: .8rem; padding: 6px 10px; border-radius: 6px;
}
.connection-status.online { background: #f0fff4; color: var(--success); }
.connection-status.online i { color: var(--success); }
.connection-status.offline { background: #fffbeb; color: #b7791f; }
.connection-status.offline i { color: #e6a817; }

/* ── Main Content ── */
.main-content {
  flex: 1;
  margin-left: var(--sidebar-w);
  padding: 28px;
  transition: margin-left .25s ease;
  min-width: 0;
}

.main-content.expanded { margin-left: 0; }

/* ── Page Sections ── */
.page { display: block; }
.page.hidden { display: none !important; }

.page-header {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 24px; flex-wrap: wrap; gap: 12px;
}
.page-header h1 {
  font-size: 1.5rem; font-weight: 700; color: var(--text);
  display: flex; align-items: center; gap: 10px;
}
.page-header h1 i { color: var(--primary); }
.page-actions { display: flex; align-items: center; gap: 8px; }

/* =====================================================
   KPI CARDS
   ===================================================== */
.kpi-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 16px;
  margin-bottom: 24px;
}

.kpi-card {
  background: var(--card-bg);
  border-radius: var(--radius);
  padding: 20px;
  box-shadow: var(--shadow-sm);
  display: flex; align-items: flex-start; gap: 14px;
  border-left: 4px solid transparent;
  transition: transform .15s, box-shadow .15s;
}
.kpi-card:hover { transform: translateY(-2px); box-shadow: var(--shadow); }

.kpi-icon {
  width: 48px; height: 48px; border-radius: 12px;
  display: flex; align-items: center; justify-content: center;
  font-size: 1.3rem; flex-shrink: 0;
}
.kpi-body { flex: 1; min-width: 0; }
.kpi-label { font-size: .78rem; font-weight: 500; color: var(--text-muted); margin-bottom: 4px; }
.kpi-value { font-size: 1.8rem; font-weight: 700; line-height: 1.2; }
.kpi-sub { font-size: .75rem; color: var(--text-muted); margin-top: 3px; }

.kpi-card.blue  { border-color: var(--primary); }
.kpi-card.blue  .kpi-icon { background: var(--primary-light); color: var(--primary); }
.kpi-card.blue  .kpi-value { color: var(--primary); }
.kpi-card.green { border-color: var(--success); }
.kpi-card.green .kpi-icon { background: #f0fff4; color: var(--success); }
.kpi-card.green .kpi-value { color: var(--success); }
.kpi-card.orange { border-color: var(--warning); }
.kpi-card.orange .kpi-icon { background: #fffbeb; color: #b7791f; }
.kpi-card.orange .kpi-value { color: #b7791f; }
.kpi-card.red   { border-color: var(--danger); }
.kpi-card.red   .kpi-icon { background: #fff5f5; color: var(--danger); }
.kpi-card.red   .kpi-value { color: var(--danger); }

/* =====================================================
   CHART GRID
   ===================================================== */
.chart-grid {
  display: grid;
  grid-template-columns: 2fr 1fr;
  gap: 16px;
  margin-bottom: 24px;
}

.chart-card {
  background: var(--card-bg);
  border-radius: var(--radius);
  padding: 20px;
  box-shadow: var(--shadow-sm);
}
.chart-card.wide { grid-column: span 2; } /* fallback */

.chart-header {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 16px;
}
.chart-header h3 { font-size: .95rem; font-weight: 600; display: flex; align-items: center; gap: 6px; }
.chart-header h3 i { color: var(--primary); }
.chart-header select {
  border: 1px solid var(--border); border-radius: 6px;
  padding: 4px 8px; font-size: .8rem;
  background: #fff; color: var(--text);
}

/* =====================================================
   CARDS
   ===================================================== */
.card {
  background: var(--card-bg);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
  margin-bottom: 20px;
  overflow: hidden;
}
.card-header {
  padding: 16px 20px;
  border-bottom: 1px solid var(--border);
  display: flex; align-items: center; justify-content: space-between;
}
.card-header h3 { font-size: .95rem; font-weight: 600; }

/* =====================================================
   TABLE
   ===================================================== */
.table-wrap { overflow-x: auto; }

.data-table {
  width: 100%; border-collapse: collapse;
  font-size: .85rem;
}
.data-table th {
  background: #f8fafc; padding: 10px 12px;
  text-align: left; font-weight: 600;
  color: var(--text-muted); font-size: .78rem;
  text-transform: uppercase; letter-spacing: .03em;
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}
.data-table td {
  padding: 10px 12px;
  border-bottom: 1px solid #f1f5f9;
  vertical-align: middle;
}
.data-table tr:last-child td { border-bottom: none; }
.data-table tr:hover td { background: var(--bg); }
.data-table.small th, .data-table.small td { padding: 7px 10px; }

/* =====================================================
   BADGES
   ===================================================== */
.badge {
  display: inline-flex; align-items: center; gap: 4px;
  padding: 3px 10px; border-radius: 20px;
  font-size: .75rem; font-weight: 600; white-space: nowrap;
}
.badge-blue    { background: var(--primary-light); color: var(--primary); }
.badge-green   { background: #f0fff4; color: var(--success); }
.badge-red     { background: #fff5f5; color: var(--danger); }
.badge-orange  { background: #fffbeb; color: #b7791f; }
.badge-gray    { background: #f7fafc; color: #718096; border: 1px solid var(--border); }
.badge-purple  { background: #faf5ff; color: #6b46c1; }

/* =====================================================
   BUTTONS
   ===================================================== */
.btn {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 8px 16px; border-radius: 8px;
  font-size: .85rem; font-weight: 500; cursor: pointer;
  border: 1.5px solid transparent; transition: all .15s;
  white-space: nowrap;
}
.btn:active { transform: scale(.97); }

.btn-primary {
  background: var(--primary); color: #fff; border-color: var(--primary);
}
.btn-primary:hover { background: var(--primary-dark); border-color: var(--primary-dark); }

.btn-outline {
  background: transparent; color: var(--text);
  border-color: var(--border);
}
.btn-outline:hover { background: var(--bg); }

.btn-danger {
  background: var(--danger); color: #fff; border-color: var(--danger);
}
.btn-outline.btn-danger {
  background: transparent; color: var(--danger); border-color: var(--danger);
}
.btn-outline.btn-danger:hover { background: #fff5f5; }

.btn-success { background: var(--success); color: #fff; border-color: var(--success); }

.btn-sm { padding: 5px 11px; font-size: .8rem; }
.btn-icon {
  width: 36px; height: 36px; padding: 0; border-radius: 8px;
  display: flex; align-items: center; justify-content: center;
  background: none; border: 1px solid transparent; cursor: pointer;
  color: var(--text-muted); transition: all .15s;
}
.btn-icon:hover { background: var(--bg); color: var(--text); border-color: var(--border); }

/* =====================================================
   FORMS
   ===================================================== */
.form-group { margin-bottom: 14px; }
.form-group label {
  display: block; font-weight: 500; margin-bottom: 5px;
  font-size: .85rem; color: var(--text);
}
.form-group input,
.form-group select,
.form-group textarea {
  width: 100%; padding: 9px 12px;
  border: 1.5px solid var(--border); border-radius: 8px;
  background: #fff; color: var(--text);
  transition: border-color .2s, box-shadow .2s;
}
.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus {
  outline: none; border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(30,111,181,.12);
}
.form-group input[readonly] { background: var(--bg); color: var(--text-muted); }
.form-group textarea { resize: vertical; min-height: 80px; }

.required { color: var(--danger); }

.form-row {
  display: grid; grid-template-columns: 1fr 1fr;
  gap: 12px;
}
.form-row-4 { grid-template-columns: repeat(4, 1fr); }

.form-actions {
  display: flex; justify-content: flex-end; gap: 8px;
  padding-top: 8px; margin-top: 8px; border-top: 1px solid var(--border);
}

.input-with-btn {
  display: flex; gap: 8px;
}
.input-with-btn input { flex: 1; }

/* =====================================================
   INPUT PAGE LAYOUT
   ===================================================== */
.input-layout {
  display: grid;
  grid-template-columns: 1.5fr 1fr;
  gap: 20px;
  align-items: start;
}

.input-form-card,
.input-history-card {
  background: var(--card-bg);
  border-radius: var(--radius);
  padding: 24px;
  box-shadow: var(--shadow-sm);
}
.input-form-card h3,
.input-history-card h3 {
  font-size: 1rem; font-weight: 600;
  margin-bottom: 20px; padding-bottom: 12px;
  border-bottom: 1px solid var(--border);
  display: flex; align-items: center; gap: 8px;
  color: var(--primary);
}

/* =====================================================
   FILTER BAR
   ===================================================== */
.filter-bar {
  background: var(--card-bg);
  border-radius: var(--radius);
  padding: 16px 20px;
  margin-bottom: 20px;
  box-shadow: var(--shadow-sm);
  display: flex; align-items: flex-end; gap: 12px;
  flex-wrap: wrap;
}
.filter-bar .form-group { margin-bottom: 0; min-width: 140px; }
.filter-bar .form-group label { font-size: .78rem; margin-bottom: 4px; }

/* =====================================================
   SUPPORT KPI
   ===================================================== */
.support-kpi {
  display: grid; grid-template-columns: repeat(5, 1fr);
  gap: 12px; margin-bottom: 20px;
}
.support-kpi-item {
  background: var(--card-bg); border-radius: var(--radius);
  padding: 14px 16px; box-shadow: var(--shadow-sm); text-align: center;
}
.support-kpi-item .label { font-size: .75rem; color: var(--text-muted); margin-bottom: 4px; }
.support-kpi-item .value { font-size: 1.4rem; font-weight: 700; color: var(--primary); }

/* =====================================================
   DISASTER LIST
   ===================================================== */
.disaster-list {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(340px, 1fr));
  gap: 16px; margin-bottom: 20px;
}

.disaster-card {
  background: var(--card-bg); border-radius: var(--radius);
  padding: 20px; box-shadow: var(--shadow-sm);
  border-top: 4px solid var(--border);
  cursor: pointer; transition: transform .15s, box-shadow .15s;
  position: relative;
}
.disaster-card:hover { transform: translateY(-2px); box-shadow: var(--shadow); }
.disaster-card.level-1 { border-top-color: var(--level-1); }
.disaster-card.level-2 { border-top-color: var(--level-2); }
.disaster-card.level-3 { border-top-color: var(--level-3); }
.disaster-card.level-4 { border-top-color: var(--level-4); }
.disaster-card.closed { opacity: .65; }

.disaster-card-header {
  display: flex; align-items: flex-start; justify-content: space-between; gap: 10px;
  margin-bottom: 10px;
}
.disaster-card-title { font-size: 1rem; font-weight: 700; }
.disaster-card-meta { font-size: .78rem; color: var(--text-muted); margin-bottom: 8px; }
.disaster-card-desc { font-size: .82rem; color: var(--text); margin-bottom: 12px; line-height: 1.5; }
.disaster-card-damage {
  display: inline-flex; align-items: center; gap: 5px;
  font-size: .8rem; font-weight: 500;
  color: #b7791f;
  background: #fffbeb;
  border: 1px solid #fef3c7;
  border-radius: 6px;
  padding: 3px 10px;
  margin-bottom: 8px;
}
.disaster-card-stats {
  display: flex; gap: 12px; flex-wrap: wrap;
}
.disaster-stat {
  display: flex; align-items: center; gap: 4px;
  font-size: .78rem; color: var(--text-muted);
}

.level-badge {
  font-size: .72rem; font-weight: 700; padding: 2px 8px;
  border-radius: 4px; color: #fff; white-space: nowrap;
}
.level-badge.level-1 { background: var(--level-1); }
.level-badge.level-2 { background: var(--level-2); color: #7b6002; }
.level-badge.level-3 { background: var(--level-3); }
.level-badge.level-4 { background: var(--level-4); }

.status-badge { }
.status-active  { background: #f0fff4; color: var(--success); border: 1px solid #c6f6d5; }
.status-watching{ background: #fffbeb; color: #b7791f; border: 1px solid #fef3c7; }
.status-closed  { background: #f7fafc; color: #718096; border: 1px solid var(--border); }

/* =====================================================
   DETAIL PANEL
   ===================================================== */
.detail-panel {
  background: var(--card-bg); border-radius: var(--radius);
  box-shadow: var(--shadow); overflow: hidden;
}
.detail-panel.hidden { display: none; }
.detail-header {
  padding: 20px 24px;
  border-bottom: 1px solid var(--border);
  display: flex; align-items: center; gap: 16px; flex-wrap: wrap;
}
.detail-header h2 { flex: 1; font-size: 1.2rem; font-weight: 700; min-width: 0; }

.update-list { padding: 20px 24px; }
.update-item {
  padding: 14px 16px; border-left: 3px solid var(--primary);
  background: var(--bg); border-radius: 0 8px 8px 0;
  margin-bottom: 10px;
}
.update-item .update-meta { font-size: .75rem; color: var(--text-muted); margin-bottom: 4px; }
.update-item .update-text { font-size: .9rem; }

/* =====================================================
   DISASTER SUMMARY CARDS (Dashboard)
   ===================================================== */
.disaster-summary-cards {
  display: flex; flex-direction: column; gap: 10px;
  max-height: 280px; overflow-y: auto; padding-right: 4px;
}
.disaster-summary-item {
  display: flex; align-items: center; gap: 12px;
  padding: 10px 14px; border-radius: 8px; background: var(--bg);
}
.disaster-summary-item .ds-name { flex: 1; font-size: .88rem; font-weight: 600; }
.disaster-summary-item .ds-count { font-size: .82rem; color: var(--text-muted); }

/* =====================================================
   BOARD
   ===================================================== */
.tab-bar {
  display: flex; gap: 4px; margin-bottom: 16px;
  background: var(--card-bg); padding: 6px;
  border-radius: var(--radius); box-shadow: var(--shadow-sm);
}
.tab-btn {
  padding: 7px 16px; border-radius: 7px; border: none;
  background: none; cursor: pointer; font-size: .85rem; font-weight: 500;
  color: var(--text-muted); transition: all .15s;
}
.tab-btn:hover { background: var(--bg); color: var(--text); }
.tab-btn.active { background: var(--primary); color: #fff; }

.board-list { display: flex; flex-direction: column; gap: 0; }

.board-item {
  background: var(--card-bg); padding: 16px 20px;
  border-bottom: 1px solid var(--border);
  display: flex; align-items: center; gap: 12px;
  cursor: pointer; transition: background .15s;
}
.board-item:first-child { border-radius: var(--radius) var(--radius) 0 0; }
.board-item:last-child { border-bottom: none; border-radius: 0 0 var(--radius) var(--radius); }
.board-item:first-child:last-child { border-radius: var(--radius); }
.board-item:hover { background: var(--bg); }

.board-item-icon {
  width: 36px; height: 36px; border-radius: 8px;
  display: flex; align-items: center; justify-content: center;
  font-size: .9rem; flex-shrink: 0;
}
.board-item-icon.notice  { background: #fff5f5; color: var(--danger); }
.board-item-icon.share   { background: #f0fff4; color: var(--success); }
.board-item-icon.photo   { background: var(--primary-light); color: var(--primary); }
.board-item-icon.report  { background: #faf5ff; color: #6b46c1; }

.board-item-body { flex: 1; min-width: 0; }
.board-item-title {
  font-size: .9rem; font-weight: 600; margin-bottom: 3px;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.board-item-meta { font-size: .75rem; color: var(--text-muted); }

.board-item-right { text-align: right; }
.board-item-right .date { font-size: .75rem; color: var(--text-muted); }

/* Board empty state */
.board-empty {
  background: var(--card-bg); border-radius: var(--radius);
  padding: 60px 20px; text-align: center; color: var(--text-muted);
}
.board-empty i { font-size: 2.5rem; margin-bottom: 12px; opacity: .4; }

/* Post detail */
.post-detail-body { padding: 24px; }
.post-meta { font-size: .82rem; color: var(--text-muted); margin-bottom: 16px; }
.post-content { line-height: 1.8; white-space: pre-wrap; margin-bottom: 20px; }
.post-images {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
  gap: 10px; margin-bottom: 20px;
}
.post-images img {
  width: 100%; aspect-ratio: 4/3; object-fit: cover;
  border-radius: 8px; cursor: pointer; transition: transform .15s;
}
.post-images img:hover { transform: scale(1.03); }
.post-files { display: flex; flex-direction: column; gap: 6px; }
.post-file-item {
  display: flex; align-items: center; gap: 8px;
  padding: 8px 12px; background: var(--bg); border-radius: 6px;
  font-size: .83rem;
}
.post-file-item i { color: var(--primary); }

/* =====================================================
   FILE UPLOAD ZONE
   ===================================================== */
.file-upload-zone {
  border: 2px dashed var(--border); border-radius: 10px;
  padding: 28px; text-align: center; cursor: pointer;
  transition: border-color .2s, background .2s;
  color: var(--text-muted);
}
.file-upload-zone:hover { border-color: var(--primary); background: var(--primary-light); }
.file-upload-zone i { font-size: 2rem; margin-bottom: 8px; display: block; }
.file-upload-zone p { font-size: .85rem; margin-bottom: 4px; }

.file-preview-list { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 10px; }
.file-preview-item {
  display: flex; align-items: center; gap: 6px;
  background: var(--bg); border-radius: 6px;
  padding: 6px 10px; font-size: .8rem;
  border: 1px solid var(--border);
}
.file-preview-item .remove-file {
  cursor: pointer; color: var(--danger);
  background: none; border: none; font-size: .85rem; padding: 0 2px;
}
.file-preview-img {
  width: 48px; height: 48px; object-fit: cover;
  border-radius: 4px; margin-right: 4px;
}

/* =====================================================
   ADMIN
   ===================================================== */

/* =====================================================
   SETTINGS
   ===================================================== */
.settings-grid {
  display: grid; grid-template-columns: 1fr 1fr; gap: 20px;
}
.settings-card {
  background: var(--card-bg); border-radius: var(--radius);
  padding: 24px; box-shadow: var(--shadow-sm);
}
.settings-card h3 {
  font-size: 1rem; font-weight: 600; margin-bottom: 12px;
  padding-bottom: 12px; border-bottom: 1px solid var(--border);
  display: flex; align-items: center; gap: 8px; color: var(--text);
}
.settings-card > .text-muted { font-size: .85rem; margin-bottom: 16px; }

.info-box {
  background: var(--primary-light); border-radius: 8px;
  padding: 14px 16px; margin-top: 16px;
}
.info-box h4 { font-size: .85rem; font-weight: 600; color: var(--primary); margin-bottom: 8px; }
.info-box ol { padding-left: 18px; }
.info-box li { font-size: .82rem; color: var(--text); margin-bottom: 5px; line-height: 1.5; }
.info-box code {
  background: rgba(30,111,181,.12); padding: 1px 5px; border-radius: 3px;
  font-family: monospace; font-size: .82rem;
}

.info-rows { display: flex; flex-direction: column; gap: 1px; }
.info-row {
  display: flex; justify-content: space-between; align-items: center;
  padding: 10px 0; border-bottom: 1px solid var(--border); font-size: .88rem;
}
.info-row:last-child { border-bottom: none; }

.connection-result {
  padding: 10px 14px; border-radius: 8px; margin-top: 10px; font-size: .85rem;
}
.connection-result.success { background: #f0fff4; color: var(--success); }
.connection-result.error   { background: #fff5f5; color: var(--danger); }

/* =====================================================
   MODALS
   ===================================================== */
.modal-overlay {
  position: fixed; inset: 0; z-index: 2000;
  background: rgba(0,0,0,.5);
  display: flex; align-items: center; justify-content: center;
  padding: 20px;
  backdrop-filter: blur(2px);
}
.modal-overlay.hidden { display: none !important; }

.modal {
  background: #fff; border-radius: 16px;
  width: 100%; max-width: 520px;
  max-height: 90vh; overflow: hidden;
  display: flex; flex-direction: column;
  box-shadow: 0 20px 60px rgba(0,0,0,.25);
  animation: modalIn .2s ease;
}
.modal.modal-large { max-width: 720px; }

@keyframes modalIn {
  from { opacity: 0; transform: scale(.95) translateY(-10px); }
  to   { opacity: 1; transform: scale(1) translateY(0); }
}

.modal-header {
  padding: 20px 24px;
  border-bottom: 1px solid var(--border);
  display: flex; align-items: center; justify-content: space-between;
  flex-shrink: 0;
}
.modal-header h3 { font-size: 1rem; font-weight: 700; }

.modal-close {
  width: 32px; height: 32px; border-radius: 6px; border: none;
  background: none; cursor: pointer; color: var(--text-muted);
  display: flex; align-items: center; justify-content: center;
  transition: background .15s;
}
.modal-close:hover { background: var(--bg); }

.modal-body {
  padding: 20px 24px;
  overflow-y: auto; flex: 1;
}

.modal-footer {
  padding: 16px 24px;
  border-top: 1px solid var(--border);
  display: flex; justify-content: flex-end; gap: 8px;
  flex-shrink: 0;
}

/* =====================================================
   TOAST
   ===================================================== */
.toast {
  position: fixed; bottom: 28px; right: 28px; z-index: 9999;
  background: #2d3748; color: #fff;
  padding: 12px 20px; border-radius: 10px;
  font-size: .88rem; box-shadow: 0 8px 24px rgba(0,0,0,.25);
  animation: toastIn .2s ease;
  max-width: 340px;
}
.toast.hidden { display: none; }
.toast.success { background: var(--success); }
.toast.error   { background: var(--danger); }
.toast.warning { background: var(--warning); color: #7b4f00; }

@keyframes toastIn {
  from { opacity: 0; transform: translateY(10px); }
  to   { opacity: 1; transform: translateY(0); }
}

/* =====================================================
   DISASTER BADGE (nav)
   ===================================================== */
.disaster-nav-badge {
  display: flex; align-items: center; gap: 6px;
  padding: 4px 12px; border-radius: 20px;
  font-size: .78rem; font-weight: 600; cursor: pointer;
  transition: opacity .15s;
}
.disaster-nav-badge:hover { opacity: .85; }
.disaster-nav-badge.level-4 { background: #fff5f5; color: var(--danger); border: 1px solid #fed7d7; }
.disaster-nav-badge.level-3 { background: #fffbeb; color: #b7791f; border: 1px solid #fef3c7; }
.disaster-nav-badge.level-2 { background: #fefce8; color: #92400e; border: 1px solid #fde68a; }
.disaster-nav-badge.level-1 { background: #f0fff4; color: var(--success); border: 1px solid #c6f6d5; }

/* =====================================================
   UTILITY
   ===================================================== */
.text-muted { color: var(--text-muted) !important; font-size: .82rem; }
.text-center { text-align: center; }
.hidden { display: none !important; }
.admin-only { display: none !important; }
.is-admin .admin-only { display: block !important; }
.is-admin li.admin-only { display: list-item !important; }
.is-admin a.admin-only { display: flex !important; }
.is-admin .admin-only.badge { display: inline-flex !important; }
.is-admin th.admin-only,
.is-admin td.admin-only { display: table-cell !important; }

/* Empty state */
.empty-state {
  text-align: center; padding: 48px 20px; color: var(--text-muted);
}
.empty-state i { font-size: 3rem; margin-bottom: 12px; opacity: .3; display: block; }
.empty-state p { font-size: .95rem; }

/* Lightbox */
.lightbox-overlay {
  position: fixed; inset: 0; z-index: 9998;
  background: rgba(0,0,0,.9);
  display: flex; align-items: center; justify-content: center;
  cursor: pointer;
}
.lightbox-overlay img { max-width: 90%; max-height: 90vh; border-radius: 4px; }

/* =====================================================
   RESPONSIVE
   ===================================================== */
/* =====================================================
   RESPONSIVE — 모바일 최적화
   ===================================================== */

/* ── 태블릿 (1200px 이하) ── */
@media (max-width: 1200px) {
  .kpi-grid { grid-template-columns: repeat(2, 1fr); }
  .support-kpi { grid-template-columns: repeat(3, 1fr); }
}

/* ── 중간 (900px 이하) ── */
@media (max-width: 900px) {
  .chart-grid { grid-template-columns: 1fr; }
  .chart-card.wide { grid-column: auto; }
  .input-layout { grid-template-columns: 1fr; }
  .settings-grid { grid-template-columns: 1fr; }
  .form-row-4 { grid-template-columns: repeat(2, 1fr); }
  .disaster-list { grid-template-columns: 1fr; }
}

/* ── 모바일 (768px 이하) ── */
@media (max-width: 768px) {
  :root {
    --sidebar-w: 0px;
    --nav-height: 56px;
  }

  html { font-size: 13px; }

  /* 사이드바: 오버레이 방식 */
  .sidebar {
    transform: translateX(-100%);
    width: 260px !important;
    z-index: 1100;
    box-shadow: 4px 0 24px rgba(0,0,0,.18);
  }
  .sidebar.open {
    transform: translateX(0);
  }

  /* 사이드바 열렸을 때 뒤 어둡게 */
  .sidebar-backdrop {
    display: none;
    position: fixed; inset: 0; z-index: 1050;
    background: rgba(0,0,0,.4);
  }
  .sidebar-backdrop.show { display: block; }

  /* 메인 콘텐츠 */
  .main-content {
    margin-left: 0 !important;
    padding: 14px 12px;
  }

  /* 네비게이션 */
  .top-nav { padding: 0 12px; gap: 8px; }
  .nav-brand span { display: none; } /* 브랜드명 숨기기 */
  .nav-brand i { font-size: 1.4rem; }
  .nav-center { gap: 4px; }
  .nav-user { font-size: .78rem; max-width: 80px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

  /* 재난 배지 — 네비게이션에서 텍스트 축약 */
  .disaster-nav-badge { padding: 3px 8px; font-size: .72rem; }
  .disaster-nav-badge span { display: none; }

  /* 페이지 헤더 */
  .page-header {
    flex-direction: column;
    align-items: flex-start;
    margin-bottom: 16px;
    gap: 8px;
  }
  .page-header h1 { font-size: 1.15rem; }
  .page-actions { width: 100%; justify-content: flex-end; flex-wrap: wrap; gap: 6px; }
  .page-actions .btn { font-size: .78rem; padding: 6px 11px; }

  /* KPI 그리드 */
  .kpi-grid { grid-template-columns: 1fr 1fr; gap: 10px; margin-bottom: 14px; }
  .kpi-card { padding: 14px 12px; gap: 10px; }
  .kpi-icon { width: 38px; height: 38px; font-size: 1rem; border-radius: 9px; }
  .kpi-value { font-size: 1.45rem; }
  .kpi-label { font-size: .72rem; }

  /* 차트 */
  .chart-grid { gap: 12px; margin-bottom: 14px; }
  .chart-card { padding: 14px; }
  .chart-card h3 { font-size: .88rem; }

  /* 지원 KPI */
  .support-kpi { grid-template-columns: repeat(3, 1fr); gap: 8px; }
  .support-kpi-item { padding: 10px 8px; }
  .support-kpi-item .value { font-size: 1.15rem; }
  .support-kpi-item .label { font-size: .7rem; }

  /* 필터 바 */
  .filter-bar {
    flex-direction: column;
    gap: 8px;
    padding: 12px;
  }
  .filter-bar .form-group { min-width: 100%; margin-bottom: 0; }
  .filter-bar .btn { width: 100%; justify-content: center; }

  /* 폼 */
  .form-row { grid-template-columns: 1fr; }
  .form-row-4 { grid-template-columns: 1fr 1fr; }
  .form-group input,
  .form-group select,
  .form-group textarea {
    font-size: 16px; /* iOS 자동 확대 방지 */
    padding: 10px 12px;
  }

  /* 테이블 — 가로 스크롤 */
  .table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }
  .data-table { font-size: .78rem; min-width: 480px; }
  .data-table th,
  .data-table td { padding: 8px 10px; }

  /* 카드 */
  .card-header { padding: 12px 14px; }
  .card-header h3 { font-size: .88rem; }

  /* 재난 현황 카드 */
  .disaster-list { grid-template-columns: 1fr; gap: 12px; }
  .disaster-card { padding: 14px; }
  .disaster-card-title { font-size: .95rem; }

  /* 게시판 탭 */
  .tab-bar { gap: 2px; padding: 4px; overflow-x: auto; -webkit-overflow-scrolling: touch; }
  .tab-btn { padding: 6px 12px; font-size: .78rem; white-space: nowrap; }

  /* 게시판 아이템 */
  .board-item { padding: 12px 14px; gap: 10px; }
  .board-item-title { font-size: .85rem; }
  .board-item-meta { font-size: .72rem; }
  .board-item-icon { width: 32px; height: 32px; font-size: .8rem; }

  /* 모달 */
  .modal-overlay { padding: 12px; align-items: flex-end; }
  .modal {
    border-radius: 16px 16px 0 0;
    max-height: 92vh;
    max-width: 100%;
  }
  .modal.modal-large { max-width: 100%; }
  .modal-header { padding: 16px 18px; }
  .modal-body { padding: 16px 18px; }
  .modal-footer { padding: 12px 18px; }
  .modal-footer .btn { flex: 1; justify-content: center; }

  /* 입력 페이지 */
  .input-layout { grid-template-columns: 1fr; gap: 14px; }
  .input-form-card,
  .input-history-card { padding: 16px; }

  /* 설정 */
  .settings-grid { grid-template-columns: 1fr; gap: 14px; }
  .settings-card { padding: 16px; }

  /* 버튼 터치 영역 확보 */
  .btn { min-height: 40px; }
  .btn-sm { min-height: 34px; font-size: .78rem; }
  .btn-icon { width: 40px; height: 40px; }

  /* 토스트 */
  .toast {
    bottom: 16px; right: 12px; left: 12px;
    max-width: 100%; text-align: center;
    font-size: .83rem;
  }

  /* 배지 */
  .badge { font-size: .7rem; padding: 3px 8px; }

  /* 디테일 패널 */
  .detail-header { padding: 14px 16px; flex-direction: column; align-items: flex-start; }
  .detail-header h2 { font-size: 1rem; }
  .update-list { padding: 14px 16px; }

  /* 사이드바 푸터 연결 상태 */
  .connection-status { font-size: .75rem; }

  /* 로그인 박스 */
  .login-box { padding: 32px 24px; }
  .login-box h2 { font-size: 1.25rem; }

  /* 빈 상태 */
  .empty-state { padding: 32px 16px; }
  .empty-state i { font-size: 2rem; }

  /* 이미지 그리드 */
  .post-images { grid-template-columns: repeat(2, 1fr); }
}

/* ── 소형 모바일 (480px 이하) ── */
@media (max-width: 480px) {
  html { font-size: 12px; }

  .login-box { padding: 28px 18px; border-radius: 16px; }
  .login-logo { width: 60px; height: 60px; font-size: 28px; }

  .kpi-grid { grid-template-columns: 1fr 1fr; gap: 8px; }
  .kpi-value { font-size: 1.3rem; }

  .support-kpi { grid-template-columns: repeat(2, 1fr); gap: 8px; }

  /* 네비 배지 완전 숨김 */
  .disaster-nav-badge { display: none; }

  /* 페이지 헤더 버튼 작게 */
  .page-actions .btn span { display: none; }
  .page-actions .btn i { margin: 0; }
  .page-actions .btn { padding: 8px 10px; min-width: 36px; }

  /* 테이블 */
  .data-table { font-size: .72rem; }

  /* 차트 높이 조정 */
  .chart-card canvas { max-height: 220px !important; }

  /* 모달 */
  .modal-body { padding: 14px; }
  .modal-footer { gap: 6px; }

  /* 폼 row 모두 1열 */
  .form-row-4 { grid-template-columns: 1fr; }

  /* 파일 업로드 */
  .file-upload-zone { padding: 20px 14px; }
  .file-upload-zone i { font-size: 1.6rem; }

  /* 게시판 탭 텍스트 축약 */
  .tab-btn { padding: 5px 10px; font-size: .75rem; }

  /* info-box */
  .info-box li { font-size: .78rem; }
}

/* ── 가로 모드 (핸드폰 landscape) ── */
@media (max-width: 768px) and (orientation: landscape) {
  .modal { max-height: 95vh; }
  .kpi-grid { grid-template-columns: repeat(4, 1fr); }
  .support-kpi { grid-template-columns: repeat(5, 1fr); }
}
