:root {
  --primary-orange: #ff6d2d;
  --orange-light: #fff1e9;
  --orange-soft: #ffd9c7;
  --navy-text: #1f2a44;
  --sky-light: #eaf4fb;
  --mint-light: #eaf8f2;
  --purple-light: #f2eeff;
  --gray-bg: #f6f7f9;
  --white: #ffffff;
  --line: #e3e6ec;
  --muted: #687385;
  --header-height: 76px;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: "Segoe UI", "Apple SD Gothic Neo", "Malgun Gothic", sans-serif;
  font-size: 14px;
  color: var(--navy-text);
  background: var(--gray-bg);
}
body.authed { padding-top: var(--header-height); }

button, input, select, textarea { font: inherit; }
button {
  cursor: pointer;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 10px 15px;
  color: inherit;
}
button:hover { border-color: var(--primary-orange); }
button.primary, .primary {
  background: var(--primary-orange);
  border-color: var(--primary-orange);
  color: #fff;
  font-weight: 600;
}
a { color: inherit; text-decoration: none; }
h1 { font-size: 26px; margin: 8px 0 12px; }
h2 { font-size: 18px; margin: 24px 0 12px; }
p.intro { color: var(--muted); line-height: 1.8; }
.muted { color: var(--muted); }

/* Header */
body.authed > header {
  position: fixed;
  inset: 0 0 auto;
  height: var(--header-height);
  z-index: 20;
  background: var(--white);
  border-bottom: 1px solid var(--line);
}
.header-inner {
  max-width: 1400px;
  height: 100%;
  margin: 0 auto;
  padding: 0 28px;
  display: flex;
  align-items: center;
  gap: 24px;
}
.logo-home { font-weight: 700; font-size: 16px; white-space: nowrap; }
.logo-home strong { color: var(--primary-orange); }
header nav { display: flex; gap: 4px; flex: 1; flex-wrap: wrap; }
header nav a { padding: 10px 14px; border-radius: 8px; font-weight: 600; font-size: 13px; color: var(--muted); }
header nav a.active { background: var(--orange-light); color: #ae4315; }
.header-actions { display: flex; align-items: center; gap: 14px; font-size: 13px; }
.notif-bell { position: relative; font-size: 18px; }
.badge-dot {
  position: absolute; top: -6px; right: -10px;
  background: var(--primary-orange); color: #fff;
  border-radius: 999px; font-size: 10px; padding: 1px 5px;
}
.user-chip { color: var(--muted); }
.text-button { border: 0; background: transparent; color: var(--muted); padding: 5px; }
.text-button:hover { color: var(--primary-orange); border-color: transparent; }

/* Layout */
#app { max-width: 1400px; margin: 0 auto; padding: 24px 28px 64px; min-height: 60vh; }
.dashboard-layout { display: flex; flex-direction: column; gap: 28px; }
.section-block { margin-bottom: 8px; }
.section-head { display: flex; align-items: baseline; justify-content: space-between; gap: 16px; margin-bottom: 12px; }
.section-head h2 { margin: 0; }
.panel { background: var(--white); border: 1px solid var(--line); border-radius: 16px; padding: 24px; box-shadow: 0 4px 20px #1f2a4405; }
.welcome.panel { background: linear-gradient(125deg, var(--white) 60%, var(--sky-light)); }
.welcome-facts { display: flex; gap: 18px; margin-top: 12px; font-size: 13px; color: var(--muted); }
.eyebrow { font-size: 11px; letter-spacing: 1.5px; color: var(--primary-orange); font-weight: 700; }

/* Cards */
.cards { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 16px; }
.service {
  display: flex; flex-direction: column; gap: 8px;
  background: var(--white); border: 1px solid var(--line); border-radius: 14px;
  padding: 18px; min-width: 0;
}
.service:hover { border-color: var(--primary-orange); }
.service-icon { font-size: 30px; }
.service h3 { margin: 0; font-size: 16px; }
.service p { margin: 0; font-size: 13px; color: var(--muted); flex: 1; }
.card-top { display: flex; justify-content: space-between; align-items: center; gap: 8px; }
.category { font-size: 11px; padding: 4px 8px; border-radius: 6px; background: var(--orange-light); color: #ae4315; white-space: nowrap; }
.card-bottom { border-top: 1px solid #eef0f2; padding-top: 12px; margin-top: auto; }
.deadline { font-size: 12px; color: var(--muted); }

/* Status badges */
.status-badge { font-size: 11px; padding: 4px 8px; border-radius: 999px; white-space: nowrap; }
.status-available { background: #dcfce7; color: #15803d; }
.status-apply { background: #fef9c3; color: #a16207; }
.status-applied { background: #dbeafe; color: #1d4ed8; }
.status-unavailable { background: #f3f4f6; color: #6b7280; }
.status-expired { background: #fee2e2; color: #b91c1c; }
.badge { display: inline-block; padding: 5px 9px; border-radius: 6px; font-size: 12px; background: #f3f4f6; color: #4b5563; }

/* Category chips */
.category-chips { display: flex; gap: 10px; flex-wrap: wrap; }
.chip { display: flex; align-items: center; gap: 6px; padding: 8px 14px; border: 1px solid var(--line); border-radius: 999px; font-size: 13px; background: var(--white); }
.chip:hover { border-color: var(--primary-orange); }
.chip .count { background: var(--gray-bg); border-radius: 999px; padding: 1px 7px; font-size: 11px; color: var(--muted); }

/* Tables */
.table-wrap { overflow-x: auto; border: 1px solid var(--line); border-radius: 12px; background: var(--white); }
table { border-collapse: collapse; width: 100%; min-width: 640px; font-size: 13px; }
th, td { padding: 14px 18px; text-align: left; border-bottom: 1px solid var(--line); white-space: nowrap; }
th { background: #fafbfc; color: var(--muted); font-size: 12px; font-weight: 600; }
tr:last-child td { border-bottom: 0; }
.inline-form { display: flex; gap: 8px; }
.inline-form select { width: auto; flex: 0 0 auto; }
.status-select { min-width: 172px; }

/* Forms */
.field { display: flex; flex-direction: column; gap: 6px; font-size: 13px; font-weight: 500; }
.field-label { font-size: 13px; }
input, select, textarea {
  padding: 11px 12px; border: 1px solid #dfe2e6; border-radius: 8px; background: #fff; color: #343a43; width: 100%;
}
.toolbar { display: flex; gap: 10px; margin-bottom: 18px; flex-wrap: wrap; }
.toolbar input { max-width: 320px; }
.apply-form { margin-top: 20px; display: flex; flex-direction: column; gap: 12px; }
.apply-form textarea { width: 100%; min-width: 320px; }
.apply-form > button.primary { align-self: flex-start; }

/* Detail */
.service-detail h1 { display: flex; align-items: center; gap: 10px; }
.detail-facts { display: grid; grid-template-columns: 110px 1fr; gap: 10px 16px; font-size: 13px; margin: 20px 0; }
.detail-facts dt { color: var(--muted); }
.detail-facts dd { margin: 0; }
.notice { font-size: 13px; color: #986b4c; background: #fff8f1; border-radius: 8px; padding: 12px 14px; line-height: 1.7; margin: 12px 0; }
.notice.error { color: #b91c1c; background: #fee2e2; }

/* Profile */
.profile-facts { display: grid; grid-template-columns: 90px 1fr; gap: 14px 16px; font-size: 13px; }
.profile-facts dt { color: var(--muted); }
.profile-facts dd { margin: 0; }

/* Auth */
.auth-wrap { display: flex; justify-content: center; padding: 60px 16px; }
.auth-card { max-width: 380px; width: 100%; background: var(--white); border: 1px solid var(--line); border-radius: 16px; padding: 32px; box-shadow: 0 4px 20px #1f2a4405; }
.auth-form { display: flex; flex-direction: column; gap: 14px; margin-top: 20px; }
.auth-hint { font-size: 11px; color: var(--muted); margin-top: 18px; text-align: center; }

/* Notifications */
.notif-list { list-style: none; padding: 0; margin: 0; display: flex; flex-direction: column; gap: 10px; }
.notif-list li { background: var(--white); border: 1px solid var(--line); border-radius: 12px; padding: 16px; }
.notif-list li.unread { border-color: var(--orange-soft); background: var(--orange-light); }
.notif-list p { margin: 6px 0; font-size: 13px; }

/* Flash */
.flash-wrap { max-width: 1400px; margin: 12px auto 0; padding: 0 28px; }
.flash { background: var(--orange-light); color: #ae4315; padding: 12px 16px; border-radius: 10px; margin-bottom: 8px; font-size: 13px; }

.empty { text-align: center; padding: 48px 20px; color: var(--muted); border: 1px dashed var(--line); border-radius: 12px; background: var(--white); }

footer { border-top: 1px solid var(--line); padding: 24px 28px; color: #8a9098; font-size: 11px; display: flex; justify-content: space-between; gap: 20px; max-width: 1400px; margin: 0 auto; }

@media (max-width: 1000px) {
  .cards { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 700px) {
  .header-inner { padding: 0 14px; gap: 10px; }
  header nav { display: none; }
  #app { padding: 16px 14px 40px; }
  .cards { grid-template-columns: 1fr; }
  .detail-facts { grid-template-columns: 1fr; }
  footer { flex-direction: column; padding: 20px 14px; }
}

/* ---- 신청 상태 색상 배지 ---- */
.app-status-gray { background: #f3f4f6; color: #4b5563; }
.app-status-blue { background: #dbeafe; color: #1d4ed8; }
.app-status-orange { background: #ffedd5; color: #c2410c; }
.app-status-green { background: #dcfce7; color: #15803d; }
.app-status-red { background: #fee2e2; color: #b91c1c; }
.app-status-navy { background: #e0e7ff; color: #3730a3; }
.app-status-muted { background: #f3f4f6; color: #9ca3af; text-decoration: line-through; }

.urgent-flag { color: #b91c1c; font-weight: 700; font-size: 12px; margin-left: 6px; }

/* ---- 서비스 카드 다중선택 ---- */
.service-body { display: contents; }
.service { position: relative; }
.check-label.select-check { font-size: 12px; color: var(--muted); gap: 5px; }
.check-label.select-check input { width: 15px; height: 15px; accent-color: var(--primary-orange); }

.batch-bar {
  position: sticky; bottom: 16px; margin-top: 18px; padding: 14px 20px;
  background: var(--orange-light); border: 1px solid var(--orange-soft); border-radius: 12px;
  display: flex; align-items: center; justify-content: space-between; gap: 16px;
}

/* ---- 신청/첨부/긴급 입력 ---- */
.apply-fields-panel + .apply-fields-panel { margin-top: 16px; }
.apply-fields-block { display: flex; flex-direction: column; gap: 14px; }
.apply-fields-heading { display: flex; align-items: center; gap: 8px; font-size: 15px; }
.service-icon-sm { font-size: 20px; }
.document-group { border: 1px solid var(--line); border-radius: 10px; padding: 14px; display: flex; flex-direction: column; gap: 10px; }
.check-label { display: flex; align-items: center; gap: 8px; font-size: 13px; font-weight: 500; }
.urgent-block { border-top: 1px solid var(--line); padding-top: 12px; }
.urgent-date-fields { margin-top: 10px; }
.split-date { display: grid; grid-template-columns: 1.4fr auto 1fr auto 1fr auto; align-items: center; gap: 6px; max-width: 420px; }
.split-date input { text-align: center; padding: 10px 6px; }
.split-date .urgent-calendar { padding: 6px; }
.field-error { color: #b91c1c; font-size: 12px; min-height: 16px; margin: 4px 0 0; }
.batch-apply-form .primary { margin-top: 10px; }

/* ---- 상태 카운트 pill / 필터 ---- */
.status-pill-row { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 16px; }
.status-pill {
  display: flex; align-items: center; gap: 6px; padding: 8px 14px; border-radius: 999px;
  border: 1px solid var(--line); background: var(--white); font-size: 12px; color: var(--muted);
}
.status-pill .count { background: var(--gray-bg); border-radius: 999px; padding: 1px 7px; font-size: 11px; }
.status-pill.active { border-color: var(--primary-orange); background: var(--orange-light); color: #ae4315; font-weight: 600; }
.filter-toolbar { align-items: flex-end; }
.filter-toolbar .field { font-size: 12px; }
.filter-toolbar input, .filter-toolbar select { min-width: 140px; }

/* ---- 신청내역 아코디언 ---- */
.app-list { display: flex; flex-direction: column; gap: 10px; }
.app-row { background: var(--white); border: 1px solid var(--line); border-radius: 12px; padding: 4px 18px; }
.app-row summary {
  cursor: pointer; list-style: none; padding: 14px 0; display: flex; align-items: center;
  gap: 14px; flex-wrap: wrap; font-size: 13px;
}
.app-row summary::-webkit-details-marker { display: none; }
.app-row summary::before { content: "›"; display: inline-block; transition: transform .15s; font-size: 18px; color: var(--muted); }
.app-row[open] summary::before { transform: rotate(90deg); }
.app-row-main { display: flex; align-items: center; gap: 4px; }
.app-row-detail { border-top: 1px solid var(--line); padding: 16px 0 18px; display: flex; flex-direction: column; gap: 6px; }
.app-row-detail h4 { margin: 14px 0 6px; font-size: 13px; color: var(--muted); }
.app-row-detail h4:first-child { margin-top: 0; }
.history-list, .attachment-list, .inquiry-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 6px; font-size: 13px; }
.inquiry-item { border: 1px solid var(--line); border-radius: 8px; padding: 10px 12px; margin-bottom: 8px; }
.inquiry-answer { color: #15803d; }
.cancel-form input { max-width: 320px; }

/* ---- 알림 드롭다운 ---- */
.notif-wrap { position: relative; }
.notif-panel {
  position: absolute; top: 36px; right: 0; width: 320px; max-height: 400px; overflow-y: auto;
  background: var(--white); border: 1px solid var(--line); border-radius: 12px;
  box-shadow: 0 12px 32px #1f2a4422; z-index: 30;
}
.notif-panel-head { display: flex; justify-content: space-between; align-items: center; padding: 12px 16px; border-bottom: 1px solid var(--line); font-size: 13px; }
.notif-panel-head a { color: var(--primary-orange); font-size: 12px; }
.notif-panel-body { padding: 6px; }
.notif-item { padding: 10px 10px; border-radius: 8px; font-size: 12px; }
.notif-item.unread { background: var(--orange-light); }
.notif-item strong { display: block; font-size: 13px; margin-bottom: 3px; }
.notif-item p { margin: 2px 0; color: var(--navy-text); }

@media (max-width: 700px) {
  .split-date { grid-template-columns: 1fr auto 1fr auto 1fr; }
  .split-date .urgent-calendar { grid-column: 1 / -1; margin-top: 6px; }
  .notif-panel { width: calc(100vw - 28px); right: -14px; }
}
