:root {
  --bg: #f6f7f9; --card: #fff; --line: #e5e7eb; --text: #1f2937;
  --muted: #6b7280; --accent: #4f46e5; --pending: #f59e0b; --done: #10b981; --danger: #ef4444;
}
* { box-sizing: border-box; }
body { margin: 0; font-family: system-ui, -apple-system, "Apple SD Gothic Neo", sans-serif;
  background: var(--bg); color: var(--text); }
.center { min-height: 100vh; display: grid; place-items: center; }
.card { background: var(--card); border: 1px solid var(--line); border-radius: 12px; padding: 24px; }
.login-box { width: 320px; }
h1, h2, h3 { margin: 0 0 12px; }
input, select, button { font: inherit; padding: 10px 12px; border-radius: 8px; border: 1px solid var(--line); }
input, select { width: 100%; margin-bottom: 10px; background: #fff; }
button { cursor: pointer; border: none; background: var(--accent); color: #fff; }
button.secondary { background: #eef2ff; color: var(--accent); }
button.danger { background: var(--danger); color: #fff; }
.error { color: var(--danger); font-size: 14px; min-height: 20px; }
header.topbar { display: flex; align-items: center; gap: 16px; padding: 12px 20px;
  background: #fff; border-bottom: 1px solid var(--line); position: sticky; top: 0; z-index: 10; }
.tabs { display: flex; gap: 8px; }
.tabs button { background: transparent; color: var(--muted); }
.tabs button.active { background: #eef2ff; color: var(--accent); }
.spacer { flex: 1; }
main { max-width: 1000px; margin: 20px auto; padding: 0 16px; }
table { width: 100%; border-collapse: collapse; background: #fff; }
th, td { padding: 10px; border-bottom: 1px solid var(--line); text-align: left; font-size: 14px; }
.badge { padding: 2px 8px; border-radius: 999px; font-size: 12px; color: #fff; white-space: nowrap; }
.badge.pending { background: var(--pending); }
.badge.done { background: var(--done); }
.badge.upload-undecided { background: #9ca3af; }
.badge.upload-filmed { background: #3b82f6; }
.badge.upload-uploaded { background: #10b981; }
.modal-bg { position: fixed; inset: 0; background: rgba(0,0,0,.4); display: grid; place-items: center; }
.hidden { display: none !important; }
.row { display: flex; gap: 10px; align-items: center; }
.muted { color: var(--muted); font-size: 13px; }

/* ---- List toolbar (전체보기 / 월별보기 filter) ---- */
.list-toolbar {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 12px;
  margin-bottom: 20px;
}
.list-toolbar h2 { margin: 0; }
.list-toolbar #monthInput { width: auto; margin-bottom: 0; padding: 8px 10px; }
.list-toolbar #resultSummary { white-space: nowrap; }
.list-toolbar #addBtn { white-space: nowrap; }

.seg {
  display: inline-flex;
  background: #eef0f4;
  border-radius: 8px;
  padding: 3px;
  gap: 2px;
}
.seg button {
  background: transparent;
  color: var(--muted);
  border: none;
  border-radius: 6px;
  padding: 6px 12px;
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  transition: background .15s ease, color .15s ease;
}
.seg button.active {
  background: #fff;
  color: var(--accent);
  box-shadow: 0 1px 2px rgba(0,0,0,.08);
}

/* ---- Channel cards ---- */
#channelCards {
  display: flex;
  flex-direction: column;
  gap: 18px;
}
.channel-group { margin-bottom: 28px; }
.channel-card {
  background: var(--card);
  border: 1px solid var(--line);
  border-left: 4px solid var(--ch-color, var(--accent));
  border-radius: 14px;
  padding: 18px 20px;
  box-shadow: 0 1px 3px rgba(16, 24, 40, .06);
}
.channel-card-header {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 14px;
}
.channel-card-header h3 { margin: 0; font-size: 16px; }
.channel-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  flex-shrink: 0;
}
.count-pill {
  background: #f3f4f6;
  color: var(--text);
  font-size: 12px;
  font-weight: 600;
  padding: 2px 10px;
  border-radius: 999px;
}
.pending-note {
  color: var(--pending);
  font-weight: 500;
}
.pending-note::before { content: '· '; }

.table-scroll { overflow-x: auto; }
.channel-card table { width: 100%; border-collapse: collapse; }
.channel-card thead th {
  background: #fafafa;
  color: var(--muted);
  font-size: 12px;
  font-weight: 600;
  text-align: left;
  padding: 8px 10px;
  border-bottom: 1px solid var(--line);
  white-space: nowrap;
}
.channel-card tbody td {
  padding: 12px 10px;
  border-bottom: 1px solid var(--line);
  font-size: 14px;
  vertical-align: middle;
}
.channel-card tbody tr:last-child td { border-bottom: none; }
.channel-card tbody tr:hover { background: #f9fafb; }

.empty-state {
  text-align: center;
  color: var(--muted);
  font-size: 13px;
  padding: 24px 0;
}

/* Desktop (>=640px): keep the classic table; prevent cells (except 제목/메모)
   from being squeezed into vertical single-character columns. */
@media (min-width: 641px) {
  .channel-card tbody td { white-space: nowrap; }
  .channel-card tbody td[data-label="제목"],
  .channel-card tbody td[data-label="메모"],
  .channel-card tbody td[data-label="영상"] { white-space: normal; }
}

.channel-card tbody td[data-label="영상"] a {
  color: var(--brand, #2563eb);
  text-decoration: none;
}
.channel-card tbody td[data-label="영상"] a:hover { text-decoration: underline; }

/* Mobile (<=640px): turn each row into a stacked "label: value" card. */
@media (max-width: 640px) {
  .channel-card .table-scroll { overflow-x: visible; }
  .channel-card table,
  .channel-card thead,
  .channel-card tbody,
  .channel-card tr,
  .channel-card td { display: block; }
  .channel-card thead { display: none; }
  .channel-card tbody tr {
    padding: 12px 0;
    border-bottom: 1px solid var(--line);
  }
  .channel-card tbody tr:last-child { border-bottom: none; }
  .channel-card tbody td {
    display: flex;
    justify-content: space-between;
    align-items: baseline;
    gap: 12px;
    padding: 6px 2px;
    border-bottom: none;
    white-space: normal;
    text-align: right;
    word-break: break-word;
  }
  .channel-card tbody td::before {
    content: attr(data-label);
    color: var(--muted);
    font-weight: 600;
    text-align: left;
    flex-shrink: 0;
  }
  .channel-card tbody td.actions-cell {
    justify-content: flex-end;
    padding-top: 10px;
  }
  .channel-card tbody td.actions-cell::before { content: none; }
}

@media (max-width: 700px) {
  .list-toolbar { align-items: stretch; }
  .list-toolbar h2 { width: 100%; }
  .list-toolbar #resultSummary { order: 3; }
}

/* ---- Revenue detail (세부 내역) ---- */
.rev-detail { margin-top: 24px; }
.rev-detail h3 { margin-bottom: 12px; }
.rev-detail-channel { margin-bottom: 20px; }
.rev-detail-channel h4 {
  display: flex;
  align-items: baseline;
  gap: 10px;
  flex-wrap: wrap;
  margin: 0 0 8px;
  font-size: 14px;
}
.rev-detail-channel .table-scroll { overflow-x: auto; }
.rev-detail-channel table { width: 100%; border-collapse: collapse; min-width: 480px; }

@media (max-width: 640px) {
  .rev-detail-channel .table-scroll { overflow-x: visible; }
  .rev-detail-channel table,
  .rev-detail-channel thead,
  .rev-detail-channel tbody,
  .rev-detail-channel tr,
  .rev-detail-channel td { display: block; min-width: 0; }
  .rev-detail-channel thead { display: none; }
  .rev-detail-channel tbody tr {
    padding: 10px 0;
    border-bottom: 1px solid var(--line);
  }
  .rev-detail-channel tbody tr:last-child { border-bottom: none; }
  .rev-detail-channel tbody td {
    display: flex;
    justify-content: space-between;
    align-items: baseline;
    gap: 12px;
    padding: 4px 2px;
    border-bottom: none;
    white-space: normal;
    text-align: right;
    word-break: break-word;
  }
  .rev-detail-channel tbody td::before {
    content: attr(data-label);
    color: var(--muted);
    font-weight: 600;
    text-align: left;
    flex-shrink: 0;
  }
}

/* ---- Calendar legend ---- */
.cal-legend {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 10px 16px;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 12px 16px;
  margin-bottom: 16px;
  box-shadow: 0 1px 3px rgba(16, 24, 40, .06);
}
.cal-legend-channels {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}
.cal-legend-pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: #f3f4f6;
  color: var(--text);
  font-size: 12px;
  font-weight: 500;
  padding: 4px 10px 4px 8px;
  border-radius: 999px;
}
.cal-legend-pill .swatch {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  flex-shrink: 0;
}
.cal-legend-marker {
  display: flex;
  gap: 14px;
  color: var(--muted);
  font-size: 12px;
  white-space: nowrap;
}

/* ---- FullCalendar polish ---- */
#cal { background: var(--card); border: 1px solid var(--line); border-radius: 14px;
  padding: 14px; box-shadow: 0 1px 3px rgba(16, 24, 40, .06); }

.fc { font-family: inherit; }

.fc .fc-toolbar { flex-wrap: wrap; gap: 10px; }
.fc .fc-toolbar-title { font-size: 17px; font-weight: 700; color: var(--text); }

.fc .fc-button-primary {
  background: #fff;
  border: 1px solid var(--line);
  color: var(--text);
  text-transform: capitalize;
  box-shadow: none;
  border-radius: 8px;
  padding: 6px 12px;
  font-weight: 500;
  transition: background .15s ease, color .15s ease, border-color .15s ease;
}
.fc .fc-button-primary:hover {
  background: #f3f4f6;
  border-color: var(--line);
  color: var(--text);
}
.fc .fc-button-primary:not(:disabled).fc-button-active,
.fc .fc-button-primary:not(:disabled):active {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}
.fc .fc-button-primary:focus,
.fc .fc-button-primary:not(:disabled).fc-button-active:focus {
  box-shadow: 0 0 0 2px rgba(79, 70, 229, .25);
}
.fc .fc-today-button {
  text-transform: none;
}
.fc .fc-button:disabled {
  opacity: .5;
}

.fc-theme-standard td, .fc-theme-standard th { border-color: var(--line); }
.fc-theme-standard .fc-scrollgrid { border-color: var(--line); }

.fc .fc-col-header-cell {
  background: #fafafa;
}
.fc .fc-col-header-cell-cushion {
  color: var(--muted);
  font-size: 12px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .02em;
  padding: 8px 4px;
}

.fc .fc-daygrid-day-number {
  color: var(--text);
  font-size: 13px;
  padding: 6px 8px;
}
.fc .fc-day-today {
  background: rgba(79, 70, 229, .06) !important;
}
.fc .fc-day-today .fc-daygrid-day-number {
  color: var(--accent);
  font-weight: 700;
}

.fc-event {
  border-radius: 6px;
  padding: 1px 4px;
  font-size: 12px;
  font-weight: 500;
  border-width: 1.5px;
  box-shadow: 0 1px 2px rgba(16, 24, 40, .08);
  cursor: pointer;
}
.fc-daygrid-event { margin-top: 2px; }
.fc-event:hover { filter: brightness(0.97); }

.fc-list-event { cursor: pointer; }
.fc-list-event:hover td { background: #f9fafb; }
.fc-theme-standard .fc-list-day-cushion {
  background: #fafafa;
}
.fc .fc-list-event-dot {
  border-width: 5px;
}

@media (max-width: 480px) {
  #cal { padding: 8px; }
  .fc .fc-toolbar { flex-direction: column; align-items: stretch; }
  .fc .fc-toolbar-chunk { display: flex; justify-content: center; }
  .fc .fc-toolbar-title { font-size: 15px; text-align: center; }
  .fc-event { font-size: 11px; }
  .cal-legend { flex-direction: column; align-items: flex-start; }
}

/* ---- Alert banner (오늘/이번 주 촬영·업로드 알림) ---- */
#alertBanner {
  margin-bottom: 20px;
}
#alertBanner.hidden {
  display: none !important;
}
.alert-banner-inner {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  background: linear-gradient(135deg, rgba(79, 70, 229, .10), rgba(79, 70, 229, .04));
  border: 1px solid rgba(79, 70, 229, .25);
  border-radius: 12px;
  padding: 14px 16px;
}
.alert-banner-body {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.alert-banner-title {
  color: var(--accent);
  font-size: 15px;
}
.alert-line {
  font-size: 14px;
  color: var(--text);
  line-height: 1.5;
  word-break: break-word;
}
.alert-banner-dismiss {
  flex-shrink: 0;
  background: transparent;
  color: var(--muted);
  border: none;
  padding: 4px 8px;
  font-size: 14px;
  line-height: 1;
  border-radius: 6px;
}
.alert-banner-dismiss:hover {
  background: rgba(0, 0, 0, .06);
  color: var(--text);
}

@media (max-width: 480px) {
  .alert-banner-inner { padding: 12px; gap: 8px; }
  .alert-line { font-size: 13px; }
}
