* {
  box-sizing: border-box;
}

html {
  height: 100%;
}

body {
  font-family: system-ui, -apple-system, "Segoe UI", sans-serif;
  margin: 0;
  min-height: 100vh;
  display: flex;
  align-items: flex-start;
  justify-content: center;
  padding: 56px 16px;
  background: linear-gradient(180deg, #f5f7fb 0%, #e9edf5 100%);
  color: #1a1d24;
}

h1 {
  font-size: 22px;
  margin: 0 0 8px;
}

/* --- login page --- */
body:has(.auth-card) {
  align-items: center;
  background:
    radial-gradient(circle at 22% 18%, rgba(45, 212, 191, 0.16), transparent 55%),
    radial-gradient(circle at 82% 78%, rgba(79, 110, 247, 0.12), transparent 50%),
    linear-gradient(180deg, #f5f7fb 0%, #e9edf5 100%);
}

.auth-card {
  width: 100%;
  max-width: 380px;
  background: #fff;
  border-radius: 20px;
  box-shadow: 0 8px 32px rgba(20, 24, 40, 0.1);
  padding: 48px 36px;
  text-align: center;
}

.auth-logo {
  width: 120px;
  height: auto;
  margin: 0 auto 22px;
  display: block;
}

.auth-tagline {
  font-size: 14px;
  color: #6b7280;
  margin: 0 0 32px;
  line-height: 1.5;
}

#google-login {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  gap: 10px;
  padding: 12px 22px;
  border: 1px solid #dadce0;
  border-radius: 10px;
  background: #fff;
  cursor: pointer;
  font-size: 15px;
  font-weight: 500;
  color: #1a1d24;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.08);
  transition: box-shadow 0.12s ease, transform 0.12s ease;
}

#google-login:hover {
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.12);
  transform: translateY(-1px);
}

/* --- app layout (sidebar + page) --- */
body:has(.app) {
  padding: 0;
  align-items: stretch;
  height: 100vh;
  min-height: 100vh;
  overflow: hidden;
}

.app {
  display: flex;
  width: 100%;
  height: 100vh;
  min-height: 100vh;
  overflow: hidden;
}

.sidebar {
  width: 220px;
  height: 100%;
  flex-shrink: 0;
  background: #fff;
  border-right: 1px solid #e5e7eb;
  display: flex;
  flex-direction: column;
  padding: 24px 16px;
  overflow-y: auto;
}

.sidebar-brand {
  display: flex;
  justify-content: center;
  padding: 0 8px;
  margin-bottom: 28px;
}

.sidebar-logo {
  width: 104px;
  height: auto;
}

.sidebar-user {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 0 4px 20px;
  margin-bottom: 8px;
  border-bottom: 1px solid #eef0f4;
}

.sidebar-avatar {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: #4f6ef7;
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 600;
  font-size: 15px;
  flex-shrink: 0;
}

.sidebar-user-info {
  min-width: 0;
}

.sidebar-user-name {
  font-weight: 600;
  font-size: 14px;
  color: #111827;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.sidebar-user-email {
  font-size: 12px;
  color: #6b7280;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.nav-links {
  display: flex;
  flex-direction: column;
  gap: 4px;
  flex: 1;
}

.nav-link {
  padding: 10px 12px;
  border-radius: 8px;
  font-size: 14px;
  font-weight: 500;
  color: #374151;
  text-decoration: none;
}

.nav-link:hover {
  background: #f3f4f6;
}

.nav-link.active {
  background: #eef1ff;
  color: #4f6ef7;
}

.nav-logout {
  width: 100%;
  padding: 10px 12px;
  border: none;
  border-radius: 8px;
  background: transparent;
  color: #dc2626;
  font-size: 14px;
  font-weight: 500;
  text-align: start;
  cursor: pointer;
}

.nav-logout:hover {
  background: #fef2f2;
}

.nav-delete-account {
  width: 100%;
  padding: 10px 12px;
  margin-bottom: 4px;
  border: none;
  border-radius: 8px;
  background: transparent;
  color: #991b1b;
  font-size: 13px;
  font-weight: 500;
  text-align: start;
  cursor: pointer;
}

.nav-delete-account:hover:not(:disabled) {
  background: #fef2f2;
}

.nav-delete-account:disabled {
  opacity: 0.6;
  cursor: not-allowed;
}

.main {
  flex: 1;
  min-width: 0;
  min-height: 0;
  overflow-y: auto;
  display: flex;
  justify-content: center;
  padding: 56px 24px;
}

.main-full {
  justify-content: flex-start;
  align-items: stretch;
  flex-direction: column;
  padding: 0;
  height: 100%;
}

/* --- app pages --- */
.page-panel {
  flex: 0 0 auto;
  width: 100%;
  min-height: 100%;
  background: #fff;
  padding: 32px 40px;
}

.page-panel .section {
  border-top: none;
  padding-top: 0;
}

.page-panel .section + .section:not([hidden]) {
  padding-top: 24px;
  border-top: 1px solid #eef0f4;
}

.page-panel .platform-list {
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
}

.platforms-wrap {
  position: relative;
}

.platforms-wrap.is-loading .platform-list,
.platforms-wrap.is-loading .section-header,
.platforms-wrap.is-loading .divider {
  filter: blur(3px);
  pointer-events: none;
  user-select: none;
}

.platforms-loading {
  position: absolute;
  inset: 0;
  z-index: 2;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(255, 255, 255, 0.45);
  backdrop-filter: blur(2px);
  -webkit-backdrop-filter: blur(2px);
}

.platforms-loading-spinner {
  width: 36px;
  height: 36px;
  border-width: 3px;
}

.section {
  padding-top: 24px;
  border-top: 1px solid #eef0f4;
}

.section h2,
.section h3 {
  font-size: 15px;
  margin: 0 0 4px;
}

.hint {
  font-size: 13px;
  color: #6b7280;
  margin: 0 0 14px;
}

.profile-support-message {
  margin: 0 0 14px;
  padding: 12px 14px;
  border-radius: 10px;
  background: #fef3c7;
  color: #92400e;
  font-size: 14px;
  font-weight: 500;
}

.primary-btn {
  padding: 10px 22px;
  border: none;
  border-radius: 8px;
  background: #4f6ef7;
  color: #fff;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
}

.primary-btn:hover {
  background: #3d5bdb;
}

.primary-btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.primary-btn:disabled:hover {
  background: #4f6ef7;
}

.status {
  display: inline-block;
  margin-left: 10px;
  font-size: 13px;
  color: #16a34a;
}

.status.error {
  color: #dc2626;
}

.status-spinner {
  display: inline-block;
  width: 16px;
  height: 16px;
  border: 2px solid #d1d5db;
  border-top-color: #4f6ef7;
  border-radius: 50%;
  animation: status-spin 0.7s linear infinite;
  vertical-align: middle;
}

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

.section-header {
  display: flex;
  align-items: center;
  gap: 16px;
}

.section-header .hint {
  margin-bottom: 0;
}

.add-btn {
  width: 46px;
  height: 46px;
  border-radius: 50%;
  border: none;
  background: linear-gradient(180deg, #6280ff 0%, #4f6ef7 100%);
  color: #fff;
  font-size: 26px;
  font-weight: 300;
  line-height: 1;
  cursor: pointer;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 3px 10px rgba(79, 110, 247, 0.35);
  transition: transform 0.12s ease, box-shadow 0.12s ease, background 0.12s ease;
}

.add-btn:hover {
  background: linear-gradient(180deg, #6f8bff 0%, #3d5bdb 100%);
  transform: translateY(-1px);
  box-shadow: 0 5px 14px rgba(79, 110, 247, 0.45);
}

.add-btn:active {
  transform: translateY(0);
}

.add-btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
  box-shadow: none;
  transform: none;
}

.divider {
  border: none;
  border-top: 1px solid #eef0f4;
  margin: 18px 0;
}

.platform-list {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 12px;
  text-align: left;
}

.platform-card {
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding: 14px;
  border: 1px solid #e5e7eb;
  border-radius: 12px;
  background: #fff;
}

.platform-card.connected {
  border-color: #86efac;
  background: #f0fdf4;
}

.platform-card.disconnected {
  opacity: 0.85;
}

.p-top {
  display: flex;
  align-items: center;
  gap: 10px;
}

.p-bottom {
  display: flex;
  justify-content: flex-end;
  padding-top: 8px;
  border-top: 1px solid #eef0f4;
}

.platform-card.connected .p-bottom {
  border-top-color: #d1fae5;
}

@media (max-width: 640px) {
  .platform-list {
    grid-template-columns: repeat(2, 1fr);
  }
}

@media (max-width: 420px) {
  .platform-list {
    grid-template-columns: 1fr;
  }
}

.p-text {
  display: flex;
  flex-direction: column;
  flex: 1;
  min-width: 0;
}

.p-name {
  font-size: 13.5px;
  font-weight: 600;
  color: #1f2937;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.p-sub {
  font-size: 11.5px;
  color: #9ca3af;
}

.platform-card.connected .p-sub {
  color: #16a34a;
}

.p-badge {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  flex-shrink: 0;
  background: var(--brand);
  color: var(--fg, #fff);
  display: flex;
  align-items: center;
  justify-content: center;
}

.p-badge svg {
  width: 20px;
  height: 20px;
}

.p-badge.p-badge-image {
  background: transparent;
  border-radius: 8px;
}

.p-badge-logo {
  width: 36px;
  height: 36px;
  object-fit: contain;
  display: block;
}

.send-toggle {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-shrink: 0;
}

.send-label {
  font-size: 11px;
  font-weight: 600;
  color: #9ca3af;
  text-transform: uppercase;
  letter-spacing: 0.03em;
}

.switch {
  position: relative;
  display: inline-block;
  width: 38px;
  height: 22px;
  flex-shrink: 0;
}

.switch input {
  opacity: 0;
  width: 0;
  height: 0;
}

.switch .slider {
  position: absolute;
  inset: 0;
  background: #d1d5db;
  border-radius: 999px;
  cursor: pointer;
  transition: background 0.15s ease;
}

.switch .slider::before {
  content: "";
  position: absolute;
  width: 16px;
  height: 16px;
  left: 3px;
  top: 3px;
  background: #fff;
  border-radius: 50%;
  transition: transform 0.15s ease;
}

.switch input:checked + .slider {
  background: #4f6ef7;
}

.switch input:checked + .slider::before {
  transform: translateX(16px);
}

.switch input:disabled + .slider {
  cursor: not-allowed;
  opacity: 0.5;
}

.secondary-btn {
  padding: 10px 18px;
  border: 1px solid #d1d5db;
  border-radius: 8px;
  background: #fff;
  color: #374151;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
}

.secondary-btn:hover {
  background: #f9fafb;
}

.danger-btn {
  border-color: #fecaca;
  color: #dc2626;
}

.danger-btn:hover {
  background: #fef2f2;
}

.maint-connection-status {
  margin: 0;
}

.maint-status-pill {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-size: 14px;
  font-weight: 600;
  padding: 8px 14px;
  border-radius: 999px;
}

.maint-status-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  flex-shrink: 0;
}

.maint-status-pill-connected {
  background: #dcfce7;
  color: #166534;
}

.maint-status-pill-connected .maint-status-dot {
  background: #22c55e;
}

.maint-status-pill-disconnected {
  background: #fef2f2;
  color: #991b1b;
}

.maint-status-pill-disconnected .maint-status-dot {
  background: #ef4444;
}

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

.maint-status-row {
  display: contents;
}

.maint-status-row dt {
  font-size: 13px;
  color: #6b7280;
  margin: 0;
}

.maint-status-row dd {
  font-size: 13px;
  font-weight: 600;
  margin: 0;
}

.maint-status-row dd.ok {
  color: #16a34a;
}

.maint-status-row dd.warn {
  color: #d97706;
}

.maint-code {
  margin-top: 16px;
  padding: 16px;
  border-radius: 12px;
  background: #eef1ff;
  text-align: center;
}

.maint-code-label {
  display: block;
  font-size: 12px;
  color: #6b7280;
  margin-bottom: 6px;
}

.maint-code-value {
  font-size: 32px;
  font-weight: 700;
  letter-spacing: 0.2em;
  color: #4f6ef7;
}

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

.maint-pair-form {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  align-items: center;
}

.maint-section-head {
  margin-bottom: 14px;
}

.maint-section-head h3 {
  margin: 0 0 4px;
}

.maint-note {
  margin: 0;
  font-size: 13px;
  color: #6b7280;
  line-height: 1.45;
}

.maint-settings-panel {
  background: #f9fafb;
  border: 1px solid #eef0f4;
  border-radius: 12px;
  padding: 18px;
}

.maint-settings-form {
  display: block;
}

.maint-settings-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px 16px;
}

.maint-field-wide {
  grid-column: 1 / -1;
}

.maint-field {
  display: grid;
  gap: 6px;
}

.maint-field > span:first-child {
  font-size: 12px;
  font-weight: 600;
  color: #4b5563;
  letter-spacing: 0.01em;
}

.maint-field-hint {
  font-size: 11px;
  color: #9ca3af;
  line-height: 1.35;
}

.maint-paired-phone {
  margin: 0;
  padding: 10px 12px;
  border: 1px solid #e5e7eb;
  border-radius: 8px;
  background: #f9fafb;
  font-size: 14px;
  font-weight: 600;
  color: #111827;
}

.maint-paired-phone.empty {
  font-weight: 500;
  color: #9ca3af;
}

.maint-input {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid #e5e7eb;
  border-radius: 8px;
  font-size: 14px;
  background: #fff;
  color: #111827;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.maint-input::placeholder {
  color: #9ca3af;
}

.maint-input:focus {
  outline: none;
  border-color: #4f6ef7;
  box-shadow: 0 0 0 3px rgba(79, 110, 247, 0.12);
}

.maint-settings-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-top: 16px;
  padding-top: 16px;
  border-top: 1px solid #eef0f4;
}

.maint-inline-status {
  margin: 0;
  font-size: 13px;
  color: #16a34a;
}

.maint-inline-status.error {
  color: #dc2626;
}

.maint-settings-footer .primary-btn {
  flex-shrink: 0;
}

.maint-screenshot-wrap {
  border: 1px solid #e5e7eb;
  border-radius: 12px;
  overflow: hidden;
  background: #f9fafb;
}

.maint-screenshot {
  display: block;
  width: 100%;
  max-height: 520px;
  object-fit: contain;
  background: #111;
}

.maint-screenshot-wrap .hint {
  padding: 10px 12px;
  margin: 0;
}

.forwarder-table-wrap {
  margin-top: 20px;
  overflow-x: auto;
}

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

.forwarder-users-table th,
.forwarder-users-table td {
  padding: 14px 12px;
  text-align: left;
  border-bottom: 1px solid #eef0f4;
  vertical-align: middle;
}

.forwarder-users-table th {
  font-size: 12px;
  font-weight: 600;
  color: #6b7280;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  background: #fafbfc;
}

.forwarder-users-table tbody tr:hover {
  background: #fafbfc;
}

.forwarder-email {
  font-weight: 600;
  color: #111827;
}

.forwarder-pill {
  display: inline-flex;
  align-items: center;
  padding: 4px 10px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 600;
}

.forwarder-pill-ok {
  background: #dcfce7;
  color: #166534;
}

.forwarder-pill-warn {
  background: #fef3c7;
  color: #92400e;
}

.forwarder-platforms {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.forwarder-platform-tag {
  display: inline-block;
  padding: 4px 8px;
  border-radius: 6px;
  background: #eef1ff;
  color: #4f6ef7;
  font-size: 12px;
  font-weight: 600;
}

.forwarder-muted {
  color: #9ca3af;
  font-size: 13px;
}

.forwarder-empty {
  text-align: center;
  color: #9ca3af;
  padding: 32px 12px !important;
}

.hidden {
  display: none !important;
}

.posts-list {
  display: flex;
  flex-direction: column;
  gap: 14px;
  margin-top: 16px;
}

.posts-empty {
  margin-top: 16px;
  padding: 20px;
  border: 1px dashed #d1d5db;
  border-radius: 12px;
  color: #6b7280;
  text-align: center;
}

.posts-item {
  border: 1px solid #e5e7eb;
  border-radius: 12px;
  padding: 16px;
  background: #fafbfc;
}

.posts-item-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 10px;
}

.posts-item-badges {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.posts-type-pill {
  font-size: 12px;
  font-weight: 600;
  padding: 4px 10px;
  border-radius: 999px;
}

.posts-type-post {
  background: #eef2ff;
  color: #4338ca;
}

.posts-type-story {
  background: #fce7f3;
  color: #9d174d;
}

.posts-type-reel {
  background: #ede9fe;
  color: #6d28d9;
}

.posts-date {
  font-size: 13px;
  color: #6b7280;
}

.posts-status-pill {
  font-size: 12px;
  font-weight: 600;
  padding: 4px 10px;
  border-radius: 999px;
}

.posts-status-active {
  background: #dcfce7;
  color: #166534;
}

.posts-status-deleted {
  background: #f3f4f6;
  color: #6b7280;
}

.posts-status-partial {
  background: #fef3c7;
  color: #92400e;
}

.posts-text {
  margin: 0 0 12px;
  line-height: 1.5;
  white-space: pre-wrap;
  word-break: break-word;
}

.posts-media {
  margin-bottom: 12px;
}

.posts-media-image,
.posts-media-video {
  display: block;
  width: 100%;
  max-width: 420px;
  max-height: 420px;
  border-radius: 10px;
  border: 1px solid #e5e7eb;
  background: #f3f4f6;
  object-fit: contain;
}

.posts-platforms {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-bottom: 8px;
}

.posts-platform-badge {
  font-size: 12px;
  font-weight: 600;
  padding: 4px 10px;
  border-radius: 999px;
  background: #eef2ff;
  color: #4338ca;
  text-transform: capitalize;
}

a.posts-platform-badge-link {
  background: #eff6ff;
  color: #2563eb;
  border: 1px solid #bfdbfe;
  text-decoration: none;
}

a.posts-platform-badge-link:hover {
  background: #dbeafe;
  text-decoration: underline;
}

.posts-item-footer {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
}

.posts-deleted-at {
  font-size: 12px;
  color: #9ca3af;
}

.posts-manual-delete-hint {
  font-size: 12px;
  color: #d97706;
}

.posts-delete-result {
  margin: 10px 0 0;
  font-size: 13px;
  white-space: pre-wrap;
  color: #374151;
}

.posts-delete-result.error {
  color: #dc2626;
}

@media (max-width: 640px) {
  .maint-status-grid,
  .maint-settings-grid {
    grid-template-columns: 1fr;
  }

  .maint-settings-footer {
    flex-direction: column;
    align-items: stretch;
  }

  .maint-settings-footer .primary-btn {
    width: 100%;
  }
}

.sidebar-footer {
  margin-top: auto;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.lang-switch-btn {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid #e5e7eb;
  border-radius: 8px;
  background: #fff;
  color: #374151;
  font-size: 14px;
  font-weight: 500;
  text-align: start;
  cursor: pointer;
}

.lang-switch-btn:hover {
  background: #f3f4f6;
}

.auth-lang-switch {
  display: flex;
  justify-content: flex-end;
  margin: -24px -12px 16px;
}

.auth-lang-switch .lang-switch-btn {
  width: auto;
  padding: 6px 12px;
  font-size: 13px;
}

[dir="rtl"] .sidebar {
  border-right: none;
  border-left: 1px solid #e5e7eb;
}

[dir="rtl"] .page-panel .hint,
[dir="rtl"] .page-panel .section h2,
[dir="rtl"] .page-panel .section h3 {
  text-align: right;
}

[dir="rtl"] .section-header {
  flex-direction: row;
  justify-content: flex-start;
}

[dir="rtl"] .section-header > div {
  text-align: right;
}

[dir="rtl"] .platform-list {
  text-align: right;
}

[dir="rtl"] .maint-settings-footer {
  flex-direction: row-reverse;
}

[dir="rtl"] .forwarder-users-table th,
[dir="rtl"] .forwarder-users-table td {
  text-align: right;
}

[dir="rtl"] .posts-item-header {
  flex-direction: row-reverse;
}

[dir="rtl"] .posts-item-badges {
  flex-direction: row-reverse;
}

[dir="rtl"] .posts-item-footer {
  flex-direction: row-reverse;
}

[dir="rtl"] .platform-card .p-top {
  flex-direction: row-reverse;
}

[dir="rtl"] .platform-card .p-bottom {
  flex-direction: row-reverse;
}

