/* ============================================================
   Админ-панель АНО ЦСК «Электросталь» — production style
   Fonts загружаются через <link> в index.html (не блокирует render)
   ============================================================ */

:root {
  --mint-50: #F0FAF5; --mint-100: #D4EFE4; --mint-200: #B5E4D0;
  --mint-300: #9BD3C3; --mint-400: #7BBFB3; --mint-500: #5C9F94;
  --mint-600: #4A847A; --mint-700: #3A6A62;
  --coral-50: #FDF6F2; --coral-100: #FAE0D0; --coral-200: #FACFB6;
  --coral-300: #F5B093; --coral-400: #ED9373; --coral-500: #C97559;
  --coral-600: #A95D44;
  --cream-50: #FFFAF3; --cream-100: #FCF3E7; --cream-200: #F7E8D4;
  --ink-900: #2C2C2C; --ink-700: #4A4A4A; --ink-500: #8A8A8A;
  --ink-300: #C8C8C8; --ink-200: #E5E5E5; --ink-100: #F0F0F0;
  --white: #FFFFFF; --red-500: #E65555; --green-500: #4FB870;

  --shadow-xs: 0 1px 2px rgba(0,0,0,0.04);
  --shadow-sm: 0 2px 8px rgba(0,0,0,0.05);
  --shadow-md: 0 8px 24px rgba(0,0,0,0.08);
  --shadow-lg: 0 16px 48px rgba(0,0,0,0.12);

  --radius-sm: 8px; --radius-md: 12px; --radius-lg: 16px; --radius-xl: 24px; --radius-full: 9999px;

  --ease-out-soft: cubic-bezier(0.16, 1, 0.3, 1);
  --ease-in-out-soft: cubic-bezier(0.65, 0, 0.35, 1);
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }

body {
  font-family: "Manrope", -apple-system, system-ui, sans-serif;
  font-size: 15px;
  color: var(--ink-900);
  background: var(--cream-50);
  line-height: 1.5;
  min-height: 100vh;
  position: relative;
  -webkit-font-smoothing: antialiased;
}

body::before {
  content: ""; position: fixed; inset: 0; z-index: -1; pointer-events: none;
  background:
    radial-gradient(ellipse 70% 50% at 10% 0%, rgba(155, 211, 195, 0.15), transparent 70%),
    radial-gradient(ellipse 60% 40% at 90% 100%, rgba(245, 176, 147, 0.12), transparent 70%),
    var(--cream-50);
}

:focus-visible { outline: 2px solid var(--mint-400); outline-offset: 3px; border-radius: var(--radius-sm); }

::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--ink-200); border-radius: var(--radius-full); }
::-webkit-scrollbar-thumb:hover { background: var(--ink-300); }

/* TOPBAR */
.topbar {
  display: flex; justify-content: space-between; align-items: center; gap: 16px;
  padding: 14px 24px;
  background: rgba(255,255,255,0.85);
  backdrop-filter: blur(12px); -webkit-backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--ink-100);
  position: sticky; top: 0; z-index: 40;
}
.brand { display: flex; align-items: center; gap: 12px; }
.brand .logo {
  font-size: 28px; line-height: 1;
  width: 44px; height: 44px;
  display: flex; align-items: center; justify-content: center;
  background: var(--mint-100); border-radius: var(--radius-md);
  box-shadow: var(--shadow-xs);
}
.brand strong {
  font-family: "Fraunces", Georgia, serif; font-weight: 500;
  font-size: 18px; letter-spacing: -0.01em; display: block; color: var(--ink-900);
}
.brand .muted { font-size: 12px; color: var(--ink-500); display: block; }
.actions { display: flex; gap: 10px; align-items: center; }

/* BUTTONS */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  min-height: 40px; padding: 8px 18px;
  font-family: "Manrope", sans-serif; font-size: 14px; font-weight: 600; line-height: 1.2;
  border: none; border-radius: var(--radius-md); cursor: pointer;
  transition: all 0.18s var(--ease-in-out-soft); text-decoration: none; white-space: nowrap;
}
.btn:active:not(:disabled) { transform: scale(0.97); }
.btn:disabled { opacity: 0.5; cursor: not-allowed; color: var(--ink-500); }

/* Контраст: ink-900 на mint-300 даёт 8.6:1 — WCAG AAA */
.btn-primary { background: var(--mint-300); color: var(--ink-900); box-shadow: var(--shadow-xs); font-weight: 700; }
.btn-primary:hover:not(:disabled) { background: var(--mint-500); color: var(--white); box-shadow: var(--shadow-sm); transform: translateY(-1px); }
/* Coral-500 тёмный + white = 4.8:1 — WCAG AA */
.btn-accent { background: var(--coral-500); color: var(--white); box-shadow: var(--shadow-xs); }
.btn-accent:hover:not(:disabled) { background: var(--coral-600); box-shadow: var(--shadow-sm); transform: translateY(-1px); }
.btn-ghost { background: transparent; color: var(--ink-700); border: 1px solid var(--ink-200); }
.btn-ghost:hover:not(:disabled) { background: var(--cream-100); border-color: var(--mint-300); color: var(--ink-900); }
.btn-danger { background: transparent; color: var(--red-500); border: 1px solid var(--red-500); }
.btn-danger:hover:not(:disabled) { background: var(--red-500); color: var(--white); }
.btn-sm { min-height: 32px; padding: 6px 12px; font-size: 13px; }
.btn-lg { min-height: 48px; padding: 10px 22px; font-size: 15px; }

.btn.loading { position: relative; color: transparent !important; pointer-events: none; }
.btn.loading::after {
  content: ""; position: absolute; inset: 0; margin: auto;
  width: 16px; height: 16px;
  border: 2px solid currentColor; border-top-color: transparent; border-radius: 50%;
  animation: spin 0.6s linear infinite; color: var(--ink-900);
}
.btn-accent.loading::after, .btn-danger.loading::after { color: var(--white); }
@keyframes spin { to { transform: rotate(360deg); } }

/* TABS */
.tabs {
  display: flex; gap: 4px; overflow-x: auto; padding: 12px 24px;
  background: rgba(255,255,255,0.6);
  border-bottom: 1px solid var(--ink-100);
  scroll-padding: 24px; scroll-behavior: smooth;
  position: sticky; top: 73px; z-index: 30;
  backdrop-filter: blur(8px);
}
.tabs::-webkit-scrollbar { height: 4px; }

.tab {
  background: transparent; border: none; color: var(--ink-700);
  padding: 8px 16px; font-family: "Manrope", sans-serif;
  font-size: 14px; font-weight: 500;
  border-radius: var(--radius-full); cursor: pointer;
  white-space: nowrap; transition: all 0.18s var(--ease-in-out-soft);
  display: inline-flex; align-items: center; gap: 6px;
}
.tab:hover { background: var(--mint-50); color: var(--mint-600); }
.tab.active { background: var(--mint-300); color: var(--ink-900); font-weight: 700; box-shadow: var(--shadow-xs); }

.tab .badge {
  background: var(--coral-300); color: var(--white);
  border-radius: var(--radius-full); font-size: 11px; font-weight: 700;
  padding: 2px 7px; min-width: 18px; text-align: center; line-height: 1.2;
}
.tab .badge:empty { display: none; }

/* MAIN */
main { padding: 32px 24px 80px; max-width: 1280px; margin: 0 auto; }

.section-head {
  display: flex; justify-content: space-between; align-items: flex-end; gap: 16px;
  margin-bottom: 28px; flex-wrap: wrap;
}
.section-head h1 {
  font-family: "Fraunces", Georgia, serif; font-weight: 500;
  font-size: 32px; letter-spacing: -0.01em; margin: 0; color: var(--ink-900);
}
.section-head p { color: var(--ink-500); font-size: 14px; margin: 4px 0 0; }

.muted { color: var(--ink-500); }

/* CARDS */
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 18px; }

.card {
  background: var(--white); border: 1px solid var(--ink-100);
  border-radius: var(--radius-lg); padding: 20px;
  transition: all 0.18s var(--ease-out-soft); box-shadow: var(--shadow-xs);
}
.card:hover { border-color: var(--mint-200); box-shadow: var(--shadow-md); transform: translateY(-2px); }
.card h3 { font-family: "Fraunces", Georgia, serif; font-weight: 500; font-size: 18px; margin: 0 0 6px; color: var(--ink-900); }
.card p { margin: 4px 0; color: var(--ink-700); font-size: 14px; }
.card .meta { color: var(--ink-500); font-size: 12px; }
.card-footer { display: flex; gap: 8px; margin-top: 16px; padding-top: 14px; border-top: 1px solid var(--ink-100); }

/* TAGS */
.tag {
  display: inline-flex; align-items: center; gap: 4px;
  padding: 4px 10px; border-radius: var(--radius-full);
  font-size: 11px; font-weight: 600; text-transform: uppercase; letter-spacing: 0.04em;
  background: var(--mint-100); color: var(--mint-700);
}
.tag.urgent { background: rgba(245,176,147,0.2); color: var(--coral-500); }
.tag.new { background: rgba(79,184,112,0.15); color: var(--green-500); }
.tag.muted { background: var(--ink-100); color: var(--ink-500); }

/* FORMS */
.form-row { display: block; margin-bottom: 16px; }
.form-row label { display: block; font-size: 13px; font-weight: 600; color: var(--ink-700); margin-bottom: 6px; }
.form-row .required { color: var(--coral-500); margin-left: 2px; }
.form-row input[type="text"], .form-row input[type="email"], .form-row input[type="tel"],
.form-row input[type="url"], .form-row input[type="number"], .form-row input[type="date"],
.form-row select, .form-row textarea {
  width: 100%; padding: 10px 14px;
  background: var(--white); border: 1px solid var(--ink-200); border-radius: var(--radius-md);
  font-family: "Manrope", sans-serif; font-size: 14px; color: var(--ink-900);
  transition: all 0.15s var(--ease-in-out-soft);
}
.form-row input:focus, .form-row select:focus, .form-row textarea:focus {
  outline: none; border-color: var(--mint-400); box-shadow: 0 0 0 3px rgba(123,191,179,0.2);
}
.form-row textarea { resize: vertical; min-height: 80px; line-height: 1.5; }
.form-row input::placeholder, .form-row textarea::placeholder { color: var(--ink-300); }
.form-row .hint { display: block; margin-top: 4px; font-size: 12px; color: var(--ink-500); }
.form-row.error input, .form-row.error textarea, .form-row.error select { border-color: var(--red-500); }
.form-row.error .hint { color: var(--red-500); }

.form-row-inline { display: flex; align-items: center; gap: 8px; }
.form-row-inline input[type="checkbox"] { width: 18px; height: 18px; accent-color: var(--mint-400); cursor: pointer; }
.form-row-inline label { margin: 0; cursor: pointer; user-select: none; }

.form-grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px 16px; }
@media (max-width: 640px) { .form-grid-2 { grid-template-columns: 1fr; } }

.form-section { margin-bottom: 20px; padding: 16px; background: var(--cream-100); border-radius: var(--radius-md); }
.form-section .section-title {
  font-family: "Fraunces", Georgia, serif; font-size: 14px; font-weight: 600;
  color: var(--ink-900); margin: 0 0 12px; text-transform: uppercase; letter-spacing: 0.04em;
}

.form-row input[type="range"] { width: 100%; accent-color: var(--mint-400); }
.slider-row { display: grid; grid-template-columns: 1fr 32px; gap: 10px; align-items: center; }
.slider-row .slider-val { text-align: right; font-weight: 700; color: var(--mint-600); }

/* MODAL */
.modal-backdrop {
  position: fixed; inset: 0; background: rgba(44,44,44,0.45); backdrop-filter: blur(4px);
  display: flex; align-items: center; justify-content: center; z-index: 100; padding: 16px;
  animation: fadeIn 0.15s var(--ease-out-soft);
}
.modal {
  background: var(--white); border-radius: var(--radius-xl); box-shadow: var(--shadow-lg);
  width: 100%; max-width: min(90vw, 760px); max-height: 90vh; overflow-y: auto; padding: 28px;
  position: relative; animation: popIn 0.22s var(--ease-out-soft);
}
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }
@keyframes popIn { from { opacity: 0; transform: translateY(8px) scale(0.97); } to { opacity: 1; transform: none; } }

.modal-head {
  display: flex; justify-content: space-between; align-items: center; gap: 16px;
  margin-bottom: 20px; padding-bottom: 16px; border-bottom: 1px solid var(--ink-100);
}
.modal-head h2 { font-family: "Fraunces", Georgia, serif; font-weight: 500; font-size: 24px; margin: 0; color: var(--ink-900); }

.modal-close {
  width: 36px; height: 36px; background: transparent; border: none; border-radius: var(--radius-md);
  font-size: 22px; color: var(--ink-500); cursor: pointer; transition: all 0.15s var(--ease-in-out-soft);
}
.modal-close:hover { background: var(--ink-100); color: var(--ink-900); }

.modal-foot {
  display: flex; justify-content: flex-end; gap: 10px;
  margin-top: 24px; padding-top: 16px; border-top: 1px solid var(--ink-100);
}

.confirm-modal { max-width: 420px; text-align: center; padding: 28px 24px; }
.confirm-modal .confirm-icon {
  width: 64px; height: 64px; margin: 0 auto 16px; border-radius: 50%;
  background: var(--coral-100); display: flex; align-items: center; justify-content: center; font-size: 32px;
}
.confirm-modal h3 { font-family: "Fraunces", Georgia, serif; font-weight: 500; font-size: 22px; margin: 0 0 8px; }
.confirm-modal p { margin: 0 0 20px; color: var(--ink-700); }

/* TOASTS */
#toast {
  position: fixed; top: max(20px, env(safe-area-inset-top));
  left: 50%; transform: translateX(-50%); z-index: 200; pointer-events: none;
}
.toast {
  background: var(--ink-900); color: var(--white); padding: 12px 20px;
  border-radius: var(--radius-md); font-size: 14px; font-weight: 500;
  box-shadow: var(--shadow-lg); margin-bottom: 8px;
  animation: slideDown 0.25s var(--ease-out-soft) forwards, fadeOut 0.3s var(--ease-in-out-soft) 2.8s forwards;
  pointer-events: auto;
}
.toast.ok { background: var(--green-500); }
.toast.err { background: var(--red-500); }
.toast.warn { background: var(--coral-400); color: var(--white); }
@keyframes slideDown { from { opacity: 0; transform: translateY(-14px); } to { opacity: 1; transform: none; } }
@keyframes fadeOut { to { opacity: 0; transform: translateY(-8px); } }

/* SPINNER / EMPTY */
.spinner {
  display: inline-block; width: 32px; height: 32px;
  border: 3px solid var(--mint-100); border-top-color: var(--mint-300);
  border-radius: 50%; animation: spin 0.7s linear infinite;
}
.empty-state { text-align: center; padding: 80px 24px; color: var(--ink-500); }
.empty-state h3 { font-family: "Fraunces", Georgia, serif; font-weight: 500; color: var(--ink-900); margin: 16px 0 8px; }
.empty-state .empty-icon { font-size: 48px; opacity: 0.5; }

/* PHOTO UPLOADER */
.photo-uploader { margin-bottom: 20px; }
.drop-area {
  padding: 32px; border: 2px dashed var(--mint-300); border-radius: var(--radius-lg);
  background: var(--mint-50); text-align: center; cursor: pointer;
  transition: all 0.18s var(--ease-out-soft);
}
.drop-area:hover, .drop-area.drag { background: var(--mint-100); border-color: var(--mint-400); }
.drop-area .icon { font-size: 40px; margin-bottom: 8px; }
.drop-area .hint { color: var(--ink-500); font-size: 13px; }

.photo-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 12px; margin-top: 16px; }
.photo-tile {
  position: relative; aspect-ratio: 1; border-radius: var(--radius-md);
  overflow: hidden; border: 2px solid transparent; cursor: pointer;
  background: var(--ink-100); transition: all 0.15s var(--ease-in-out-soft);
}
.photo-tile.selected { border-color: var(--mint-400); box-shadow: var(--shadow-sm); }
.photo-tile img { width: 100%; height: 100%; object-fit: cover; display: block; }
.photo-tile .remove {
  position: absolute; top: 4px; right: 4px;
  width: 24px; height: 24px; background: var(--coral-400); color: var(--white);
  border: none; border-radius: 50%; cursor: pointer; font-size: 14px; line-height: 1;
  display: flex; align-items: center; justify-content: center;
}

/* DASHBOARD */
.dashboard-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 16px; margin-bottom: 32px; }

.stat-card {
  background: var(--white); border: 1px solid var(--ink-100);
  border-radius: var(--radius-lg); padding: 20px; position: relative; overflow: hidden;
}
.stat-card .stat-label {
  color: var(--ink-500); font-size: 12px; font-weight: 600;
  text-transform: uppercase; letter-spacing: 0.05em; margin-bottom: 8px;
}
.stat-card .stat-value {
  font-family: "Fraunces", Georgia, serif; font-size: 36px; font-weight: 500;
  color: var(--ink-900); line-height: 1.1;
}
.stat-card .stat-hint { color: var(--ink-500); font-size: 13px; margin-top: 6px; }
.stat-card.accent-mint { border-top: 3px solid var(--mint-300); }
.stat-card.accent-coral { border-top: 3px solid var(--coral-300); }
.stat-card.accent-cream { border-top: 3px solid var(--cream-200); }

.progress-bar { height: 6px; background: var(--ink-100); border-radius: var(--radius-full); overflow: hidden; margin-top: 10px; }
.progress-bar-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--mint-300), var(--coral-300));
  border-radius: var(--radius-full);
  transition: width 0.3s var(--ease-out-soft);
}

.dashboard-row {
  display: grid; grid-template-columns: 2fr 1fr; gap: 16px;
}
@media (max-width: 900px) { .dashboard-row { grid-template-columns: 1fr; } }

/* SUBSCRIBERS EMAIL LIST */
.sub-list { background: var(--white); border-radius: var(--radius-lg); border: 1px solid var(--ink-100); padding: 16px; }
.sub-list .sub-item {
  display: flex; justify-content: space-between; align-items: center;
  padding: 10px 12px; border-radius: var(--radius-sm);
}
.sub-list .sub-item:hover { background: var(--cream-100); }
.sub-list .sub-email { font-family: "Manrope", monospace; color: var(--ink-700); }
.sub-list .sub-date { color: var(--ink-500); font-size: 12px; }

/* APPLICATIONS */
.app-meta {
  display: grid; grid-template-columns: auto 1fr; gap: 6px 12px;
  margin: 12px 0; font-size: 13px;
}
.app-meta dt { color: var(--ink-500); font-weight: 500; }
.app-meta dd { margin: 0; color: var(--ink-900); }

.status-select {
  padding: 4px 10px; border-radius: var(--radius-full); font-size: 12px; font-weight: 600;
  border: 1px solid; cursor: pointer; background: transparent;
}
.status-select.new { border-color: var(--green-500); color: var(--green-500); }
.status-select.review { border-color: var(--coral-400); color: var(--coral-500); }
.status-select.accepted { border-color: var(--mint-500); color: var(--mint-700); background: var(--mint-50); }
.status-select.rejected { border-color: var(--ink-300); color: var(--ink-500); }
.status-select.done { border-color: var(--mint-400); color: var(--mint-700); }

/* MOBILE */
@media (max-width: 640px) {
  .topbar { padding: 10px 14px; flex-wrap: wrap; gap: 8px; }
  .topbar .brand strong { font-size: 15px; }
  .topbar .brand .muted { font-size: 11px; }
  .topbar .actions .btn { padding: 6px 10px; font-size: 12px; min-height: 36px; }
  .tabs { padding: 8px 12px; top: auto; gap: 2px; }
  .tab { padding: 6px 10px; font-size: 12px; min-height: 32px; }
  main { padding: 16px 12px 60px; }
  .section-head h1 { font-size: 22px; }
  .grid { grid-template-columns: 1fr; gap: 12px; }
  .modal { padding: 16px 12px; border-radius: var(--radius-lg); }
  .modal-head { margin-bottom: 14px; padding-bottom: 12px; }
  .modal-head h2 { font-size: 18px; }
  .modal-foot { gap: 6px; }
  .modal-foot .btn { min-height: 40px; padding: 8px 14px; font-size: 13px; }
  .card { padding: 14px; }
  .form-row input, .form-row select, .form-row textarea { padding: 10px 12px; font-size: 16px; /* prevents iOS zoom */ }
  .form-section { padding: 12px; }
}

@media (max-width: 420px) {
  .topbar .actions .btn-ghost.btn-sm { display: none; } /* скрываем второстепенные на очень узких */
}

@media print { .topbar, .tabs, .modal-backdrop, .actions { display: none; } }
