@import url('https://fonts.googleapis.com/css2?family=Manrope:wght@400;500;600;700;800&family=Syne:wght@600;700;800&display=swap');

:root {
  --bg: #f6f3ef;
  --bg-2: #efeae3;
  --surface: rgba(255, 252, 248, 0.88);
  --surface-solid: #fffdf9;
  --ink: #1c1917;
  --muted: #6f675f;
  --line: rgba(28, 25, 23, 0.1);
  --accent: #c1121f;
  --accent-2: #9b0e18;
  --accent-soft: rgba(193, 18, 31, 0.1);
  --ok: #0f7a4c;
  --warn: #b45309;
  --danger: #b91c1c;
  --shadow: 0 18px 50px rgba(28, 25, 23, 0.08);
  --radius: 22px;
  --radius-sm: 14px;
  --nav-h: 72px;
  --font: 'Manrope', sans-serif;
  --display: 'Syne', sans-serif;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font-family: var(--font);
  color: var(--ink);
  background:
    radial-gradient(1200px 600px at 10% -10%, rgba(193, 18, 31, 0.12), transparent 55%),
    radial-gradient(900px 500px at 100% 0%, rgba(28, 25, 23, 0.08), transparent 50%),
    linear-gradient(180deg, var(--bg), var(--bg-2));
  min-height: 100vh;
}

a { color: inherit; text-decoration: none; }
button, input, select, textarea { font: inherit; }
img { max-width: 100%; display: block; }

.app-shell { min-height: 100vh; }

.topbar {
  position: sticky;
  top: 0;
  z-index: 40;
  height: var(--nav-h);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 0 28px;
  backdrop-filter: blur(16px);
  background: rgba(246, 243, 239, 0.78);
  border-bottom: 1px solid var(--line);
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  font-family: var(--display);
  font-weight: 800;
  letter-spacing: -0.03em;
  font-size: 1.2rem;
}

.brand-mark {
  width: 36px;
  height: 36px;
  border-radius: 12px;
  background: linear-gradient(145deg, var(--accent), #7f0a12);
  box-shadow: 0 10px 24px rgba(193, 18, 31, 0.35);
  position: relative;
}
.brand-mark::after {
  content: '';
  position: absolute;
  inset: 9px;
  border: 2px solid rgba(255,255,255,0.85);
  border-radius: 999px;
  border-top-color: transparent;
  transform: rotate(-25deg);
}

.nav-links {
  display: flex;
  align-items: center;
  gap: 8px;
}
.nav-links a {
  padding: 10px 14px;
  border-radius: 999px;
  color: var(--muted);
  font-weight: 600;
  transition: 0.2s ease;
}
.nav-links a:hover,
.nav-links a.active {
  color: var(--ink);
  background: rgba(255,255,255,0.7);
}

.user-chip {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 12px 8px 8px;
  border-radius: 999px;
  background: var(--surface-solid);
  border: 1px solid var(--line);
}
.avatar {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: var(--accent-soft);
  color: var(--accent);
  display: grid;
  place-items: center;
  font-weight: 800;
  font-size: 0.85rem;
}
.btn {
  appearance: none;
  border: none;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 12px 18px;
  border-radius: 999px;
  font-weight: 700;
  transition: 0.2s ease;
}
.btn:disabled { opacity: 0.55; cursor: not-allowed; }
.btn-primary {
  background: linear-gradient(145deg, var(--accent), var(--accent-2));
  color: #fff;
  box-shadow: 0 12px 28px rgba(193, 18, 31, 0.28);
}
.btn-primary:hover:not(:disabled) { transform: translateY(-1px); }
.btn-secondary {
  background: var(--surface-solid);
  border: 1px solid var(--line);
  color: var(--ink);
}
.btn-ghost {
  background: transparent;
  color: var(--muted);
}
.btn-danger {
  background: rgba(185, 28, 28, 0.1);
  color: var(--danger);
}
.btn-sm { padding: 8px 12px; font-size: 0.9rem; }

.page {
  width: min(1240px, calc(100% - 40px));
  margin: 0 auto;
  padding: 28px 0 60px;
}

.page-head {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 20px;
  margin-bottom: 28px;
}
.page-head h1 {
  font-family: var(--display);
  font-size: clamp(1.8rem, 3vw, 2.6rem);
  letter-spacing: -0.04em;
  margin: 0 0 6px;
}
.page-head p {
  margin: 0;
  color: var(--muted);
}

.masonry {
  columns: 4 240px;
  column-gap: 18px;
}
.board-card {
  break-inside: avoid;
  margin-bottom: 18px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  overflow: hidden;
  box-shadow: var(--shadow);
  cursor: pointer;
  transition: transform 0.25s ease, box-shadow 0.25s ease;
  animation: rise 0.45s ease both;
}
.board-card:hover {
  transform: translateY(-4px);
  box-shadow: 0 24px 60px rgba(28, 25, 23, 0.12);
}
.board-cover {
  aspect-ratio: 16 / 9;
  background: #ddd5cb;
  position: relative;
  overflow: hidden;
}
.board-cover img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  transition: transform 0.4s ease;
}
.board-card:hover .board-cover img { transform: scale(1.04); }
.board-cover .placeholder {
  width: 100%;
  height: 100%;
  display: grid;
  place-items: center;
  color: var(--muted);
  font-weight: 700;
}
.board-meta {
  padding: 14px 16px 16px;
}
.board-meta h3 {
  margin: 0 0 6px;
  font-size: 1rem;
  line-height: 1.35;
}
.board-meta .meta-row {
  display: flex;
  justify-content: space-between;
  gap: 8px;
  color: var(--muted);
  font-size: 0.85rem;
}
.pin-count {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 10px;
  border-radius: 999px;
  background: var(--accent-soft);
  color: var(--accent);
  font-weight: 700;
  font-size: 0.78rem;
}

.empty-state {
  text-align: center;
  padding: 80px 20px;
  border: 1px dashed var(--line);
  border-radius: var(--radius);
  background: rgba(255,255,255,0.45);
}
.empty-state h2 {
  font-family: var(--display);
  margin: 0 0 8px;
}
.empty-state p { color: var(--muted); margin: 0 0 18px; }

.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(20, 16, 14, 0.55);
  backdrop-filter: blur(8px);
  z-index: 80;
  display: none;
  align-items: center;
  justify-content: center;
  padding: 20px;
}
.modal-backdrop.open { display: flex; animation: fade 0.2s ease; }
.modal {
  width: min(980px, 100%);
  max-height: min(92vh, 900px);
  overflow: auto;
  background: var(--surface-solid);
  border-radius: 28px;
  border: 1px solid var(--line);
  box-shadow: 0 30px 80px rgba(0,0,0,0.28);
  animation: pop 0.28s ease;
}
.modal-lg { width: min(1100px, 100%); }
.modal-header {
  position: sticky;
  top: 0;
  z-index: 2;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 18px 22px;
  background: rgba(255,253,249,0.92);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--line);
}
.modal-header h2 {
  margin: 0;
  font-family: var(--display);
  font-size: 1.35rem;
  letter-spacing: -0.03em;
}
.modal-body { padding: 22px; }
.modal-actions {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  justify-content: flex-end;
  padding: 0 22px 22px;
}

.form-grid {
  display: grid;
  gap: 16px;
}
.form-grid.two { grid-template-columns: 1fr 1fr; }
.field label {
  display: block;
  font-weight: 700;
  margin-bottom: 8px;
  font-size: 0.92rem;
}
.field .hint {
  color: var(--muted);
  font-size: 0.82rem;
  margin-top: 6px;
}
.field input,
.field select,
.field textarea {
  width: 100%;
  padding: 13px 14px;
  border-radius: 14px;
  border: 1px solid var(--line);
  background: #fff;
  outline: none;
  transition: 0.2s ease;
}
.field input:focus,
.field select:focus,
.field textarea:focus {
  border-color: rgba(193, 18, 31, 0.45);
  box-shadow: 0 0 0 4px var(--accent-soft);
}
.req { color: var(--accent); }

.dropzone {
  border: 1.5px dashed rgba(28, 25, 23, 0.22);
  border-radius: 20px;
  padding: 28px 18px;
  text-align: center;
  background:
    linear-gradient(180deg, rgba(255,255,255,0.8), rgba(246,243,239,0.65));
  cursor: pointer;
  transition: 0.2s ease;
}
.dropzone:hover,
.dropzone.dragover {
  border-color: var(--accent);
  background: var(--accent-soft);
}
.dropzone strong { display: block; margin-bottom: 4px; }
.dropzone span { color: var(--muted); font-size: 0.9rem; }

.selected-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(96px, 1fr));
  gap: 10px;
  margin-top: 14px;
}
.selected-item {
  position: relative;
  aspect-ratio: 1;
  border-radius: 14px;
  overflow: hidden;
  border: 1px solid var(--line);
  cursor: zoom-in;
  background: #eee;
}
.selected-item img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}
.selected-item .remove {
  position: absolute;
  top: 6px;
  right: 6px;
  width: 24px;
  height: 24px;
  border: none;
  border-radius: 50%;
  background: rgba(0,0,0,0.65);
  color: #fff;
  cursor: pointer;
  display: grid;
  place-items: center;
  font-size: 14px;
  line-height: 1;
}
.selected-item .idx {
  position: absolute;
  left: 6px;
  bottom: 6px;
  background: rgba(0,0,0,0.55);
  color: #fff;
  font-size: 0.7rem;
  font-weight: 700;
  padding: 2px 6px;
  border-radius: 999px;
}

.pins-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 16px;
}
.pin-card {
  border: 1px solid var(--line);
  border-radius: 18px;
  overflow: hidden;
  background: #fff;
}
.pin-card .thumb {
  aspect-ratio: 3/4;
  background: #ebe4db;
  cursor: zoom-in;
}
.pin-card .thumb img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}
.pin-card .body { padding: 12px 14px 14px; }
.pin-card h4 {
  margin: 0 0 8px;
  font-size: 0.95rem;
  line-height: 1.35;
}
.pin-card .detail {
  font-size: 0.8rem;
  color: var(--muted);
  margin: 0 0 6px;
  word-break: break-word;
}
.pin-card .detail strong { color: var(--ink); }

.panel {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 22px;
  margin-bottom: 18px;
}
.panel h2 {
  margin: 0 0 6px;
  font-family: var(--display);
  letter-spacing: -0.03em;
}
.panel .sub { color: var(--muted); margin: 0 0 18px; }

.table {
  width: 100%;
  border-collapse: collapse;
}
.table th,
.table td {
  text-align: left;
  padding: 12px 10px;
  border-bottom: 1px solid var(--line);
  font-size: 0.94rem;
}
.table th { color: var(--muted); font-weight: 700; }
.badge {
  display: inline-flex;
  padding: 4px 10px;
  border-radius: 999px;
  font-size: 0.78rem;
  font-weight: 700;
}
.badge-admin { background: var(--accent-soft); color: var(--accent); }
.badge-user { background: rgba(28,25,23,0.06); color: var(--muted); }

.toast-wrap {
  position: fixed;
  right: 18px;
  bottom: 18px;
  z-index: 120;
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.toast {
  min-width: 260px;
  max-width: 380px;
  padding: 14px 16px;
  border-radius: 16px;
  background: #1c1917;
  color: #fff;
  box-shadow: var(--shadow);
  animation: rise 0.25s ease;
}
.toast.ok { background: #14532d; }
.toast.err { background: #7f1d1d; }

.progress-box {
  display: none;
  margin-top: 14px;
  padding: 14px;
  border-radius: 16px;
  background: rgba(28,25,23,0.04);
  border: 1px solid var(--line);
}
.progress-box.show { display: block; }
.progress-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  font-weight: 600;
}
.progress-count {
  font-size: 0.85rem;
  color: var(--muted);
  white-space: nowrap;
}
.progress-detail {
  margin-top: 8px;
  font-size: 0.82rem;
  color: var(--muted);
  min-height: 1.2em;
}
.progress-bar {
  height: 8px;
  border-radius: 999px;
  background: rgba(28,25,23,0.08);
  overflow: hidden;
  margin-top: 10px;
}
.progress-bar > span {
  display: block;
  height: 100%;
  width: 0%;
  background: linear-gradient(90deg, var(--accent), #ff5a5f);
  transition: width 0.3s ease;
}

.login-page {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
  position: relative;
  overflow: hidden;
}
.login-page::before {
  content: '';
  position: absolute;
  width: 520px;
  height: 520px;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(193,18,31,0.25), transparent 70%);
  top: -120px;
  right: -80px;
  animation: float 8s ease-in-out infinite;
}
.login-page::after {
  content: '';
  position: absolute;
  width: 420px;
  height: 420px;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(28,25,23,0.12), transparent 70%);
  bottom: -140px;
  left: -100px;
  animation: float 10s ease-in-out infinite reverse;
}
.login-card {
  width: min(420px, 100%);
  position: relative;
  z-index: 1;
  padding: 34px 30px;
  border-radius: 28px;
  background: rgba(255,253,249,0.9);
  border: 1px solid var(--line);
  box-shadow: var(--shadow);
  backdrop-filter: blur(12px);
  animation: pop 0.35s ease;
}
.login-card .brand { margin-bottom: 22px; }
.login-card h1 {
  font-family: var(--display);
  margin: 0 0 8px;
  font-size: 2rem;
  letter-spacing: -0.04em;
}
.login-card .lead {
  color: var(--muted);
  margin: 0 0 24px;
}
.login-card .btn { width: 100%; margin-top: 8px; }
.login-hint {
  margin-top: 18px;
  padding: 12px 14px;
  border-radius: 14px;
  background: rgba(28,25,23,0.04);
  color: var(--muted);
  font-size: 0.86rem;
}

.preview-backdrop {
  position: fixed;
  inset: 0;
  z-index: 100;
  background: rgba(0,0,0,0.82);
  display: none;
  align-items: center;
  justify-content: center;
  padding: 24px;
}
.preview-backdrop.open { display: flex; }
.preview-backdrop img {
  max-width: min(920px, 100%);
  max-height: 88vh;
  border-radius: 18px;
  box-shadow: 0 20px 60px rgba(0,0,0,0.45);
}
.preview-close {
  position: absolute;
  top: 18px;
  right: 18px;
  border: none;
  background: rgba(255,255,255,0.15);
  color: #fff;
  width: 42px;
  height: 42px;
  border-radius: 50%;
  cursor: pointer;
  font-size: 1.2rem;
}

.provider-cards {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 12px;
  margin-bottom: 16px;
}
.provider-card {
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 14px;
  cursor: pointer;
  background: #fff;
  transition: 0.2s ease;
}
.provider-card.active {
  border-color: var(--accent);
  box-shadow: 0 0 0 4px var(--accent-soft);
}
.provider-card strong { display: block; margin-bottom: 4px; }
.provider-card span { color: var(--muted); font-size: 0.82rem; }

@keyframes rise {
  from { opacity: 0; transform: translateY(10px); }
  to { opacity: 1; transform: translateY(0); }
}
@keyframes fade {
  from { opacity: 0; }
  to { opacity: 1; }
}
@keyframes pop {
  from { opacity: 0; transform: translateY(12px) scale(0.98); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}
@keyframes float {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(18px); }
}

@media (max-width: 900px) {
  .form-grid.two,
  .provider-cards { grid-template-columns: 1fr; }
  .page-head { flex-direction: column; align-items: stretch; }
  .topbar {
    padding: 10px 16px;
    height: auto;
    flex-wrap: wrap;
  }
  .nav-links {
    order: 3;
    width: 100%;
    overflow-x: auto;
  }
  .page { width: min(100% - 24px, 1240px); }
  .masonry { columns: 2 140px; }
}
