:root {
  --bg: #F5F6FA;
  --white: #FFFFFF;
  --card: #FFFFFF;
  --border: #E8ECF0;
  --text-main: #1A1A2E;
  --text-sub: #6B7280;
  --text-dim: #B0B8C4;
  --accent: #FF6B35;
  --accent-light: #FFF0EB;
}

* { margin: 0; padding: 0; box-sizing: border-box; -webkit-tap-highlight-color: transparent; }

body {
  background: var(--bg);
  color: var(--text-main);
  font-family: -apple-system, 'Apple SD Gothic Neo', 'Noto Sans KR', sans-serif;
  font-size: 15px;
  min-height: 100vh;
}

a { text-decoration: none; color: inherit; }
.hidden { display: none !important; }

/* ====== 로그인 ====== */
.login-screen {
  display: flex; align-items: center; justify-content: center;
  min-height: 100vh; padding: 24px;
  background: var(--bg);
}
.login-box {
  width: 100%; max-width: 360px;
  background: var(--card); border-radius: 20px;
  padding: 40px 28px; text-align: center;
  box-shadow: 0 4px 24px rgba(0,0,0,0.08);
}
.login-box h1 { font-size: 26px; font-weight: 800; color: var(--accent); margin-bottom: 6px; }
.login-box .subtitle { font-size: 14px; color: var(--text-sub); margin-bottom: 32px; }
.login-box input {
  width: 100%; padding: 14px 16px;
  background: var(--bg); border: 1.5px solid var(--border);
  border-radius: 12px; color: var(--text-main);
  font-size: 16px; text-align: center;
  outline: none; margin-bottom: 12px;
  transition: border-color 0.2s;
}
.login-box input:focus { border-color: var(--accent); background: #fff; }
.login-box button {
  width: 100%; padding: 14px;
  background: var(--accent); border: none;
  border-radius: 12px; color: #fff;
  font-size: 16px; font-weight: 700; cursor: pointer;
}
.login-box button:active { opacity: 0.85; }
.login-error { display: none; color: #E74C3C; font-size: 13px; margin-top: 10px; }

@keyframes shake {
  0%, 100% { transform: translateX(0); }
  20%, 60% { transform: translateX(-8px); }
  40%, 80% { transform: translateX(8px); }
}
.shake { animation: shake 0.4s ease; border-color: #E74C3C !important; }

/* ====== 대시보드 ====== */
.header {
  padding: 20px 16px 12px;
  background: var(--white);
  border-bottom: 1px solid var(--border);
  position: sticky; top: 0; z-index: 10;
}
.header h1 { font-size: 22px; font-weight: 800; }
.header-sub {
  font-size: 13px; color: var(--text-sub);
  margin: 2px 0 14px; display: flex; align-items: center; gap: 8px;
}
.header-count {
  background: var(--accent); color: #fff;
  font-size: 11px; font-weight: 700;
  padding: 2px 8px; border-radius: 20px;
}

.header-top {
  display: flex; justify-content: space-between;
  align-items: flex-start; margin-bottom: 4px;
}
.refresh-btn {
  flex-shrink: 0;
  background: var(--accent); color: #fff;
  border: none; border-radius: 10px;
  padding: 8px 14px; font-size: 13px; font-weight: 700;
  cursor: pointer; white-space: nowrap;
}
.refresh-btn:disabled { opacity: 0.6; cursor: not-allowed; }
.refresh-btn:active:not(:disabled) { opacity: 0.85; }

.progress-wrap {
  margin: 10px 0 6px;
}
.progress-bar-bg {
  background: var(--border); border-radius: 20px;
  height: 8px; overflow: hidden; margin-bottom: 6px;
}
.progress-bar-fill {
  height: 100%; background: var(--accent);
  border-radius: 20px;
  transition: width 0.3s ease;
  width: 0%;
}
.progress-text {
  font-size: 12px; color: var(--text-sub);
}
.last-updated-row {
  font-size: 11px; color: var(--text-dim);
  margin-bottom: 10px;
}

.filter-bar {
  display: flex; gap: 8px;
  overflow-x: auto; scrollbar-width: none;
}
.filter-bar::-webkit-scrollbar { display: none; }
.filter-chip {
  flex-shrink: 0; padding: 6px 14px;
  background: var(--bg); border: 1.5px solid var(--border);
  border-radius: 20px; color: var(--text-sub);
  font-size: 13px; cursor: pointer; white-space: nowrap;
  font-weight: 500;
}
.filter-chip.active {
  background: var(--accent); border-color: var(--accent);
  color: #fff; font-weight: 700;
}
.filter-chip.chip-cancel { color: #E74C3C; border-color: #E74C3C44; }
.filter-chip.chip-cancel.active { background: #E74C3C; border-color: #E74C3C; color: #fff; }
.filter-chip.chip-done { color: #95A5A6; border-color: #95A5A644; }
.filter-chip.chip-done.active { background: #95A5A6; border-color: #95A5A6; color: #fff; }

.card-list { padding: 16px; display: flex; flex-direction: column; gap: 12px; }

.ad-card {
  display: block; background: var(--card);
  border: 1.5px solid var(--border); border-radius: 16px; padding: 16px;
  box-shadow: 0 2px 8px rgba(0,0,0,0.05);
  transition: border-color 0.15s, transform 0.1s;
}
.ad-card:active { transform: scale(0.98); border-color: var(--accent); }

.card-top {
  display: flex; justify-content: space-between;
  align-items: flex-start; margin-bottom: 10px; gap: 8px;
}
.card-brand { font-size: 17px; font-weight: 800; flex: 1; }
.stage-badge {
  flex-shrink: 0; font-size: 11px; font-weight: 700;
  padding: 4px 10px; border-radius: 20px;
}
.card-row {
  display: flex; gap: 10px; margin-bottom: 8px;
  font-size: 13px; color: var(--text-sub);
}
.card-amount { font-weight: 700; color: var(--accent); }
.card-schedule { font-size: 12px; color: var(--text-sub); margin-bottom: 6px; }
.card-contact {
  font-size: 13px; color: var(--text-sub);
  margin-bottom: 6px; display: flex; flex-wrap: wrap; align-items: center; gap: 4px;
}
.card-phone {
  color: #2980B9; font-weight: 600;
}
.card-agency { color: var(--text-dim); }
.card-updated { font-size: 11px; color: var(--text-dim); margin-top: 4px; }

/* ====== 상세 페이지 ====== */
.detail-page { padding-bottom: 60px; max-width: 480px; margin: 0 auto; }

.back-btn {
  display: block; padding: 16px;
  color: var(--accent); font-size: 14px; font-weight: 700;
}
.back-btn:active { opacity: 0.7; }

.detail-header {
  background: var(--white); padding: 12px 16px 20px;
  border-bottom: 1px solid var(--border);
}
.detail-header h1 { font-size: 22px; font-weight: 800; margin-bottom: 10px; }

.section {
  background: var(--white); margin-top: 8px;
  padding: 20px 16px;
  border-top: 1px solid var(--border);
  border-bottom: 1px solid var(--border);
}
.section-title {
  font-size: 11px; font-weight: 800;
  color: var(--text-dim); text-transform: uppercase;
  letter-spacing: 1px; margin-bottom: 14px;
}

/* 기본 정보 */
.info-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.info-item { background: var(--bg); border-radius: 10px; padding: 12px; }
.info-label { font-size: 11px; color: var(--text-dim); margin-bottom: 4px; }
.info-value { font-size: 14px; font-weight: 700; color: var(--text-main); }

/* 담당자 */
.contact-box { background: var(--bg); border-radius: 12px; padding: 14px; }
.contact-row {
  display: flex; justify-content: space-between;
  align-items: center; margin-bottom: 8px;
}
.contact-name { font-size: 16px; font-weight: 700; }
.call-btn {
  background: #E8F5E9; color: #27AE60;
  border: 1.5px solid #27AE6055;
  padding: 8px 14px; border-radius: 20px;
  font-size: 13px; font-weight: 700;
}
.call-btn:active { opacity: 0.7; }
.no-phone { font-size: 13px; color: var(--text-dim); }
.contact-agency { font-size: 13px; color: var(--text-sub); margin-bottom: 10px; }
.phone-edit-row { display: flex; gap: 8px; align-items: center; margin-top: 8px; }

/* 타임라인 */
.tl-item { display: flex; gap: 12px; min-height: 52px; }
.tl-left {
  display: flex; flex-direction: column;
  align-items: center; flex-shrink: 0; width: 18px;
}
.tl-dot {
  width: 14px; height: 14px;
  background: var(--border); border-radius: 50%;
  flex-shrink: 0; margin-top: 3px;
}
.tl-line {
  flex: 1; width: 2px;
  background: var(--border); margin: 4px 0;
}
.tl-right { flex: 1; padding-bottom: 14px; }
.tl-name { font-size: 14px; font-weight: 600; display: flex; align-items: center; gap: 6px; }
.tl-now {
  font-size: 10px; background: var(--accent); color: #fff;
  padding: 2px 7px; border-radius: 10px; font-weight: 700;
}
.tl-date { font-size: 12px; color: var(--text-sub); margin: 3px 0; }
.tl-summary {
  font-size: 13px; color: var(--text-sub);
  background: var(--bg); border-radius: 8px;
  padding: 8px 10px; margin-top: 6px; line-height: 1.5;
}

/* 메일 히스토리 */
.mail-list { display: flex; flex-direction: column; gap: 10px; }
.mail-item {
  border-radius: 12px; padding: 12px;
  border: 1.5px solid var(--border);
}
.mail-item.received { background: #F0F6FF; border-left: 3px solid #4A90E2; }
.mail-item.sent { background: #FFF5F0; border-left: 3px solid var(--accent); }
.mail-meta { display: flex; justify-content: space-between; margin-bottom: 6px; }
.mail-dir { font-size: 11px; font-weight: 800; }
.mail-item.received .mail-dir { color: #4A90E2; }
.mail-item.sent .mail-dir { color: var(--accent); }
.mail-date { font-size: 11px; color: var(--text-dim); }
.mail-title { font-size: 14px; font-weight: 700; margin-bottom: 4px; color: var(--text-main); }
.mail-summary { font-size: 13px; color: var(--text-sub); margin-bottom: 8px; }
.mail-toggle {
  background: none; border: 1.5px solid var(--border);
  color: var(--text-sub); font-size: 12px;
  padding: 5px 10px; border-radius: 8px; cursor: pointer;
}
.mail-toggle:active { opacity: 0.7; }
.mail-body {
  margin-top: 10px; padding: 12px;
  background: var(--white); border-radius: 8px;
  font-size: 13px; color: var(--text-sub);
  line-height: 1.7; border: 1.5px solid var(--border);
}

/* 파토 버튼 */
.cancel-zone {
  padding: 24px 16px;
  text-align: center;
}
.cancel-btn {
  background: none; border: 1.5px solid #E74C3C;
  color: #E74C3C; border-radius: 12px;
  padding: 12px 28px; font-size: 14px; font-weight: 700;
  cursor: pointer; width: 100%;
}
.cancel-btn:active { background: #ffeaea; }

/* 금액 입력 */
.amount-unknown { color: #E67E22; font-weight: 700; font-size: 13px; }
.amount-note { font-size: 11px; color: #aaa; }
.info-item-full { grid-column: 1 / -1; }
.amount-value { font-size: 16px; font-weight: 800; color: var(--accent); margin-bottom: 8px; }
.amount-edit-row { display: flex; gap: 8px; align-items: center; }
.amount-input {
  flex: 1; padding: 8px 10px;
  background: var(--bg); border: 1.5px solid var(--border);
  border-radius: 8px; font-size: 14px; color: var(--text-main);
  outline: none;
}
.amount-input:focus { border-color: var(--accent); }
.amount-save-btn {
  flex-shrink: 0; padding: 8px 14px;
  background: var(--accent); color: #fff;
  border: none; border-radius: 8px;
  font-size: 13px; font-weight: 700; cursor: pointer;
}
.amount-save-btn:active { opacity: 0.8; }

/* 메모 */
.memo-box {
  background: var(--bg); border-radius: 12px;
  padding: 14px; font-size: 14px;
  color: var(--text-sub); line-height: 1.7;
}
