:root {
    --brand: #315c3a;
    --brand-dark: #203e2c;
    --brand-soft: #dfead8;
    --accent-coral: #f18b7e;
    --accent-purple: #a993d9;
    --surface: rgba(255, 255, 255, .96);
    --background: #f3f6f2;
    --text: #17211a;
    --muted: #69756c;
    --border: #dce5dc;
    --danger: #c43b3b;
    --sidebar-collapsed: 72px;
    --sidebar-expanded: 232px;
    --shadow: 0 18px 50px rgba(27, 53, 34, .12);
    --radius: 16px;
  }

  * { box-sizing: border-box; }

  html, body {
    margin: 0;
    min-height: 100%;
    font-family: "DM Sans", Arial, sans-serif;
    color: var(--text);
    background:
      radial-gradient(circle at 92% 8%, rgba(169, 147, 217, .13), transparent 25%),
      radial-gradient(circle at 72% 94%, rgba(241, 139, 126, .1), transparent 24%),
      var(--background);
  }

  button, input, select, textarea { font: inherit; }
  button { cursor: pointer; }
  .hidden { display: none !important; }

  .material-symbols-rounded {
    font-variation-settings: "FILL" 0, "wght" 500, "GRAD" 0, "opsz" 24;
  }

  .app-shell { min-height: 100vh; }

  .sidebar {
    position: fixed;
    inset: 0 auto 0 0;
    width: var(--sidebar-collapsed);
    background: rgba(255, 255, 255, .97);
    border-right: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    z-index: 50;
    transition: width .22s ease, box-shadow .22s ease;
  }

  .sidebar:hover,
  .sidebar:focus-within {
    width: var(--sidebar-expanded);
    box-shadow: 18px 0 40px rgba(28, 48, 33, .12);
  }

  .brand {
    min-height: 70px;
    padding: 13px 15px;
    display: flex;
    align-items: center;
    gap: 12px;
    border-bottom: 1px solid var(--border);
    white-space: nowrap;
  }

  .brand-mark {
    width: 42px;
    height: 42px;
    flex: 0 0 42px;
    border-radius: 14px;
    display: grid;
    place-items: center;
    background: linear-gradient(145deg, #3c7048, #203e2c);
    color: white;
    box-shadow: 0 8px 18px rgba(49, 92, 58, .22);
  }

  .brand-copy,
  .nav-label,
  .sidebar-note-copy {
    opacity: 0;
    transform: translateX(-7px);
    pointer-events: none;
    transition: opacity .16s ease, transform .16s ease;
  }

  .sidebar:hover .brand-copy,
  .sidebar:hover .nav-label,
  .sidebar:hover .sidebar-note-copy,
  .sidebar:focus-within .brand-copy,
  .sidebar:focus-within .nav-label,
  .sidebar:focus-within .sidebar-note-copy {
    opacity: 1;
    transform: translateX(0);
    pointer-events: auto;
  }

  .brand strong, .brand small { display: block; }
  .brand strong { font-size: 14px; }
  .brand small { margin-top: 2px; color: var(--muted); font-size: 11px; }

  .main-nav {
    flex: 1;
    padding: 10px 9px;
    overflow-y: auto;
    overflow-x: hidden;
    scrollbar-width: thin;
  }

  .nav-item {
    width: 100%;
    min-height: 44px;
    margin-bottom: 4px;
    padding: 8px 13px;
    border: 0;
    border-radius: 13px;
    background: transparent;
    color: #4d5950;
    display: flex;
    align-items: center;
    justify-content: flex-start;
    gap: 13px;
    text-align: left;
    white-space: nowrap;
    transition: background .16s ease, color .16s ease, transform .16s ease;
  }

  .nav-item:hover {
    background: #f0f5ef;
    color: var(--brand-dark);
    transform: translateX(1px);
  }

  .nav-item.active {
    background: linear-gradient(135deg, #dce9d7, #edf4ea);
    color: var(--brand-dark);
    font-weight: 700;
  }

  .nav-item .material-symbols-rounded {
    width: 28px;
    flex: 0 0 28px;
    text-align: center;
    font-size: 21px;
  }

  .nav-label { font-size: 13px; }

  .sidebar-mini-note {
    min-height: 58px;
    padding: 10px 22px;
    border-top: 1px solid var(--border);
    display: flex;
    align-items: center;
    gap: 13px;
    color: var(--muted);
    white-space: nowrap;
  }

  .sidebar-mini-note .material-symbols-rounded {
    width: 28px;
    flex: 0 0 28px;
    color: var(--accent-purple);
  }

  .sidebar-note-copy { font-size: 11px; }

  .main-content {
    margin-left: var(--sidebar-collapsed);
    min-height: 100vh;
  }

  .topbar {
    position: sticky;
    top: 0;
    z-index: 30;
    min-height: 72px;
    padding: 10px 20px;
    border-bottom: 1px solid rgba(220, 229, 220, .9);
    background: rgba(255, 255, 255, .86);
    backdrop-filter: blur(16px);
    display: flex;
    align-items: center;
    gap: 14px;
  }

  .page-heading { flex: 1; min-width: 0; }

  .eyebrow {
    display: flex;
    align-items: center;
    gap: 6px;
    margin-bottom: 2px;
    color: #7a867d;
    font-size: 9px;
    font-weight: 700;
    letter-spacing: .12em;
  }

  .live-dot {
    width: 7px;
    height: 7px;
    border-radius: 50%;
    background: #39a85a;
    box-shadow: 0 0 0 4px rgba(57, 168, 90, .12);
  }

  .page-heading h1 { margin: 0; font-size: 19px; line-height: 1.15; }
  .page-heading p { margin: 3px 0 0; color: var(--muted); font-size: 11px; }
  .topbar-actions { display: flex; gap: 7px; }

  .button, .icon-button {
    min-height: 38px;
    border: 1px solid transparent;
    border-radius: 11px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 7px;
    font-weight: 700;
    transition: transform .16s ease, background .16s ease, box-shadow .16s ease;
  }

  .button { padding: 8px 12px; font-size: 12px; }
  .button:hover, .icon-button:hover { transform: translateY(-1px); }

  .button-primary {
    color: white;
    background: linear-gradient(135deg, #3c7048, #294d33);
    box-shadow: 0 8px 18px rgba(49, 92, 58, .2);
  }

  .button-primary:hover { background: linear-gradient(135deg, #315c3a, #203e2c); }
  .button-ghost { color: #3c463f; background: white; border-color: var(--border); }
  .button-danger { color: white; background: var(--danger); }

  .icon-button {
    position: relative;
    width: 38px;
    flex: 0 0 38px;
    background: white;
    border-color: var(--border);
    color: #465049;
  }

  .tooltip-trigger .button-tooltip {
    position: absolute;
    top: calc(100% + 8px);
    right: 0;
    padding: 6px 8px;
    border-radius: 8px;
    background: #17211a;
    color: white;
    font-size: 10px;
    white-space: nowrap;
    opacity: 0;
    visibility: hidden;
    transform: translateY(-3px);
    transition: .15s ease;
  }

  .tooltip-trigger:hover .button-tooltip {
    opacity: 1;
    visibility: visible;
    transform: translateY(0);
  }

  .content-area { padding: 16px 20px 32px; }

  .social-hero {
    min-height: 94px;
    margin-bottom: 14px;
    padding: 15px 20px;
    border: 1px solid rgba(255, 255, 255, .8);
    border-radius: 18px;
    background: linear-gradient(120deg, rgba(26, 57, 42, .96), rgba(49, 92, 58, .9));
    color: white;
    box-shadow: 0 14px 35px rgba(32, 62, 44, .16);
    display: flex;
    align-items: center;
    justify-content: space-between;
    overflow: hidden;
  }

  .hero-copy { max-width: 610px; }

  .hero-badge {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 4px 8px;
    border: 1px solid rgba(255, 255, 255, .18);
    border-radius: 999px;
    background: rgba(255, 255, 255, .09);
    font-size: 9px;
    font-weight: 700;
    letter-spacing: .04em;
  }

  .hero-badge .material-symbols-rounded { font-size: 14px; color: #ffd6a5; }
  .social-hero h2 { margin: 8px 0 4px; max-width: 580px; font-size: 17px; line-height: 1.2; }
  .social-hero p { margin: 0; color: rgba(255, 255, 255, .72); font-size: 10px; }
  .hero-visual { width: 280px; height: 92px; margin-right: -18px; }
  .hero-visual svg { width: 100%; height: 100%; }

  .toolbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    margin-bottom: 10px;
  }

  .search-box {
    width: min(390px, 100%);
    height: 38px;
    padding: 0 11px;
    border: 1px solid var(--border);
    border-radius: 11px;
    background: rgba(255, 255, 255, .92);
    display: flex;
    align-items: center;
    gap: 8px;
    color: var(--muted);
  }

  .search-box:focus-within {
    border-color: #8cab92;
    box-shadow: 0 0 0 3px rgba(49, 92, 58, .09);
  }

  .search-box input {
    flex: 1;
    min-width: 0;
    border: 0;
    outline: 0;
    background: transparent;
    font-size: 12px;
  }

  .record-count { color: var(--muted); font-size: 11px; white-space: nowrap; }

  .table-card {
    overflow: hidden;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: rgba(255, 255, 255, .96);
    box-shadow: 0 7px 22px rgba(38, 62, 43, .05);
  }

  .table-scroll { overflow-x: auto; }
  table { width: 100%; min-width: 780px; border-collapse: collapse; }

  th, td {
    padding: 8px 9px;
    border-bottom: 1px solid #e8eee8;
    text-align: left;
    vertical-align: middle;
    font-size: 11px;
  }

  th {
    position: sticky;
    top: 0;
    z-index: 2;
    background: #f7faf6;
    color: #526056;
    font-size: 10px;
    font-weight: 700;
    white-space: nowrap;
  }

  tbody tr:hover { background: #fbfdfb; }
  td.actions { width: 78px; white-space: nowrap; text-align: right; }

  .row-action {
    width: 29px;
    height: 29px;
    padding: 0;
    border: 0;
    border-radius: 8px;
    background: transparent;
    color: #59645c;
  }

  .row-action .material-symbols-rounded { font-size: 18px; }
  .row-action:hover { background: #edf3ec; }
  .row-action.delete:hover { background: #fdecec; color: var(--danger); }

  .pill {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 22px;
    max-width: 180px;
    padding: 3px 9px;
    border-radius: 999px;
    color: #182019;
    font-size: 9px;
    font-weight: 700;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  .bool-pill {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    color: #667168;
    font-weight: 600;
  }

  .bool-pill.yes { color: var(--brand); }
  .bool-pill .material-symbols-rounded { font-size: 17px; }

  .link-cell {
    display: inline-block;
    max-width: 180px;
    color: #315eb8;
    text-decoration: none;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  .link-cell:hover { text-decoration: underline; }

.state-panel {
  min-height: 300px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  color: var(--muted);
  text-align: center;
}

.state-panel h2 { margin: 10px 0 4px; color: var(--text); font-size: 16px; }
.state-panel p { margin: 0; font-size: 12px; }
.state-icon { color: #9aaa9c; font-size: 46px; }

.spinner {
  width: 32px;
  height: 32px;
  border: 3px solid #dbe5db;
  border-top-color: var(--brand);
  border-radius: 50%;
  animation: spin .8s linear infinite;
}

@keyframes spin { to { transform: rotate(360deg); } }

.modal, .confirm-modal {
  position: fixed;
  inset: 0;
  z-index: 100;
  padding: 16px;
  display: grid;
  place-items: center;
}

.modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(14, 24, 17, .55);
  backdrop-filter: blur(5px);
}

.modal-panel, .confirm-panel {
  position: relative;
  width: min(760px, 100%);
  max-height: min(860px, calc(100vh - 32px));
  overflow: hidden;
  border: 1px solid rgba(255, 255, 255, .7);
  border-radius: 20px;
  background: rgba(255, 255, 255, .98);
  box-shadow: var(--shadow);
}

.modal-wide { width: min(1020px, 100%); }

.modal-header {
  padding: 15px 18px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
}

.modal-kicker {
  display: block;
  margin-bottom: 3px;
  color: #8a968c;
  font-size: 8px;
  font-weight: 700;
  letter-spacing: .14em;
}

.modal-header h2 { margin: 0; font-size: 18px; }
.modal-header p { margin: 3px 0 0; color: var(--muted); font-size: 11px; }

.modal-body {
  max-height: calc(100vh - 138px);
  padding: 16px 18px;
  overflow-y: auto;
}

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

.field {
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 5px;
}

.field.field-wide { grid-column: 1 / -1; }

.field-caption {
  display: flex;
  align-items: center;
  gap: 5px;
}

.field > span,
.field-caption > span:first-child {
  color: #435047;
  font-size: 10px;
  font-weight: 700;
}

.field small { color: var(--muted); font-size: 9px; line-height: 1.4; }

.field input,
.field select,
.field textarea,
.dropdown-filter input {
  width: 100%;
  min-height: 38px;
  padding: 8px 10px;
  border: 1px solid #d6dfd6;
  border-radius: 10px;
  outline: none;
  background: white;
  font-size: 12px;
}

.field textarea { min-height: 82px; resize: vertical; }

.field input:focus,
.field select:focus,
.field textarea:focus,
.dropdown-filter input:focus {
  border-color: #87a48d;
  box-shadow: 0 0 0 3px rgba(49, 92, 58, .09);
}

.field input[readonly] { background: #f3f6f3; color: #69736b; }

.input-with-button,
.select-with-button {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 38px;
  gap: 7px;
}

.inline-add-button,
.inline-refresh-button {
  width: 38px;
  height: 38px;
  border: 1px solid #d6dfd6;
  border-radius: 10px;
  background: #f8faf8;
  color: var(--brand);
}

.inline-add-button:hover,
.inline-refresh-button:hover { background: var(--brand-soft); }

.help-tip {
  position: relative;
  width: 16px;
  height: 16px;
  display: inline-grid;
  place-items: center;
  border-radius: 50%;
  background: #eaf0e9;
  color: #627066;
  font-size: 10px;
  cursor: help;
}

.help-tip .material-symbols-rounded { font-size: 13px; }

.help-bubble {
  position: absolute;
  left: 50%;
  bottom: calc(100% + 8px);
  z-index: 20;
  width: 235px;
  padding: 8px 9px;
  border-radius: 9px;
  background: #17211a;
  color: white;
  font-size: 9px;
  font-weight: 500;
  line-height: 1.45;
  opacity: 0;
  visibility: hidden;
  transform: translate(-50%, 4px);
  transition: .15s ease;
  pointer-events: none;
}

.help-tip:hover .help-bubble,
.help-tip:focus .help-bubble {
  opacity: 1;
  visibility: visible;
  transform: translate(-50%, 0);
}

.checkbox-field {
  min-height: 38px;
  padding: 7px 0;
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 11px;
  font-weight: 600;
}

.checkbox-field input {
  width: 18px;
  height: 18px;
  accent-color: var(--brand);
}

.upload-field { grid-column: 1 / -1; }

.upload-dropzone {
  min-height: 125px;
  padding: 14px;
  border: 1.5px dashed #aebcaf;
  border-radius: 14px;
  background: linear-gradient(135deg, rgba(223, 234, 216, .45), rgba(235, 228, 249, .35));
  display: grid;
  grid-template-columns: 110px minmax(0, 1fr);
  gap: 14px;
  align-items: center;
  cursor: pointer;
}

.upload-dropzone:hover { border-color: var(--brand); }

.upload-preview {
  width: 110px;
  height: 92px;
  overflow: hidden;
  border-radius: 12px;
  background: #e8eee8;
  display: grid;
  place-items: center;
  color: #78857b;
}

.upload-preview img { width: 100%; height: 100%; object-fit: cover; }
.upload-preview .material-symbols-rounded { font-size: 34px; }
.upload-copy strong, .upload-copy span { display: block; }
.upload-copy strong { margin-bottom: 4px; font-size: 12px; }
.upload-copy span { color: var(--muted); font-size: 10px; line-height: 1.5; }
.upload-file-name { margin-top: 7px; color: var(--brand) !important; font-weight: 700; }

.sticky-actions {
  position: sticky;
  bottom: -16px;
  margin: 16px -18px -16px;
  padding: 11px 18px;
  border-top: 1px solid var(--border);
  background: rgba(255, 255, 255, .96);
  backdrop-filter: blur(10px);
}

.modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
}

.settings-tabs {
  padding: 9px 18px 0;
  display: flex;
  gap: 6px;
}

.settings-tab {
  min-height: 36px;
  padding: 7px 11px;
  border: 1px solid var(--border);
  border-radius: 10px 10px 0 0;
  background: #f5f8f4;
  color: #5f6a62;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 11px;
  font-weight: 700;
}

.settings-tab .material-symbols-rounded { font-size: 17px; }

.settings-tab.active {
  border-bottom-color: white;
  background: white;
  color: var(--brand);
}

.settings-section { border-top: 1px solid var(--border); }

.dropdown-layout {
  display: grid;
  grid-template-columns: 300px minmax(0, 1fr);
  max-height: calc(100vh - 185px);
}

.dropdown-editor {
  padding: 16px;
  border-right: 1px solid var(--border);
  overflow-y: auto;
}

.dropdown-editor .field { margin-bottom: 11px; }

.field-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 9px;
}

.editor-actions {
  margin-top: 14px;
  display: flex;
  justify-content: flex-end;
  gap: 7px;
}

.dropdown-list-wrap { padding: 16px; overflow-y: auto; }
.dropdown-filter { margin-bottom: 10px; }
.dropdown-list { display: flex; flex-direction: column; gap: 6px; }

.dropdown-item {
  padding: 8px 10px;
  border: 1px solid var(--border);
  border-radius: 11px;
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  gap: 9px;
}

.dropdown-item.inactive { opacity: .52; }
.dropdown-meta { min-width: 0; }
.dropdown-meta strong { display: block; margin-bottom: 3px; font-size: 11px; }
.dropdown-meta small { color: var(--muted); font-size: 9px; }
.dropdown-actions { display: flex; gap: 2px; }

.integration-panel {
  padding: 18px;
  display: grid;
  grid-template-columns: minmax(0, .85fr) minmax(320px, 1.15fr);
  gap: 18px;
}

.integration-card {
  min-height: 230px;
  padding: 20px;
  border-radius: 17px;
  background:
    radial-gradient(circle at 90% 15%, rgba(255, 255, 255, .18), transparent 25%),
    linear-gradient(145deg, #4e356e, #b14d6d 55%, #d8804f);
  color: white;
  display: flex;
  align-items: flex-start;
  gap: 14px;
}

.integration-icon {
  width: 48px;
  height: 48px;
  flex: 0 0 48px;
  border-radius: 15px;
  display: grid;
  place-items: center;
  background: rgba(255, 255, 255, .16);
}

.integration-card h3 { margin: 4px 0 7px; font-size: 17px; }

.integration-card p {
  margin: 0 0 13px;
  color: rgba(255, 255, 255, .78);
  font-size: 11px;
  line-height: 1.6;
}

.integration-card a { color: white; font-size: 11px; font-weight: 700; }
.integration-form { padding: 4px 0; }
.integration-form .field { margin-bottom: 11px; }

.integration-status {
  margin-bottom: 12px;
  padding: 10px 11px;
  border-radius: 11px;
  background: #f2f6f1;
  color: #536058;
  font-size: 10px;
  line-height: 1.45;
}

.integration-status.configured {
  background: #e5f4e7;
  color: #2b6a38;
}

.integration-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  margin-top: 14px;
}

.plotting-matrix-view .table-card { display: block; }
  .plotting-matrix-view .mobile-cards { display: none !important; }

  .plotting-matrix-view table {
    min-width: max-content;
    border-collapse: separate;
    border-spacing: 0;
  }

  .plotting-matrix-view thead { display: none; }

  .plotting-matrix-view td {
    padding: 5px 6px;
    border-right: 1px solid #697784;
    border-bottom: 1px solid #697784;
  }

  .plotting-matrix-view tr:first-child td { border-top: 1px solid #697784; }
  .plotting-matrix-view td:first-child { border-left: 1px solid #697784; }

  .plot-project-cell {
    position: sticky;
    left: 0;
    z-index: 5;
    min-width: 180px;
    max-width: 190px;
    background: #dfead8;
    vertical-align: middle;
  }

  .plot-project-content {
    min-height: 72px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
  }

  .plot-project-content strong,
  .plot-project-content small { display: block; }

  .plot-project-content strong { font-size: 11px; line-height: 1.3; }
  .plot-project-content small { margin-top: 4px; color: #5f6c62; font-size: 9px; }

  .plot-add-room {
    width: 30px;
    height: 30px;
    flex: 0 0 30px;
    display: grid;
    place-items: center;
    border: 1px solid #aab9ad;
    border-radius: 9px;
    background: rgba(255, 255, 255, .75);
    color: var(--brand);
  }

  .plot-room-cell,
  .plot-pic-cell {
    min-width: 142px;
    width: 142px;
    text-align: center;
  }

  .plot-room-cell { height: 38px; background: #dce5f6; }
  .plot-pic-cell { height: 38px; background: #f8fafc; }

  .plot-room-name {
    width: 100%;
    padding: 3px;
    border: 0;
    background: transparent;
    color: #17211a;
    font-size: 10px;
    font-weight: 700;
    line-height: 1.25;
  }

  .plot-room-name:hover { text-decoration: underline; }
  .plot-pic-pill { min-width: 90px; }
  .plot-empty-cell { background: #f1f4f7; color: #9aa4ad; }

  .plot-cell-actions {
    display: flex;
    justify-content: center;
    gap: 1px;
    margin-top: 1px;
    opacity: 0;
    transition: opacity .15s ease;
  }

  .plot-pic-cell:hover .plot-cell-actions,
  .plot-pic-cell:focus-within .plot-cell-actions { opacity: 1; }

  .plot-cell-actions .row-action { width: 24px; height: 24px; }
  .plot-cell-actions .row-action .material-symbols-rounded { font-size: 15px; }

  .confirm-panel {
    width: min(370px, 100%);
    padding: 23px;
    text-align: center;
  }

  .confirm-icon {
    width: 50px;
    height: 50px;
    margin: 0 auto 10px;
    border-radius: 50%;
    background: #fdeaea;
    color: var(--danger);
    display: grid;
    place-items: center;
    font-size: 28px;
  }

  .confirm-panel h3 { margin: 0; }

  .confirm-panel p {
    color: var(--muted);
    font-size: 11px;
    line-height: 1.5;
  }

  .confirm-panel .modal-actions { justify-content: center; }

  .toast-container {
    position: fixed;
    right: 14px;
    bottom: 14px;
    z-index: 200;
    display: flex;
    flex-direction: column;
    gap: 7px;
  }

  .toast {
    min-width: 260px;
    max-width: 400px;
    padding: 10px 12px;
    border-radius: 11px;
    background: #17211a;
    color: white;
    box-shadow: var(--shadow);
    font-size: 11px;
    animation: toastIn .2s ease;
  }

  .toast.error { background: #8e2929; }

  @keyframes toastIn {
    from { opacity: 0; transform: translateY(7px); }
  }

  .mobile-cards,
  .mobile-backdrop,
  .mobile-only { display: none; }

  @media (max-width: 980px) {
    .sidebar {
      width: 250px;
      transform: translateX(-102%);
      box-shadow: var(--shadow);
      transition: transform .2s ease;
    }

    .sidebar.open { transform: translateX(0); }

    .sidebar .brand-copy,
    .sidebar .nav-label,
    .sidebar .sidebar-note-copy {
      opacity: 1;
      transform: none;
      pointer-events: auto;
    }

    .mobile-backdrop {
      position: fixed;
      inset: 0;
      z-index: 45;
      display: block;
      background: rgba(16, 25, 18, .45);
      opacity: 0;
      visibility: hidden;
      transition: .2s ease;
    }

    .mobile-backdrop.open { opacity: 1; visibility: visible; }
    .main-content { margin-left: 0; }
    .mobile-only { display: inline-flex; }
  }

  @media (max-width: 760px) {
    .topbar { min-height: 64px; padding: 9px 11px; }
    .eyebrow, .page-heading p { display: none; }

    .page-heading h1 {
      font-size: 16px;
      overflow: hidden;
      text-overflow: ellipsis;
      white-space: nowrap;
    }

    .desktop-label { display: none; }
    .topbar-actions { gap: 4px; }
    .topbar .button { min-width: 38px; padding: 7px 9px; }
    .topbar .button span:last-child { display: none; }
    .content-area { padding: 12px 10px 26px; }
    .social-hero { display: none; }

    .toolbar {
      align-items: stretch;
      flex-direction: column;
    }

    .record-count { padding-left: 2px; }
    .table-card { display: none; }
    .mobile-cards { display: grid; gap: 9px; }

    .record-card {
      padding: 11px;
      border: 1px solid var(--border);
      border-radius: 13px;
      background: white;
      box-shadow: 0 5px 16px rgba(38, 62, 43, .04);
    }

    .record-card-title {
      padding-bottom: 8px;
      border-bottom: 1px solid #edf1ed;
      display: flex;
      align-items: flex-start;
      justify-content: space-between;
      gap: 8px;
    }

    .record-card-title strong { font-size: 12px; line-height: 1.35; }
    .card-actions { display: flex; }

    .record-fields {
      padding-top: 9px;
      display: grid;
      gap: 7px;
    }

    .record-field {
      display: grid;
      grid-template-columns: 102px minmax(0, 1fr);
      gap: 7px;
      font-size: 10px;
    }

    .record-field dt { color: var(--muted); }

    .record-field dd {
      min-width: 0;
      margin: 0;
      word-break: break-word;
    }

    .form-grid { grid-template-columns: 1fr; }
    .field.field-wide, .upload-field { grid-column: auto; }

    .modal {
      padding: 0;
      align-items: end;
    }

    .modal-panel {
      max-height: 94vh;
      border-radius: 20px 20px 0 0;
    }

    .dropdown-layout,
    .integration-panel {
      grid-template-columns: 1fr;
      overflow-y: auto;
    }

    .dropdown-editor {
      border-right: 0;
      border-bottom: 1px solid var(--border);
      overflow: visible;
    }

    .dropdown-list-wrap { overflow: visible; }
    .modal-wide { height: 94vh; overflow-y: auto; }

    .upload-dropzone { grid-template-columns: 82px minmax(0, 1fr); }
    .upload-preview { width: 82px; height: 76px; }

    .plotting-matrix-view .table-card { display: block; }

    .plotting-matrix-view .table-scroll {
      -webkit-overflow-scrolling: touch;
    }

    .plot-project-cell {
      min-width: 145px;
      max-width: 155px;
    }

    .plot-room-cell,
    .plot-pic-cell {
      min-width: 125px;
      width: 125px;
    }

    .plot-cell-actions { opacity: 1; }

    .toast-container {
      left: 10px;
      right: 10px;
      bottom: 10px;
    }

    .toast {
      width: 100%;
      min-width: 0;
      max-width: none;
    }
  }

  .title-link {
    color: var(--brand-dark);
    font-weight: 700;
    text-decoration: none;
    text-underline-offset: 3px;
  }

  .title-link:hover {
    color: #315eb8;
    text-decoration: underline;
  }

  .title-link::after {
    content: ' ↗';
    color: #7a867d;
    font-size: .85em;
  }

  .insight-link-row {
    grid-template-columns: minmax(0, 1fr) 42px;
  }

  .insight-sync-button {
    width: 42px;
    height: 38px;
    background: linear-gradient(145deg, #e8f1e6, #f3edf9);
  }

  .insight-sync-button:disabled {
    cursor: not-allowed;
    opacity: .45;
  }

  #instagramInsightStatus {
    min-height: 14px;
  }


  .sort-control {
    width: 230px;
    height: 38px;
    padding: 0 9px 0 11px;
    border: 1px solid var(--border);
    border-radius: 11px;
    background: rgba(255, 255, 255, .92);
    display: flex;
    align-items: center;
    gap: 7px;
    color: var(--muted);
  }

  .sort-control:focus-within {
    border-color: #8cab92;
    box-shadow: 0 0 0 3px rgba(49, 92, 58, .09);
  }

  .sort-control .material-symbols-rounded {
    flex: 0 0 auto;
    font-size: 19px;
  }

  .sort-control select {
    width: 100%;
    min-width: 0;
    height: 100%;
    padding: 0 23px 0 0;
    border: 0;
    outline: 0;
    background: transparent;
    color: #435047;
    font-size: 11px;
    font-weight: 600;
    cursor: pointer;
  }

  @media (max-width: 760px) {
    .sort-control {
      width: 100%;
    }
  }



  /* v3.4 — preview foto */
  .photo-preview-trigger {
    min-height: 32px;
    padding: 6px 10px;
    border: 1px solid #cfdacf;
    border-radius: 9px;
    background: #f7faf6;
    color: var(--brand-dark);
    display: inline-flex;
    align-items: center;
    gap: 6px;
    font-size: 10px;
    font-weight: 700;
  }

  .photo-preview-trigger:hover {
    background: var(--brand-soft);
    border-color: #9eb09f;
  }

  .photo-preview-trigger .material-symbols-rounded { font-size: 17px; }

  .photo-preview-panel {
    position: relative;
    width: min(920px, 100%);
    max-height: calc(100vh - 32px);
    overflow: hidden;
    border: 1px solid rgba(255, 255, 255, .7);
    border-radius: 20px;
    background: #fff;
    box-shadow: var(--shadow);
  }

  .photo-preview-header {
    min-height: 66px;
    padding: 14px 16px;
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
  }

  .photo-preview-header h2 { margin: 0; font-size: 18px; }

  .photo-preview-body {
    min-height: 260px;
    max-height: calc(100vh - 190px);
    padding: 14px;
    overflow: auto;
    background: #eef3ee;
    display: grid;
    place-items: center;
  }

  .photo-preview-image {
    display: block;
    max-width: 100%;
    max-height: calc(100vh - 225px);
    object-fit: contain;
    border-radius: 12px;
    box-shadow: 0 12px 32px rgba(18, 36, 24, .16);
  }

  .photo-preview-loading,
  .photo-preview-error {
    min-height: 220px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    text-align: center;
    color: var(--muted);
  }

  .photo-preview-error {
    padding: 20px;
    color: #8e2929;
    font-size: 13px;
  }

  .photo-preview-actions {
    padding: 11px 16px;
    border-top: 1px solid var(--border);
    display: flex;
    justify-content: flex-end;
    gap: 8px;
  }

  /* v3.4 — card Plotting khusus mobile */
  .plot-mobile-project-card {
    overflow: hidden;
    border: 1px solid var(--border);
    border-radius: 16px;
    background: white;
    box-shadow: 0 7px 20px rgba(38, 62, 43, .06);
  }

  .plot-mobile-project-header {
    min-height: 62px;
    padding: 13px 14px;
    background: #dfead8;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
  }

  .plot-mobile-project-header strong,
  .plot-mobile-project-header small { display: block; }
  .plot-mobile-project-header strong { font-size: 16px; line-height: 1.3; }
  .plot-mobile-project-header small { margin-top: 3px; color: #59675d; font-size: 12px; }

  .plot-mobile-add {
    width: 46px;
    height: 46px;
    flex: 0 0 46px;
    border: 1px solid #a7b7a9;
    border-radius: 13px;
    background: rgba(255,255,255,.85);
    color: var(--brand);
  }

  .plot-mobile-room-list { display: grid; }

  .plot-mobile-room {
    min-height: 66px;
    padding: 10px 10px 10px 14px;
    border-top: 1px solid #e8eee8;
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    align-items: center;
    gap: 8px;
  }

  .plot-mobile-room-copy {
    min-width: 0;
    padding: 0;
    border: 0;
    background: transparent;
    text-align: left;
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    gap: 7px;
  }

  .plot-mobile-room-copy strong { font-size: 15px; line-height: 1.35; }
  .plot-mobile-room-actions { display: flex; }

  /* v3.4 — mobile yang lebih nyaman disentuh */
  @media (max-width: 760px) {
    html { -webkit-text-size-adjust: 100%; }

    .sidebar { width: min(86vw, 320px); }
    .brand { min-height: 76px; padding: 14px 16px; }
    .brand-mark { width: 46px; height: 46px; flex-basis: 46px; }
    .brand strong { font-size: 16px; }
    .brand small { font-size: 12px; }

    .main-nav { padding: 10px; }
    .nav-item {
      min-height: 52px;
      padding: 10px 13px;
      border-radius: 14px;
      gap: 13px;
    }
    .nav-item .material-symbols-rounded { font-size: 24px; }
    .nav-label { font-size: 15px; }
    .sidebar-mini-note { min-height: 64px; }
    .sidebar-note-copy { font-size: 12px; }

    .topbar { min-height: 72px; padding: 10px 12px; }
    .page-heading h1 { font-size: 19px; }
    .icon-button,
    .topbar .button,
    .row-action {
      min-width: 44px;
      width: 44px;
      min-height: 44px;
      height: 44px;
      border-radius: 12px;
    }

    .topbar-actions { gap: 6px; }
    .content-area { padding: 14px 12px 28px; }

    .search-box,
    .sort-control {
      height: 50px;
      border-radius: 14px;
      padding-left: 14px;
    }
    .search-box input,
    .sort-control select { font-size: 16px; }
    .record-count { font-size: 13px; }

    .mobile-cards { gap: 12px; }
    .record-card { padding: 15px; border-radius: 16px; }
    .record-card-title { padding-bottom: 12px; gap: 10px; }
    .record-card-title strong { font-size: 16px; line-height: 1.4; }
    .card-actions { gap: 4px; }
    .record-fields { padding-top: 12px; gap: 10px; }
    .record-field {
      grid-template-columns: minmax(112px, .42fr) minmax(0, 1fr);
      gap: 10px;
      font-size: 14px;
      line-height: 1.4;
    }
    .record-field dt { font-size: 12px; font-weight: 700; }
    .record-field dd { font-size: 14px; }
    .pill { min-height: 28px; padding: 5px 10px; font-size: 12px; }
    .photo-preview-trigger { min-height: 42px; padding: 8px 12px; font-size: 13px; }

    .modal { padding: 0; align-items: stretch; }
    .modal-panel,
    .photo-preview-panel {
      width: 100%;
      height: 100dvh;
      max-height: 100dvh;
      border-radius: 0;
    }
    .modal-header,
    .photo-preview-header { padding: 16px; min-height: 78px; }
    .modal-header h2,
    .photo-preview-header h2 { font-size: 23px; }
    .modal-header p { font-size: 14px; }
    .modal-body {
      max-height: calc(100dvh - 78px);
      padding: 16px;
    }

    .field { gap: 7px; }
    .field > span,
    .field-caption > span:first-child { font-size: 14px; }
    .field small { font-size: 12px; }
    .field input,
    .field select,
    .field textarea,
    .dropdown-filter input {
      min-height: 50px;
      padding: 11px 13px;
      border-radius: 13px;
      font-size: 16px;
    }
    .field textarea { min-height: 120px; }
    .input-with-button,
    .select-with-button,
    .insight-link-row { grid-template-columns: minmax(0, 1fr) 50px; }
    .inline-add-button,
    .inline-refresh-button,
    .insight-sync-button { width: 50px; height: 50px; border-radius: 13px; }
    .help-tip { width: 22px; height: 22px; }
    .help-tip .material-symbols-rounded { font-size: 17px; }
    .help-bubble { width: min(270px, 80vw); font-size: 12px; }

    .sticky-actions {
      bottom: -16px;
      padding: 12px 16px max(12px, env(safe-area-inset-bottom));
    }
    .sticky-actions .button,
    .photo-preview-actions .button {
      min-height: 50px;
      padding: 11px 17px;
      font-size: 15px;
    }

    .upload-dropzone {
      min-height: 150px;
      grid-template-columns: 100px minmax(0, 1fr);
      padding: 14px;
    }
    .upload-preview { width: 100px; height: 96px; }
    .upload-copy strong { font-size: 15px; }
    .upload-copy span { font-size: 12px; }

    .plotting-matrix-view .table-card { display: none; }
    .plotting-matrix-view .mobile-cards { display: grid !important; }

    .photo-preview-body {
      min-height: 0;
      max-height: none;
      height: calc(100dvh - 148px);
      padding: 10px;
    }
    .photo-preview-image { max-height: calc(100dvh - 185px); }
    .photo-preview-actions {
      min-height: 70px;
      padding: 10px 12px max(10px, env(safe-area-inset-bottom));
    }
  }

  @media (max-width: 420px) {
    .record-field { grid-template-columns: 1fr; gap: 3px; }
    .record-field dt { margin-top: 3px; }
    .topbar-actions { gap: 4px; }
    .topbar { padding-inline: 8px; }
    .page-heading h1 { font-size: 17px; }
  }

/* =========================================================
   PWA shell, authentication, install, and mobile refinements
   ========================================================= */

.auth-gate {
  position: fixed;
  inset: 0;
  z-index: 500;
  display: grid;
  place-items: center;
  padding: 20px;
  background:
    radial-gradient(circle at 18% 15%, rgba(169, 147, 217, .23), transparent 28%),
    radial-gradient(circle at 85% 84%, rgba(241, 139, 126, .19), transparent 28%),
    linear-gradient(145deg, #eff5ed, #f8faf7);
}

.auth-gate.hidden { display: none; }

.auth-card {
  width: min(420px, 100%);
  padding: 34px 28px;
  border: 1px solid rgba(255, 255, 255, .9);
  border-radius: 28px;
  background: rgba(255, 255, 255, .95);
  box-shadow: 0 28px 80px rgba(28, 55, 36, .18);
  text-align: center;
}

.auth-logo {
  width: 72px;
  height: 72px;
  margin: 0 auto 18px;
  border-radius: 23px;
  display: grid;
  place-items: center;
  color: white;
  background: linear-gradient(145deg, #3c7048, #203e2c);
  box-shadow: 0 16px 32px rgba(49, 92, 58, .24);
}

.auth-logo .material-symbols-rounded { font-size: 38px; }
.auth-kicker {
  color: #839087;
  font-size: 10px;
  font-weight: 800;
  letter-spacing: .16em;
}

.auth-card h1 { margin: 8px 0 8px; font-size: 27px; }
.auth-card p {
  margin: 0 auto 22px;
  max-width: 320px;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.65;
}

.auth-button {
  width: 100%;
  min-height: 50px;
  font-size: 14px;
}

.google-g {
  width: 25px;
  height: 25px;
  display: inline-grid;
  place-items: center;
  border-radius: 50%;
  background: white;
  color: #4285f4;
  font-weight: 800;
}

.auth-message {
  min-height: 18px;
  margin-top: 12px;
  color: var(--danger);
  font-size: 11px;
  line-height: 1.45;
}

.network-banner,
.update-banner {
  position: fixed;
  z-index: 450;
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  border-radius: 0 0 13px 13px;
  box-shadow: 0 8px 24px rgba(20, 35, 24, .18);
}

.network-banner {
  top: 0;
  padding: 8px 14px;
  background: #8b2f2f;
  color: white;
  font-size: 11px;
  font-weight: 700;
}

.network-banner .material-symbols-rounded { font-size: 17px; }

.update-banner {
  bottom: 16px;
  padding: 10px 12px 10px 15px;
  background: #17211a;
  color: white;
  font-size: 11px;
}

.update-banner button {
  min-height: 32px;
  padding: 5px 10px;
  border: 0;
  border-radius: 8px;
  background: white;
  color: var(--brand-dark);
  font-weight: 800;
}

.sidebar-account {
  min-height: 64px;
  padding: 9px 13px;
  border-top: 1px solid var(--border);
  display: flex;
  align-items: center;
  gap: 10px;
  white-space: nowrap;
}

.sidebar-account-icon {
  width: 42px;
  height: 42px;
  flex: 0 0 42px;
  border-radius: 14px;
  display: grid;
  place-items: center;
  background: #edf3ec;
  color: var(--brand);
}

.sidebar-account-copy {
  min-width: 0;
  flex: 1;
  opacity: 0;
  transform: translateX(-7px);
  transition: opacity .16s ease, transform .16s ease;
}

.sidebar-account-copy strong,
.sidebar-account-copy small {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
}

.sidebar-account-copy strong { font-size: 11px; }
.sidebar-account-copy small { margin-top: 2px; color: var(--muted); font-size: 9px; }

.sidebar-signout {
  width: 34px;
  height: 34px;
  flex: 0 0 34px;
  padding: 0;
  border: 0;
  border-radius: 10px;
  background: transparent;
  color: #667168;
  opacity: 0;
  pointer-events: none;
}

.sidebar:hover .sidebar-account-copy,
.sidebar:focus-within .sidebar-account-copy,
.sidebar:hover .sidebar-signout,
.sidebar:focus-within .sidebar-signout {
  opacity: 1;
  transform: none;
  pointer-events: auto;
}

.sidebar-signout:hover { background: #fdecec; color: var(--danger); }

.install-help-panel {
  position: relative;
  width: min(390px, 100%);
  padding: 28px 24px 24px;
  border-radius: 24px;
  background: white;
  box-shadow: var(--shadow);
  text-align: center;
}

.install-help-close { position: absolute; top: 13px; right: 13px; }

.install-help-icon {
  width: 62px;
  height: 62px;
  margin: 0 auto 14px;
  border-radius: 20px;
  display: grid;
  place-items: center;
  background: var(--brand-soft);
  color: var(--brand);
}

.install-help-icon .material-symbols-rounded { font-size: 34px; }
.install-help-panel h2 { margin: 0 0 8px; font-size: 20px; }
.install-help-panel p { margin: 0; color: var(--muted); font-size: 12px; line-height: 1.6; }

.install-help-steps {
  margin: 18px 0;
  display: grid;
  gap: 8px;
  text-align: left;
}

.install-help-steps span {
  min-height: 42px;
  padding: 9px 11px;
  border: 1px solid var(--border);
  border-radius: 12px;
  display: flex;
  align-items: center;
  gap: 9px;
  font-size: 11px;
  font-weight: 600;
}

.install-help-steps b {
  width: 24px;
  height: 24px;
  flex: 0 0 24px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  background: var(--brand);
  color: white;
  font-size: 10px;
}

@media (max-width: 980px) {
  .sidebar .sidebar-account-copy,
  .sidebar .sidebar-signout {
    opacity: 1;
    transform: none;
    pointer-events: auto;
  }
}

@media (max-width: 760px) {
  body {
    padding-top: env(safe-area-inset-top);
    padding-bottom: env(safe-area-inset-bottom);
  }

  .auth-card {
    padding: 30px 22px;
    border-radius: 24px;
  }

  .auth-card h1 { font-size: 24px; }

  .network-banner {
    width: calc(100% - 20px);
    top: env(safe-area-inset-top);
    border-radius: 0 0 12px 12px;
    text-align: center;
  }

  .update-banner {
    left: 10px;
    right: 10px;
    bottom: calc(10px + env(safe-area-inset-bottom));
    transform: none;
  }

  .topbar {
    padding-top: max(9px, env(safe-area-inset-top));
  }

  .topbar-actions .icon-button,
  .topbar-actions .button {
    min-width: 44px;
    min-height: 44px;
  }

  .sidebar {
    padding-top: env(safe-area-inset-top);
    padding-bottom: env(safe-area-inset-bottom);
  }

  .sidebar-account {
    min-height: 72px;
  }

  .install-help-panel {
    margin-bottom: env(safe-area-inset-bottom);
  }
}

@media (display-mode: standalone) {
  .topbar {
    padding-top: max(10px, env(safe-area-inset-top));
  }
}

/* Supabase email/password authentication */
.auth-form {
  display: grid;
  gap: 12px;
  text-align: left;
}

.auth-field {
  display: grid;
  gap: 6px;
}

.auth-field span {
  color: #566158;
  font-size: 11px;
  font-weight: 700;
}

.auth-field input {
  width: 100%;
  min-height: 48px;
  padding: 0 14px;
  border: 1px solid #d9e1d9;
  border-radius: 13px;
  outline: none;
  background: #fbfcfb;
  color: #1f2a22;
  font: inherit;
  font-size: 14px;
  transition: border-color .16s ease, box-shadow .16s ease, background .16s ease;
}

.auth-field input:focus {
  border-color: #6f9878;
  background: #fff;
  box-shadow: 0 0 0 4px rgba(60, 112, 72, .12);
}

.auth-divider {
  position: relative;
  margin: 17px 0;
  color: #97a099;
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: .12em;
}

.auth-divider::before {
  content: '';
  position: absolute;
  inset: 50% 0 auto;
  height: 1px;
  background: #e5eae5;
}

.auth-divider span {
  position: relative;
  z-index: 1;
  padding: 0 10px;
  background: rgba(255, 255, 255, .98);
}
