:root {
  --cf-control-bg: rgba(16, 20, 38, 0.7);
  --cf-control-border: rgba(255, 255, 255, 0.18);
  --cf-control-focus: rgba(143, 240, 255, 0.55);
  --cf-control-text: var(--color-text);
  --cf-control-muted: var(--color-muted);
}

.cf-header-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

.cf-sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}


.cf-language-switcher {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 6px 10px;
  border-radius: 999px;
  border: 1px solid var(--cf-control-border);
  background: rgba(255, 255, 255, 0.08);
  backdrop-filter: blur(var(--blur-soft));
}

/* --- Header actions (language + account dropdown) --- */
.cf-header-actions {
  display: inline-flex;
  align-items: center;
  gap: 10px;
}

.cf-account {
  position: relative;
  display: inline-flex;
  align-items: center;
}

.cf-account-trigger {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  padding: 6px 10px;
  border-radius: 999px;
  border: 1px solid var(--cf-control-border);
  background: rgba(255, 255, 255, 0.08);
  backdrop-filter: blur(var(--blur-soft));
}

.cf-account-trigger:hover {
  background: rgba(255, 255, 255, 0.12);
}

.cf-account-trigger:focus {
  outline: 2px solid var(--cf-control-focus);
  outline-offset: 2px;
}

.cf-account-avatar {
  width: 28px;
  height: 28px;
  border-radius: 999px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-weight: 800;
  letter-spacing: 0.02em;
  color: rgba(255, 255, 255, 0.92);
  background: rgba(143, 240, 255, 0.16);
  border: 1px solid rgba(143, 240, 255, 0.28);
  box-shadow: 0 0 0 3px rgba(143, 240, 255, 0.07);
}

.cf-account-email {
  max-width: 320px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  color: rgba(255, 255, 255, 0.92);
  font-size: 13px;
}

.cf-account-caret {
  opacity: 0.7;
  font-size: 12px;
  margin-left: 2px;
}

.cf-account-menu {
  position: absolute;
  right: 0;
  top: calc(100% + 10px);
  width: min(420px, calc(100vw - 24px));
  border-radius: 14px;
  padding: 12px;
  border: 1px solid rgba(255, 255, 255, 0.16);
  background: rgba(10, 14, 28, 0.78);
  backdrop-filter: blur(var(--blur-strong));
  box-shadow: 0 18px 48px rgba(0, 0, 0, 0.55);
  z-index: 50;
}

.cf-account-meta {
  display: grid;
  gap: 10px;
  padding: 4px 2px 10px;
}

.cf-account-meta-row {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 14px;
}

.cf-account-meta-label {
  font-size: 12px;
  opacity: 0.7;
}

.cf-account-meta-value {
  font-size: 12px;
  font-weight: 700;
  color: rgba(255, 255, 255, 0.9);
  text-align: right;
}

.cf-account-sep {
  height: 1px;
  background: rgba(255, 255, 255, 0.12);
  margin: 10px 0;
}

.cf-account-item {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 10px 10px;
  border-radius: 12px;
  color: rgba(255, 255, 255, 0.92);
  text-decoration: none;
  border: 1px solid transparent;
  background: rgba(255, 255, 255, 0.05);
}

.cf-account-item:hover {
  background: rgba(255, 255, 255, 0.09);
}

.cf-account-danger {
  background: rgba(239, 68, 68, 0.12);
  border-color: rgba(239, 68, 68, 0.18);
  color: rgba(255, 255, 255, 0.95);
}

.cf-account-danger:hover {
  background: rgba(239, 68, 68, 0.18);
}

.cf-account-logout {
  margin: 0;
}

.cf-account-ref {
  display: grid;
  gap: 10px;
}

.cf-account-ref-title {
  font-size: 12px;
  opacity: 0.7;
  padding: 0 2px;
}

.cf-account-ref-row {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 10px;
  align-items: center;
}

.cf-account-ref-input {
  width: 100%;
  border-radius: 12px;
  padding: 10px 12px;
}

.cf-account-ref-copy {
  border-radius: 12px;
  padding: 10px 14px;
  white-space: nowrap;
}

.cf-account-ref-note {
  font-size: 12px;
  opacity: 0.75;
  min-height: 16px;
  padding: 0 2px;
}

.cf-account-menu-header {
  padding: 8px 10px 10px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.1);
  margin-bottom: 8px;
}

.cf-account-title {
  font-weight: 700;
  margin-bottom: 4px;
}

.cf-account-subtitle {
  font-size: 12px;
  opacity: 0.75;
}

.cf-muted {
  color: var(--cf-control-muted);
}

.cf-text-sm {
  font-size: 12px;
}

.cf-warning {
  color: #fbbf24;
}

.cf-link {
  color: var(--color-accent-1);
  text-decoration: none;
  font-size: 13px;
}

.cf-link:hover {
  color: #c7f4ff;
}

.cf-inline-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
}

.cf-section-note {
  margin-top: 8px;
}

.cf-section-title {
  margin: 0 0 6px 0;
}

.cf-list {
  margin: 0 0 0 16px;
}

.cf-stack {
  display: grid;
  gap: 12px;
  margin-bottom: 12px;
}

.cf-alert {
  margin-top: 8px;
  padding: 8px 10px;
  border-radius: 10px;
  font-size: 13px;
}

.cf-alert-warning {
  background: rgba(245, 158, 11, 0.14);
  color: #fbbf24;
  border: 1px solid rgba(245, 158, 11, 0.2);
}

.cf-alert-danger {
  background: rgba(239, 68, 68, 0.12);
  color: #fecaca;
  border: 1px solid rgba(239, 68, 68, 0.2);
}

.cf-status-online {
  color: #34d399;
}

.cf-status-offline {
  color: #fca5a5;
}

.cf-badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 2px 8px;
  border-radius: 999px;
  font-size: 11px;
  background: rgba(147, 197, 253, 0.16);
  border: 1px solid rgba(147, 197, 253, 0.3);
  color: #bfdbfe;
  margin-left: 6px;
}

.cf-table thead th {
  text-align: left;
  padding: 8px 6px;
  font-size: 12px;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: rgba(255, 255, 255, 0.7);
}

.cf-table tbody tr {
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
}

.cf-table tbody tr:hover {
  background: rgba(255, 255, 255, 0.04);
}

.cf-table td {
  padding: 8px 6px;
  vertical-align: top;
}

.cf-icon-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 34px;
  height: 34px;
  padding: 0;
  border-radius: 10px;
  border: 1px solid rgba(255, 255, 255, 0.14);
  background: rgba(255, 255, 255, 0.08);
  color: #e5e7eb;
  font-weight: 700;
  line-height: 1;
}

.cf-icon-btn:hover {
  background: rgba(255, 255, 255, 0.14);
}

.cf-dash-section-header {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-bottom: 16px;
}

.cf-dash-section-header p {
  margin: 0;
  font-size: 14px;
}

.cf-dash-grid {
  display: grid;
  gap: 16px;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  margin-bottom: 16px;
}

.cf-dash-grid-wide {
  grid-template-columns: repeat(auto-fit, minmax(320px, 1fr));
}

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

.cf-dash-card-header h3 {
  margin: 0;
  font-size: 18px;
}

.cf-dash-card-body {
  display: grid;
  gap: 10px;
}

.cf-stat-list {
  display: grid;
  gap: 8px;
}

.cf-stat-row {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  font-size: 14px;
}

.cf-dash-subcard {
  margin-top: 12px;
  padding: 12px;
  border-radius: 12px;
  border: 1px solid rgba(255, 255, 255, 0.12);
  background: rgba(15, 23, 42, 0.25);
}

.cf-section-block {
  margin-top: 12px;
}

.cf-analytics-grid {
  display: grid;
  gap: 16px;
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
}

.cf-analytics-card {
  border-radius: 14px;
  border: 1px solid rgba(255, 255, 255, 0.12);
  background: rgba(10, 14, 28, 0.55);
  padding: 14px;
  display: grid;
  gap: 12px;
}

.cf-chart-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.cf-chart-header h3 {
  margin: 0;
  font-size: 16px;
}

.cf-chart-legend {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-size: 12px;
  color: rgba(255, 255, 255, 0.7);
}

.cf-chart-dot {
  display: inline-block;
  width: 8px;
  height: 8px;
  border-radius: 999px;
  margin-right: 4px;
}

.cf-chart-dot-primary { background: #8ff0ff; }
.cf-chart-dot-secondary { background: #7a5cff; }
.cf-chart-dot-warning { background: #fbbf24; }

.cf-chart {
  width: 100%;
  min-height: 200px;
  border-radius: 12px;
  background: rgba(15, 23, 42, 0.3);
  border: 1px solid rgba(255, 255, 255, 0.08);
  display: grid;
  place-items: center;
}

.cf-chart svg {
  width: 100%;
  height: auto;
}

.cf-chart-note {
  margin-top: 12px;
  font-size: 13px;
  color: rgba(255, 255, 255, 0.7);
}

.cf-provider-list {
  display: grid;
  gap: 12px;
}

.cf-provider-card {
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 12px;
  padding: 12px;
  background: rgba(15, 23, 42, 0.35);
}

.cf-provider-header {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.cf-provider-status {
  font-size: 12px;
  color: rgba(255, 255, 255, 0.6);
}

.cf-provider-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 8px;
}

.cf-album-create-stack {
  display: grid;
  gap: 6px;
}

.cf-device-name-display {
  background: transparent;
  border: none;
  padding: 0;
  color: inherit;
  font: inherit;
  text-align: left;
  cursor: pointer;
}

.cf-device-name-display:hover {
  text-decoration: underline;
}

.cf-device-name-form {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  align-items: center;
  margin-top: 6px;
}

.cf-device-name-form input {
  min-width: 160px;
}

.cf-album-title {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
  min-width: 0;
  overflow-wrap: anywhere;
  word-break: break-word;
}

.cf-album-status-badge {
  display: inline-flex;
  align-items: center;
  border-radius: 999px;
  padding: 2px 8px;
  font-size: 11px;
  font-weight: 600;
  background: rgba(245, 158, 11, 0.15);
  color: #b45309;
}

.cf-album-status-badge.is-critical {
  background: rgba(239, 68, 68, 0.15);
  color: #b91c1c;
}

.cf-tab-panel label {
  display: grid;
  grid-template-columns: minmax(160px, 1fr) minmax(160px, 260px);
  gap: 10px;
  align-items: center;
  margin: 10px 0;
}

.cf-tab-panel label > span {
  color: rgba(255, 255, 255, 0.85);
}

.cf-tab-panel input,
.cf-tab-panel select {
  width: 100%;
  max-width: 100%;
}

.cf-help-full {
  margin: 0 0 12px 0;
  padding: 10px 12px;
  border-radius: 10px;
  border: 1px solid rgba(255, 255, 255, 0.12);
  background: rgba(15, 23, 42, 0.25);
  color: #e5e7eb;
  font-size: 13px;
  line-height: 1.5;
}

.cf-help-full p {
  margin: 0 0 8px 0;
}

.cf-help-full p:last-child {
  margin-bottom: 0;
}

.cf-help-compact {
  display: flex;
  align-items: center;
  gap: 10px;
  margin: 0 0 12px 0;
  color: rgba(255, 255, 255, 0.7);
  font-size: 13px;
}

.cf-help-dialog {
  max-width: 520px;
  border-radius: 12px;
  border: 1px solid rgba(255, 255, 255, 0.18);
  background: #0f172a;
  color: #e5e7eb;
  padding: 16px;
}

.cf-help-dialog::backdrop {
  background: rgba(15, 23, 42, 0.65);
}

.cf-help-dialog-body p {
  margin: 0 0 10px 0;
}

.cf-help-dialog-body p:last-child {
  margin-bottom: 0;
}

.cf-help-dialog-actions {
  display: flex;
  justify-content: flex-end;
  margin-top: 16px;
}

.album-sync-badge {
  padding: 2px 6px;
  border-radius: 999px;
  font-size: 12px;
  background: rgba(15, 23, 42, 0.8);
  color: #e5e7eb;
}

.cf-provider-folder {
  margin: 6px 0;
}

.cf-mailru-form {
  display: grid;
  gap: 6px;
}

@media (max-width: 768px) {
  .cf-account-email { display: none; }
  .cf-account-menu { width: min(420px, calc(100vw - 16px)); }
}

button,
input:not([type="checkbox"]):not([type="radio"]),
select,
textarea {
  font-family: inherit;
  font-size: 14px;
  color: var(--cf-control-text);
  background: var(--cf-control-bg);
  border: 1px solid var(--cf-control-border);
  border-radius: 12px;
  padding: 8px 12px;
  transition: border-color 0.2s ease, box-shadow 0.2s ease, background 0.2s ease, transform 0.2s ease;
}

button,
input[type="submit"] {
  cursor: pointer;
  font-weight: 600;
  background: rgba(255, 255, 255, 0.1);
}

button:hover,
input[type="submit"]:hover {
  background: rgba(255, 255, 255, 0.18);
  transform: translateY(-1px);
}

button:disabled,
input:disabled,
select:disabled,
textarea:disabled {
  opacity: 0.55;
  cursor: not-allowed;
  background: rgba(255, 255, 255, 0.06);
}

button:focus,
input:not([type="checkbox"]):not([type="radio"]):focus,
select:focus,
textarea:focus {
  outline: 2px solid var(--cf-control-focus);
  outline-offset: 1px;
  border-color: transparent;
  box-shadow: 0 0 0 3px rgba(143, 240, 255, 0.12);
}

input:not([type="checkbox"]):not([type="radio"])::placeholder,
textarea::placeholder {
  color: var(--cf-control-muted);
}

input[type="checkbox"],
input[type="radio"] {
  width: 16px;
  height: 16px;
  accent-color: var(--color-accent-1);
}

select {
  min-width: 120px;
}

table.cf-responsive-table {
  width: 100%;
  border-collapse: collapse;
}

.cf-filter-bar {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  align-items: center;
  margin-bottom: 12px;
}

.cf-pagination {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  align-items: center;
  margin-top: 12px;
  font-size: 13px;
}

.cf-pagination a,
.cf-pagination span {
  padding: 6px 10px;
  border-radius: 999px;
  border: 1px solid var(--cf-control-border);
  color: var(--cf-control-text);
  text-decoration: none;
  background: rgba(255, 255, 255, 0.05);
}

.cf-pagination .is-current {
  background: rgba(143, 240, 255, 0.18);
  border-color: rgba(143, 240, 255, 0.4);
  color: var(--cf-control-text);
}

.cf-pagination .is-disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

@media (max-width: 1024px) {
  .cf-responsive-table thead {
    display: none;
  }
  .cf-responsive-table tbody tr {
    display: block;
    border: 1px solid rgba(255, 255, 255, 0.14);
    border-radius: 14px;
    padding: 10px 12px;
    margin-bottom: 12px;
    background: rgba(15, 23, 42, 0.35);
  }
  .cf-responsive-table tbody tr:last-child {
    margin-bottom: 0;
  }
  .cf-responsive-table td {
    display: grid;
    grid-template-columns: minmax(160px, 35%) minmax(0, 1fr);
    gap: 10px;
    padding: 6px 0;
  }
  .cf-responsive-table td::before {
    content: attr(data-label);
    font-weight: 600;
    color: #cbd5f5;
  }
  .cf-responsive-table td > * {
    min-width: 0;
  }
}

@media (max-width: 768px) {
  .cf-responsive-table td {
    grid-template-columns: 1fr;
  }
  .cf-responsive-table td::before {
    margin-bottom: 4px;
  }
}

/* --- Dialogs (account delete) --- */
.cf-dialog {
  border: 1px solid rgba(255, 255, 255, 0.16);
  border-radius: 16px;
  padding: 0;
  background: rgba(10, 14, 28, 0.88);
  color: rgba(255, 255, 255, 0.92);
  backdrop-filter: blur(var(--blur-strong));
  box-shadow: 0 18px 48px rgba(0, 0, 0, 0.6);
}

.cf-dialog::backdrop {
  background: rgba(0, 0, 0, 0.55);
  backdrop-filter: blur(2px);
}

.cf-dialog-content {
  padding: 18px 18px 16px;
}

.cf-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  border-radius: 12px;
  padding: 10px 14px;
  border: 1px solid var(--cf-control-border);
  background: rgba(255, 255, 255, 0.08);
  color: rgba(255, 255, 255, 0.92);
  font-weight: 700;
}

.cf-btn:hover {
  background: rgba(255, 255, 255, 0.14);
}

.cf-btn-danger {
  border-color: rgba(239, 68, 68, 0.22);
  background: rgba(239, 68, 68, 0.16);
}

.cf-btn-danger:hover {
  background: rgba(239, 68, 68, 0.22);
}

.cf-menu-item {
  width: 100%;
  text-align: left;
  padding: 10px 10px;
  border-radius: 12px;
  border: 1px solid transparent;
  background: transparent;
}

.cf-menu-item:hover {
  background: rgba(255, 255, 255, 0.08);
}

.cf-menu-danger {
  color: #fecaca;
}

.cf-menu-sep {
  height: 1px;
  background: rgba(255, 255, 255, 0.10);
  margin: 8px 0;
}

.cf-menu-form {
  margin: 0;
}

@media (max-width: 1024px) {
  .cf-responsive-table .cf-album-form {
    width: 100%;
  }
  .cf-responsive-table .cf-album-form label {
    grid-template-columns: 1fr;
  }
  .cf-responsive-table .cf-album-form input,
  .cf-responsive-table .cf-album-form select,
  .cf-responsive-table .cf-album-form button {
    width: 100%;
  }
  .cf-responsive-table .cf-form-actions {
    justify-content: flex-start;
  }
}

@media (max-width: 640px) {
  .cf-tab-panel label {
    grid-template-columns: 1fr;
  }
}

/* =========================
   Dashboard shell (cf-dash-*)
   ========================= */
body.cf-dashboard-page .site-header,
body.cf-dashboard-page .site-footer {
  display: none;
}

body.cf-dashboard-page main,
body.cf-dashboard-page .content,
body.cf-dashboard-page .container {
  max-width: none;
  width: 100%;
  padding: 0;
  margin: 0;
}

.cf-dash-shell {
  min-height: 100vh;
  display: grid;
  grid-template-columns: 280px minmax(0, 1fr);
  gap: 0;
}

.cf-dash-sidebar {
  position: sticky;
  top: 0;
  height: 100vh;
  padding: 18px;
  border-right: 1px solid rgba(255,255,255,0.08);
  background: rgba(10, 12, 18, 0.40);
  backdrop-filter: blur(18px);
}

.cf-dash-sidebar-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 14px;
}

.cf-dash-sidebar-title {
  font-weight: 800;
  font-size: 18px;
  letter-spacing: 0.2px;
}

.cf-dash-toggle {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 1px solid rgba(255,255,255,0.14);
  border-radius: 14px;
  padding: 10px 12px;
  background: rgba(255,255,255,0.06);
  color: inherit;
  cursor: pointer;
}

.cf-dash-nav {
  display: grid;
  gap: 8px;
  margin-top: 10px;
}

.cf-dash-link {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  border-radius: 14px;
  text-decoration: none;
  color: rgba(255,255,255,0.78);
  border: 1px solid rgba(255,255,255,0.06);
  background: rgba(255,255,255,0.03);
}

.cf-dash-link:hover {
  color: rgba(255,255,255,0.92);
  border-color: rgba(255,255,255,0.12);
  background: rgba(255,255,255,0.06);
}

.cf-dash-link.is-active {
  color: rgba(255,255,255,0.95);
  border-color: rgba(180,140,255,0.35);
  background: rgba(180,140,255,0.10);
}

.cf-dash-overlay {
  display: none;
}

/* Main */
.cf-dash-main {
  min-width: 0;
  padding: 24px;
}

.cf-dash-mobile-bar {
  display: none;
  align-items: center;
  gap: 12px;
  margin-bottom: 16px;
}

/* Sections: показываем одну активную (JS переключает) */
.cf-dash-section {
  margin-bottom: 32px;
  display: none;
}
.cf-dash-section.is-active {
  display: block;
}

/* If JS didn't run, keep usable fallback */
html:not(.cf-dash-js) .cf-dash-section {
  display: block;
}

/* Mobile */
@media (max-width: 980px) {
  .cf-dash-shell {
    grid-template-columns: 1fr;
  }

  .cf-dash-sidebar {
    position: fixed;
    inset: 0 auto 0 0;
    width: 86vw;
    max-width: 320px;
    transform: translateX(-105%);
    transition: transform 160ms ease;
    z-index: 50;
  }

  .cf-dash-shell.is-open .cf-dash-sidebar {
    transform: translateX(0);
  }

  .cf-dash-overlay {
    display: block;
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.45);
    backdrop-filter: blur(2px);
    opacity: 0;
    pointer-events: none;
    transition: opacity 160ms ease;
    z-index: 40;
  }

  .cf-dash-shell.is-open .cf-dash-overlay {
    opacity: 1;
    pointer-events: auto;
  }

  .cf-dash-main {
    padding: 18px;
  }

  .cf-dash-mobile-bar {
    display: flex;
    align-items: center;
    gap: 12px;
    position: sticky;
    top: 0;
    z-index: 10;
    padding: 10px 10px;
    margin: -18px -18px 18px -18px;
    border-bottom: 1px solid rgba(255,255,255,0.08);
    background: rgba(10, 12, 18, 0.40);
    backdrop-filter: blur(18px);
  }

  .cf-dash-mobile-title {
    font-weight: 800;
    opacity: 0.9;
  }
}
