/* ===== Reset / Base ===== */
* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html, body {
  height: 100%;
}

body {
  font-family: "Segoe UI", Tahoma, Geneva, Verdana, sans-serif;
  font-size: 14px;
  color: #333;
  background: #f8f8f8;
  display: flex;
  flex-direction: column;
}

.hidden {
  display: none !important;
}

/* ===== Header ===== */
.ms-welcome__header {
  background: #1ab4d7; /* Xero blue */
  padding: 16px;
  color: #fff;
}

.header-content {
  display: flex;
  align-items: center;
  gap: 12px;
}

.header-icon {
  width: 40px;
  height: 40px;
  object-fit: contain;
}

.ms-welcome__header h1 {
  font-size: 20px;
  color: #fff;
}

.header-title {
  letter-spacing: 1px;
  text-transform: uppercase;
}

.header-title strong {
  font-weight: 700;
}

.header-title-light {
  font-weight: 300;
}

.header-title-sub {
  font-weight: 400;
  font-size: 12px;
  letter-spacing: 0.5px;
  margin-left: 2px;
}

/* ===== Main ===== */
.ms-welcome__header {
  flex-shrink: 0;
}

.ms-welcome__main {
  padding: 16px;
  flex: 1;
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

.section {
  background: #fff;
  border: 1px solid #e0e0e0;
  border-radius: 4px;
  padding: 16px;
  margin-bottom: 12px;
}

#org-section {
  flex: 1;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  margin-bottom: 0;
}

.org-header {
  flex-shrink: 0;
}

#page-list {
  flex: 1;
  overflow-y: auto;
}

#page-form {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.section h2 {
  font-size: 16px;
  font-weight: 600;
  margin-bottom: 8px;
  color: #1ab4d7;
}

.description {
  color: #666;
  margin-bottom: 16px;
  line-height: 1.5;
}

/* ===== Organisation header ===== */
.org-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  padding-bottom: 10px;
}

.org-identity {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.org-name {
  font-size: 13px;
  font-weight: 600;
  color: #222;
}

.org-email {
  font-size: 11px;
  color: #888;
}

.org-disconnect-link {
  background: none;
  border: none;
  cursor: pointer;
  font-family: inherit;
  font-size: 11px;
  color: #aaa;
  padding: 0;
  flex-shrink: 0;
  align-self: flex-start;
  transition: color 0.12s ease;
}

.org-disconnect-link:hover {
  color: #c0392b;
}

/* ===== Org mode tab strip ===== */
.org-tabs {
  display: flex;
  border-bottom: 2px solid #e8e8e8;
  margin: 0 -16px 12px;
  padding: 0 16px;
}

.org-tab-btn {
  background: none;
  border: none;
  border-bottom: 2px solid transparent;
  margin-bottom: -2px;
  padding: 7px 14px 7px 0;
  font-family: inherit;
  font-size: 13px;
  font-weight: 500;
  color: #999;
  cursor: pointer;
  transition: color 0.12s ease, border-color 0.12s ease;
}

.org-tab-btn.active {
  color: #1ab4d7;
  border-bottom-color: #1ab4d7;
}

.org-tab-btn:not(.active):hover {
  color: #555;
}

.org-badge {
  font-size: 11px;
  color: inherit;
  margin-left: 3px;
}

.endpoint-item-query {
  background: #f0fafc;
  border: 1px solid #d4eef5;
  border-radius: 4px;
  margin-bottom: 4px;
}

/* ===== Buttons ===== */
.ms-Button {
  border: none;
  border-radius: 2px;
  cursor: pointer;
  font-family: inherit;
  font-size: 14px;
  padding: 8px 16px;
  transition: background 0.15s ease;
}

.ms-Button--primary {
  background: #1ab4d7;
  color: #fff;
}

.ms-Button--primary:hover {
  background: #139bb8;
}

.ms-Button--primary:disabled {
  background: #a8dcea;
  cursor: not-allowed;
}

.ms-Button--default {
  background: #fff;
  color: #333;
  border: 1px solid #ccc;
}

.ms-Button--default:hover {
  background: #f3f3f3;
}

.btn-full {
  width: 100%;
  margin-top: 12px;
}

.btn-small {
  padding: 4px 10px;
  font-size: 12px;
}

/* ===== Endpoint search ===== */
.endpoint-search {
  margin-bottom: 8px;
}

/* ===== Pinned section ===== */
.pinned-section {
  margin-bottom: 4px;
}

.pinned-section .endpoint-item {
  background: #fafafa;
}

/* ===== Endpoint list ===== */
.endpoint-group-header {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: #888;
  padding: 12px 0 4px;
  margin: 0;
}

.endpoint-group-header:first-child {
  padding-top: 4px;
}

.endpoint-group-toggle {
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 4px;
  user-select: none;
}

.endpoint-group-toggle:hover {
  color: #1ab4d7;
}

.endpoint-group-icon {
  font-size: 8px;
  transition: transform 0.15s ease;
  display: inline-block;
}

.endpoint-group.collapsed .endpoint-group-icon {
  transform: rotate(-90deg);
}

.endpoint-group.collapsed .endpoint-group-items {
  display: none;
}

.endpoint-item {
  display: flex;
  align-items: center;
  width: 100%;
  background: none;
  border: none;
  border-bottom: 1px solid #f0f0f0;
  padding: 10px 4px;
  cursor: pointer;
  font-family: inherit;
  font-size: 14px;
  color: #333;
  text-align: left;
  transition: background 0.12s ease;
}

.endpoint-item:hover {
  background: #e8f8fc;
}

.endpoint-item:last-child {
  border-bottom: none;
}

.endpoint-item-label {
  flex: 1;
}

.endpoint-item-badge {
  font-size: 12px;
  color: #1ab4d7;
  margin-right: 4px;
}

.endpoint-item-chevron {
  font-size: 18px;
  color: #bbb;
  flex-shrink: 0;
  line-height: 1;
}

.endpoint-pin {
  font-size: 14px;
  color: #ccc;
  cursor: pointer;
  margin-right: 6px;
  flex-shrink: 0;
  transition: color 0.12s ease;
  line-height: 1;
}

.endpoint-pin:hover {
  color: #f5a623;
}

.endpoint-pin.pinned {
  color: #f5a623;
}

.endpoint-item.search-hidden {
  display: none;
}

.endpoint-group.search-hidden {
  display: none;
}

.endpoint-separator {
  height: 1px;
  background: #ddd;
  margin: 8px 0;
}

/* ===== Form header ===== */
.form-header {
  display: flex;
  align-items: center;
  gap: 8px;
  padding-bottom: 10px;
  border-bottom: 1px solid #eee;
  flex-shrink: 0;
}

.form-scroll-area {
  flex: 1;
  overflow-y: auto;
  padding-top: 10px;
}

.form-footer {
  flex-shrink: 0;
  border-top: 1px solid #eee;
  padding: 8px 0 0;
  background: #fff;
}

.footer-save-row {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-bottom: 8px;
}

.footer-save-row input[type="checkbox"] {
  margin: 0;
  cursor: pointer;
  accent-color: #1ab4d7;
}

.footer-save-label {
  font-size: 12px;
  color: #555;
  cursor: pointer;
  user-select: none;
}

.btn-back {
  background: none;
  border: 1px solid #ccc;
  border-radius: 2px;
  cursor: pointer;
  width: 28px;
  height: 28px;
  font-size: 20px;
  color: #555;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.15s ease, color 0.15s ease;
  flex-shrink: 0;
  line-height: 1;
  padding: 0 0 2px;
}

.btn-back:hover {
  background: #f3f3f3;
  color: #1ab4d7;
}

.form-title {
  font-size: 16px;
  font-weight: 600;
  color: #1ab4d7;
}

.tab-content {
  padding-top: 8px;
}

/* ===== Filters ===== */
.filter-group {
  margin-bottom: 10px;
}

.custom-date-range {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-top: 6px;
}

.custom-date-range .ms-Input {
  flex: 1;
  min-width: 0;
}

.date-sep {
  font-size: 12px;
  color: #888;
  flex-shrink: 0;
}

.sort-controls {
  display: flex;
  gap: 6px;
}

.sort-controls .sort-field {
  flex: 2;
}

.sort-controls .sort-dir {
  flex: 1;
}

.ms-Label {
  display: block;
  font-size: 12px;
  font-weight: 600;
  color: #555;
  margin-bottom: 4px;
}

.ms-Dropdown,
.ms-Input {
  width: 100%;
  padding: 6px 8px;
  border: 1px solid #ccc;
  border-radius: 2px;
  font-family: inherit;
  font-size: 13px;
  color: #333;
  background: #fff;
  outline: none;
  transition: border-color 0.15s ease;
}

.ms-Dropdown:focus,
.ms-Input:focus {
  border-color: #1ab4d7;
}

/* ===== Status bar ===== */
.status-bar {
  display: flex;
  align-items: center;
  gap: 8px;
  background: #e8f7fb;
  border: 1px solid #1ab4d7;
  border-radius: 4px;
  padding: 10px 12px;
  margin-bottom: 8px;
  color: #0d7a94;
}

/* ===== Error bar ===== */
.error-bar {
  background: #fde8e8;
  border: 1px solid #d93025;
  border-radius: 4px;
  padding: 10px 12px;
  margin-bottom: 8px;
  color: #d93025;
}

/* ===== Custom Query editor ===== */
.query-editor {
  width: 100%;
  min-height: 160px;
  padding: 8px;
  border: 1px solid #ccc;
  border-radius: 2px;
  font-family: "Cascadia Code", "Fira Code", "Consolas", "Courier New", monospace;
  font-size: 12px;
  line-height: 1.5;
  color: #333;
  background: #fafafa;
  resize: vertical;
  outline: none;
  tab-size: 2;
  white-space: pre;
  overflow-x: auto;
}

.query-editor:focus {
  border-color: #1ab4d7;
  background: #fff;
}

.query-editor::placeholder {
  color: #aaa;
  font-style: italic;
}

/* ===== Schema browser ===== */
.schema-browser {
  margin-top: 16px;
  border-top: 1px solid #eee;
  padding-top: 12px;
}

.schema-toggle {
  background: none;
  border: none;
  cursor: pointer;
  font-family: inherit;
  font-size: 13px;
  font-weight: 600;
  color: #1ab4d7;
  padding: 4px 0;
  display: flex;
  align-items: center;
  gap: 6px;
}

.schema-toggle:hover {
  color: #139bb8;
}

.schema-toggle-icon {
  font-size: 10px;
  transition: transform 0.15s ease;
  display: inline-block;
}

.schema-toggle-icon.expanded {
  transform: rotate(90deg);
}

.schema-content {
  margin-top: 8px;
}

.schema-search {
  width: 100%;
  box-sizing: border-box;
  margin-bottom: 6px;
  font-size: 12px;
  padding: 5px 8px;
}

.schema-panes {
  display: flex;
  gap: 1px;
  border: 1px solid #ddd;
  border-radius: 3px;
  height: 280px;
  overflow: hidden;
  background: #ddd;
}

.schema-table-list {
  width: 45%;
  overflow-y: auto;
  background: #fafafa;
}

.schema-column-list {
  width: 55%;
  overflow-y: auto;
  background: #fff;
}

.schema-table-item {
  padding: 5px 8px;
  font-size: 12px;
  font-weight: 600;
  color: #555;
  cursor: pointer;
  border-bottom: 1px solid #eee;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.schema-table-item:hover {
  background: #e8f8fc;
  color: #1ab4d7;
}

.schema-table-item.active {
  background: #1ab4d7;
  color: #fff;
}

.schema-table-item .schema-col-count {
  font-size: 10px;
  font-weight: 400;
  opacity: 0.65;
}

.schema-column-item {
  padding: 3px 10px;
  font-size: 11px;
  font-family: "Cascadia Code", "Fira Code", "Consolas", "Courier New", monospace;
  color: #555;
  cursor: pointer;
  border-bottom: 1px solid #f5f5f5;
}

.schema-column-item:hover {
  background: #e8f8fc;
  color: #1ab4d7;
}

.schema-column-empty {
  padding: 20px 10px;
  text-align: center;
  font-size: 12px;
  color: #999;
}

.schema-hint {
  font-size: 11px;
  color: #888;
  margin-bottom: 4px;
}

.schema-qualify-toggle {
  display: flex;
  align-items: center;
  gap: 4px;
  font-size: 11px;
  color: #666;
  margin: 0 0 4px 0;
  padding-left: 45%;
  cursor: pointer;
}
.schema-qualify-toggle input { margin: 0; }

/* ===== Spinner ===== */
.spinner {
  width: 16px;
  height: 16px;
  border: 2px solid #1ab4d7;
  border-top-color: transparent;
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
  flex-shrink: 0;
}

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

/* ===== Footer import button ===== */
.btn-footer-import {
  width: 100%;
  margin-top: 8px;
}

/* ===== Saved Imports ===== */
.imports-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 6px;
  padding-bottom: 10px;
  margin-bottom: 10px;
  border-bottom: 1px solid #eee;
}

.imports-toolbar-left {
  display: flex;
  gap: 6px;
}

.imports-toolbar-right {
  display: flex;
  align-items: center;
  gap: 4px;
}

.imports-info-icon {
  font-size: 14px;
  color: #aaa;
  cursor: help;
  user-select: none;
  line-height: 1;
  flex-shrink: 0;
}

.imports-info-icon:hover {
  color: #1ab4d7;
}

.imports-save-banner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  background: #fffbe6;
  border: 1px solid #f5c518;
  border-radius: 4px;
  padding: 8px 10px;
  margin-bottom: 10px;
  font-size: 12px;
  color: #555;
}

.btn-banner-dismiss {
  background: none;
  border: 1px solid #ccc;
  border-radius: 3px;
  padding: 2px 8px;
  font-size: 11px;
  cursor: pointer;
  white-space: nowrap;
  color: #666;
  flex-shrink: 0;
}

.btn-banner-dismiss:hover {
  background: #f5f5f5;
  border-color: #aaa;
}

.import-schedule-select {
  font-size: 11px;
  padding: 3px 6px;
  border: 1px solid #ddd;
  border-radius: 2px;
  color: #555;
  background: #fff;
}

.imports-empty {
  text-align: center;
  padding: 32px 16px;
  color: #888;
}

.imports-empty-hint {
  color: #aaa;
  margin-top: 6px;
  line-height: 1.5;
}

.import-item {
  background: #fafafa;
  border: 1px solid #e8e8e8;
  border-radius: 6px;
  padding: 12px;
  margin-bottom: 8px;
  transition: border-color 0.15s;
}

.import-item:hover {
  border-color: #ccc;
}

.import-item-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 8px;
}

.import-item-info {
  flex: 1;
  min-width: 0;
}

.import-item-label {
  font-size: 13px;
  font-weight: 600;
  color: #333;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.import-item-sheet {
  font-size: 11px;
  color: #1ab4d7;
  margin-top: 2px;
}

.import-item-time {
  font-size: 11px;
  color: #999;
  margin-top: 2px;
}

.import-item-actions {
  display: flex;
  gap: 2px;
  flex-shrink: 0;
  margin-top: 1px;
}

.btn-icon {
  background: none;
  border: 1px solid transparent;
  border-radius: 3px;
  cursor: pointer;
  width: 28px;
  height: 28px;
  font-size: 14px;
  color: #888;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.15s, color 0.15s, border-color 0.15s;
}

.btn-icon:hover {
  background: #fff;
  border-color: #ddd;
  color: #1ab4d7;
}

.btn-icon.btn-delete:hover {
  color: #d93025;
  border-color: #f5c6c2;
  background: #fef2f1;
}

.btn-icon.btn-edit:hover {
  color: #1ab4d7;
  border-color: #b3e5f0;
  background: #e8f7fb;
}

.import-item-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-top: 8px;
  padding-top: 8px;
  border-top: 1px solid #eee;
}

.import-schedule-row {
  display: flex;
  align-items: center;
  gap: 6px;
}

.import-schedule-label {
  font-size: 11px;
  color: #888;
  flex-shrink: 0;
}

/* ===== Import detail panel ===== */
.import-detail-toggle {
  background: none;
  border: none;
  cursor: pointer;
  font-family: inherit;
  font-size: 11px;
  font-weight: 600;
  color: #1ab4d7;
  padding: 0;
  display: flex;
  align-items: center;
  gap: 4px;
}

.import-detail-toggle:hover {
  color: #139bb8;
}

.import-detail-toggle-icon {
  font-size: 9px;
  transition: transform 0.15s ease;
  display: inline-block;
}

.import-detail-toggle-icon.expanded {
  transform: rotate(90deg);
}

.import-detail {
  background: #f8f8f8;
  border: 1px solid #eee;
  border-radius: 2px;
  padding: 8px 10px;
  margin-top: 6px;
}

.import-detail-row {
  font-size: 12px;
  color: #555;
  padding: 2px 0;
}

.import-detail-key {
  font-weight: 600;
  color: #333;
}

.import-detail-sql {
  font-family: "Cascadia Code", "Fira Code", "Consolas", "Courier New", monospace;
  font-size: 11px;
  line-height: 1.4;
  color: #333;
  background: #fff;
  border: 1px solid #ddd;
  border-radius: 2px;
  padding: 6px 8px;
  margin: 0 0 6px;
  white-space: pre-wrap;
  word-break: break-word;
  max-height: 150px;
  overflow-y: auto;
}

/* ===== Confirm modal ===== */
.confirm-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.35);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 100;
}

.confirm-dialog {
  background: #fff;
  border-radius: 4px;
  padding: 20px;
  max-width: 320px;
  width: 90%;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.2);
}

.confirm-dialog p {
  margin-bottom: 16px;
  line-height: 1.5;
  color: #333;
}

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

/* ===== Output Sheet control ===== */
.sheet-destination {
  background: #f0fafc;
  border-left: 3px solid #1ab4d7;
  border-radius: 0 2px 2px 0;
  padding: 8px 10px;
  margin-bottom: 14px;
}

.sheet-new-row {
  margin-top: 6px;
}

.sheet-overwrite-warning {
  display: block;
  margin-top: 5px;
  font-size: 11px;
  font-style: italic;
  color: #b35900;
}

.ms-Input.input-error {
  border-color: #d93025;
  background: #fff8f8;
}

.ms-Input.input-error:focus {
  border-color: #d93025;
}

