:root {
  --bg: #f4f6f8;
  --card: #ffffff;
  --text: #1a1f26;
  --muted: #5c6773;
  --border: #d8dee6;
  --primary: #1e4d72;
  --primary-hover: #163a56;
  --error: #b42318;
  --radius: 10px;
  --shadow: 0 1px 3px rgba(0, 0, 0, 0.08);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.5;
}

.hidden {
  display: none !important;
}

#app {
  max-width: 960px;
  margin: 0 auto;
  padding: 2rem 1.25rem 3rem;
}

.panel {
  max-width: 420px;
  margin: 4rem auto 0;
}

.brand h1 {
  margin: 0 0 0.25rem;
  font-size: 1.75rem;
}

.brand p,
.muted {
  color: var(--muted);
}

.card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 1.25rem;
}

label {
  display: block;
  margin-bottom: 1rem;
  font-size: 0.9rem;
  font-weight: 600;
}

input[type="email"],
input[type="password"],
input[type="search"],
input[type="text"] {
  display: block;
  width: 100%;
  margin-top: 0.35rem;
  padding: 0.65rem 0.75rem;
  border: 1px solid var(--border);
  border-radius: 8px;
  font: inherit;
}

input[type="search"] {
  max-width: 320px;
}

.btn {
  border: 1px solid transparent;
  border-radius: 8px;
  padding: 0.55rem 1rem;
  font: inherit;
  cursor: pointer;
  background: #e8edf2;
}

.btn.primary {
  background: var(--primary);
  color: #fff;
}

.btn.primary:hover {
  background: var(--primary-hover);
}

.btn.ghost {
  background: transparent;
  border-color: var(--border);
}

.btn.small {
  padding: 0.35rem 0.65rem;
  font-size: 0.875rem;
}

.btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.error {
  color: var(--error);
  font-size: 0.9rem;
}

.error.banner {
  margin-top: 1rem;
  padding: 0.75rem 1rem;
  background: #fef3f2;
  border: 1px solid #fecdca;
  border-radius: var(--radius);
}

.topbar {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 1rem;
  margin-bottom: 1.5rem;
}

.topbar h1 {
  margin: 0;
  font-size: 1.5rem;
}

.topbar-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  justify-content: flex-end;
}

.admin-form h3 {
  margin-top: 0;
}

.form-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0 1rem;
}

.org-list {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  margin-top: 1rem;
}

.org-card h3 {
  margin: 0 0 0.35rem;
}

.org-card p {
  margin: 0.15rem 0;
  font-size: 0.9rem;
}

.user-list {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.user-card {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  gap: 1rem;
  align-items: flex-start;
}

.user-card-main h3 {
  margin: 0 0 0.25rem;
}

.user-card-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  align-items: center;
  margin-top: 0.35rem;
}

.role-badge {
  display: inline-block;
  font-size: 0.75rem;
  font-weight: 600;
  padding: 0.2rem 0.55rem;
  border-radius: 999px;
  background: #e8edf2;
  color: var(--text);
}

.role-badge.admin {
  background: #dbeafe;
  color: #1e4d72;
}

.user-card-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
}

select {
  display: block;
  width: 100%;
  margin-top: 0.35rem;
  padding: 0.65rem 0.75rem;
  border: 1px solid var(--border);
  border-radius: 8px;
  font: inherit;
  background: #fff;
}

.video-custom-fields {
  margin-top: 1rem;
  padding-top: 1rem;
  border-top: 1px solid var(--border);
}

.checkbox-row {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin-top: 1rem;
  font-weight: 500;
}

.checkbox-row input {
  width: auto;
  margin: 0;
}

.success {
  color: #166534;
  margin: 0.75rem 0 0;
}

.settings-section {
  margin-bottom: 2rem;
  padding-bottom: 1.5rem;
  border-bottom: 1px solid var(--border);
}

.settings-section:last-child {
  border-bottom: none;
  margin-bottom: 0;
  padding-bottom: 0;
}

.section-hint {
  margin: 0.25rem 0 0;
  font-size: 0.9rem;
}

.compact-form {
  margin-top: 0.75rem;
}

.inline-form {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
  align-items: flex-end;
}

.inline-form label.grow {
  flex: 1 1 220px;
  margin-bottom: 0;
}

.client-list,
.contact-list {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  margin-top: 0.75rem;
}

.client-card {
  text-align: left;
  width: 100%;
  cursor: pointer;
}

.client-card h3 {
  margin: 0 0 0.25rem;
}

.contact-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 1rem;
}

.contact-row-actions {
  display: flex;
  gap: 0.5rem;
  flex-shrink: 0;
}

.contact-row p {
  margin: 0;
  font-weight: 500;
}

.contact-row .small {
  font-size: 0.85rem;
  font-weight: 400;
  margin-top: 0.15rem;
}

#contact-role-custom-wrap {
  margin-top: 0.75rem;
}

.toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  margin: 1.25rem 0 0.75rem;
}

.toolbar h2,
.toolbar h3 {
  margin: 0;
}

.breadcrumb {
  margin: 0.25rem 0 0.75rem;
  font-size: 0.95rem;
}

.breadcrumb .link-btn {
  background: none;
  border: none;
  padding: 0;
  color: var(--primary);
  cursor: pointer;
  font: inherit;
  text-decoration: underline;
}

.project-grid {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.group-header {
  margin: 1.25rem 0 0.5rem;
  font-size: 1rem;
  font-weight: 700;
  color: var(--primary);
}

.group-header:first-child {
  margin-top: 0.25rem;
}

.project-card {
  text-align: left;
  width: 100%;
  cursor: pointer;
  transition: border-color 0.15s;
}

.project-card:hover {
  border-color: var(--primary);
}

.project-card h3 {
  margin: 0 0 0.35rem;
  font-size: 1.05rem;
}

.project-card p {
  margin: 0.15rem 0;
  font-size: 0.9rem;
}

.back {
  margin-bottom: 1rem;
}

.project-header h2 {
  margin: 0 0 0.75rem;
}

.meta-grid {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 0.35rem 1rem;
  margin: 0;
  font-size: 0.9rem;
}

.meta-grid dt {
  color: var(--muted);
  font-weight: 600;
}

.meta-grid dd {
  margin: 0;
}

.table-wrap {
  overflow-x: auto;
  padding: 0;
}

table {
  width: 100%;
  border-collapse: collapse;
}

th,
td {
  padding: 0.85rem 1rem;
  text-align: left;
  border-bottom: 1px solid var(--border);
  font-size: 0.95rem;
}

th {
  font-size: 0.8rem;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  color: var(--muted);
  background: #f9fafb;
}

td.actions {
  white-space: nowrap;
  text-align: right;
}

td.actions .btn + .btn {
  margin-left: 0.35rem;
}

.badge-missing {
  color: var(--error);
  font-size: 0.85rem;
}

.export-card {
  margin-top: 0.5rem;
}

.bundle-info {
  margin: 0.75rem 0 1rem;
}

.export-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
}

dialog {
  border: none;
  border-radius: var(--radius);
  padding: 0;
  max-width: 520px;
  width: calc(100% - 2rem);
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.15);
}

dialog::backdrop {
  background: rgba(0, 0, 0, 0.35);
}

.dialog-body h3 {
  margin-top: 0;
}

.dialog-actions {
  display: flex;
  gap: 0.5rem;
  margin-top: 1rem;
}

@media (max-width: 640px) {
  .form-grid {
    grid-template-columns: 1fr;
  }

  th:nth-child(3),
  td:nth-child(3) {
    display: none;
  }
}

.toolbar-split {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 1rem;
  flex-wrap: wrap;
}

.editor-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 1rem;
  flex-wrap: wrap;
  margin-bottom: 1rem;
}

.editor-tab-bar {
  display: flex;
  gap: 0.35rem;
}

.editor-tab {
  border: 1px solid var(--border);
  background: #fff;
  border-radius: 999px;
  padding: 0.45rem 0.9rem;
  cursor: pointer;
  font: inherit;
}

.editor-tab.active {
  background: var(--primary);
  border-color: var(--primary);
  color: #fff;
}

.editor-stack {
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.editor-block h3 {
  margin: 0 0 0.75rem;
}

.editor-block-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 1rem;
  flex-wrap: wrap;
  margin-bottom: 0.75rem;
}

.editor-block-header h3 {
  margin: 0;
}

.editor-sections-list,
.editor-entries-list {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.editor-section-card textarea,
.editor-block textarea {
  width: 100%;
  margin-top: 0.5rem;
}

.editor-section-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 0.5rem;
}

.editor-entry-card img.editor-entry-photo,
.editor-entry-card video.editor-entry-video {
  display: block;
  max-width: min(100%, 360px);
  max-height: 240px;
  width: auto;
  height: auto;
  border-radius: 8px;
  background: #111;
}

.editor-entry-media {
  line-height: 0;
}

.editor-entry-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 0.5rem;
  margin-bottom: 0.5rem;
}

.editor-entry-reorder {
  display: flex;
  justify-content: flex-end;
  gap: 0.4rem;
  margin-bottom: 0.5rem;
}

.editor-entry-item + .editor-entry-item {
  border-top: 1px solid var(--border);
  margin-top: 0.75rem;
  padding-top: 0.75rem;
}

.editor-entry-actions {
  display: flex;
  gap: 0.35rem;
  flex-wrap: wrap;
}

.editor-entry-caption {
  margin-top: 0.5rem;
  padding: 0.75rem;
  background: #f3f8ff;
  border-radius: 8px;
}

.editor-add-content {
  margin-top: 1rem;
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.editor-add-actions {
  display: flex;
  gap: 0.5rem;
  flex-wrap: wrap;
}

.file-btn {
  cursor: pointer;
  display: inline-flex;
  align-items: center;
}

.editor-save-row {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.editor-create-export {
  margin-top: 1rem;
}

.share-links-panel {
  margin-top: 1rem;
}

.activity-panel {
  margin-top: 1rem;
}

.sync-panel {
  margin-top: 1rem;
}

.share-links-list {
  display: flex;
  flex-direction: column;
  gap: 0.65rem;
}

.activity-list {
  display: flex;
  flex-direction: column;
  gap: 0.55rem;
}

.share-link-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 0.75rem;
  align-items: center;
  padding: 0.75rem;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: #fff;
}

.share-link-row.inactive {
  background: #f8fafc;
}

.share-link-main {
  min-width: 0;
}

.share-link-main h4 {
  margin: 0 0 0.25rem;
  font-size: 0.98rem;
}

.share-link-url {
  margin-top: 0.35rem;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 0.85rem;
}

.share-link-actions {
  display: flex;
  gap: 0.35rem;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.activity-row {
  padding: 0.75rem;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: #fff;
}

.activity-row.sync-failed {
  border-color: #fecaca;
  background: #fff7f7;
}

.activity-row.sync-clickable {
  cursor: pointer;
}

.activity-row.sync-clickable:hover,
.activity-row.sync-clickable:focus {
  border-color: #93c5fd;
  outline: none;
}

.activity-row h4 {
  margin: 0 0 0.25rem;
  font-size: 0.96rem;
}

.activity-row p {
  margin: 0.2rem 0 0;
}

.sync-path {
  overflow-wrap: anywhere;
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", monospace;
  font-size: 0.88rem;
}

.sync-events-list {
  margin-top: 0.75rem;
}

.sync-settings-events {
  margin-top: 1rem;
}

.sync-settings-events h4 {
  margin: 0 0 0.5rem;
}

.status-badge {
  display: inline-flex;
  align-items: center;
  padding: 0.16rem 0.45rem;
  border-radius: 999px;
  background: #e7f7ed;
  color: #116329;
  font-size: 0.78rem;
  font-weight: 700;
}

.status-badge.inactive {
  background: #f1f5f9;
  color: #64748b;
}

.small-select {
  min-height: 2rem;
  padding: 0.25rem 0.45rem;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: #fff;
  font-size: 0.85rem;
}

.btn.small {
  padding: 0.25rem 0.55rem;
  font-size: 0.85rem;
}

.btn.danger {
  color: var(--error);
}

.inline-label {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
  font-size: 0.9rem;
}

.address-autocomplete {
  position: relative;
  display: block;
}

.address-autocomplete-list {
  position: absolute;
  z-index: 40;
  left: 0;
  right: 0;
  top: calc(100% + 4px);
  margin: 0;
  padding: 0.25rem 0;
  list-style: none;
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 8px;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.12);
  max-height: 240px;
  overflow: auto;
}

.address-autocomplete-list.hidden {
  display: none;
}

.address-autocomplete-item {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 0.1rem;
  width: 100%;
  padding: 0.55rem 0.75rem;
  border: 0;
  background: transparent;
  text-align: left;
  cursor: pointer;
  font: inherit;
  color: inherit;
}

.address-autocomplete-item:hover,
.address-autocomplete-item:focus {
  background: #f3f5f7;
}

.address-autocomplete-item small {
  color: var(--muted, #667);
  font-size: 0.8rem;
}
