:root {
  --bg:            #F7F4EF;
  --surface:       #FFFFFF;
  --surface-alt:   #F0ECE4;
  --surface-sunk:  #EAE5DB;
  --border:        #E1DACB;
  --border-strong: #CFC6B0;

  --text:          #2B271F;
  --text-muted:    #6B6455;
  --text-faint:    #948C79;

  --accent:        #C2632F;
  --accent-hover:  #A6501F;
  --accent-tint:   #F1E0D2;

  --success:       #4C7A4E;
  --success-tint:  #E2EEE0;
  --warning:       #B4862B;
  --warning-tint:  #F3E7C9;
  --danger:        #AA3B2C;
  --danger-tint:   #F5DEDA;

  --radius-sm: 6px;
  --radius-md: 10px;
  --radius-lg: 16px;

  --shadow-modal: 0 20px 50px rgba(43, 39, 31, 0.25);
  --shadow-card: 0 1px 2px rgba(43, 39, 31, 0.06);

  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", Inter, Helvetica, Arial, sans-serif;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  font-size: 15px;
  line-height: 1.5;
}

h1, h2, h3, h4 { margin: 0; font-weight: 600; letter-spacing: -0.01em; }
p { margin: 0; }

button, input, textarea, select {
  font-family: inherit;
  font-size: inherit;
  color: inherit;
}

textarea { resize: vertical; }

a { color: var(--accent); text-decoration: none; }
a:hover { color: var(--accent-hover); }

::selection { background: var(--accent-tint); }

/* ---------- buttons ---------- */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 9px 16px;
  border-radius: var(--radius-sm);
  border: 1px solid transparent;
  background: var(--surface-alt);
  color: var(--text);
  font-weight: 500;
  cursor: pointer;
  transition: background 0.12s ease, border-color 0.12s ease, color 0.12s ease;
  white-space: nowrap;
}
.btn:hover { background: var(--surface-sunk); }
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }

.btn-primary { background: var(--accent); color: #fff; }
.btn-primary:hover { background: var(--accent-hover); }

.btn-danger { background: var(--danger); color: #fff; }
.btn-danger:hover { background: #8E301F; }

.btn-ghost { background: transparent; border-color: var(--border); }
.btn-ghost:hover { background: var(--surface-alt); }

.btn-small { padding: 6px 12px; font-size: 13px; }
.btn-icon { padding: 6px 10px; font-size: 16px; line-height: 1; }
.btn-block { width: 100%; }

.link-btn {
  background: none;
  border: none;
  padding: 0;
  color: var(--accent);
  cursor: pointer;
  font-weight: 500;
}
.link-btn:hover { color: var(--accent-hover); }
.link-btn.is-danger { color: var(--danger); }
.link-btn.is-danger:hover { color: #8E301F; }

/* ---------- login ---------- */

.login-body {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--bg);
}

.login-card {
  width: 100%;
  max-width: 360px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 36px 32px;
  text-align: center;
  box-shadow: var(--shadow-card);
}

.login-mark {
  width: 44px;
  height: 44px;
  margin: 0 auto 16px;
  border-radius: 12px;
  background: var(--accent);
  color: #fff;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 15px;
}

.login-card h1 { font-size: 19px; margin-bottom: 4px; }
.login-sub { color: var(--text-muted); font-size: 13px; margin-bottom: 24px; }

.login-form { text-align: left; display: flex; flex-direction: column; gap: 6px; }
.login-form label { font-size: 13px; font-weight: 500; color: var(--text-muted); margin-top: 10px; }
.login-form button { margin-top: 18px; }

input[type="text"], input[type="password"], input[type="number"], input[type="date"],
input[type="email"], input[type="tel"], input[type="url"],
textarea, .select {
  width: 100%;
  padding: 9px 11px;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  background: var(--surface);
  color: var(--text);
}
input:focus, textarea:focus, select:focus, button:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 1px;
}

.alert { padding: 10px 12px; border-radius: var(--radius-sm); font-size: 13px; margin-bottom: 14px; }
.alert-danger { background: var(--danger-tint); color: var(--danger); }

/* ---------- app shell ---------- */

.app-shell { min-height: 100vh; display: flex; flex-direction: column; }

.topbar {
  display: flex;
  align-items: center;
  gap: 24px;
  padding: 12px 24px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 10;
}

.topbar-brand { display: flex; align-items: center; gap: 10px; flex-shrink: 0; }
.topbar-mark {
  width: 30px; height: 30px; border-radius: 8px;
  background: var(--accent); color: #fff; font-weight: 700; font-size: 12px;
  display: flex; align-items: center; justify-content: center;
}
.topbar-title { font-weight: 600; font-size: 15px; }

.topbar-nav { display: flex; gap: 4px; flex: 1; }
.nav-tab {
  display: inline-flex; align-items: center;
  background: none; border: none; padding: 8px 14px; border-radius: var(--radius-sm);
  font-weight: 500; color: var(--text-muted); cursor: pointer; text-decoration: none;
}
.nav-tab:hover { background: var(--surface-alt); color: var(--text); }
.nav-tab.is-active { background: var(--accent-tint); color: var(--accent-hover); }

.topbar-user { display: flex; align-items: center; gap: 12px; flex-shrink: 0; }
.topbar-username { font-size: 13px; color: var(--text-muted); }

.app-main { flex: 1; padding: 24px; max-width: 1400px; width: 100%; margin: 0 auto; }

.panel-head {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 18px; gap: 12px; flex-wrap: wrap;
}
.panel-head-actions { display: flex; gap: 10px; align-items: center; }
.search-input { max-width: 240px; }
.select { width: auto; padding: 8px 10px; }

.type-filter-row { margin-bottom: 14px; }
.filter-switch {
  display: inline-flex;
  background: var(--surface-alt);
  border-radius: var(--radius-sm);
  padding: 3px;
  gap: 2px;
}
.filter-btn {
  background: none; border: none; padding: 6px 14px; border-radius: 5px;
  font-size: 13px; font-weight: 500; color: var(--text-muted); cursor: pointer;
  white-space: nowrap;
}
.filter-btn.is-active { background: var(--surface); color: var(--text); box-shadow: var(--shadow-card); }

/* ---------- calendar layout ---------- */

.calendar-layout {
  display: grid;
  grid-template-columns: 2fr 1fr;
  gap: 20px;
  align-items: start;
}

@media (max-width: 900px) {
  .calendar-layout { grid-template-columns: 1fr; }
}

.calendar-panel {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 16px;
}

.calendar-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 14px;
  flex-wrap: wrap;
  gap: 10px;
}

.calendar-nav { display: flex; align-items: center; gap: 8px; }
.calendar-title { font-size: 17px; min-width: 160px; text-align: center; }

.calendar-toolbar-right { display: flex; align-items: center; gap: 10px; }

.calendar-view-switch {
  display: flex;
  background: var(--surface-alt);
  border-radius: var(--radius-sm);
  padding: 3px;
  gap: 2px;
}
.view-btn {
  background: none; border: none; padding: 6px 14px; border-radius: 5px;
  font-size: 13px; font-weight: 500; color: var(--text-muted); cursor: pointer;
}
.view-btn.is-active { background: var(--surface); color: var(--text); box-shadow: var(--shadow-card); }

.calendar-grid {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 6px;
}
.calendar-grid.hide-weekends {
  grid-template-columns: repeat(5, 1fr);
}

.cal-weekday {
  font-size: 12px;
  font-weight: 600;
  color: var(--text-faint);
  text-align: center;
  padding: 4px 0 8px;
}

.cal-day {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  height: 108px;
  min-width: 0;
  overflow: hidden;
  padding: 6px;
  display: flex;
  flex-direction: column;
  gap: 4px;
  cursor: pointer;
  transition: border-color 0.12s ease, background 0.12s ease;
}
.cal-day:hover { border-color: var(--border-strong); }
.cal-day.is-outside { background: var(--surface-alt); opacity: 0.55; }
.cal-day.is-today { border-color: var(--accent); }
.cal-day.is-week-view { height: 260px; }

.cal-day-num { font-size: 12px; font-weight: 600; color: var(--text-muted); flex-shrink: 0; }
.cal-day.is-today .cal-day-num { color: var(--accent); }

.cal-cards { display: flex; flex-direction: column; gap: 4px; overflow-y: auto; flex: 1; min-height: 0; min-width: 0; }

.cal-card {
  background: var(--accent-tint);
  border-radius: 5px;
  padding: 4px 6px;
  font-size: 12px;
  color: var(--text);
  display: flex;
  align-items: flex-start;
  gap: 5px;
  cursor: grab;
  line-height: 1.3;
  min-width: 0;
  flex-shrink: 0;
}
.cal-card:active { cursor: grabbing; }
.cal-card-thumb {
  width: 16px; height: 16px; border-radius: 3px; object-fit: cover; flex-shrink: 0;
}
.cal-card-title {
  flex: 1;
  min-width: 0;
  white-space: normal;
  word-break: break-word;
  overflow: hidden;
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
}
.cal-card.sortable-ghost { opacity: 0.4; }
.cal-day.drag-over { background: var(--accent-tint); border-color: var(--accent); }

/* ---------- sidebar ---------- */

.calendar-sidebar { display: flex; flex-direction: column; gap: 16px; }

.sidebar-block {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 16px;
}

.sidebar-block-head {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 10px;
}
.sidebar-block-head h3 { font-size: 14px; }

.month-note-textarea {
  min-height: 110px;
  border-color: var(--border);
}

.inline-notes-textarea {
  min-height: 80px;
  border-color: var(--border);
  width: 100%;
}

.sidebar-block-foot { min-height: 16px; margin-top: 6px; }
.save-status { font-size: 12px; color: var(--text-faint); }

.blast-list { display: flex; flex-direction: column; gap: 8px; }
.blast-item {
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 10px;
  cursor: pointer;
  display: flex;
  gap: 8px;
  align-items: center;
}
.blast-item:hover { border-color: var(--border-strong); background: var(--surface-alt); }
.blast-item-thumb { width: 30px; height: 30px; border-radius: 5px; object-fit: cover; flex-shrink: 0; }
.blast-item-body { flex: 1; min-width: 0; }
.blast-item-title { font-size: 13px; font-weight: 500; }
.blast-item-snippet { font-size: 12px; color: var(--text-muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.empty-hint { font-size: 13px; color: var(--text-faint); text-align: center; padding: 12px 0; }

/* ---------- tables ---------- */

.table-wrap {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  overflow-x: auto;
}

.data-table { width: 100%; border-collapse: collapse; }
.data-table th, .data-table td {
  padding: 12px 16px;
  text-align: left;
  border-bottom: 1px solid var(--border);
  font-size: 13.5px;
  white-space: nowrap;
}
.data-table th { color: var(--text-faint); font-weight: 600; font-size: 12px; }
.data-table th.sortable-th { cursor: pointer; user-select: none; }
.data-table th.sortable-th:hover { color: var(--text); }
.data-table th.is-sorted { color: var(--accent-hover); }
.data-table tbody tr { cursor: pointer; }
.data-table tbody tr:hover { background: var(--surface-alt); }
.data-table tbody tr:last-child td { border-bottom: none; }
.col-actions { width: 40px; text-align: right; }

.badge {
  display: inline-flex; align-items: center; padding: 3px 9px;
  border-radius: 999px; font-size: 11.5px; font-weight: 600;
}
.badge-pr { background: var(--accent-tint); color: var(--accent-hover); }
.badge-partner { background: var(--success-tint); color: var(--success); }

.badge-pr-status { white-space: nowrap; }
.badge-pr-status-contacted { background: var(--surface-sunk); color: var(--text-muted); }
.badge-pr-status-sent { background: var(--warning-tint); color: var(--warning); }
.badge-pr-status-confirmed { background: var(--accent-tint); color: var(--accent-hover); }
.badge-pr-status-posted { background: var(--success); color: #fff; }

.empty-state { padding: 48px 24px; text-align: center; color: var(--text-muted); }
.empty-state-sub { font-size: 13px; color: var(--text-faint); margin-top: 4px; }

.row-menu { position: relative; }
.row-menu-btn {
  background: none; border: none; cursor: pointer; color: var(--text-faint);
  font-size: 18px; padding: 2px 8px; border-radius: 5px; line-height: 1;
}
.row-menu-btn:hover { background: var(--surface-sunk); color: var(--text); }
.row-menu-dropdown {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-sm);
  box-shadow: var(--shadow-modal); min-width: 130px; overflow: hidden;
}
.row-menu-dropdown button {
  display: block; width: 100%; text-align: left; padding: 9px 12px;
  background: none; border: none; cursor: pointer; font-size: 13px; color: var(--text);
}
.row-menu-dropdown button:hover { background: var(--surface-alt); }
.row-menu-dropdown button.is-danger { color: var(--danger); }

/* ---------- columns picker ---------- */

.columns-menu {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-sm);
  box-shadow: var(--shadow-modal); min-width: 190px; padding: 6px; overflow: hidden;
}
.columns-menu-row {
  display: flex; align-items: center; gap: 8px; padding: 7px 8px; border-radius: 5px;
  font-size: 13px; cursor: pointer;
}
.columns-menu-row:hover { background: var(--surface-alt); }
.columns-menu-row input { width: auto; margin: 0; }

/* ---------- modals ---------- */

.modal-overlay {
  position: fixed; inset: 0; background: rgba(43, 39, 31, 0.45);
  display: flex; align-items: center; justify-content: center;
  padding: 24px; z-index: 100;
}

.modal {
  background: var(--surface);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-modal);
  width: 100%;
  max-width: 480px;
  max-height: 88vh;
  display: flex;
  flex-direction: column;
}
.modal.modal-wide { max-width: 640px; }
.modal.modal-small { max-width: 380px; }

.modal-head {
  display: flex; align-items: center; justify-content: space-between;
  padding: 18px 20px; border-bottom: 1px solid var(--border); flex-shrink: 0;
}
.modal-head h3 { font-size: 16px; }
.modal-head h3.modal-title-lg { font-size: 22px; }
.modal-close { background: none; border: none; font-size: 18px; color: var(--text-faint); cursor: pointer; padding: 4px 8px; }
.modal-close:hover { color: var(--text); }

.modal-body { padding: 20px; overflow-y: auto; }
.modal-foot {
  display: flex; align-items: center; justify-content: flex-end; gap: 10px;
  padding: 14px 20px; border-top: 1px solid var(--border); flex-shrink: 0;
}
.modal-foot.spread { justify-content: space-between; }

.field { margin-bottom: 14px; }
.field label { display: block; font-size: 13px; font-weight: 500; color: var(--text-muted); margin-bottom: 5px; }
.field-row { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.field-hint { font-size: 12px; color: var(--text-faint); margin-top: 4px; }

.dropzone {
  border: 1.5px dashed var(--border-strong);
  border-radius: var(--radius-md);
  padding: 18px;
  text-align: center;
  color: var(--text-faint);
  font-size: 13px;
  cursor: text;
}
.dropzone:focus-visible { outline: 2px solid var(--accent); }
.dropzone.has-image { padding: 0; border-style: solid; overflow: hidden; }
.dropzone img { display: block; width: 100%; max-height: 280px; object-fit: contain; background: var(--surface-alt); }

.dropzone-empty { display: flex; flex-direction: column; align-items: center; gap: 10px; }
.dropzone-hint { margin: 0; }

.image-actions { display: flex; gap: 8px; margin-top: 10px; }

.card-view-title { font-size: 13px; color: var(--text-faint); margin-bottom: 8px; }
.card-view-notes { white-space: pre-wrap; font-size: 14px; line-height: 1.6; }
.card-view-notes.is-empty { color: var(--text-faint); cursor: pointer; }

/* PR package rows */
.pr-package-list { display: flex; flex-direction: column; gap: 14px; margin-bottom: 6px; }
.pr-package-row { border: 1px solid var(--border); border-radius: var(--radius-md); padding: 12px; }
.pr-package-row-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 10px; gap: 8px; }
.pr-package-name-wrap { flex: 1; min-width: 0; }

.inline-edit-text {
  display: inline-block; font-weight: 500; font-size: 13.5px; cursor: text;
  padding: 3px 6px; border-radius: 5px; border: 1px solid transparent;
}
.inline-edit-text:hover { background: var(--surface-alt); border-color: var(--border); }
.inline-edit-text.is-placeholder { color: var(--text-faint); font-style: italic; }
.inline-edit-input {
  font: inherit; font-weight: 500; font-size: 13.5px; padding: 3px 6px;
  border: 1px solid var(--accent); border-radius: 5px; width: 100%; max-width: 260px;
}

.pr-flow { display: flex; align-items: stretch; gap: 6px; flex-wrap: wrap; }
.pr-flow-step {
  flex: 1;
  min-width: 130px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 9px 10px;
  background: var(--surface-alt);
  transition: background 0.12s ease, border-color 0.12s ease;
  overflow: hidden;
}
.pr-flow-step.is-filled { background: var(--accent-tint); border-color: var(--accent); }
.pr-flow-label { font-size: 11px; font-weight: 600; color: var(--text-faint); margin-bottom: 6px; white-space: nowrap; }
.pr-flow-step.is-filled .pr-flow-label { color: var(--accent-hover); }
.pr-flow-input {
  width: 100%; max-width: 100%; box-sizing: border-box;
  border: none; background: transparent; padding: 0 2px 0 0;
  font-size: 12.5px; color: var(--text);
}
.pr-flow-input:focus { outline: none; }
.pr-flow-input::-webkit-calendar-picker-indicator {
  cursor: pointer;
  opacity: 0.55;
  margin-left: 2px;
  border-radius: 3px;
  transition: opacity 0.12s ease, background 0.12s ease;
}
.pr-flow-input::-webkit-calendar-picker-indicator:hover {
  opacity: 1;
  background: var(--surface-sunk);
}
.pr-flow-input.pr-flow-link.has-value {
  color: var(--success);
  font-weight: 600;
}
.pr-flow-arrow {
  display: flex; align-items: center; justify-content: center;
  color: var(--text-faint); font-size: 14px; flex-shrink: 0; width: 16px;
}

.pr-add-btn-wrap { margin-top: 4px; }

.detail-section { margin-bottom: 18px; }
.detail-section h4 { font-size: 12px; color: var(--text-faint); margin-bottom: 8px; font-weight: 600; }
.detail-line { font-size: 14px; margin-bottom: 3px; white-space: pre-wrap; }
.detail-handles { display: flex; gap: 14px; flex-wrap: wrap; font-size: 13.5px; }
.detail-handles span { color: var(--text-muted); }
.detail-handles a { color: var(--accent); }
.detail-handles a:hover { color: var(--accent-hover); }

/* ---------- toasts ---------- */

.toast-root {
  position: fixed; bottom: 20px; left: 50%; transform: translateX(-50%);
  display: flex; flex-direction: column; gap: 8px; z-index: 200;
}
.toast {
  background: var(--text);
  color: #fff;
  padding: 12px 16px;
  border-radius: var(--radius-sm);
  display: flex; align-items: center; gap: 14px;
  font-size: 13.5px;
  box-shadow: var(--shadow-modal);
}
.toast button {
  background: none; border: none; color: var(--accent-tint); font-weight: 600; cursor: pointer; font-size: 13px;
}
.toast button:hover { color: #fff; }

/* misc */
.checkbox-row { display: flex; align-items: center; gap: 8px; margin-bottom: 8px; }
.checkbox-row input { width: auto; }
.toggle-group { display: flex; gap: 8px; }
.toggle-option {
  flex: 1; padding: 9px; text-align: center; border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm); cursor: pointer; font-size: 13px; color: var(--text-muted);
}
.toggle-option.is-active { border-color: var(--accent); background: var(--accent-tint); color: var(--accent-hover); font-weight: 600; }