/* ============================================================
   COMMAND CENTRE — STYLESHEET
   ============================================================ */

/* ── Reset ── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
button { font-family: inherit; }
input, textarea, select { font-family: inherit; }

/* ── CSS Variables ── */
:root {
  /* Light theme backgrounds */
  --bg:       #f1f5f9;
  --surface:  #ffffff;
  --surface2: #f8fafc;
  --surface3: #f1f5f9;

  /* Borders */
  --border:   #e2e8f0;
  --border2:  #cbd5e1;

  /* Text */
  --text:   #0f172a;
  --muted:  #64748b;
  --muted2: #94a3b8;

  /* Accent — indigo */
  --accent:      #4f46e5;
  --accent-dim:  rgba(79,70,229,0.08);
  --accent-dark: #ffffff;

  /* Semantic colours — vivid for light backgrounds */
  --blue:        #3b82f6;  --blue-dim:    rgba(59,130,246,0.10);
  --purple:      #8b5cf6;  --purple-dim:  rgba(139,92,246,0.10);
  --green:       #16a34a;  --green-dim:   rgba(22,163,74,0.10);
  --orange:      #ea580c;  --orange-dim:  rgba(234,88,12,0.10);
  --pink:        #db2777;  --pink-dim:    rgba(219,39,119,0.10);
  --red:         #dc2626;  --red-dim:     rgba(220,38,38,0.10);
  --teal:        #0d9488;  --teal-dim:    rgba(13,148,136,0.10);
}

body {
  font-family: 'DM Sans', sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
}

.hidden { display: none !important; }

/* ============================================================
   LOGIN SCREEN
   ============================================================ */

#login-screen {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--bg);
}

.login-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 32px;
  width: 360px;
  max-width: calc(100vw - 40px);
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.login-header { display: flex; flex-direction: column; gap: 4px; }

.login-logo {
  font-family: 'DM Mono', monospace;
  font-size: 11px;
  font-weight: 500;
  color: var(--accent);
  text-transform: uppercase;
  letter-spacing: 0.1em;
}

.login-sub { font-size: 12px; color: var(--muted); }

.login-error {
  font-size: 12px;
  color: var(--red);
  margin-top: -4px;
}

/* ============================================================
   DASHBOARD LAYOUT
   ============================================================ */

#dashboard {
  display: flex;
  flex-direction: column;
  height: 100vh;
  overflow: hidden;
}

/* ── Row 1: Topbar ── */
#topbar {
  height: 50px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 20px;
  flex-shrink: 0;
  position: relative;
  z-index: 20;
}

.topbar-logo {
  font-family: 'DM Mono', monospace;
  font-size: 11px;
  font-weight: 500;
  color: var(--accent);
  text-transform: uppercase;
  letter-spacing: 0.1em;
}

.user-chip {
  display: flex;
  align-items: center;
  gap: 8px;
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: 20px;
  padding: 4px 12px 4px 4px;
  cursor: pointer;
  font-size: 12px;
  color: var(--text);
  position: relative;
  user-select: none;
}
.user-chip:hover { border-color: var(--border2); }

.avatar {
  width: 24px;
  height: 24px;
  border-radius: 50%;
  border: 1.5px solid var(--accent);
  background: var(--surface3);
  font-family: 'DM Mono', monospace;
  font-size: 9px;
  font-weight: 500;
  color: var(--accent);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.user-menu {
  position: absolute;
  top: calc(100% + 6px);
  right: 0;
  background: var(--surface2);
  border: 1px solid var(--border2);
  border-radius: 8px;
  padding: 4px;
  min-width: 110px;
  z-index: 100;
  box-shadow: 0 4px 16px rgba(0,0,0,0.12);
}

.user-menu button {
  display: block;
  width: 100%;
  background: none;
  border: none;
  color: var(--text);
  font-size: 12px;
  padding: 8px 10px;
  text-align: left;
  cursor: pointer;
  border-radius: 5px;
}
.user-menu button:hover { background: var(--surface3); }

/* ── Row 2: App Row ── */
#app-row {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  padding: 8px 20px;
  gap: 6px;
  overflow-x: auto;
  flex-shrink: 0;
  scrollbar-width: none;
}
#app-row::-webkit-scrollbar { display: none; }

#product-buttons {
  display: flex;
  gap: 6px;
  align-items: center;
}

.product-btn {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 5px 12px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: transparent;
  color: var(--muted);
  font-size: 12px;
  font-weight: 500;
  cursor: pointer;
  white-space: nowrap;
  transition: border-color 0.15s, color 0.15s, background 0.15s;
}
.product-btn:hover { border-color: var(--border2); color: var(--text); }
.product-btn.active {
  background: var(--accent-dim);
  border-color: var(--accent);
  color: var(--accent);
}

.product-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  flex-shrink: 0;
}

/* ── Pending badge (iOS-style) ── */
.nav-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 16px;
  height: 16px;
  padding: 0 4px;
  border-radius: 99px;
  background: #ef4444;
  color: #ffffff;
  font-size: 9px;
  font-weight: 700;
  line-height: 1;
  flex-shrink: 0;
  vertical-align: middle;
  margin-left: 3px;
}

.btn-add-product {
  width: 28px;
  height: 28px;
  border-radius: 7px;
  border: 1.5px dashed var(--border2);
  background: transparent;
  color: var(--muted2);
  font-size: 18px;
  line-height: 1;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: border-color 0.15s, color 0.15s;
}
.btn-add-product:hover { border-color: var(--accent); color: var(--accent); }

/* ── Row 3: Section Row ── */
#section-row {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: stretch;
  padding: 0 20px;
  flex-shrink: 0;
  gap: 0;
}

#section-tabs {
  display: flex;
  align-items: stretch;
  gap: 0;
  overflow-x: auto;
  flex: 1;
  scrollbar-width: none;
}
#section-tabs::-webkit-scrollbar { display: none; }

.section-tab {
  padding: 0 14px;
  height: 42px;
  border: none;
  background: none;
  color: var(--muted);
  font-size: 12px;
  font-weight: 500;
  cursor: pointer;
  white-space: nowrap;
  border-bottom: 2px solid transparent;
  transition: color 0.15s, border-color 0.15s;
}
.section-tab:hover { color: var(--text); }
.section-tab.active { color: var(--accent); border-bottom-color: var(--accent); }

.section-delete-btn {
  display: inline-block;
  margin-left: 5px;
  color: var(--muted2);
  font-size: 14px;
  line-height: 1;
  padding: 0 2px;
  border-radius: 3px;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.12s, color 0.12s;
  vertical-align: middle;
}
.section-tab:hover .section-delete-btn { opacity: 1; pointer-events: auto; }
.section-delete-btn:hover { color: var(--red); }

.btn-add-section {
  padding: 0 14px;
  height: 42px;
  border: none;
  background: none;
  color: var(--muted2);
  font-size: 12px;
  cursor: pointer;
  white-space: nowrap;
  transition: color 0.15s;
}
.btn-add-section:hover { color: var(--accent); }

.section-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
  padding-left: 12px;
  border-left: 1px solid var(--border);
  margin-left: 8px;
}

.btn-share-board {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 30px;
  height: 30px;
  border-radius: 7px;
  border: 1px solid var(--border2);
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  transition: color 0.15s, border-color 0.15s;
  flex-shrink: 0;
}
.btn-share-board:hover { color: var(--text); border-color: var(--border2); }

/* ── Floating Action Button ── */
.fab {
  position: fixed;
  bottom: 28px;
  right: 28px;
  width: 52px;
  height: 52px;
  border-radius: 16px;
  border: none;
  background: var(--accent);
  color: #ffffff;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  box-shadow: 0 4px 16px rgba(79,70,229,0.35);
  transition: transform 0.15s, box-shadow 0.15s, opacity 0.15s;
  z-index: 90;
}
.fab:hover {
  transform: scale(1.07);
  box-shadow: 0 6px 22px rgba(79,70,229,0.45);
}
.fab:active { transform: scale(0.96); }

/* ── Row 4: Content Area ── */
#content-area {
  flex: 1;
  overflow-y: auto;
  padding: 18px 24px 24px;
  background: var(--bg);
}

#card-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 10px;
  align-content: start;
}
@media (max-width: 1100px) {
  #card-grid { grid-template-columns: repeat(3, 1fr); }
}
@media (max-width: 860px) {
  #card-grid { grid-template-columns: repeat(2, 1fr); }
}

/* ============================================================
   CARDS
   ============================================================ */

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 14px;
  min-height: 148px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  cursor: pointer;
  transition: border-color 0.15s, transform 0.15s, opacity 0.3s, box-shadow 0.15s;
  position: relative;
  box-shadow: 0 1px 3px rgba(0,0,0,0.05);
}
.card:hover {
  border-color: var(--border2);
  transform: translateY(-2px);
  box-shadow: 0 6px 20px rgba(0,0,0,0.09);
}

/* ── Section-tinted card backgrounds ── */
.card.tint-marketing { background: rgba(220,38,38,0.04);   border-color: rgba(220,38,38,0.12); }
.card.tint-seo       { background: rgba(22,163,74,0.04);   border-color: rgba(22,163,74,0.12); }
.card.tint-dev       { background: rgba(59,130,246,0.04);  border-color: rgba(59,130,246,0.12); }
.card.tint-content   { background: rgba(139,92,246,0.04);  border-color: rgba(139,92,246,0.12); }
.card.tint-ads       { background: rgba(234,88,12,0.04);   border-color: rgba(234,88,12,0.12); }
.card.tint-design    { background: rgba(219,39,119,0.04);  border-color: rgba(219,39,119,0.12); }
.card.tint-product   { background: rgba(13,148,136,0.04);  border-color: rgba(13,148,136,0.12); }

.card.tint-marketing:hover { box-shadow: 0 6px 20px rgba(220,38,38,0.10); }
.card.tint-seo:hover       { box-shadow: 0 6px 20px rgba(22,163,74,0.10); }
.card.tint-dev:hover       { box-shadow: 0 6px 20px rgba(59,130,246,0.10); }
.card.tint-content:hover   { box-shadow: 0 6px 20px rgba(139,92,246,0.10); }
.card.tint-ads:hover       { box-shadow: 0 6px 20px rgba(234,88,12,0.10); }
.card.tint-design:hover    { box-shadow: 0 6px 20px rgba(219,39,119,0.10); }
.card.tint-product:hover   { box-shadow: 0 6px 20px rgba(13,148,136,0.10); }

.card.done { opacity: 0.42; }
.card.done .card-title {
  text-decoration: line-through;
  color: var(--muted);
}

/* Card Header */
.card-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 8px;
}

.card-title {
  font-size: 13px;
  font-weight: 600;
  color: var(--text);
  line-height: 1.45;
  flex: 1;
  min-width: 0;
  word-break: break-word;
  overflow-wrap: anywhere;
}

/* Status Pill */
.status-pill {
  font-size: 9px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  padding: 3px 7px;
  border-radius: 4px;
  cursor: pointer;
  white-space: nowrap;
  flex-shrink: 0;
  border: 1px solid transparent;
  transition: opacity 0.15s;
}
.status-pill:hover { opacity: 0.8; }

.status-todo      { background: var(--surface3); color: var(--muted); border-color: var(--border2); }
.status-inprogress { background: var(--blue-dim); color: var(--blue); }
.status-done      { background: var(--green-dim); color: var(--green); }

/* Card Body */
.card-body {
  font-size: 12px;
  color: var(--muted);
  line-height: 1.6;
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
  flex: 1;
  word-break: break-word;
  overflow-wrap: anywhere;
}

/* Attachments row */
/* ── Card attachment previews ── */
.card-attachments-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(70px, 1fr));
  gap: 5px;
  flex-shrink: 0;
}

.card-img-preview {
  border-radius: 7px;
  overflow: hidden;
  cursor: pointer;
  flex-shrink: 0;
  background: var(--surface3);
  height: 72px;
}
.card-img-preview img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
  transition: opacity 0.15s;
}
.card-img-preview:hover img { opacity: 0.88; }

.card-file-preview {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 7px 10px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--surface3);
  flex-shrink: 0;
}
.card-file-preview.is-pdf { background: var(--red-dim); border-color: rgba(220,38,38,0.15); }
.card-file-icon { font-size: 15px; flex-shrink: 0; }
.card-file-name {
  font-size: 10px;
  color: var(--muted);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* legacy chip (kept for old URL-only cards) */
.card-attachments { display: flex; flex-wrap: wrap; gap: 5px; }
.attachment-chip {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 10px;
  background: var(--surface3);
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 2px 7px;
  color: var(--muted);
  max-width: 200px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* ── Drop Zone (brief modal) ── */
.drop-zone {
  border: 1.5px dashed var(--border2);
  border-radius: 10px;
  padding: 16px;
  cursor: pointer;
  transition: border-color 0.15s, background 0.15s;
  background: var(--surface2);
  outline: none;
}
.drop-zone.drag-over {
  border-color: var(--accent);
  background: var(--accent-dim);
}
.drop-zone-idle {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  color: var(--muted);
  font-size: 12px;
  text-align: center;
  pointer-events: none;
}
.drop-zone-idle svg { color: var(--muted2); }
.drop-browse {
  color: var(--accent);
  cursor: pointer;
  pointer-events: auto;
  text-decoration: underline;
}
.drop-zone-preview {
  display: flex;
  align-items: center;
  gap: 10px;
}
.drop-preview-icon { flex-shrink: 0; }
.drop-preview-info {
  display: flex;
  flex-direction: column;
  gap: 4px;
  min-width: 0;
  flex: 1;
}
.drop-preview-name {
  font-size: 12px;
  color: var(--text);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.drop-files-list {
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.drop-file-item {
  display: flex;
  align-items: center;
  gap: 7px;
  padding: 5px 8px;
  background: var(--surface3);
  border: 1px solid var(--border);
  border-radius: 7px;
  font-size: 12px;
}
.drop-file-item-icon { font-size: 14px; flex-shrink: 0; }
.drop-file-item-name {
  flex: 1;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  color: var(--text);
}
.drop-remove-btn {
  font-size: 11px;
  color: var(--muted2);
  background: none;
  border: none;
  cursor: pointer;
  padding: 0 2px;
  flex-shrink: 0;
  transition: color 0.12s;
}
.drop-remove-btn:hover { color: var(--red); }
.drop-add-more {
  font-size: 11px;
  color: var(--accent);
  cursor: pointer;
  text-decoration: underline;
  margin-top: 2px;
}
.drop-zone-uploading {
  display: flex;
  align-items: center;
  gap: 10px;
  color: var(--muted);
  font-size: 12px;
}
.upload-spinner {
  width: 16px;
  height: 16px;
  border: 2px solid var(--border2);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
  flex-shrink: 0;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* Card Footer */
.card-footer {
  display: flex;
  align-items: center;
  gap: 5px;
  margin-top: auto;
}

.team-tag {
  font-size: 10px;
  font-weight: 500;
  padding: 2px 7px;
  border-radius: 4px;
  white-space: nowrap;
}

.priority-badge {
  font-size: 9px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  padding: 2px 6px;
  border-radius: 4px;
  white-space: nowrap;
}

.card-date {
  font-family: 'DM Mono', monospace;
  font-size: 10px;
  color: var(--muted2);
  margin-left: auto;
  white-space: nowrap;
}

.card-actions {
  display: none;
  align-items: center;
  gap: 3px;
  margin-left: 6px;
  flex-shrink: 0;
}
.card:hover .card-actions { display: flex; }

.card-action-btn {
  width: 24px;
  height: 24px;
  border-radius: 5px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--muted);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.12s, border-color 0.12s, color 0.12s;
}
.card-action-btn:hover {
  background: var(--surface2);
  border-color: var(--border2);
  color: var(--text);
}
.card-action-btn.edit:hover { color: var(--accent); }
.card-action-btn.danger:hover { color: var(--red); }

/* ── Tag / priority colour helpers ── */
.tag-marketing { background: var(--red-dim);    color: var(--red);    }
.tag-seo       { background: var(--green-dim);  color: var(--green);  }
.tag-dev       { background: var(--blue-dim);   color: var(--blue);   }
.tag-content   { background: var(--purple-dim); color: var(--purple); }
.tag-ads       { background: var(--orange-dim); color: var(--orange); }
.tag-design    { background: var(--pink-dim);   color: var(--pink);   }
.tag-product   { background: var(--teal-dim);   color: var(--teal);   }
.tag-default   { background: var(--surface3);   color: var(--muted);  }

.priority-high   { background: var(--red-dim);    color: var(--red);    }
.priority-medium { background: var(--orange-dim); color: var(--orange); }
.priority-low    { background: var(--surface3);   color: var(--muted);  }

/* Product dot colours */
.dot-blue   { background: var(--blue);   }
.dot-purple { background: var(--purple); }
.dot-orange { background: var(--orange); }
.dot-green  { background: var(--green);  }
.dot-pink   { background: var(--pink);   }
.dot-teal   { background: var(--teal);   }

/* ── "Add New" card ── */
.card-add-new {
  background: transparent;
  border: 1.5px dashed var(--border2);
  border-radius: 12px;
  min-height: 172px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 8px;
  cursor: pointer;
  transition: border-color 0.15s, color 0.15s, background 0.15s;
  color: var(--muted2);
}
.card-add-new:hover {
  border-color: var(--accent);
  color: var(--accent);
  background: var(--accent-dim);
}
.card-add-new .add-icon { font-size: 20px; line-height: 1; }
.card-add-new .add-label { font-size: 12px; font-weight: 500; }

/* Card entrance animation */
@keyframes card-in {
  from { opacity: 0; transform: scale(0.95); }
  to   { opacity: 1; transform: scale(1);    }
}
.card-new { animation: card-in 0.2s ease forwards; }

/* ============================================================
   FORMS (shared across modals + login)
   ============================================================ */

.form-group {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.form-label {
  font-size: 10px;
  font-weight: 500;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}
.form-optional { font-size: 9px; color: var(--muted2); text-transform: none; letter-spacing: 0; }

.form-input, .form-textarea, .form-select {
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 9px 11px;
  color: var(--text);
  font-size: 12px;
  width: 100%;
  transition: border-color 0.15s;
  appearance: none;
  -webkit-appearance: none;
}
.form-input:focus, .form-textarea:focus, .form-select:focus {
  outline: none;
  border-color: var(--accent);
}
.form-input::placeholder, .form-textarea::placeholder { color: var(--muted2); }
.form-textarea { min-height: 90px; resize: vertical; line-height: 1.6; }

/* Rich text editor */
.rte-toolbar {
  display: flex;
  gap: 2px;
  margin-bottom: 4px;
}
.rte-btn {
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: 5px;
  color: var(--muted);
  width: 28px;
  height: 26px;
  font-size: 12px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.12s, color 0.12s;
}
.rte-btn:hover { background: var(--surface3, #334155); color: var(--text); }
.form-rte {
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 9px 11px;
  color: var(--text);
  font-size: 12px;
  width: 100%;
  min-height: 90px;
  max-height: 260px;
  overflow-y: auto;
  line-height: 1.6;
  box-sizing: border-box;
  outline: none;
  transition: border-color 0.15s;
  word-break: break-word;
}
.form-rte:focus { border-color: var(--accent); }
.form-rte:empty::before {
  content: attr(data-placeholder);
  color: var(--muted2);
  pointer-events: none;
}
.form-select { background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='6'%3E%3Cpath d='M0 0l5 6 5-6z' fill='%2364748b'/%3E%3C/svg%3E"); background-repeat: no-repeat; background-position: right 10px center; padding-right: 28px; cursor: pointer; }
.form-select option { background: #ffffff; }

.form-grid-3 {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  gap: 10px;
}

/* ── Buttons ── */
.btn-primary {
  padding: 9px 16px;
  background: var(--accent);
  color: var(--accent-dark);
  border: none;
  border-radius: 8px;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  transition: opacity 0.15s;
}
.btn-primary:hover { opacity: 0.88; }
.btn-primary:disabled { opacity: 0.5; cursor: not-allowed; }

.btn-secondary {
  padding: 9px 16px;
  background: transparent;
  color: var(--muted);
  border: 1px solid var(--border2);
  border-radius: 8px;
  font-size: 12px;
  font-weight: 500;
  cursor: pointer;
  transition: color 0.15s, border-color 0.15s;
}
.btn-secondary:hover { color: var(--text); }

.btn-danger {
  padding: 9px 16px;
  background: var(--red);
  color: #ffffff;
  border: none;
  border-radius: 8px;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  transition: opacity 0.15s;
}
.btn-danger:hover { opacity: 0.88; }
.btn-danger:disabled { opacity: 0.4; cursor: not-allowed; }

.btn-full { width: 100%; }

/* ============================================================
   MODALS
   ============================================================ */

.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(15,23,42,0.45);
  backdrop-filter: blur(8px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  padding: 20px;
}

.modal {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  width: 520px;
  max-width: 100%;
  max-height: calc(100vh - 40px);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  animation: modal-in 0.2s ease;
}
.modal-sm { width: 340px; }

@keyframes modal-in {
  from { opacity: 0; transform: translateY(14px) scale(0.97); }
  to   { opacity: 1; transform: translateY(0)    scale(1);    }
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 18px 20px 0;
  flex-shrink: 0;
}

.modal-title {
  font-size: 14px;
  font-weight: 600;
  color: var(--text);
}

.modal-close {
  background: none;
  border: none;
  color: var(--muted);
  font-size: 14px;
  cursor: pointer;
  padding: 4px 6px;
  border-radius: 4px;
  line-height: 1;
  transition: color 0.15s;
}
.modal-close:hover { color: var(--text); }

.modal-body {
  padding: 16px 20px;
  display: flex;
  flex-direction: column;
  gap: 14px;
  overflow-y: auto;
  flex: 1;
}

.modal-footer {
  padding: 0 20px 18px;
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  flex-shrink: 0;
}

.delete-warning {
  font-size: 13px;
  color: var(--muted);
  line-height: 1.6;
  padding: 10px 12px;
  background: var(--red-dim);
  border: 1px solid rgba(220,38,38,0.15);
  border-radius: 8px;
}
.delete-warning strong { color: var(--red); }

/* ── View Modal ── */
.view-modal {
  width: 600px;
  max-height: calc(100vh - 80px);
}

.view-top {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  padding: 18px 20px 14px;
  flex-shrink: 0;
}

.view-title {
  font-size: 17px;
  font-weight: 600;
  color: var(--text);
  line-height: 1.4;
}

.view-meta {
  display: flex;
  align-items: center;
  gap: 7px;
  padding: 0 20px 14px;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
  flex-wrap: wrap;
}

.view-meta .status-pill { cursor: default; }
.view-meta .status-pill:hover { opacity: 1; }

.view-body {
  padding: 16px 20px;
  font-size: 13px;
  color: var(--muted);
  line-height: 1.75;
  word-break: break-word;
  overflow-y: auto;
  flex: 1;
}

.view-attachments {
  padding: 0 20px 18px;
  flex-shrink: 0;
}
.view-attachments:empty { padding: 0; }

.view-attach-label {
  font-size: 10px;
  font-weight: 500;
  color: var(--muted2);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-bottom: 8px;
}

.view-file-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.view-img-thumb {
  width: 80px;
  height: 60px;
  border-radius: 6px;
  object-fit: cover;
  cursor: pointer;
  border: 1px solid var(--border);
  transition: border-color 0.15s, transform 0.15s;
}
.view-img-thumb:hover { border-color: var(--accent); transform: scale(1.03); }

.view-file-chip {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-size: 11px;
  color: var(--muted);
  background: var(--surface3);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 7px 11px;
  cursor: pointer;
  transition: color 0.15s, border-color 0.15s;
}
.view-file-chip:hover { color: var(--text); border-color: var(--border2); }

/* ============================================================
   TOAST
   ============================================================ */

.toast {
  position: fixed;
  bottom: 18px;
  right: 18px;
  background: var(--surface2);
  border: 1px solid var(--border2);
  border-radius: 8px;
  padding: 9px 14px;
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 12px;
  color: var(--text);
  z-index: 9999;
  box-shadow: 0 4px 20px rgba(0,0,0,0.12);
  animation: toast-in 0.25s ease;
  max-width: 320px;
}

.toast-dot {
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: var(--accent);
  flex-shrink: 0;
}

@keyframes toast-in {
  from { opacity: 0; transform: translateY(50px); }
  to   { opacity: 1; transform: translateY(0);    }
}

/* ============================================================
   LIGHTBOX
   ============================================================ */

.lightbox {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.92);
  backdrop-filter: blur(8px);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 14px;
  z-index: 2000;
}

.lightbox-close {
  position: fixed;
  top: 16px;
  right: 16px;
  width: 34px;
  height: 34px;
  border-radius: 50%;
  background: rgba(255,255,255,0.14);
  border: none;
  color: #fff;
  font-size: 14px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.15s;
  z-index: 1;
}
.lightbox-close:hover { background: rgba(255,255,255,0.25); }

#lightbox-img {
  max-width: 90vw;
  max-height: 85vh;
  object-fit: contain;
  border-radius: 8px;
  display: block;
}

.lightbox-filename {
  font-family: 'DM Mono', monospace;
  font-size: 11px;
  color: rgba(255,255,255,0.4);
}

/* ============================================================
   BOARD VIEWER + CARD VIEWER (share link pages)
   ============================================================ */

#board-viewer {
  min-height: 100vh;
  background: var(--bg);
  padding: 36px 28px 40px;
}

.viewer-header {
  font-size: 18px;
  font-weight: 600;
  color: var(--text);
  margin-bottom: 20px;
}

.viewer-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 12px;
}
@media (max-width: 860px) {
  .viewer-grid { grid-template-columns: repeat(2, 1fr); }
}

#card-viewer-page {
  min-height: 100vh;
  background: var(--bg);
  display: flex;
  align-items: flex-start;
  justify-content: center;
  padding: 60px 20px;
}

#card-viewer-inner .view-modal {
  /* Reuse view-modal styles but as a static block, not in an overlay */
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  width: 600px;
  max-width: calc(100vw - 40px);
  display: flex;
  flex-direction: column;
  max-height: none;
  overflow: visible;
}

/* ── Loading Screen ── */
#loading {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--bg);
  color: var(--muted2);
  font-family: 'DM Mono', monospace;
  font-size: 11px;
  letter-spacing: 0.08em;
}

/* ── Link Expired ── */
#link-expired {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--bg);
  color: var(--muted);
  font-size: 14px;
}

/* ============================================================
   RESPONSIVE — TABLET  (≤ 860px)
   Already handled: card-grid and viewer-grid → 2 columns
   ============================================================ */

@media (max-width: 860px) {
  #content-area { padding: 14px 16px 20px; }
  #topbar       { padding: 0 16px; }
  #app-row      { padding: 7px 16px; }
  #section-row  { padding: 0 16px; }
  #board-viewer { padding: 24px 16px 32px; }
}

/* ============================================================
   RESPONSIVE — MOBILE  (≤ 600px)
   ============================================================ */

@media (max-width: 600px) {

  /* ── Card grid: single column ── */
  #card-grid   { grid-template-columns: 1fr; gap: 10px; }
  .viewer-grid { grid-template-columns: 1fr; gap: 10px; }

  /* ── Topbar ── */
  #topbar { padding: 0 14px; }
  #owner-name-label { display: none; }
  .user-chip { padding: 4px; gap: 0; }

  /* ── App Row ── */
  #app-row { padding: 7px 14px; }

  /* ── Section Row ── */
  #section-row { padding: 0 0 0 14px; }
  .section-actions { padding-left: 10px; margin-left: 0; }

  /* ── FAB: slightly smaller on mobile ── */
  .fab { bottom: 20px; right: 18px; width: 48px; height: 48px; border-radius: 14px; }

  /* ── Content area ── */
  #content-area { padding: 12px 14px 20px; }

  /* ── Modals: bottom sheet ── */
  .modal-overlay {
    padding: 0;
    align-items: flex-end;
  }
  .modal, .modal-sm {
    width: 100%;
    max-width: 100%;
    max-height: 92vh;
    border-radius: 20px 20px 0 0;
  }
  .view-modal {
    width: 100%;
    max-width: 100%;
    max-height: 92vh;
    border-radius: 20px 20px 0 0;
  }

  /* ── Modal bottom sheet drag handle ── */
  .modal::before, .view-modal::before {
    content: '';
    display: block;
    width: 36px;
    height: 4px;
    background: var(--border2);
    border-radius: 2px;
    margin: 10px auto 0;
    flex-shrink: 0;
  }

  /* ── Form grid: stack vertically ── */
  .form-grid-3 { grid-template-columns: 1fr; }

  /* ── Board viewer ── */
  #board-viewer { padding: 20px 14px 28px; }
  .viewer-header { font-size: 15px; }

  /* ── Card viewer page ── */
  #card-viewer-page { padding: 20px 14px; align-items: flex-start; }
  #card-viewer-inner .view-modal {
    border-radius: 12px;
    max-height: none;
  }

  /* ── Cards: tighten padding slightly ── */
  .card { padding: 13px; }

  /* ── Login card ── */
  .login-card { padding: 24px 20px; border-radius: 16px; }

  /* ── Toast: full width at bottom ── */
  .toast {
    left: 14px;
    right: 14px;
    bottom: 14px;
    max-width: none;
  }
}

/* ============================================================
   RESPONSIVE — SMALL PHONE  (≤ 400px)
   ============================================================ */

@media (max-width: 400px) {
  .product-btn { padding: 4px 9px; font-size: 11px; }
  .section-tab { padding: 0 10px; font-size: 11px; }
  .topbar-logo { font-size: 10px; }
}
