:root {
  --blush: #f7e9e9;
  --blush-2: #fcf4f1;
  --rose: #d99098;
  --rose-deep: #c06f7d;
  --gold: #c9a86a;
  --sage: #9bae9a;
  --ink: #4a4140;
  --ink-soft: #8a7d7b;
  --line: #ecdfdc;
  --card: #ffffff;
  --bg: #fbf6f4;
  --ok: #6f9b6f;
  --warn: #d4a24e;
  --danger: #c97a7a;
  --shadow: 0 8px 28px rgba(176, 130, 130, 0.14);
  --shadow-sm: 0 3px 12px rgba(176, 130, 130, 0.10);
  --radius: 18px;
  --serif: "Gowun Batang", serif;
  --sans: "Pretendard", -apple-system, system-ui, sans-serif;
}

* { box-sizing: border-box; margin: 0; padding: 0; }
html, body { height: 100%; }
body {
  font-family: var(--sans);
  color: var(--ink);
  background:
    radial-gradient(1200px 600px at 80% -10%, #fbeef0 0%, transparent 60%),
    radial-gradient(900px 500px at -10% 10%, #f3f6f1 0%, transparent 55%),
    var(--bg);
  -webkit-font-smoothing: antialiased;
}
.hidden { display: none !important; }
button { font-family: inherit; cursor: pointer; }
input, select, textarea { font-family: inherit; font-size: 15px; color: var(--ink); }

/* ===== 잠금 화면 ===== */
.lock-screen {
  position: fixed; inset: 0; z-index: 100;
  display: flex; align-items: center; justify-content: center;
  background:
    radial-gradient(800px 500px at 50% 0%, #fae3e6 0%, transparent 60%),
    linear-gradient(160deg, #fcf4f1, #f3f6f1);
  padding: 24px;
}
.lock-card {
  background: rgba(255,255,255,0.78);
  backdrop-filter: blur(8px);
  border: 1px solid var(--line);
  border-radius: 26px;
  box-shadow: var(--shadow);
  padding: 48px 40px;
  width: 100%; max-width: 420px;
  text-align: center;
}
.lock-rings { font-size: 48px; margin-bottom: 8px; }
.lock-title { font-family: var(--serif); font-size: 28px; color: var(--rose-deep); margin-bottom: 8px; }
.lock-sub { color: var(--ink-soft); margin-bottom: 28px; font-size: 14px; }
.lock-input-row { display: flex; gap: 8px; }
.lock-input-row input {
  flex: 1; padding: 14px 16px; border: 1px solid var(--line);
  border-radius: 12px; background: #fff; text-align: center; letter-spacing: 4px;
}
.lock-input-row input:focus { outline: none; border-color: var(--rose); box-shadow: 0 0 0 3px var(--blush); }
.lock-error { color: var(--danger); font-size: 13px; margin-top: 14px; min-height: 18px; }

/* ===== 버튼 ===== */
.btn-primary {
  background: linear-gradient(135deg, var(--rose), var(--rose-deep));
  color: #fff; border: none; border-radius: 12px; padding: 13px 20px;
  font-weight: 600; font-size: 15px; box-shadow: var(--shadow-sm);
  transition: transform .12s ease, filter .12s ease;
}
.btn-primary:hover { filter: brightness(1.05); transform: translateY(-1px); }
.btn-ghost {
  background: #fff; color: var(--rose-deep); border: 1px solid var(--line);
  border-radius: 12px; padding: 10px 16px; font-weight: 600; font-size: 14px;
  transition: all .12s ease;
}
.btn-ghost:hover { border-color: var(--rose); background: var(--blush-2); }
.icon-btn {
  background: transparent; border: none; font-size: 18px; line-height: 1;
  padding: 8px; border-radius: 10px; transition: background .12s;
}
.icon-btn:hover { background: var(--blush); }
.link-btn { background: none; border: none; color: var(--ink-soft); text-decoration: underline; font-size: 13px; }
.link-btn:hover { color: var(--rose-deep); }

/* ===== 헤더 ===== */
.app-header {
  position: sticky; top: 0; z-index: 20;
  background: rgba(255,255,255,0.85); backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--line);
}
.header-inner {
  max-width: 1080px; margin: 0 auto; padding: 18px 24px;
  display: flex; align-items: center; justify-content: space-between; gap: 16px;
}
.brand { font-family: var(--serif); font-size: 22px; color: var(--rose-deep); }
.brand-sub { font-size: 13px; color: var(--ink-soft); margin-top: 2px; }
.header-right { display: flex; align-items: center; gap: 12px; }
.dday {
  display: flex; flex-direction: column; align-items: flex-end; line-height: 1.2;
  background: linear-gradient(135deg, var(--blush), #fff);
  border: 1px solid var(--line); border-radius: 14px; padding: 8px 16px;
}
.dday-label { font-size: 11px; color: var(--ink-soft); }
.dday-num { font-family: var(--serif); font-size: 22px; color: var(--rose-deep); font-weight: 700; }
.dday-date { font-size: 11px; color: var(--ink-soft); }

/* ===== 탭 ===== */
.tabs {
  max-width: 1080px; margin: 0 auto; padding: 0 16px 12px;
  display: flex; gap: 6px; overflow-x: auto; scrollbar-width: none;
}
.tabs::-webkit-scrollbar { display: none; }
.tab {
  white-space: nowrap; padding: 9px 16px; border-radius: 999px;
  border: 1px solid transparent; background: transparent; color: var(--ink-soft);
  font-weight: 600; font-size: 14px; transition: all .12s ease;
}
.tab:hover { background: var(--blush-2); color: var(--rose-deep); }
.tab.active {
  background: linear-gradient(135deg, var(--rose), var(--rose-deep));
  color: #fff; box-shadow: var(--shadow-sm);
}

/* ===== 컨텐츠 ===== */
.content { max-width: 1080px; margin: 0 auto; padding: 28px 24px 64px; }
.section-head {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 20px; gap: 12px; flex-wrap: wrap;
}
.section-title { font-family: var(--serif); font-size: 24px; color: var(--ink); }
.section-desc { font-size: 13px; color: var(--ink-soft); margin-top: 4px; }

/* ===== 카드 ===== */
.grid { display: grid; gap: 16px; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); }
.card {
  background: var(--card); border: 1px solid var(--line); border-radius: var(--radius);
  box-shadow: var(--shadow-sm); padding: 20px; transition: transform .12s, box-shadow .12s;
  position: relative;
}
.card:hover { transform: translateY(-2px); box-shadow: var(--shadow); }
.card-top { display: flex; align-items: flex-start; justify-content: space-between; gap: 10px; }
.card-title { font-size: 17px; font-weight: 700; color: var(--ink); }
.card-actions { display: flex; gap: 2px; opacity: .55; }
.card:hover .card-actions { opacity: 1; }
.card-row { display: flex; gap: 8px; font-size: 14px; margin-top: 10px; color: var(--ink); }
.card-row .k { color: var(--ink-soft); min-width: 64px; }
.card-memo { margin-top: 12px; font-size: 13px; color: var(--ink-soft); white-space: pre-wrap; line-height: 1.6;
  border-top: 1px dashed var(--line); padding-top: 10px; }
.card-link { color: var(--rose-deep); text-decoration: none; word-break: break-all; }
.card-link:hover { text-decoration: underline; }

/* 상세 계약 카드 */
.card-wide { grid-column: 1 / -1; }
.contract-event {
  display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 12px;
  background: var(--blush-2); border: 1px solid var(--line); border-radius: 14px;
  padding: 16px; margin-top: 14px;
}
.ce-item .ce-k { font-size: 12px; color: var(--ink-soft); margin-bottom: 3px; }
.ce-item .ce-v { font-size: 14px; font-weight: 600; }
.contract-items td.dim { color: var(--ink-soft); }
.contract-items td.strong { font-weight: 700; color: var(--ink); }
.contract-items .neg { color: var(--ok); }
.contract-total {
  display: flex; justify-content: flex-end; align-items: baseline; gap: 24px;
  margin-top: 14px; flex-wrap: wrap; font-size: 14px;
}
.contract-total .ct-list { color: var(--ink-soft); text-decoration: line-through; }
.contract-total .ct-paid { color: var(--ok); }
.contract-total .ct-remain { color: var(--ink-soft); }
.contract-total .ct-final { color: var(--ink); }
.contract-total .ct-final strong { font-family: var(--serif); font-size: 20px; color: var(--rose-deep); margin-left: 6px; }

.toggle-detail {
  margin-top: 14px; width: 100%; display: flex; align-items: center; justify-content: center; gap: 6px;
  background: var(--blush-2); color: var(--rose-deep); border: 1px solid var(--line);
  border-radius: 11px; padding: 9px; font-weight: 600; font-size: 14px; transition: all .12s;
}
.toggle-detail:hover { background: var(--blush); border-color: var(--rose); }
.toggle-detail .tg-chev { transition: transform .2s ease; font-size: 12px; }
.toggle-detail.open .tg-chev { transform: rotate(180deg); }
.contract-detail { animation: fade .2s ease; }
.contract-detail .card-row { margin-top: 10px; }

/* 상태 뱃지 */
.badge { font-size: 12px; font-weight: 700; padding: 4px 10px; border-radius: 999px; white-space: nowrap; }
.badge.확정, .badge.계약완료 { background: #e7f1e7; color: var(--ok); }
.badge.후보, .badge.검토중 { background: #fdf2e3; color: var(--warn); }
.badge.계약예정 { background: #eaf0f7; color: #5d7fa8; }
.badge.보류 { background: #f0ece9; color: var(--ink-soft); }
.badge.탈락, .badge.취소 { background: #f7e9e9; color: var(--danger); }

/* 빈 상태 */
.empty {
  text-align: center; padding: 56px 20px; color: var(--ink-soft);
  border: 2px dashed var(--line); border-radius: var(--radius); background: #fff;
}
.empty .em-emoji { font-size: 40px; display: block; margin-bottom: 12px; }
.empty .em-title { font-size: 16px; color: var(--ink); margin-bottom: 6px; }

/* ===== 예산 대시보드 ===== */
.budget-hero {
  background: linear-gradient(135deg, #fff, var(--blush-2));
  border: 1px solid var(--line); border-radius: 22px; padding: 26px;
  box-shadow: var(--shadow-sm); margin-bottom: 22px;
}
.budget-total-row { display: flex; align-items: center; justify-content: space-between; gap: 16px; flex-wrap: wrap; }
.budget-set { display: flex; align-items: center; gap: 10px; }
.budget-set input { padding: 10px 14px; border: 1px solid var(--line); border-radius: 10px; width: 180px; text-align: right; }
.budget-stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(140px,1fr)); gap: 14px; margin-top: 22px; }
.stat { background: #fff; border: 1px solid var(--line); border-radius: 14px; padding: 16px; }
.stat .s-label { font-size: 12px; color: var(--ink-soft); }
.stat .s-val { font-family: var(--serif); font-size: 22px; margin-top: 6px; font-weight: 700; }
.stat .s-val.spent { color: var(--rose-deep); }
.stat .s-val.left { color: var(--ok); }
.stat .s-val.over { color: var(--danger); }
.progress { height: 12px; border-radius: 999px; background: var(--blush); overflow: hidden; margin-top: 16px; }
.progress > span { display: block; height: 100%; border-radius: 999px;
  background: linear-gradient(90deg, var(--rose), var(--rose-deep)); transition: width .4s ease; }
.progress.over > span { background: linear-gradient(90deg, #d98a8a, var(--danger)); }

.cat-bars { display: grid; gap: 14px; margin-top: 6px; }
.cat-bar { background: #fff; border: 1px solid var(--line); border-radius: 14px; padding: 14px 16px; }
.cat-bar .cb-top { display: flex; justify-content: space-between; font-size: 14px; margin-bottom: 8px; }
.cat-bar .cb-name { font-weight: 700; }
.cat-bar .cb-amt { color: var(--ink-soft); }
.mini-progress { height: 8px; border-radius: 999px; background: var(--blush); overflow: hidden; }
.mini-progress > span { display: block; height: 100%; background: linear-gradient(90deg, var(--sage), #7e9a7d); }

/* 테이블 (예산 항목) */
.table-wrap { background: #fff; border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; box-shadow: var(--shadow-sm); }
table { width: 100%; border-collapse: collapse; font-size: 14px; }
thead th { background: var(--blush-2); color: var(--ink-soft); font-weight: 600; text-align: left; padding: 12px 14px; font-size: 13px; }
tbody td { padding: 12px 14px; border-top: 1px solid var(--line); }
tbody tr:hover { background: var(--blush-2); }
td.num, th.num { text-align: right; }
.row-actions { display: flex; gap: 2px; justify-content: flex-end; }

/* ===== 달력 ===== */
.cal-head { display: flex; align-items: center; justify-content: center; gap: 18px; margin-bottom: 18px; }
.cal-head h3 { font-family: var(--serif); font-size: 20px; min-width: 150px; text-align: center; }
.calendar { background: #fff; border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; box-shadow: var(--shadow-sm); }
.cal-grid { display: grid; grid-template-columns: repeat(7, 1fr); }
.cal-dow { text-align: center; padding: 12px 0; font-size: 13px; font-weight: 600; color: var(--ink-soft); background: var(--blush-2); }
.cal-dow.sun { color: var(--danger); }
.cal-cell { min-height: 96px; border-top: 1px solid var(--line); border-left: 1px solid var(--line); padding: 6px; cursor: pointer; transition: background .12s; }
.cal-cell:nth-child(7n+1) { border-left: none; }
.cal-cell:hover { background: var(--blush-2); }
.cal-cell.muted { background: #fbfafa; color: #cbc3c1; }
.cal-cell.today { background: var(--blush); }
.cal-date { font-size: 13px; font-weight: 600; }
.cal-cell.today .cal-date { color: var(--rose-deep); }
.cal-cell .sun-date { color: var(--danger); }
.cal-cell.wedding { background: linear-gradient(135deg, #fbe4e8, #fff); }
.cal-event { font-size: 11px; padding: 2px 6px; border-radius: 6px; margin-top: 3px;
  background: var(--blush); color: var(--rose-deep); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.cal-event.식장 { background: #fdeef0; color: var(--rose-deep); }
.cal-event.신혼여행 { background: #eaf2ea; color: #5e7e5e; }
.cal-event.스드메 { background: #f3ecf7; color: #7d5d9b; }
.cal-event.웨딩플래너 { background: #eef2f8; color: #5d7fa8; }
.cal-event.신혼집 { background: #fcf3e6; color: #9b7d3d; }
.cal-event.wedding-day { background: var(--rose-deep); color: #fff; font-weight: 700; }
.upcoming { margin-top: 24px; }
.upcoming h4 { font-family: var(--serif); font-size: 16px; margin-bottom: 12px; color: var(--ink); }
.up-item { display: flex; align-items: center; gap: 12px; background: #fff; border: 1px solid var(--line);
  border-radius: 12px; padding: 12px 16px; margin-bottom: 8px; }
.up-date { font-family: var(--serif); font-weight: 700; color: var(--rose-deep); min-width: 88px; }
.up-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--rose); }

/* ===== 모달 ===== */
.modal-overlay {
  position: fixed; inset: 0; z-index: 200; background: rgba(74,65,64,0.4);
  backdrop-filter: blur(3px); display: flex; align-items: center; justify-content: center; padding: 20px;
}
.modal {
  background: #fff; border-radius: 22px; width: 100%; max-width: 480px;
  max-height: 90vh; overflow-y: auto; box-shadow: var(--shadow);
}
.modal-head { display: flex; align-items: center; justify-content: space-between; padding: 22px 24px 8px; }
.modal-head h3 { font-family: var(--serif); font-size: 20px; color: var(--ink); }
.modal-form { padding: 8px 24px 26px; display: grid; gap: 14px; }
.field label { display: block; font-size: 13px; font-weight: 600; color: var(--ink-soft); margin-bottom: 6px; }
.field input, .field select, .field textarea {
  width: 100%; padding: 11px 13px; border: 1px solid var(--line); border-radius: 11px; background: #fff;
}
.field input:focus, .field select:focus, .field textarea:focus { outline: none; border-color: var(--rose); box-shadow: 0 0 0 3px var(--blush); }
.field textarea { resize: vertical; min-height: 80px; line-height: 1.6; }
.field-row { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.modal-actions { display: flex; gap: 10px; margin-top: 8px; }
.modal-actions .btn-primary { flex: 1; }

/* 반응형 */
@media (max-width: 640px) {
  .header-inner { flex-wrap: wrap; }
  .brand { font-size: 19px; }
  .content { padding: 20px 14px 60px; }
  .cal-cell { min-height: 64px; }
  .field-row { grid-template-columns: 1fr; }
  .dday { padding: 6px 12px; }
}

.app-footer {
  max-width: 1080px; margin: 0 auto; padding: 20px 24px 36px;
  display: flex; align-items: center; gap: 16px; color: var(--ink-soft); font-size: 13px;
  border-top: 1px solid var(--line);
}
.app-footer span { margin-right: auto; }
.fade-in { animation: fade .25s ease; }
@keyframes fade { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }
