:root {
  color-scheme: dark;
  --bg: #080a12;
  --surface: #11131d;
  --surface-soft: #171a26;
  --footer: #05060b;
  --text: #f4f5f8;
  --muted: #b5b8c5;
  --line: #343847;
  --accent: #14a8e5;
  --accent-strong: #37c2f3;
  --danger: #ff6b7a;
  --shadow: 0 18px 48px rgba(0, 0, 0, 0.28);
}

[data-theme="light"] {
  color-scheme: light;
  --bg: #f4f6fb;
  --surface: #ffffff;
  --surface-soft: #f8fafc;
  --footer: #101522;
  --text: #172033;
  --muted: #667085;
  --line: #dbe2ea;
  --accent: #0b8bdc;
  --accent-strong: #0873b7;
  --danger: #c0253a;
  --shadow: 0 18px 48px rgba(23, 32, 51, 0.08);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
  color: var(--text);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  letter-spacing: 0;
}

body {
  display: flex;
  flex-direction: column;
}

button,
input {
  font: inherit;
}

button {
  cursor: pointer;
}

a {
  color: inherit;
}

.shell {
  width: min(1400px, calc(100% - 64px));
  flex: 1 0 auto;
  margin: 0 auto;
  padding: 28px 0 58px;
}

.topbar {
  display: flex;
  min-height: 64px;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 12px;
  color: inherit;
  text-decoration: none;
}

.brand-mark {
  position: relative;
  display: inline-grid;
  width: 40px;
  height: 40px;
  place-items: center;
  border-radius: 8px;
  background: var(--accent);
  box-shadow: 0 10px 26px color-mix(in srgb, var(--accent) 24%, transparent);
}

.brand-mark::after {
  content: "";
  position: absolute;
  right: 8px;
  top: 8px;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--surface);
}

.logo-bars {
  width: 19px;
  height: 15px;
  border-top: 5px solid #101522;
  border-bottom: 5px solid #101522;
}

.logo-bars::after {
  content: "";
  display: block;
  width: 13px;
  height: 5px;
  margin-top: 5px;
  background: #101522;
}

.brand strong,
.brand small,
.session-user,
.service-card h2,
.service-card p {
  display: block;
}

.brand strong {
  font-size: 17px;
  font-weight: 620;
}

.brand small {
  margin-top: 2px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 400;
}

.top-actions,
.session {
  display: flex;
  align-items: center;
  gap: 10px;
}

.top-actions {
  flex-wrap: wrap;
  justify-content: flex-end;
}

.session-user {
  color: var(--muted);
  font-size: 14px;
  font-weight: 500;
}

.ghost-button,
.theme-toggle,
.icon-button,
.primary-action,
.service-action {
  min-height: 40px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  color: var(--text);
  font-weight: 520;
  transition: transform 120ms ease, border-color 160ms ease, background 160ms ease, color 160ms ease, box-shadow 160ms ease;
}

.ghost-button,
.theme-toggle {
  padding: 0 15px;
}

.theme-toggle {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  padding-left: 6px;
}

.theme-track {
  position: relative;
  display: inline-flex;
  width: 64px;
  height: 32px;
  align-items: center;
  justify-content: space-between;
  padding: 0 9px;
  border-radius: 999px;
  background: color-mix(in srgb, var(--surface-soft) 84%, var(--accent));
}

.theme-icon {
  position: relative;
  z-index: 1;
  color: var(--muted);
  font-size: 13px;
  line-height: 1;
}

.theme-thumb {
  position: absolute;
  left: 3px;
  top: 3px;
  width: 26px;
  height: 26px;
  border-radius: 999px;
  background: var(--surface);
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.22);
  transition: transform 160ms ease, background 160ms ease;
}

[data-theme="dark"] .theme-thumb {
  transform: translateX(32px);
}

.theme-text {
  min-width: 38px;
  text-align: left;
}

.ghost-button:hover,
.theme-toggle:hover,
.icon-button:hover,
.service-action:hover {
  border-color: color-mix(in srgb, var(--accent) 55%, var(--line));
  background: var(--surface-soft);
}

.ghost-button:active,
.theme-toggle:active,
.icon-button:active,
.primary-action:active,
.service-action:active,
.service-card:active {
  transform: translateY(1px) scale(0.99);
}

.intro {
  max-width: 940px;
  padding: 76px 0 44px;
}

.workspace-bar {
  display: inline-flex;
  align-items: center;
  justify-content: flex-end;
  gap: 8px;
  margin: 0;
  padding: 0;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
}

.workspace-bar label {
  width: auto;
}

.workspace-bar label span {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
}

.workspace-bar select,
.admin-card select,
.edit-card select {
  width: 100%;
  min-height: 44px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 0 12px;
  background: var(--surface-soft);
  color: var(--text);
}

.workspace-bar select {
  width: 190px;
  min-height: 40px;
  border: 0;
  background: transparent;
}

.workspace-role {
  display: inline-flex;
  min-height: 40px;
  align-items: center;
  border-width: 0 0 0 1px;
  border-style: solid;
  border-color: var(--line);
  border-radius: 0 8px 8px 0;
  padding: 0 13px;
  color: var(--accent);
  font-size: 13px;
  font-weight: 620;
}

.user-switch {
  position: relative;
}

.user-switch-menu summary {
  min-height: 40px;
  list-style: none;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 8px 13px;
  background: var(--surface);
  color: var(--text);
  font-weight: 620;
  cursor: pointer;
}

.user-switch-menu summary::-webkit-details-marker {
  display: none;
}

.user-switch-menu small {
  display: block;
  margin-top: 2px;
  color: var(--accent);
  font-size: 12px;
  font-weight: 620;
}

.user-switch-panel {
  position: absolute;
  right: 0;
  z-index: 30;
  display: grid;
  width: 300px;
  gap: 6px;
  margin-top: 8px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 10px;
  background: var(--surface);
  box-shadow: var(--shadow);
}

.user-switch-panel p {
  margin: 0 0 4px;
  padding: 0 2px;
  color: var(--muted);
  font-size: 11px;
  font-weight: 620;
  letter-spacing: 0.18em;
  text-transform: uppercase;
}

.switch-user-row,
.switch-restore {
  width: 100%;
  border: 0;
  border-radius: 8px;
  padding: 9px 10px;
  background: transparent;
  color: var(--text);
  text-align: left;
}

.switch-user-row:hover {
  background: var(--surface-soft);
}

.switch-restore {
  background: color-mix(in srgb, var(--accent) 14%, var(--surface));
  color: var(--accent);
}

.switch-restore:hover {
  background: color-mix(in srgb, var(--accent) 20%, var(--surface));
}

.switch-user-row strong,
.switch-user-row span,
.switch-restore strong,
.switch-restore span {
  display: block;
}

.switch-user-row span,
.switch-restore span {
  margin-top: 2px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 520;
}

.eyebrow {
  margin: 0 0 12px;
  color: var(--accent);
  font-size: 13px;
  font-weight: 620;
  letter-spacing: 0.14em;
  text-transform: uppercase;
}

h1 {
  max-width: 900px;
  margin: 0;
  font-size: clamp(40px, 5.2vw, 72px);
  line-height: 1.02;
  font-weight: 520;
  letter-spacing: 0;
}

.intro-copy {
  max-width: 760px;
  margin: 20px 0 0;
  color: var(--muted);
  font-size: 22px;
  font-weight: 400;
  line-height: 1.42;
}

.services {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 18px;
}

.service-card {
  display: grid;
  min-height: 274px;
  grid-template-rows: 44px auto minmax(82px, 1fr) auto;
  padding: 30px 28px 24px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  box-shadow: none;
  color: inherit;
  text-decoration: none;
  transition: transform 160ms ease, border-color 160ms ease, box-shadow 160ms ease, background 160ms ease;
}

.service-icon {
  display: block;
  width: 40px;
  height: 40px;
  object-fit: contain;
}

.service-card:hover {
  border-color: color-mix(in srgb, var(--accent) 58%, var(--line));
  box-shadow: var(--shadow);
  transform: translateY(-2px);
}

.service-card.locked::after {
  content: "Login required";
  position: absolute;
  right: 18px;
  top: 18px;
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 5px 9px;
  color: var(--muted);
  font-size: 12px;
  background: var(--surface-soft);
}

.service-card h2 {
  margin: 4px 0 12px;
  color: var(--accent);
  font-size: 26px;
  line-height: 1.18;
  font-weight: 620;
}

.service-card p {
  margin: 0;
  color: var(--muted);
  font-size: 20px;
  line-height: 1.34;
  font-weight: 400;
}

.service-action {
  display: inline-flex;
  width: fit-content;
  align-items: center;
  gap: 12px;
  margin-top: 22px;
  padding: 0 15px;
  background: transparent;
}

.login-dialog {
  width: min(430px, calc(100% - 32px));
  padding: 0;
  border: 0;
  border-radius: 8px;
  background: transparent;
}

.edit-dialog {
  width: min(860px, calc(100% - 32px));
  padding: 0;
  border: 0;
  border-radius: 8px;
  background: transparent;
}

.login-dialog::backdrop,
.edit-dialog::backdrop {
  background: rgba(5, 6, 11, 0.64);
  backdrop-filter: blur(5px);
}

.login-card,
.edit-card {
  display: grid;
  gap: 16px;
  padding: 26px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  box-shadow: var(--shadow);
}

.edit-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
}

.edit-grid label:first-child,
.edit-grid label:nth-child(3) {
  grid-column: 1 / -1;
}

.edit-grid label:first-child {
  grid-column: auto;
}

.field-title {
  display: block;
  margin-bottom: 7px;
  color: var(--muted);
  font-weight: 500;
}

.modal-actions {
  display: flex;
  justify-content: end;
  gap: 10px;
}

.login-head {
  display: flex;
  align-items: start;
  justify-content: space-between;
  gap: 16px;
}

.login-head h2 {
  margin: 0;
  font-size: 34px;
  font-weight: 520;
}

.icon-button {
  width: 40px;
  padding: 0;
  font-size: 25px;
  line-height: 1;
}

label span {
  display: block;
  margin-bottom: 7px;
  color: var(--muted);
  font-weight: 500;
}

input {
  width: 100%;
  min-height: 48px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 0 14px;
  background: var(--surface-soft);
  color: var(--text);
  outline: none;
}

input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 18%, transparent);
}

.form-error {
  min-height: 20px;
  margin: 0;
  color: var(--danger);
  font-weight: 500;
}

.primary-action {
  min-height: 48px;
  border-color: var(--accent);
  background: var(--accent);
  color: #101522;
}

.primary-action:hover {
  background: var(--accent-strong);
}

.admin-panel {
  margin-top: 40px;
  border-top: 1px solid var(--line);
  padding-top: 34px;
}

.section-head {
  max-width: 820px;
  margin-bottom: 22px;
}

.section-head h2 {
  margin: 0;
  font-size: 34px;
  font-weight: 520;
}

.section-head p:last-child {
  margin: 12px 0 0;
  color: var(--muted);
  line-height: 1.45;
}

.admin-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 16px;
}

.admin-card {
  display: grid;
  align-content: start;
  gap: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 18px;
  background: var(--surface);
}

.admin-card h3 {
  margin: 0 0 4px;
  font-size: 18px;
  font-weight: 620;
}

.service-checks {
  display: grid;
  gap: 8px;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface-soft);
}

.workspace-access-list {
  display: grid;
  gap: 10px;
  max-height: 360px;
  overflow: auto;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface-soft);
}

.workspace-access-row {
  display: grid;
  grid-template-columns: minmax(220px, 0.8fr) minmax(260px, 1.2fr);
  gap: 10px;
  align-items: start;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 10px;
  background: var(--surface);
}

.workspace-access-main {
  display: grid;
  gap: 8px;
}

.workspace-access-row select {
  min-height: 38px;
  padding: 0 10px;
}

.workspace-service-list {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
  gap: 6px;
}

.service-check-row {
  display: flex;
  align-items: center;
  gap: 6px;
  min-height: 28px;
  color: var(--muted);
  font-size: 12px;
}

.service-check-row input {
  width: auto;
  min-height: auto;
}

.check-row {
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--muted);
  font-size: 14px;
}

.check-row input {
  width: auto;
  min-height: auto;
}

.admin-list {
  margin-top: 18px;
}

.workspace-list {
  display: grid;
  gap: 10px;
  margin-top: 18px;
}

.workspace-row {
  display: grid;
  grid-template-columns: minmax(360px, 1.1fr) minmax(260px, 1fr) auto;
  gap: 12px;
  align-items: end;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 14px;
  background: var(--surface);
}

.workspace-main {
  display: grid;
  grid-template-columns: minmax(180px, 1fr) 150px minmax(180px, 0.8fr);
  gap: 10px;
}

.workspace-main select {
  width: 100%;
  min-height: 48px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 0 12px;
  background: var(--surface-soft);
  color: var(--text);
}

.workspace-meta {
  display: grid;
  align-self: center;
  gap: 5px;
  min-width: 0;
}

.workspace-meta strong,
.workspace-meta span {
  min-width: 0;
  overflow-wrap: anywhere;
}

.workspace-meta span {
  color: var(--muted);
  font-size: 14px;
  line-height: 1.35;
}

.workspace-meta .workspace-agent-mark {
  color: var(--accent);
  font-weight: 620;
}

.admin-table {
  display: grid;
  gap: 8px;
}

.admin-row {
  display: grid;
  grid-template-columns: minmax(180px, 1fr) minmax(140px, 0.8fr) 120px minmax(220px, 1.4fr) auto;
  gap: 12px;
  align-items: center;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 12px 14px;
  background: var(--surface);
}

.admin-row strong,
.admin-row span,
.admin-row small {
  min-width: 0;
  overflow-wrap: anywhere;
}

.admin-row strong {
  font-weight: 620;
}

.admin-row span,
.admin-row small {
  color: var(--muted);
}

.admin-actions {
  display: flex;
  justify-content: end;
  gap: 8px;
}

.edit-user-button,
.delete-user-button {
  min-height: 40px;
  padding: 0 16px;
  border-radius: 8px;
  font-size: 15px;
  font-weight: 620;
  cursor: pointer;
}

.edit-user-button {
  border: 1px solid color-mix(in srgb, var(--accent) 45%, var(--line));
  background: color-mix(in srgb, var(--accent) 8%, var(--surface));
  color: var(--accent);
}

.delete-user-button {
  border: 1px solid color-mix(in srgb, var(--danger) 45%, var(--line));
  background: color-mix(in srgb, var(--danger) 8%, var(--surface));
  color: var(--danger);
}

.edit-user-button:hover {
  background: color-mix(in srgb, var(--accent) 14%, var(--surface));
  border-color: color-mix(in srgb, var(--accent) 65%, var(--line));
}

.delete-user-button:hover:not(:disabled) {
  background: color-mix(in srgb, var(--danger) 14%, var(--surface));
  border-color: color-mix(in srgb, var(--danger) 65%, var(--line));
}

.edit-user-button:active,
.delete-user-button:active:not(:disabled) {
  transform: translateY(1px);
}

.delete-user-button:disabled {
  opacity: 0.42;
  cursor: not-allowed;
}

.page-footer {
  flex-shrink: 0;
  background: var(--footer);
  color: #f4f5f8;
  border-top: 1px solid color-mix(in srgb, var(--line) 60%, transparent);
}

.footer-inner {
  display: grid;
  grid-template-columns: minmax(260px, 1.4fr) minmax(150px, 0.7fr) minmax(190px, 0.8fr) minmax(150px, 0.6fr);
  width: min(1400px, calc(100% - 64px));
  margin: 0 auto;
  gap: 32px;
  padding: 40px 0 30px;
}

.footer-logo {
  display: inline-flex;
  align-items: center;
  gap: 12px;
  color: var(--accent);
  font-size: 15px;
  font-weight: 600;
  letter-spacing: 0.28em;
  line-height: 1;
  text-transform: uppercase;
  text-decoration: none;
}

.brand-mark.small {
  width: 40px;
  height: 40px;
  border-radius: 8px;
}

.brand-mark.small::after {
  right: 7px;
  top: 7px;
  width: 7px;
  height: 7px;
}

.brand-mark.small .logo-bars {
  width: 16px;
  height: 13px;
  border-top-width: 4px;
  border-bottom-width: 4px;
}

.brand-mark.small .logo-bars::after {
  width: 11px;
  height: 4px;
  margin-top: 4px;
}

.footer-brand p {
  max-width: 520px;
  margin: 12px 0 0;
  color: #aeb4c3;
  font-size: 14px;
  line-height: 1.55;
}

.footer-column,
.footer-status {
  display: grid;
  align-content: start;
  gap: 10px;
}

.footer-column h3,
.footer-status h3 {
  margin: 0 0 4px;
  color: var(--accent);
  font-size: 14px;
  font-weight: 700;
  text-transform: uppercase;
}

.footer-column a,
.footer-login,
.footer-status span {
  color: #d8dce6;
  font-size: 14px;
  text-decoration: none;
}

.footer-column a:hover,
.footer-login:hover {
  color: var(--accent);
}

.footer-login {
  width: fit-content;
  border: 0;
  padding: 0;
  background: transparent;
  cursor: pointer;
}

.footer-note {
  max-width: 260px;
  color: #8d95a8;
  font-size: 13px;
  line-height: 1.4;
}

.footer-status span {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  color: #aeb4c3;
}

.footer-status i {
  width: 8px;
  height: 8px;
  border-radius: 999px;
  background: var(--accent);
  box-shadow: 0 0 0 4px color-mix(in srgb, var(--accent) 18%, transparent);
}

.footer-bottom {
  display: flex;
  width: min(1400px, calc(100% - 64px));
  margin: 0 auto;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  padding: 18px 0 22px;
  border-top: 1px solid rgba(255, 255, 255, 0.08);
  color: #8d95a8;
  font-size: 13px;
}

@media (max-width: 1180px) {
  .services {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .admin-grid {
    grid-template-columns: 1fr;
  }

  .admin-row {
    grid-template-columns: 1fr 1fr;
  }

  .workspace-row {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 720px) {
  .shell,
  .footer-inner,
  .footer-bottom {
    width: min(100% - 24px, 1400px);
  }

  .shell {
    padding-top: 16px;
  }

  .topbar,
  .top-actions,
  .session {
    align-items: stretch;
  }

  .topbar {
    flex-direction: column;
  }

  .footer-inner {
    grid-template-columns: 1fr;
    gap: 24px;
  }

  .footer-bottom {
    flex-direction: column;
    align-items: flex-start;
  }

  .top-actions {
    width: 100%;
    justify-content: space-between;
    flex-wrap: wrap;
  }

  .workspace-bar {
    align-items: stretch;
    flex-direction: column;
  }

  .intro {
    padding: 44px 0 30px;
  }

  h1 {
    font-size: 40px;
  }

  .intro-copy,
  .service-card p {
    font-size: 18px;
  }

  .services {
    grid-template-columns: 1fr;
  }

  .admin-row {
    grid-template-columns: 1fr;
  }

  .workspace-main {
    grid-template-columns: 1fr;
  }

  .admin-actions,
  .modal-actions {
    justify-content: stretch;
    flex-direction: column;
  }

  .edit-grid {
    grid-template-columns: 1fr;
  }

  .edit-user-button,
  .delete-user-button,
  .modal-actions .ghost-button,
  .modal-actions .primary-action {
    width: 100%;
  }

}
