:root {
  --primary: #6d5efc;
  --primary-hover: #5b4de0;
  --bg: #f4f4f6;
  --surface: #fff;
  --text: #1c1c1f;
  --muted: #5c5c66;
  --border: #e4e4e7;
  --danger: #b42318;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  min-height: 100%;
  font-family: "DM Sans", system-ui, sans-serif;
  background: var(--bg);
  color: var(--text);
}

button, input { font: inherit; }

.hidden { display: none !important; }

.login-view {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px 16px;
}

.login-card {
  width: min(440px, 100%);
  padding: 28px 24px 24px;
  border-radius: 16px;
  border: 1px solid var(--border);
  background: var(--surface);
  box-shadow: 0 8px 30px rgba(28, 28, 31, 0.08);
}

.login-brand { margin-bottom: 20px; }

.login-title {
  margin: 0;
  font-size: 1.2rem;
  font-weight: 600;
}

.login-subtitle {
  margin: 2px 0 0;
  font-size: 0.88rem;
  color: var(--muted);
}

.field { display: block; margin-bottom: 14px; }

.field-label {
  display: block;
  margin-bottom: 6px;
  font-size: 0.82rem;
  font-weight: 600;
}

input {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: #fff;
}

.login-password { position: relative; }

.login-password input { padding-right: 96px; }

.login-password-toggle {
  position: absolute;
  top: 50%;
  right: 8px;
  transform: translateY(-50%);
  border: 0;
  background: transparent;
  color: var(--primary);
  cursor: pointer;
}

.form-actions { margin-top: 8px; }

.primary-btn, .secondary-btn, .danger-btn {
  border: 0;
  border-radius: 8px;
  padding: 10px 14px;
  cursor: pointer;
}

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

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

.secondary-btn {
  background: #fff;
  color: var(--text);
  border: 1px solid var(--border);
}

.danger-btn {
  background: var(--danger);
  color: #fff;
  border: 1px solid var(--danger);
}

.danger-btn:hover { background: #9a1e14; border-color: #9a1e14; }

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

.app-shell {
  display: flex;
  align-items: flex-start;
  min-height: 100vh;
}

.side-nav {
  position: sticky;
  top: 0;
  width: 220px;
  flex: 0 0 220px;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding: 20px 12px;
  background: var(--surface);
  border-right: 1px solid var(--border);
}

.nav-link {
  display: block;
  padding: 10px 12px;
  border-radius: 8px;
  color: var(--text);
  font-size: 0.95rem;
  font-weight: 500;
  text-decoration: none;
}

.nav-link:hover { background: rgba(109, 94, 252, 0.08); }

.nav-link:focus-visible {
  outline: 2px solid var(--primary);
  outline-offset: 2px;
}

.nav-link.is-current {
  background: rgba(109, 94, 252, 0.14);
  color: var(--primary);
  font-weight: 600;
}

.nav-sub {
  margin: 0 0 4px 14px;
  padding-left: 8px;
  border-left: 2px solid rgba(109, 94, 252, 0.35);
}

.nav-sub-link { padding-left: 32px; }

.nav-logout {
  margin-top: auto;
  align-self: flex-start;
}

.app-main {
  flex: 1;
  min-width: 0;
}

.app-view {
  max-width: 1100px;
  margin: 0;
  padding: 24px 16px 48px;
}

@media (max-width: 640px) {
  .app-shell { flex-direction: column; }

  .side-nav {
    position: static;
    width: 100%;
    flex: none;
    min-height: 0;
    flex-direction: row;
    flex-wrap: wrap;
    align-items: center;
    border-right: 0;
    border-bottom: 1px solid var(--border);
    padding: 10px 12px;
  }

  .nav-sub {
    flex: 1 0 100%;
    margin: 0;
    border-left: 0;
    padding-left: 0;
  }

  .nav-sub .nav-link { padding-left: 22px; }

  .nav-sub .nav-sub-link { padding-left: 40px; }

  .nav-logout { margin-top: 0; }
}

.topbar {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  align-items: center;
  margin-bottom: 20px;
}

.detail-topbar { justify-content: flex-start; }

.topbar h1 { margin: 0; }

.users-org-link {
  color: inherit;
  text-decoration: underline;
  text-underline-offset: 0.15em;
}

.users-org-link:focus-visible {
  outline: 2px solid var(--primary);
  outline-offset: 2px;
}

.topbar-actions, .inline-form {
  display: flex;
  gap: 8px;
  align-items: center;
}

.panel, .link-panel {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 16px;
  margin-bottom: 16px;
}

.data-table {
  width: 100%;
  border-collapse: collapse;
  background: var(--surface);
  margin-bottom: 20px;
}

.data-table th, .data-table td {
  text-align: left;
  padding: 10px 12px;
  border-bottom: 1px solid var(--border);
  vertical-align: top;
}

.org-row { cursor: pointer; }

.tiles {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: 12px;
  margin-bottom: 20px;
}

.tile {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 14px;
}

.tile span {
  display: block;
  color: var(--muted);
  font-size: 0.82rem;
}

.tile strong { font-size: 1.4rem; }

.link-list { padding-left: 18px; }

.row-actions {
  position: relative;
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  align-items: center;
}

.row-menu-wrap { position: relative; }

.row-menu {
  position: absolute;
  top: calc(100% + 4px);
  right: 0;
  z-index: 5;
  min-width: 12rem;
  padding: 4px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  box-shadow: 0 8px 24px rgba(28, 28, 31, 0.12);
}

tr.is-open .row-actions { z-index: 3; }

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

.row-menu-item:hover,
.row-menu-item:focus-visible { background: rgba(109, 94, 252, 0.08); }

.empty { color: var(--muted); }

.filename-field { max-width: 480px; }

a.secondary-btn {
  display: inline-block;
  text-decoration: none;
  line-height: 1.2;
}

.invite-email {
  margin: 0 0 14px;
  font-weight: 600;
}

body.platform-is-updating #app-shell {
  pointer-events: none;
}

.platform-update-overlay {
  position: fixed;
  inset: 0;
  z-index: 40;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(28, 28, 31, 0.45);
  pointer-events: auto;
  touch-action: none;
  user-select: none;
}

.platform-update-overlay-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 14px;
  padding: 28px 36px;
  border: 1px solid var(--border);
  border-radius: 16px;
  background: var(--surface);
  text-align: center;
}

.platform-update-spinner {
  width: 32px;
  height: 32px;
  border: 2px solid var(--border);
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: platform-update-spin 0.75s linear infinite;
}

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

.platform-update-overlay-text {
  margin: 0;
  font-size: 1.05rem;
  font-weight: 600;
}

.platform-update-banner {
  position: fixed;
  z-index: 35;
  left: 50%;
  bottom: 20px;
  transform: translateX(-50%);
  display: flex;
  align-items: center;
  gap: 12px;
  max-width: calc(100% - 32px);
  padding: 12px 14px;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: var(--surface);
  box-shadow: 0 8px 24px rgba(28, 28, 31, 0.12);
}

.platform-update-reload {
  border: 0;
  border-radius: 8px;
  padding: 8px 12px;
  background: var(--primary);
  color: #fff;
  cursor: pointer;
}
