/* ============= TOKENS — витягнуті з Figma UI Kit ============= */
:root {
  /* Spacing */
  --space-2:  2px;
  --space-4:  4px;
  --space-6:  6px;
  --space-8:  8px;
  --space-10: 10px;
  --space-12: 12px;
  --space-16: 16px;
  --space-20: 20px;
  --space-28: 28px;

  /* Radius */
  --radius-s:    8px;
  --radius-m:   12px;
  --radius-l:   16px;
  --radius-full: 999px;

  /* Colors — semantic */
  --bg-white:        #ffffff;
  --bg-row:          #f4f5f8;  /* Row · X background */
  --bg-search:       #f5f6fa;  /* Search/Light background */
  --bg-page:         #f7f8fa;

  --text-primary:    #0d0f19;  /* Title, Row name */
  --text-secondary:  #4d5063;  /* Subtitle "for ..." */
  --text-muted:      #9da0b5;  /* Row meta */
  --text-placeholder:#8390b7;  /* Search placeholder */
  --text-inverse:    #fcfcfc;

  --border-chip:     #d4dae7;  /* Limitation Option pill border */
  --border-light:    #e4e6ee;
  --feedback-error:  #e5484d;
  --feedback-success:#28a765;

  --icon-secondary:  #6b6f87;

  /* Brand */
  --brand-grad:       linear-gradient(106.33deg, #00F0FF 0.58%, #1DA5F1 98.1%);
  --brand-grad-hover: linear-gradient(99.99deg,  #00E0FF 24.11%, #1DA5F1 101.7%);
  --brand-shadow:     0 4px 7px #7fbdd9;  /* ONLY :focus-visible — Figma "Focused" state */
  --brand-500: #2AA7EE;

  /* Type */
  --font-mont: 'Montserrat', -apple-system, BlinkMacSystemFont, sans-serif;
  --font-inter: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;

  /* Shadows */
  --shadow-modal:   0 16px 48px rgba(0,0,0,0.08);
  --shadow-popover: 0 8px 24px rgba(13,15,25,0.12);
}

/* ============= PAGE LAYOUT (галерея) ============= */
* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; font-family: var(--font-inter); color: var(--text-primary); background: var(--bg-page); }

.page-header { padding: 32px 32px 16px; }
.page-header h1 { font-family: var(--font-mont); font-weight: 700; font-size: 24px; margin: 0 0 8px; letter-spacing: -0.5px; }
.page-header p { color: var(--text-muted); font-size: 14px; }
.page-header a { color: var(--brand-500); text-decoration: none; }

.grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(540px, 1fr));
  gap: 32px;
  padding: 16px 32px 64px;
}

.state { background: transparent; }
.state > header { margin-bottom: 12px; }
.state > header h2 { margin: 0 0 4px; font-size: 14px; color: var(--text-secondary); font-weight: 500; }
.state > header small { color: var(--text-muted); font-size: 12px; }

.page-footer { padding: 32px; text-align: center; color: var(--text-muted); font-size: 13px; }
.page-footer a { color: var(--brand-500); text-decoration: none; }

/* ============= MODAL ============= */
.modal {
  width: 496px;
  background: var(--bg-white);
  border-radius: var(--radius-l);
  padding: var(--space-28);
  display: flex;
  flex-direction: column;
  gap: var(--space-20);
  box-shadow: var(--shadow-modal);
  overflow: hidden;
  position: relative;
}

/* ============= HEADER ============= */
.modal__header { display: flex; flex-direction: column; gap: var(--space-4); }
.title-row { display: flex; justify-content: space-between; align-items: center; }
.h1 {
  margin: 0;
  font-family: var(--font-mont);
  font-weight: 700;
  font-size: 24px;
  line-height: 28px;
  letter-spacing: -0.5px;
  color: var(--text-primary);
}
.subtitle {
  font-family: var(--font-inter);
  font-weight: 400;
  font-size: 14px;
  line-height: 20px;
  color: var(--text-secondary);
}

.close {
  width: 20px; height: 20px;
  border: 0; background: transparent;
  padding: 0;
  cursor: pointer;
  display: inline-flex; align-items: center; justify-content: center;
}
.close img { width: 13.33px; height: 13.33px; }
.close:disabled { opacity: 0.4; cursor: not-allowed; }

/* ============= SEARCH ============= */
.search {
  height: 40px;
  background: var(--bg-search);
  border-radius: var(--radius-s);
  display: flex; align-items: center;
  padding: 8px 20px;
  gap: 8px;
}
.search input {
  flex: 1;
  background: transparent;
  border: 0; outline: 0;
  font-family: var(--font-mont);
  font-weight: 500;
  font-size: 13px;
  line-height: 1.4;
  color: var(--text-primary);
}
.search input::placeholder { color: var(--text-placeholder); }
.search__icon { width: 14.184px; height: 14.184px; flex-shrink: 0; display: inline-flex; }
.search__icon img { width: 100%; height: 100%; }

/* ============= ACCOUNT LIST ============= */
.account-list {
  display: flex;
  flex-direction: column;
  gap: var(--space-6);
}

/* ============= ACCOUNT ROW ============= */
.acc-row {
  background: var(--bg-row);
  border-radius: var(--radius-m);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}
.acc-row__main {
  display: flex; align-items: center;
  padding: 8px 10px;
  gap: 12px;
}
.acc-row__icon {
  width: 17px; height: 13px;
  flex-shrink: 0;
  display: inline-flex;
}
.acc-row__icon img { width: 100%; height: 100%; }

.acc-row__body {
  flex: 1; min-width: 0;
  display: flex; flex-direction: column;
  gap: 2px;
}
.acc-row__name {
  font-family: var(--font-inter);
  font-weight: 500;
  font-size: 14px;
  line-height: 18px;
  color: var(--text-primary);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.acc-row__meta {
  font-family: var(--font-inter);
  font-weight: 400;
  font-size: 12px;
  line-height: 16px;
  color: var(--text-muted);
}

/* ============= LIMITATION OPTION (pill) ============= */
.lim-opt {
  width: 184px;
  flex-shrink: 0;
  border: 1px solid var(--border-chip);
  background: transparent;
  border-radius: var(--radius-full);
  padding: 4px 12px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  font-family: var(--font-mont);
  font-weight: 400;
  font-size: 12px;
  line-height: 1.5;
  color: var(--text-primary);
  text-align: center;
  cursor: pointer;
  transition: background 120ms ease;
}
.lim-opt:hover { background: rgba(0,0,0,0.02); }
.lim-opt__icon { width: 10px; height: 10px; flex-shrink: 0; display: inline-flex; }
.lim-opt__icon img { width: 100%; height: 100%; object-fit: contain; }
.lim-opt__icon--close { width: 10px; height: 10px; }
.lim-opt__label { flex: 1; min-width: 0; }
.lim-opt--mini { width: auto; min-width: 140px; }

/* ============= PER-PROJECT EXPAND ============= */
.acc-row__expand {
  padding: 8px 10px 10px;
  display: flex; flex-direction: column;
  gap: 8px;
}
.acc-row__expand-title {
  font-family: var(--font-inter);
  font-size: 11px;
  font-weight: 500;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--text-muted);
  padding-left: 29px; /* aligned with text column */
}
.proj-rule {
  display: flex; align-items: center;
  gap: 12px;
  padding-left: 29px;
}
.proj-rule__arrow {
  color: var(--text-muted);
  font-size: 14px;
}
.proj-rule__tag {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 6px 10px 6px 8px;
  border-radius: var(--radius-full);
  background: var(--bg-white);
  border: 1px solid var(--border-chip);
  font-family: var(--font-inter);
  font-size: 12px;
  font-weight: 500;
  color: var(--text-primary);
}
.proj-rule__tag .dot {
  width: 8px; height: 8px; border-radius: 50%; background: var(--brand-500);
}
.proj-rule__tag .dot--orange { background: #F0A23A; }
.proj-rule__tag .dot--green  { background: #28A765; }
.proj-rule__tag .dot--blue   { background: var(--brand-500); }
.proj-rule__tag .x {
  margin-left: 2px;
  color: var(--text-muted);
  cursor: pointer;
  font-size: 10px;
}

.add-proj {
  margin-left: 29px;
  background: transparent;
  border: 0;
  padding: 4px 0;
  color: var(--brand-500);
  font-family: var(--font-inter);
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  text-align: left;
}
.add-proj:hover { text-decoration: underline; }

/* ============= POPOVER ============= */
.popover {
  position: absolute;
  background: var(--bg-white);
  border-radius: var(--radius-m);
  box-shadow: var(--shadow-popover);
  padding: 6px;
  display: flex; flex-direction: column;
  gap: 2px;
  min-width: 200px;
  z-index: 10;
  border: 1px solid var(--border-light);
  /* motion: enter — popover fade-and-rise (120ms, ease-out) */
  animation: popover-in 120ms cubic-bezier(0.16, 1, 0.3, 1);
  transform-origin: top right;
}
@keyframes popover-in {
  from { opacity: 0; transform: translateY(-4px) scale(0.98); }
  to   { opacity: 1; transform: translateY(0) scale(1); }
}
.popover__item {
  padding: 8px 10px;
  border-radius: var(--radius-s);
  font-family: var(--font-mont);
  font-size: 13px;
  color: var(--text-primary);
  cursor: pointer;
  display: flex; align-items: center; justify-content: space-between;
  gap: 8px;
}
.popover__item:hover { background: var(--bg-row); }
.popover__item.is-active { background: var(--bg-row); font-weight: 500; }
.popover__item .check { color: var(--brand-500); }
.popover--lim {
  top: 256px;
  right: 28px;
}
.popover--proj {
  left: 57px;
  top: 320px;
  min-width: 220px;
}

/* ============= FOOTER ============= */
.modal__footer { display: flex; }
.btn {
  flex: 1;
  height: 40px;
  border-radius: var(--radius-s);
  border: 0;
  font-family: var(--font-mont);
  font-weight: 600;
  font-size: 14px;
  line-height: 1;
  color: var(--text-inverse);
  cursor: pointer;
  display: inline-flex; align-items: center; justify-content: center;
  gap: 8px;
  padding: 8px 12px;
  transition: opacity 120ms ease, transform 120ms ease;
}
.btn--primary {
  background: var(--brand-grad);
  /* Default — NO drop-shadow. Colored shadow = :focus-visible only (Figma "Focused" state). */
}
.btn--primary:hover:not(:disabled) { background: var(--brand-grad-hover); }
.btn--primary:focus-visible {
  outline: 0;
  filter: drop-shadow(var(--brand-shadow));
}
.btn:disabled { opacity: 0.6; cursor: not-allowed; }

/* ============= EMPTY ============= */
.empty {
  padding: 36px 12px;
  display: flex; flex-direction: column; align-items: center;
  gap: 12px;
}
.empty__text {
  font-family: var(--font-inter);
  font-size: 14px;
  line-height: 20px;
  color: var(--text-secondary);
  text-align: center;
  max-width: 280px;
}
.empty__cta {
  background: transparent;
  border: 0;
  font-family: var(--font-inter);
  font-size: 14px;
  font-weight: 500;
  color: var(--brand-500);
  cursor: pointer;
}

/* ============= LOADING (skeleton) ============= */
.skel-row {
  display: flex; align-items: center;
  gap: 12px;
  padding: 8px 10px;
  border-radius: var(--radius-m);
  background: var(--bg-row);
}
.skel { background: linear-gradient(90deg, #e8eaf0 0%, #d4d7de 50%, #e8eaf0 100%); background-size: 200% 100%; animation: shimmer 1.6s ease-in-out infinite; border-radius: 6px; }
.skel--icon { width: 17px; height: 13px; flex-shrink: 0; }
.skel--name { height: 12px; width: 40%; }
.skel--meta { height: 10px; width: 30%; margin-top: 4px; }
.skel--body { flex: 1; }
.skel--btn  { height: 26px; width: 184px; border-radius: 999px; }
@keyframes shimmer { 0% { background-position: 200% 0; } 100% { background-position: -200% 0; } }

/* ============= TOAST ============= */
.state--toast .modal { display: none; }
.toast {
  width: 360px;
  background: var(--bg-white);
  border-radius: var(--radius-m);
  padding: 12px 14px;
  display: flex; align-items: center; gap: 12px;
  box-shadow: var(--shadow-modal);
  border: 1px solid var(--border-light);
  /* motion: enter — toast slide up + fade (180ms, ease-out) */
  animation: toast-in 180ms cubic-bezier(0.16, 1, 0.3, 1);
}
@keyframes toast-in {
  from { opacity: 0; transform: translateY(12px); }
  to   { opacity: 1; transform: translateY(0); }
}
/* respect reduced-motion */
@media (prefers-reduced-motion: reduce) {
  .popover, .toast { animation: none; }
}
.toast__icon {
  width: 28px; height: 28px;
  border-radius: 8px;
  display: flex; align-items: center; justify-content: center;
  font-weight: 700; font-size: 14px;
  color: var(--text-inverse);
  flex-shrink: 0;
}
.toast--success { border-left: 3px solid var(--feedback-success); }
.toast--success .toast__icon { background: var(--feedback-success); }
.toast--error   { border-left: 3px solid var(--feedback-error); }
.toast--error   .toast__icon { background: var(--feedback-error); }
.toast__body { flex: 1; display: flex; flex-direction: column; min-width: 0; font-family: var(--font-inter); }
.toast__body strong { font-size: 14px; font-weight: 500; }
.toast__body span { font-size: 12px; color: var(--text-muted); }
.toast__close {
  background: transparent; border: 0;
  color: var(--icon-secondary);
  cursor: pointer;
  font-size: 14px;
}
