:root {
  --bg-page: #f5f6f8;
  --text-main: #222222;
  --surface: #ffffff;
  --surface-2: #f9fafb;
  --surface-3: #f4f7ff;
  --border: #e5e7eb;
  --border-soft: #f3f4f6;
  --shadow-soft: 0 2px 10px rgba(0, 0, 0, 0.08);
  --shadow-pop: 0 8px 20px rgba(0, 0, 0, 0.12);
  --shadow-brand: 0 8px 18px rgba(17, 99, 238, 0.28);
  --text-heading: #111827;
  --text-subtle: #374151;
  --text-muted: #4b5563;
  --text-faint: #9ca3af;
  --text-inverse: #ffffff;
  --brand: #0073ea;
  --brand-strong: #005bb5;
  --brand-fill: #1767f1;
  --brand-fill-hover: #1457cb;
  --focus: #2563eb;
  --danger: #b91c1c;
  --overlay: rgba(17, 24, 39, 0.45);
}

:root[data-monday-theme="dark"] {
  --bg-page: #181b3a;
  --text-main: #d5dbf2;
  --surface: #20264f;
  --surface-2: #2b315f;
  --surface-3: #242b56;
  --border: #46507f;
  --border-soft: #3b4371;
  --shadow-soft: 0 2px 10px rgba(9, 12, 34, 0.45);
  --shadow-pop: 0 8px 20px rgba(9, 12, 34, 0.5);
  --shadow-brand: 0 8px 18px rgba(64, 144, 255, 0.32);
  --text-heading: #f4f6ff;
  --text-subtle: #c7cee9;
  --text-muted: #9da8cc;
  --text-faint: #7f89af;
  --text-inverse: #ffffff;
  --brand: #579bfc;
  --brand-strong: #80b5ff;
  --brand-fill: #579bfc;
  --brand-fill-hover: #80b5ff;
  --focus: #579bfc;
  --danger: #ff8a8a;
  --overlay: rgba(7, 10, 29, 0.65);
}

:root[data-monday-theme="night"] {
  --bg-page: #111111;
  --text-main: #f5f5f5;
  --surface: #1f1f1f;
  --surface-2: #2a2a2a;
  --surface-3: #252525;
  --border: #3a3a3a;
  --border-soft: #2f2f2f;
  --shadow-soft: 0 2px 10px rgba(0, 0, 0, 0.5);
  --shadow-pop: 0 8px 20px rgba(0, 0, 0, 0.45);
  --shadow-brand: 0 8px 18px rgba(102, 168, 255, 0.28);
  --text-heading: #f9fafb;
  --text-subtle: #d1d5db;
  --text-muted: #9ca3af;
  --text-faint: #6b7280;
  --text-inverse: #ffffff;
  --brand: #66a8ff;
  --brand-strong: #8fc0ff;
  --brand-fill: #2f7af9;
  --brand-fill-hover: #4b8ffd;
  --focus: #66a8ff;
  --danger: #f87171;
  --overlay: rgba(0, 0, 0, 0.6);
}

:root[data-monday-theme="boards-light"] {
  --bg-page: #f7f5f1;
  --text-main: #1a2448;
  --surface: #ffffff;
  --surface-2: #f6f3ec;
  --surface-3: #f3efe6;
  --border: #e6e1d6;
  --border-soft: #efeae0;
  --shadow-soft: 0 2px 10px rgba(26, 36, 72, 0.06);
  --shadow-pop: 0 8px 20px rgba(26, 36, 72, 0.1);
  --shadow-brand: 0 8px 18px rgba(213, 179, 109, 0.35);
  --text-heading: #1a2448;
  --text-subtle: #3d4a6e;
  --text-muted: #747474;
  --text-faint: #9a9284;
  --text-inverse: #1a2448;
  --brand: #1a2448;
  --brand-strong: #121a36;
  --brand-fill: #d5b36d;
  --brand-fill-hover: #c4a15c;
  --focus: #d5b36d;
  --danger: #9b2c2c;
  --overlay: rgba(26, 36, 72, 0.4);
}

:root[data-monday-theme="boards-dark"] {
  --bg-page: #0c1020;
  --text-main: #f3efe6;
  --surface: #171e36;
  --surface-2: #1c2544;
  --surface-3: #12182c;
  --border: #2c3658;
  --border-soft: #243052;
  --shadow-soft: 0 2px 10px rgba(0, 0, 0, 0.35);
  --shadow-pop: 0 8px 20px rgba(0, 0, 0, 0.45);
  --shadow-brand: 0 8px 18px rgba(213, 179, 109, 0.25);
  --text-heading: #f3efe6;
  --text-subtle: #d9d0c0;
  --text-muted: #b7ad9a;
  --text-faint: #8d846f;
  --text-inverse: #1a2448;
  --brand: #d5b36d;
  --brand-strong: #e4c78a;
  --brand-fill: #d5b36d;
  --brand-fill-hover: #e4c78a;
  --focus: #d5b36d;
  --danger: #f0a0a0;
  --overlay: rgba(0, 0, 0, 0.6);
}

body {
  margin: 0;
  font-family: Arial, sans-serif;
  background: var(--bg-page);
  color: var(--text-main);
}

.container {
  max-width: 960px;
  margin: 16px auto;
  background: var(--surface);
  border-radius: 10px;
  padding: 16px;
  box-shadow: var(--shadow-soft);
}

.container > .app-header {
  display: flex !important;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin: 0 0 10px 0;
}

.app-header h1 {
  margin: 0;
  font-size: 20px;
  color: var(--text-heading);
  font-weight: 700;
  letter-spacing: 0.2px;
}

.app-header button.logout-btn {
  margin-left: auto;
  border: 1px solid var(--border);
  background: linear-gradient(180deg, var(--surface) 0%, var(--surface-3) 100%);
  color: var(--brand-strong);
  border-radius: 999px;
  padding: 8px 14px;
  font-family: Arial, sans-serif;
  font-size: 13px;
  font-weight: 700;
  line-height: 1;
  min-height: 32px;
  box-sizing: border-box;
  cursor: pointer;
  -webkit-appearance: none;
  appearance: none;
  box-shadow: 0 1px 2px rgba(16, 24, 40, 0.06);
  transition: background-color 120ms ease, box-shadow 120ms ease, transform 120ms ease;
}

.header-actions {
  display: flex;
  align-items: center;
  gap: 10px;
}

.upload-actions {
  position: relative;
}

button.upload-btn {
  border: 1px solid var(--brand-fill);
  background: var(--brand-fill);
  color: var(--text-inverse);
  border-radius: 999px;
  padding: 8px 14px;
  font-family: Arial, sans-serif;
  font-size: 13px;
  font-weight: 700;
  line-height: 1;
  min-height: 32px;
  cursor: pointer;
}

button.upload-btn:hover {
  background: var(--brand-fill-hover);
}

.upload-menu {
  position: absolute;
  right: 0;
  top: calc(100% + 6px);
  min-width: 150px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface);
  box-shadow: var(--shadow-pop);
  padding: 4px;
  z-index: 40;
}

.upload-menu-item {
  display: block;
  width: 100%;
  border: 0;
  background: transparent;
  text-align: left;
  padding: 8px 10px;
  border-radius: 6px;
  cursor: pointer;
}

.upload-menu-item:hover {
  background: var(--surface-2);
}

.app-header button.logout-btn:hover {
  background: linear-gradient(180deg, var(--surface-2) 0%, var(--surface-3) 100%);
  box-shadow: 0 2px 8px rgba(0, 115, 234, 0.2);
  transform: translateY(-1px);
}

.app-header button.logout-btn:active {
  transform: translateY(0);
}

.app-header button.logout-btn:focus-visible {
  outline: 2px solid var(--focus);
  outline-offset: 2px;
}

#status {
  margin: 0 0 12px 0;
  color: var(--text-subtle);
}

.auth-empty {
  border: 1px solid var(--border);
  border-radius: 14px;
  background: var(--surface);
  padding: 28px 28px 22px;
  margin: 0;
  box-shadow: var(--shadow-pop);
}

.auth-empty h2 {
  margin: 0 0 10px 0;
  font-size: 30px;
  line-height: 1.18;
  letter-spacing: -0.02em;
  color: var(--text-heading);
  font-weight: 800;
}

.auth-empty p {
  margin: 0 0 20px 0;
  color: var(--text-subtle);
  font-size: 15px;
  line-height: 1.45;
}

.auth-empty .sign-in-btn {
  display: block;
  margin: 0 auto;
}

.auth-centered {
  max-width: 440px;
  width: 100%;
  margin: 0 auto;
}

.container.auth-only {
  max-width: 560px;
  min-height: 420px;
  padding: 0;
  margin: 24px auto;
  background: transparent;
  box-shadow: none;
  border-radius: 0;
  display: flex;
  align-items: center;
  justify-content: center;
}

.container.auth-only .app-header,
.container.auth-only .breadcrumb,
.container.auth-only #status,
.container.auth-only .items-table-wrap {
  display: none !important;
}

.container.auth-only .auth-empty {
  width: 100%;
  margin: 0;
}

/* Item has no SharePoint URL in columns — same centered layout as auth-only but different content. */
.container.missing-sharepoint {
  max-width: 560px;
  min-height: 420px;
  padding: 0;
  margin: 24px auto;
  background: transparent;
  box-shadow: none;
  border-radius: 0;
  display: flex;
  align-items: center;
  justify-content: center;
}

.container.missing-sharepoint .app-header,
.container.missing-sharepoint .breadcrumb,
.container.missing-sharepoint #status,
.container.missing-sharepoint .items-table-wrap,
.container.missing-sharepoint #auth-empty {
  display: none !important;
}

.container.missing-sharepoint #no-sharepoint-link {
  width: 100%;
  margin: 0;
}

.no-sharepoint-link {
  border: 1px solid var(--border);
  border-radius: 12px;
  background: var(--surface);
  padding: 22px 22px 24px;
  box-shadow: var(--shadow-pop);
}

.no-sharepoint-link h2 {
  margin: 0 0 10px 0;
  font-size: 18px;
  color: var(--text-heading);
}

.no-sharepoint-link p {
  margin: 0;
  font-size: 14px;
  line-height: 1.5;
  color: var(--text-subtle);
}

button.sign-in-btn {
  border: 1px solid var(--brand-fill);
  background: linear-gradient(180deg, var(--brand) 0%, var(--brand-fill) 100%);
  color: var(--text-inverse);
  border-radius: 10px;
  padding: 11px 18px;
  font: inherit;
  font-size: 15px;
  font-weight: 700;
  letter-spacing: 0.01em;
  cursor: pointer;
  box-shadow: var(--shadow-brand);
  transition: transform 120ms ease, box-shadow 120ms ease, background 120ms ease;
}

button.sign-in-btn:hover {
  background: linear-gradient(180deg, var(--brand-strong) 0%, var(--brand-fill-hover) 100%);
  transform: translateY(-1px);
  box-shadow: var(--shadow-brand);
}

button.sign-in-btn:active {
  transform: translateY(0);
  box-shadow: var(--shadow-brand);
}

button.sign-in-btn:focus-visible {
  outline: 2px solid var(--focus);
  outline-offset: 2px;
}

.breadcrumb {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 4px;
  margin: 0 0 12px 0;
  font-size: 14px;
  line-height: 1.4;
}

.breadcrumb-sep {
  color: var(--text-faint);
  user-select: none;
}

button.breadcrumb-link {
  background: none;
  border: none;
  padding: 0;
  margin: 0;
  font: inherit;
  color: var(--brand);
  cursor: pointer;
  text-decoration: underline;
  text-underline-offset: 2px;
}

button.breadcrumb-link:hover {
  color: var(--brand-strong);
}

.breadcrumb-current {
  color: var(--text-subtle);
  font-weight: 600;
}

.items-table-wrap {
  overflow-x: auto;
  border: 1px solid var(--border);
  border-radius: 8px;
}

.items-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 14px;
}

.items-table thead th {
  text-align: left;
  padding: 10px 12px;
  background: var(--surface-2);
  color: var(--text-subtle);
  font-weight: 600;
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
  vertical-align: middle;
}

.items-table .th-sortable {
  padding: 0;
}

/* Plain header look: strip default button chrome (incl. monday / embedded browsers) */
button.th-sort-head {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  width: 100%;
  box-sizing: border-box;
  margin: 0;
  padding: 10px 12px;
  border: 0;
  background: transparent;
  font: inherit;
  font-size: inherit;
  font-weight: 600;
  color: inherit;
  line-height: inherit;
  cursor: pointer;
  text-align: left;
  -webkit-appearance: none;
  appearance: none;
  box-shadow: none;
  border-radius: 0;
  outline: none;
}

button.th-sort-head::-moz-focus-inner {
  border: 0;
  padding: 0;
}

button.th-sort-head:hover {
  background: rgba(0, 0, 0, 0.03);
}

button.th-sort-head:focus-visible {
  box-shadow: inset 0 0 0 2px var(--brand);
}

.th-sort-text {
  flex: 1;
  min-width: 0;
}

.sort-arrow {
  flex-shrink: 0;
  font-size: 10px;
  line-height: 1;
  opacity: 0.5;
  color: var(--text-subtle);
}

.items-table tbody td {
  padding: 10px 12px;
  border-bottom: 1px solid var(--border-soft);
  vertical-align: middle;
}

.items-table tbody tr:last-child td {
  border-bottom: none;
}

.items-table .col-action {
  width: 1%;
  white-space: nowrap;
  text-align: right;
}

.items-table .item-name {
  word-break: break-word;
  max-width: 280px;
}

.items-table .item-date {
  color: var(--text-muted);
  white-space: nowrap;
}

.items-table tbody tr.item-folder {
  cursor: pointer;
}

.items-table tbody tr.item-folder:hover {
  background: color-mix(in srgb, var(--brand) 10%, transparent);
}

.items-table tbody tr.item-folder.drop-target {
  background: color-mix(in srgb, var(--brand) 18%, transparent);
  box-shadow: inset 0 0 0 2px var(--brand);
}

.items-table tbody tr.item-folder.is-dragging {
  opacity: 0.5;
}

.items-table-wrap.drag-over {
  box-shadow: inset 0 0 0 2px var(--brand);
  border-color: var(--brand);
}

.items-table tbody tr.item-folder:focus-visible {
  outline: 2px solid var(--brand);
  outline-offset: -2px;
}

.items-table tbody tr.item-file {
  cursor: pointer;
}

.items-table tbody tr.item-file:hover {
  background: var(--surface-2);
}

.items-table tbody tr.item-file:focus-visible {
  outline: 2px solid var(--brand);
  outline-offset: -2px;
}

.items-table .item-folder-hint,
.items-table .item-file-hint {
  color: var(--brand);
  font-size: 14px;
}

button.item-open-btn {
  background: none;
  border: none;
  padding: 0;
  margin: 0;
  font: inherit;
  color: var(--brand);
  cursor: pointer;
  text-decoration: underline;
  text-underline-offset: 2px;
}

button.item-open-btn:hover {
  color: var(--brand-strong);
}

.row-actions {
  position: relative;
  display: inline-block;
}

button.row-actions-trigger {
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text-subtle);
  border-radius: 6px;
  width: 30px;
  height: 28px;
  cursor: pointer;
  line-height: 1;
  padding: 0;
}

button.row-actions-trigger:hover {
  background: var(--surface-2);
}

/* Fixed + JS top/left: escapes .items-table-wrap overflow (horizontal scroll forces vertical clip). */
.row-actions-menu {
  position: fixed;
  z-index: 10000;
  min-width: 120px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface);
  box-shadow: var(--shadow-pop);
  display: none;
  padding: 4px;
  margin: 0;
  opacity: 1;
  pointer-events: auto;
}

.row-actions.open .row-actions-menu {
  display: block;
}

.row-actions.open .row-actions-menu:not(.is-placed) {
  opacity: 0;
  pointer-events: none;
}

button.row-actions-menu-item {
  display: block;
  width: 100%;
  border: 0;
  background: transparent;
  text-align: left;
  padding: 8px 10px;
  border-radius: 6px;
  cursor: pointer;
  color: var(--text-subtle);
}

button.row-actions-menu-item:hover {
  background: var(--surface-2);
}

button.row-actions-menu-item.danger {
  color: var(--danger);
}

.upload-progress-overlay {
  position: fixed;
  top: 14px;
  right: 14px;
  width: min(320px, calc(100vw - 28px));
  z-index: 9999;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.upload-progress-item {
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--surface);
  box-shadow: var(--shadow-pop);
  padding: 8px 10px;
}

.upload-progress-name {
  font-size: 12px;
  color: var(--text-heading);
  margin-bottom: 6px;
  word-break: break-all;
}

.upload-progress-track {
  width: 100%;
  height: 8px;
  border-radius: 999px;
  background: var(--border);
  overflow: hidden;
}

.upload-progress-fill {
  height: 100%;
  width: 0%;
  background: var(--focus);
  transition: width 120ms linear;
}

.upload-progress-meta {
  margin-top: 6px;
  font-size: 12px;
  color: var(--text-muted);
}

.app-modal {
  position: fixed;
  inset: 0;
  background: var(--overlay);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 10000;
}

.app-modal[hidden] {
  display: none !important;
}

.app-modal-card {
  width: min(440px, calc(100vw - 24px));
  background: var(--surface);
  border-radius: 12px;
  border: 1px solid var(--border);
  box-shadow: 0 18px 36px rgba(0, 0, 0, 0.3);
  padding: 14px;
}

.app-modal-card h3 {
  margin: 0 0 6px 0;
  font-size: 18px;
}

.app-modal-card p {
  margin: 0 0 10px 0;
  color: var(--text-subtle);
}

#app-modal-input {
  width: 100%;
  box-sizing: border-box;
  margin-bottom: 10px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text-main);
  border-radius: 8px;
  padding: 8px 10px;
}

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

.app-modal-btn {
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text-subtle);
  border-radius: 8px;
  padding: 8px 12px;
  cursor: pointer;
}

.app-modal-btn.primary {
  background: var(--brand-fill);
  border-color: var(--brand-fill);
  color: var(--text-inverse);
}

.muted-placeholder {
  color: var(--text-muted);
}
