:root {
  color-scheme: light;
  font-family: Inter, ui-sans-serif, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  color: #202538;
  background: #f3f6f9;
  font-synthesis: none;
  text-rendering: optimizeLegibility;
  --admin-blue: #1264f6;
  --admin-blue-dark: #0754db;
  --admin-blue-soft: #eaf1ff;
  --sidebar: #111522;
  --sidebar-text: #aeb8ce;
  --panel: #fff;
  --surface: #f7f8fb;
  --page: #f3f6f9;
  --text: #202538;
  --text-muted: #75809a;
  --border: #e7ebf2;
  --shadow: 0 3px 10px rgba(32, 48, 78, 0.07);
}

* {
  box-sizing: border-box;
}

html,
body {
  min-width: 320px;
  min-height: 100%;
  margin: 0;
}

html {
  scroll-behavior: smooth;
  scroll-padding-top: 84px;
}

body {
  min-height: 100vh;
}

button,
input,
textarea {
  font: inherit;
}

button,
a {
  -webkit-tap-highlight-color: transparent;
}

/* Public authorization shell */

.site-shell {
  display: flex;
  min-height: 100vh;
  flex-direction: column;
  background: #fff;
}

.site-header {
  position: sticky;
  top: 0;
  z-index: 20;
  flex: 0 0 auto;
  height: 60px;
  border-bottom: 1px solid #ededed;
  background: rgba(255, 255, 255, 0.95);
  backdrop-filter: blur(12px);
}

.site-header__inner,
.site-footer__inner {
  width: min(1200px, calc(100% - 48px));
  margin: 0 auto;
}

.site-header__inner {
  display: flex;
  height: 100%;
  align-items: center;
  justify-content: space-between;
}

.brand {
  display: inline-flex;
  align-items: center;
  color: #252528;
  gap: 9px;
  text-decoration: none;
}

.brand__name {
  font-size: 18px;
  font-weight: 760;
  letter-spacing: -0.04em;
}

.site-header__label {
  color: #8a8a8f;
  font-size: 13px;
  font-weight: 600;
}

.site-main {
  display: flex;
  flex: 1 0 auto;
  min-width: 0;
  min-height: 500px;
}

.site-footer {
  flex: 0 0 auto;
  min-height: 150px;
  padding: 34px 0 24px;
  color: #d6d6d8;
  background: #242426;
}

.site-footer__inner {
  display: grid;
  gap: 26px;
}

.brand--footer {
  color: #fff;
}

.site-footer__brand p {
  max-width: 280px;
  margin: 14px 0 0;
  color: #96969c;
  font-size: 13px;
  line-height: 1.5;
}

.site-footer__copyright {
  color: #6f6f74;
  font-size: 11px;
}

/* Admin application shell */

.admin-body {
  background: var(--page);
}

.admin-shell {
  display: grid;
  min-height: 100vh;
  grid-template-columns: 208px minmax(0, 1fr);
}

.app-sidebar {
  position: sticky;
  top: 0;
  z-index: 40;
  display: flex;
  height: 100vh;
  min-height: 620px;
  flex-direction: column;
  padding: 18px 10px 14px;
  overflow: hidden;
  color: #fff;
  border-bottom-right-radius: 20px;
  background: var(--sidebar);
}

.sidebar-brand {
  display: flex;
  height: 44px;
  flex: 0 0 auto;
  align-items: center;
  gap: 9px;
  padding: 0 9px;
  color: #fff;
  font-size: 15px;
  font-weight: 760;
  text-decoration: none;
}

.sidebar-brand img {
  flex: 0 0 auto;
}

.sidebar-nav {
  display: flex;
  min-height: 0;
  flex: 1 1 auto;
  flex-direction: column;
  gap: 4px;
  margin-top: 24px;
}

.sidebar-nav__label {
  margin: 17px 10px 7px;
  color: #65718a;
  font-size: 9px;
  font-weight: 760;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

.sidebar-nav__item {
  display: flex;
  min-width: 0;
  height: 38px;
  align-items: center;
  gap: 10px;
  padding: 0 10px;
  color: var(--sidebar-text);
  border-radius: 10px;
  font-size: 12px;
  font-weight: 540;
  text-decoration: none;
  transition: color 150ms ease, background 150ms ease;
}

.sidebar-nav__item svg {
  width: 18px;
  height: 18px;
  flex: 0 0 auto;
  fill: currentColor;
}

.sidebar-nav__item span {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.sidebar-nav__item b {
  display: grid;
  min-width: 20px;
  height: 20px;
  margin-left: auto;
  padding: 0 5px;
  place-items: center;
  color: #fff;
  border-radius: 999px;
  background: #ff6969;
  font-size: 9px;
}

.sidebar-nav__item:hover {
  color: #fff;
  background: rgba(255, 255, 255, 0.07);
}

.sidebar-nav__item--current,
.sidebar-nav__item.is-active {
  color: #fff;
  background: var(--admin-blue);
}

.admin-frame {
  min-width: 0;
}

.app-header {
  position: sticky;
  top: 0;
  z-index: 30;
  display: flex;
  height: 64px;
  align-items: center;
  justify-content: space-between;
  padding: 0 24px;
  border-bottom: 1px solid var(--border);
  background: rgba(255, 255, 255, 0.96);
  box-shadow: 0 1px 5px rgba(36, 51, 79, 0.05);
  backdrop-filter: blur(12px);
}

.app-page-title,
.app-header__actions {
  display: flex;
  min-width: 0;
  align-items: center;
}

.app-page-title {
  gap: 8px;
  font-size: 12px;
}

.app-page-title strong {
  overflow: hidden;
  color: #364158;
  font-weight: 650;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.app-page-title__icon {
  display: grid;
  width: 27px;
  height: 27px;
  flex: 0 0 auto;
  place-items: center;
  color: #4f5d77;
  border: 1px solid #dce2ec;
  border-radius: 8px;
  background: #f7f9fc;
}

.app-page-title__icon svg {
  width: 15px;
  height: 15px;
  fill: currentColor;
}

.app-header__actions {
  flex: 0 0 auto;
  gap: 8px;
}

.app-header__actions form {
  margin: 0;
}

.header-logout-button {
  display: flex;
  height: 42px;
  align-items: center;
  gap: 6px;
  padding: 0 11px;
  color: #667289;
  border: 1px solid #dfe5ee;
  border-radius: 10px;
  background: #fff;
  font-size: 9px;
  font-weight: 650;
  cursor: pointer;
}

.header-logout-button:hover {
  color: #bd3445;
  border-color: #efcbd0;
  background: #fff7f8;
}

.header-logout-button svg {
  width: 15px;
  height: 15px;
  fill: currentColor;
}

.site-main--admin {
  min-height: calc(100vh - 64px);
  background: var(--page);
}

/* Workspace */

.admin-workspace {
  width: 100%;
  min-width: 0;
  padding: 20px 24px 36px;
}

.workspace-panel {
  min-width: 0;
  overflow: clip;
  border: 1px solid #edf0f5;
  border-radius: 15px;
  background: #fff;
  box-shadow: var(--shadow);
}

.workspace-panel__header {
  display: flex;
  min-height: 49px;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  padding: 8px 18px;
  border-bottom: 1px solid #edf0f5;
}

.workspace-panel__header h1,
.workspace-panel__header h2 {
  margin: 0;
  color: #252c3d;
  font-size: 14px;
  font-weight: 660;
}

.workspace-panel--screen {
  width: 100%;
}

.workspace-panel__body {
  padding: 12px 18px 18px;
}

.accounts-page {
  padding: 16px;
  border-radius: 12px;
  background: var(--surface);
}

.account-notice {
  margin-bottom: 12px;
  padding: 9px 11px;
  border: 1px solid;
  border-radius: 8px;
  font-size: 10px;
}

.account-notice--success {
  color: #176b50;
  border-color: #b9e2d3;
  background: #eefaf6;
}

.account-notice--error {
  color: #a33b48;
  border-color: #f0c9cf;
  background: #fff5f6;
}

.panel-section-heading {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 18px;
  margin-bottom: 14px;
}

.panel-section-heading h2 {
  margin: 0;
  color: #3c4860;
  font-size: 12px;
  font-weight: 720;
}

.panel-section-heading p {
  margin: 5px 0 0;
  color: #7d89a1;
  font-size: 10px;
  line-height: 1.45;
}

.panel-section-heading a {
  flex: 0 0 auto;
  color: var(--admin-blue);
  font-size: 10px;
  font-weight: 650;
  text-decoration: none;
}

.client-binding {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  margin: 0 0 14px;
  padding: 12px 14px;
  border: 1px solid #d8e4fb;
  border-radius: 10px;
  background: #f4f8ff;
}

.client-binding > div {
  min-width: 0;
}

.client-binding span {
  display: block;
  margin-bottom: 5px;
  color: #68758d;
  font-size: 8px;
  font-weight: 720;
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

.client-binding code {
  display: block;
  overflow: hidden;
  color: #26334b;
  font-size: 11px;
  font-weight: 720;
  text-overflow: ellipsis;
}

.client-binding p {
  margin: 5px 0 0;
  color: #7c88a0;
  font-size: 9px;
}

.client-binding button {
  height: 32px;
  flex: 0 0 auto;
  padding: 0 12px;
  color: #fff;
  border: 0;
  border-radius: 8px;
  background: var(--admin-blue);
  font-size: 9px;
  font-weight: 700;
  cursor: pointer;
}

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

.account-card {
  min-width: 0;
  padding: 14px;
  border: 1px solid #e3e8f0;
  border-radius: 10px;
  background: #fff;
}

.account-card__topline,
.account-card__actions {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.account-avatar {
  display: grid;
  width: 34px;
  height: 34px;
  flex: 0 0 auto;
  place-items: center;
  color: #fff;
  border-radius: 50%;
  background: linear-gradient(145deg, #2c7df4, #6659e8);
  font-size: 13px;
  font-weight: 760;
}

.account-avatar--logo {
  overflow: hidden;
  width: 44px;
  height: 44px;
  border: 1px solid #e8ebf1;
  background: #fff;
}

.account-avatar--logo img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: contain;
}

.account-sync-state {
  color: #27785e;
  font-size: 8px;
  font-weight: 680;
}

.account-card__identity {
  margin-top: 12px;
}

.account-card__identity h3 {
  overflow: hidden;
  margin: 0;
  color: #30384b;
  font-size: 13px;
  line-height: 1.3;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.account-card__identity p {
  overflow: hidden;
  margin: 3px 0 0;
  color: #818ba0;
  font-size: 10px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.account-locations {
  margin-top: 12px;
  border: 1px solid #e8edf4;
  border-radius: 8px;
  background: #f8faff;
}

.account-locations summary {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 9px 10px;
  color: #59657b;
  font-size: 9px;
  font-weight: 680;
  cursor: pointer;
  list-style: none;
}

.account-locations summary::-webkit-details-marker {
  display: none;
}

.account-locations summary strong {
  display: grid;
  min-width: 20px;
  height: 20px;
  place-items: center;
  padding: 0 5px;
  color: var(--admin-blue);
  border-radius: 10px;
  background: var(--admin-blue-soft);
  font-size: 8px;
}

.account-locations__counts,
.account-locations__empty,
.account-locations__more {
  margin: 0;
  padding: 0 10px 8px;
  color: #8993a6;
  font-size: 8px;
}

.account-locations ul {
  display: grid;
  gap: 0;
  margin: 0;
  padding: 0 10px 8px;
  list-style: none;
}

.account-locations li {
  display: grid;
  gap: 2px;
  padding: 6px 0;
  border-top: 1px solid #e8edf4;
}

.account-location-title {
  overflow: hidden;
  color: #3f4a60;
  font-size: 9px;
  font-weight: 650;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.account-location-title small {
  margin-left: 5px;
  padding: 1px 4px;
  color: #6e61d8;
  border-radius: 5px;
  background: #eeebff;
  font-size: 6px;
}

.account-location-meta {
  overflow: hidden;
  color: #9099aa;
  font-size: 8px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.account-pwa-empty {
  margin-top: 12px;
  padding: 9px 10px;
  color: #8b94a6;
  border: 1px dashed #dfe4ec;
  border-radius: 8px;
  background: #fafbfc;
  font-size: 8px;
  line-height: 1.45;
}

.account-card__actions {
  justify-content: space-between;
  min-height: 25px;
  margin-top: 14px;
  padding-top: 10px;
  border-top: 1px solid #edf0f4;
}

.account-card__actions form {
  margin: 0;
}

.account-action {
  padding: 4px 0;
  border: 0;
  background: transparent;
  font-size: 9px;
  font-weight: 680;
  cursor: pointer;
}

.account-action--danger {
  color: #939caf;
}

.account-action--refresh {
  color: var(--admin-blue);
}

.account-action--refresh:hover {
  color: var(--admin-blue-dark);
}

.account-action--danger:hover {
  color: #c13b49;
}

.account-card--add {
  display: flex;
  min-height: 164px;
  align-items: center;
  justify-content: center;
  flex-direction: column;
  gap: 6px;
  color: #8691a6;
  border-style: dashed;
  text-align: center;
  text-decoration: none;
}

.account-card--add > span {
  display: grid;
  width: 34px;
  height: 34px;
  margin-bottom: 3px;
  place-items: center;
  color: var(--admin-blue);
  border-radius: 50%;
  background: var(--admin-blue-soft);
  font-size: 20px;
}

.account-card--add strong {
  color: #536078;
  font-size: 10px;
}

.account-card--add small {
  color: #9aa4b6;
  font-size: 8px;
}

.account-card--add:hover {
  border-color: #8fb5fc;
  background: #f8fbff;
}

@media (max-width: 1120px) {
  .admin-shell {
    grid-template-columns: 72px minmax(0, 1fr);
  }

  .app-sidebar {
    padding-inline: 9px;
  }

  .sidebar-brand {
    justify-content: center;
    padding: 0;
  }

  .sidebar-brand span,
  .sidebar-nav__item span,
  .sidebar-nav__item b,
  .sidebar-nav__label {
    display: none;
  }

  .sidebar-nav__item {
    justify-content: center;
    padding: 0;
  }

  .account-grid {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 880px) {
  .admin-workspace {
    padding-inline: 16px;
  }

  .account-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 680px) {
  html {
    scroll-padding-top: 74px;
  }

  .admin-shell {
    display: block;
    padding-bottom: 62px;
  }

  .app-sidebar {
    position: fixed;
    top: auto;
    right: 0;
    bottom: 0;
    left: 0;
    z-index: 50;
    width: 100%;
    height: 62px;
    min-height: 0;
    padding: 7px 8px;
    border-radius: 15px 15px 0 0;
  }

  .sidebar-brand,
  .sidebar-nav__label {
    display: none;
  }

  .sidebar-nav {
    display: grid;
    height: 100%;
    grid-template-columns: repeat(6, 1fr);
    gap: 3px;
    margin: 0;
  }

  .sidebar-nav__item {
    height: 48px;
    justify-content: center;
    flex-direction: column;
    gap: 2px;
    padding: 3px 2px;
    font-size: 8px;
  }

  .sidebar-nav__item span {
    display: block;
    max-width: 100%;
  }

  .sidebar-nav__item b {
    display: none;
  }

  .sidebar-nav__item svg {
    width: 17px;
    height: 17px;
  }

  .app-header {
    height: 58px;
    padding: 0 12px;
  }

  .header-logout-button span {
    display: none;
  }

  .app-page-title {
    min-width: 0;
  }

  .app-page-title strong {
    max-width: 150px;
    font-size: 10px;
  }

  .header-logout-button {
    width: 40px;
    justify-content: center;
    padding: 0;
  }

  .app-header__actions {
    gap: 3px;
  }

  .site-main--admin {
    min-height: calc(100vh - 120px);
  }

  .admin-workspace {
    padding: 12px 10px 24px;
  }

  .workspace-panel__header {
    padding-inline: 13px;
  }

  .workspace-panel__body {
    padding: 9px;
  }

  .accounts-page {
    padding: 12px;
  }

  .panel-section-heading {
    align-items: flex-start;
  }

  .panel-section-heading p {
    max-width: 235px;
  }

  .client-binding {
    align-items: flex-start;
    flex-direction: column;
  }

  .account-grid {
    grid-template-columns: 1fr;
  }

  .site-header__inner,
  .site-footer__inner {
    width: min(100% - 24px, 1200px);
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    scroll-behavior: auto !important;
    transition-duration: 0.01ms !important;
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
  }
}
