/* === OZ.tools Design System v2 === */

/* --- Font faces --- */
@font-face {
  font-family: 'Inter';
  src: url('fonts/Inter-Regular.woff2') format('woff2');
  font-weight: 400;
  font-style: normal;
  font-display: swap;
}
@font-face {
  font-family: 'Inter';
  src: url('fonts/Inter-Medium.woff2') format('woff2');
  font-weight: 500;
  font-style: normal;
  font-display: swap;
}
@font-face {
  font-family: 'Inter';
  src: url('fonts/Inter-SemiBold.woff2') format('woff2');
  font-weight: 600;
  font-style: normal;
  font-display: swap;
}
@font-face {
  font-family: 'Inter';
  src: url('fonts/Inter-Bold.woff2') format('woff2');
  font-weight: 700;
  font-style: normal;
  font-display: swap;
}

/* --- Tokens --- */
:root {
  --ds-bg-page: #F5F5F5;
  --ds-bg-card: #FFFFFF;
  --ds-brand: #424242;
  --ds-brand-financial: #4f8cff;
  --ds-tier-pro: #7E57C2;
  --ds-text-secondary: #666666;
  --ds-text-muted: #999999;
  --ds-border: #E0E0E0;
  --ds-success: #2E7D32;
  --ds-error: #C62828;
  --ds-warning: #F9A825;
  --ds-radius: 8px;
  --ds-radius-lg: 12px;
  --ds-font: Inter, system-ui, -apple-system, 'Segoe UI', sans-serif;
}

/* --- Reset + Base --- */
*, *::before, *::after { box-sizing: border-box; }
[hidden] { display: none !important; }
body {
  font-family: var(--ds-font);
  margin: 0;
  background: var(--ds-bg-page);
  color: var(--ds-brand);
  font-size: 14px;
  line-height: 1.5;
}
a { color: var(--ds-brand-financial); text-decoration: none; }
a:hover { text-decoration: underline; }
h1 { font-size: 24px; font-weight: 600; margin: 0 0 8px; }
h2 { font-size: 18px; font-weight: 600; margin: 24px 0 12px; }
h3 { font-size: 15px; font-weight: 600; margin: 16px 0 8px; }

/* --- Layout --- */
.ds-wrap {
  max-width: 480px;
  margin: 40px auto;
  padding: 32px;
  background: var(--ds-bg-card);
  border-radius: var(--ds-radius-lg);
  box-shadow: 0 1px 4px rgba(0,0,0,.06);
}
.ds-wrap-wide { max-width: 720px; }
.ds-wrap-admin { max-width: 1200px; }
.ds-wrap-full {
  max-width: none;
  margin: 0;
  padding: 0;
  background: none;
  border-radius: 0;
  box-shadow: none;
}

/* --- Header --- */
.ds-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 24px;
  height: 48px;
  background: var(--ds-bg-card);
  border-bottom: 1px solid var(--ds-border);
}
.ds-header-logo {
  font-weight: 700;
  color: var(--ds-brand);
  font-size: 15px;
  text-decoration: none;
}
.ds-header-logo:hover { text-decoration: none; }
.ds-header-logo span {
  font-weight: 400;
  color: var(--ds-text-muted);
}
.ds-header-left {
  display: flex;
  align-items: center;
  gap: 8px;
}
.ds-header-separator {
  color: var(--ds-text-muted);
  font-weight: 400;
}
.ds-header-service {
  color: var(--ds-text-secondary);
  font-weight: 400;
  font-size: 15px;
  max-width: 32ch;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.ds-header-service-link {
  color: var(--ds-brand-financial);
  text-decoration: none;
}
.ds-header-service-link:hover { text-decoration: underline; }
.ds-header-breadcrumb-current { color: var(--ds-text-primary); font-weight: 500; }
.ds-header-right {
  display: flex;
  align-items: center;
  gap: 12px;
}
.ds-header-email {
  color: var(--ds-text-secondary);
  font-size: 13px;
  font-weight: 500;
}
.ds-header-link {
  color: var(--ds-brand-financial);
  font-size: 13px;
  font-weight: 500;
  text-decoration: none;
}
.ds-header-link:hover { text-decoration: underline; }
#oz-header { min-height: 48px; }

/* --- Navigation --- */
.ds-nav {
  display: flex;
  gap: 0;
  background: var(--ds-bg-card);
  border-bottom: 1px solid var(--ds-border);
  padding: 0 24px;
}
.ds-nav-link {
  color: var(--ds-text-secondary);
  text-decoration: none;
  padding: 10px 16px;
  font-size: 13px;
  font-weight: 500;
  border-bottom: 2px solid transparent;
}
.ds-nav-link:hover {
  color: var(--ds-brand);
  text-decoration: none;
}
.ds-nav-link.active {
  color: var(--ds-brand);
  border-bottom-color: var(--ds-brand);
}
.ds-nav-admin {
  margin-left: auto;
  color: var(--ds-warning);
}

/* --- Buttons --- */
.ds-btn {
  display: inline-block;
  padding: 10px 20px;
  border-radius: var(--ds-radius);
  font-size: 14px;
  font-weight: 500;
  font-family: var(--ds-font);
  cursor: pointer;
  border: none;
  text-decoration: none;
  text-align: center;
  line-height: 1.4;
  transition: background 0.15s;
}
.ds-btn:hover { text-decoration: none; }
.ds-btn:disabled,
.ds-btn[disabled] {
  opacity: 0.5;
  cursor: not-allowed;
  pointer-events: none;
}
.ds-btn-primary {
  background: var(--ds-brand-financial);
  color: #fff;
}
.ds-btn-primary:hover { background: #3d7ae6; }
.ds-btn-dark {
  background: var(--ds-brand);
  color: #fff;
}
.ds-btn-dark:hover { background: #333; }
.ds-btn-secondary {
  background: transparent;
  color: var(--ds-brand);
  border: 1px solid var(--ds-border);
}
.ds-btn-secondary:hover { background: #f5f5f5; }
.ds-btn-success {
  background: var(--ds-success);
  color: #fff;
}
.ds-btn-danger {
  background: var(--ds-error);
  color: #fff;
}
.ds-btn-muted {
  background: var(--ds-text-secondary);
  color: #fff;
}
.ds-btn-sm { padding: 6px 12px; font-size: 13px; }
.ds-btn-icon {
  width: 32px;
  height: 32px;
  padding: 0;
  font-size: 15px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  vertical-align: middle;
}
.ds-btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

/* --- Inputs --- */
.ds-input, .ds-select, .ds-textarea {
  display: block;
  width: 100%;
  padding: 10px 14px;
  font-size: 14px;
  font-family: var(--ds-font);
  border: 1px solid var(--ds-border);
  border-radius: var(--ds-radius);
  background: var(--ds-bg-card);
  color: var(--ds-brand);
  outline: none;
  transition: border-color 0.15s, box-shadow 0.15s;
}
.ds-input:focus, .ds-select:focus, .ds-textarea:focus {
  border-color: var(--ds-brand-financial);
  box-shadow: 0 0 0 3px rgba(79,140,255,0.1);
}
.ds-input[readonly], .ds-input:disabled,
.ds-select:disabled, .ds-textarea[readonly], .ds-textarea:disabled {
  background: var(--ds-bg-soft, #f5f5f5);
  color: var(--ds-text-secondary);
  cursor: not-allowed;
}
.ds-input[readonly]:focus, .ds-textarea[readonly]:focus {
  border-color: var(--ds-border);
  box-shadow: none;
}
.ds-textarea { resize: vertical; }
.ds-label {
  display: block;
  margin: 12px 0;
  font-size: 14px;
  font-weight: 500;
}
.ds-label > .ds-input,
.ds-label > .ds-select,
.ds-label > .ds-textarea {
  margin-top: 4px;
}

/* --- Cards --- */
.ds-card {
  background: var(--ds-bg-card);
  border: 1px solid var(--ds-border);
  border-radius: var(--ds-radius-lg);
  padding: 24px;
}

/* --- Badges (tier) --- */
.ds-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 12px;
  border-radius: 20px;
  font-size: 12px;
  font-weight: 500;
}
.ds-badge-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: currentColor;
}
.ds-badge-free { background: #E8F5E9; color: var(--ds-success); }
.ds-badge-start { background: #E3F2FD; color: var(--ds-brand-financial); }
.ds-badge-pro { background: #EDE7F6; color: var(--ds-tier-pro); }

/* --- Status pills --- */
.ds-status {
  display: inline-block;
  padding: 2px 10px;
  border-radius: 4px;
  font-size: 12px;
  font-weight: 500;
}
.ds-status-new { background: #FFF8E1; color: #F57F17; }
.ds-status-approved { background: #E8F5E9; color: var(--ds-success); }
.ds-status-rejected { background: #FFEBEE; color: var(--ds-error); }

/* --- Company sections (page /company) --- */
.company-section {
  background: var(--ds-bg-card);
  border: 1px solid var(--ds-border);
  border-radius: var(--ds-radius-lg);
  padding: 24px;
  margin-bottom: 24px;
}
.company-section > h2 {
  margin: 0 0 8px 0;
  font-size: 18px;
  font-weight: 600;
}
.company-section > .section-hint {
  margin: 0 0 16px 0;
  font-size: 14px;
  color: var(--ds-text-muted);
}
.company-section > .section-hint:last-child {
  margin-bottom: 0;
}
.company-section--danger {
  background: transparent;
  border: 1px dashed var(--ds-border);
}

.member-row,
.invitation-row {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 0;
  border-bottom: 1px solid var(--ds-border);
}
.member-row:last-child,
.invitation-row:last-child { border-bottom: none; }
.member-email,
.invitation-email {
  flex: 1 1 auto;
  font-weight: 500;
}
.member-role,
.invitation-role {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 12px;
  background: var(--ds-bg-page);
  font-size: 12px;
  color: var(--ds-text-secondary);
}
.member-actions,
.invitation-actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.audit-list {
  list-style: none;
  margin: 0;
  padding: 0;
}
.audit-item {
  display: flex;
  gap: 12px;
  padding: 8px 0;
  border-bottom: 1px solid var(--ds-border);
  font-size: 13px;
}
.audit-item:last-child { border-bottom: none; }
.audit-ts {
  color: var(--ds-text-muted);
  white-space: nowrap;
}

/* --- Wallets --- */
.ds-wallets {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 10px;
  margin: 16px 0;
}
.ds-wallet {
  background: var(--ds-bg-page);
  border-radius: var(--ds-radius);
  padding: 14px;
  text-align: center;
}
.ds-wallet-total {
  background: var(--ds-brand);
  color: #fff;
}
.ds-wallet-label {
  display: block;
  font-size: 11px;
  color: var(--ds-text-muted);
  margin-bottom: 4px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}
.ds-wallet-total .ds-wallet-label { color: rgba(255,255,255,0.7); }
.ds-wallet-value {
  display: block;
  font-size: 22px;
  font-weight: 600;
}

/* --- Tables --- */
.ds-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
  margin: 8px 0;
}
.ds-table th {
  text-align: left;
  padding: 8px;
  border-bottom: 2px solid var(--ds-border);
  color: var(--ds-text-secondary);
  font-weight: 500;
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.3px;
}
.ds-table td {
  padding: 8px;
  border-bottom: 1px solid #f0f0f0;
}
.ds-table tbody tr:hover { background: #fafafa; }

/* --- Tariff cards --- */
.ds-tariffs {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 16px;
  margin: 16px 0;
}
.ds-tariff-card {
  background: var(--ds-bg-page);
  border: 1px solid var(--ds-border);
  border-radius: var(--ds-radius-lg);
  padding: 24px;
  text-align: center;
}
.ds-tariff-card.featured {
  border-color: var(--ds-tier-pro);
  border-width: 2px;
}
.ds-tariff-price {
  font-size: 20px;
  font-weight: 600;
  margin: 8px 0;
}

/* --- Payment methods --- */
.ds-payment-methods {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 12px;
  margin: 12px 0;
}
.ds-method-card {
  background: var(--ds-bg-page);
  border-radius: var(--ds-radius);
  padding: 16px;
}
.ds-method-card h4 { margin: 0 0 4px; font-size: 14px; }
.ds-method-card p { margin: 0; font-size: 13px; color: var(--ds-text-secondary); }

/* --- Pagination --- */
.ds-pagination { display: flex; gap: 8px; margin: 12px 0; }

/* --- Utility --- */
.ds-hint { color: var(--ds-text-secondary); font-size: 13px; }
.ds-error,
.error-text { color: var(--ds-error); font-size: 14px; }

/* --- Toast --- */
.ds-toast {
  position: fixed;
  top: 20px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 9999;
  padding: 12px 20px;
  border-radius: 8px;
  font-size: 14px;
  font-weight: 500;
  box-shadow: 0 8px 24px rgba(0,0,0,0.15);
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.2s ease;
}
.ds-toast.ds-toast--show { opacity: 1; }
.ds-toast--success { background: #16a34a; color: #fff; }
.ds-toast--error { background: var(--ds-error); color: #fff; }
.ds-positive { color: var(--ds-success); }
.ds-negative { color: var(--ds-error); }
.ds-text-muted { color: var(--ds-text-muted); }
.ds-text-center { text-align: center; }
.ds-mt-1 { margin-top: 8px; }
.ds-mt-2 { margin-top: 16px; }
.ds-mt-3 { margin-top: 24px; }
.ds-mt-4 { margin-top: 32px; }
.ds-mb-1 { margin-bottom: 8px; }
.ds-mb-2 { margin-bottom: 16px; }

/* --- Modal overlay --- */
.ds-modal-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.55);
  z-index: 100;
  align-items: center;
  justify-content: center;
  padding: 16px;
  overflow-y: auto;
}
.ds-modal-overlay:not([hidden]),
.ds-modal-overlay.is-open {
  display: flex;
}
.ds-modal-overlay.hidden { display: none; }
body.modal-open { overflow: hidden; }

/* Generic visibility helper used by templates without their own state CSS */
.hidden { display: none !important; }

/* --- Form / vertical stack helper ---
 * Use on any container where children should sit vertically with breathing
 * room: forms with input + button, blocks of label+input pairs, modal bodies.
 * `.ds-stack > .ds-input, .ds-stack > .ds-select` get `width: 100%` so that
 * inputs span the container width consistently. */
.ds-stack {
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: 12px;
}
.ds-stack > .ds-input,
.ds-stack > .ds-select,
.ds-stack > .ds-textarea {
  width: 100%;
}
.ds-stack > .ds-btn {
  align-self: flex-start;
}
.ds-stack-tight { gap: 8px; }
.ds-stack-loose { gap: 20px; }

/* --- Form field (label + input/select stack) ---
 * Use as a wrapper around a label + input pair when the form is laid out as
 * blocks rather than inline (.ds-label). Pair with .ds-stack on the parent
 * <form> to get consistent spacing between fields. */
.ds-field {
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.ds-field > label {
  font-size: 13px;
  font-weight: 500;
  color: var(--ds-text-secondary);
}
.ds-field > .ds-input,
.ds-field > .ds-select,
.ds-field > .ds-textarea {
  width: 100%;
}

.ds-modal {
  position: relative;
  background: var(--ds-bg-card);
  border-radius: var(--ds-radius-lg);
  padding: 28px;
  width: 100%;
  max-width: 480px;
  max-height: calc(100vh - 32px);
  overflow-y: auto;
  box-shadow: 0 24px 60px rgba(0, 0, 0, 0.25);
  animation: ds-modal-pop 120ms ease-out;
}
.ds-modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 12px;
}
.ds-modal-title {
  margin: 0;
  font-size: 18px;
  font-weight: 600;
  color: var(--ds-text);
}
.ds-modal-close {
  position: absolute;
  top: 12px;
  right: 12px;
  width: 32px;
  height: 32px;
  border: none;
  background: transparent;
  border-radius: 50%;
  font-size: 16px;
  line-height: 1;
  color: var(--ds-text-muted);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
}
.ds-modal-close:hover {
  background: var(--ds-bg-page);
  color: var(--ds-text);
}
@keyframes ds-modal-pop {
  from { opacity: 0; transform: translateY(8px) scale(0.98); }
  to   { opacity: 1; transform: translateY(0) scale(1); }
}

/* --- Responsive --- */
@media (max-width: 600px) {
  .ds-wallets { grid-template-columns: repeat(2, 1fr); }
  .ds-tariffs { grid-template-columns: 1fr; }
  .ds-payment-methods { grid-template-columns: 1fr; }
  .ds-modal-overlay { padding: 0; align-items: flex-end; }
  .ds-modal {
    max-width: 100%;
    max-height: 92vh;
    border-radius: var(--ds-radius-lg) var(--ds-radius-lg) 0 0;
    padding: 20px;
  }
}

.ds-modal--wide {
  max-width: 1200px;
  min-height: 600px;
  padding: 24px;
}

.ds-modal-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 24px;
  align-items: stretch;
}

@media (max-width: 600px) {
  .ds-modal-grid {
    grid-template-columns: 1fr;
  }
}

/* Image templates scoping additions — 2026-05-13 */

.is-hidden {
  display: none !important;
}

.ds-chip {
  display: inline-flex;
  align-items: center;
  padding: 4px 10px;
  border-radius: 12px;
  font-size: 12px;
  gap: 4px;
  background: #fff;
  border: 1px solid var(--ds-border);
  color: var(--ds-text);
  cursor: pointer;
  transition: background 0.12s, border-color 0.12s, color 0.12s;
}
button.ds-chip { font-family: inherit; }
.ds-chip:hover {
  background: #f3f4f6;
  border-color: #9ca3af;
}
.ds-chip--selected {
  background: var(--ds-primary, #4f46e5);
  border-color: var(--ds-primary, #4f46e5);
  color: #fff;
}
.ds-chip--selected:hover {
  background: var(--ds-primary, #4f46e5);
  border-color: var(--ds-primary, #4f46e5);
}
.ds-chip-cloud {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  align-items: center;
}

.ds-chip-muted {
  background: var(--ds-color-bg-muted, #e5e7eb);
  color: var(--ds-color-text-muted, #6b7280);
  border-color: transparent;
  cursor: default;
}

.ds-chip-success {
  background: var(--ds-color-bg-success-soft, #d1fae5);
  color: var(--ds-color-text-success, #065f46);
  border-color: transparent;
  cursor: default;
}

/* Admin filter layout — label + control в одну строку. */
.admin-filters {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-bottom: 16px;
}
.admin-filter-row {
  display: flex;
  align-items: center;
  gap: 12px;
}
.admin-filter-row > .ds-label {
  flex: 0 0 120px;
  font-weight: 500;
  font-size: 13px;
  color: var(--ds-text-secondary);
  margin: 0;
}
.admin-filter-row > .ds-select,
.admin-filter-row > .ds-input {
  flex: 1;
}
.admin-filter-row > .ds-chip-cloud {
  flex: 1;
  min-height: 32px;
}
.admin-filter-actions {
  margin-top: 4px;
}

.ds-modal-lg {
  max-width: 720px;
  max-height: 90vh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}
.ds-modal-lg > h2 { flex-shrink: 0; }
.ds-modal-lg > form {
  display: flex;
  flex-direction: column;
  flex: 1 1 auto;
  min-height: 0;
  overflow: hidden;
}
.ds-modal-body {
  overflow-y: auto;
  flex: 1 1 auto;
  min-height: 0;
  padding-right: 4px; /* room for scrollbar */
}

/* Inline form field — label слева, control 1fr. Используется в admin modal. */
.ds-field-inline {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 12px;
}
.ds-field-inline > label {
  flex: 0 0 160px;
  font-size: 13px;
  font-weight: 500;
  color: var(--ds-text-secondary);
  margin: 0;
}
.ds-field-inline > .ds-input,
.ds-field-inline > .ds-select {
  flex: 1;
}
.ds-field-inline > .ds-field-control {
  flex: 1;
  display: flex;
  flex-direction: column;
}
.ds-field-inline > .ds-field-control > .ds-hint {
  margin: 4px 0 0;
  font-size: 12px;
}
.ds-field-inline > .ds-radio-group {
  flex: 1;
  display: flex;
  flex-wrap: wrap;
  gap: 16px;
}

.ds-modal-footer {
  display: flex;
  gap: 8px;
  justify-content: flex-end;
  margin-top: 16px;
  flex-shrink: 0;
  padding-top: 12px;
  border-top: 1px solid var(--ds-border);
}

.ds-textarea-mono {
  font-family: ui-monospace, "SF Mono", Menlo, Monaco, Consolas, monospace;
  font-size: 13px;
}

.ds-banner {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 16px;
  border-radius: 6px;
  margin: 8px 0;
}

.ds-banner-info {
  background: var(--ds-color-bg-info-soft, #dbeafe);
  color: var(--ds-color-text-info, #1e40af);
  border-left: 4px solid var(--ds-color-info, #3b82f6);
}

.ds-banner-warning {
  background: var(--ds-color-bg-warning-soft, #fef9c3);
  color: var(--ds-color-text-warning, #854d0e);
  border-left: 4px solid var(--ds-color-warning, #eab308);
}

.ds-radio-group {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
}

.ds-radio-group label {
  display: inline-flex;
  align-items: center;
  gap: 4px;
}

.ds-hint-warning {
  color: var(--ds-color-text-warning, #92400e);
  background: var(--ds-color-bg-warning-soft, #fef3c7);
  padding: 8px 12px;
  border-radius: 4px;
}

.ds-hint-error {
  color: var(--ds-color-text-danger, #b91c1c);
}

.ds-empty-state {
  text-align: center;
  padding: 32px 16px;
  color: var(--ds-color-text-muted, #6b7280);
}

.ds-empty-state p {
  margin-bottom: 12px;
}

.ds-counter {
  display: inline-block;
  padding: 2px 8px;
  font-size: 13px;
  color: var(--ds-color-text-muted, #6b7280);
}

.ds-counter.is-warning {
  color: var(--ds-color-text-warning, #92400e);
  font-weight: 600;
}

.ds-btn-ghost {
  background: transparent;
  border: 1px solid var(--ds-color-border, #d1d5db);
  color: var(--ds-color-text, #111827);
}

.ds-field-row {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  align-items: end;
}

.ds-stack-md {
  gap: 16px;
}

/* --- Help tooltip --- */
.ds-help-tooltip {
  display: inline-flex; align-items: center; justify-content: center;
  width: 16px; height: 16px;
  margin-left: 6px; padding: 0;
  border: 1px solid var(--ds-border, #BDBDBD);
  border-radius: 50%;
  background: transparent;
  color: var(--ds-text-secondary, #757575);
  font-size: 11px; font-weight: 600; line-height: 1;
  cursor: help;
  position: relative;
  vertical-align: middle;
}
.ds-help-tooltip:hover,
.ds-help-tooltip:focus,
.ds-help-tooltip[aria-expanded="true"] {
  border-color: var(--ds-text-primary, #212121);
  color: var(--ds-text-primary, #212121);
  outline: none;
}
.ds-help-tooltip::after {
  content: attr(data-tooltip);
  position: absolute; bottom: calc(100% + 8px); left: 50%; transform: translateX(-50%);
  min-width: 180px; max-width: 280px;
  padding: 8px 12px;
  background: var(--ds-text-primary, #212121); color: #fff;
  font-size: 12px; line-height: 1.4; font-weight: 400;
  border-radius: 6px;
  box-shadow: 0 4px 12px rgba(0,0,0,0.15);
  white-space: normal; text-align: left;
  opacity: 0; pointer-events: none;
  transition: opacity 0.15s ease;
  z-index: 1000;
}
.ds-help-tooltip:hover::after,
.ds-help-tooltip:focus::after,
.ds-help-tooltip[aria-expanded="true"]::after {
  opacity: 1; pointer-events: auto;
}

/* --- Generic tooltip host: any element with .ds-tooltip-host + data-tooltip
       gets a hover/focus tooltip. Use for icon-buttons (Изменить, Удалить,
       Посмотреть) where native title=""  is too slow and not mobile-aware. */
.ds-tooltip-host {
  position: relative;
}
.ds-tooltip-host::after {
  content: attr(data-tooltip);
  position: absolute; bottom: calc(100% + 8px); left: 50%; transform: translateX(-50%);
  min-width: 120px; max-width: 240px;
  padding: 6px 10px;
  background: var(--ds-text-primary, #212121); color: #fff;
  font-size: 12px; line-height: 1.4; font-weight: 400;
  border-radius: 6px;
  box-shadow: 0 4px 12px rgba(0,0,0,0.15);
  white-space: normal; text-align: left;
  opacity: 0; pointer-events: none;
  transition: opacity 0.15s ease;
  z-index: 1000;
}
.ds-tooltip-host:hover::after,
.ds-tooltip-host:focus-visible::after {
  opacity: 1;
}

/* --- Header narrow-viewport fix (320px) --- */
@media (max-width: 360px) {
  .ds-header {
    padding: 0 12px;
  }
  .ds-header-right {
    gap: 6px;
  }
  .ds-header-email {
    display: none;
  }
}
