/* ==========================================================================
   Личный кабинет клиента — дизайн-система
   Белый фон + красный акцент. Мягкий, современный корпоративный стиль.
   ========================================================================== */

:root{
  --red: #d81f27;
  --red-dark: #b3151c;
  --red-light: #fdeceb;
  --ink: #23262b;
  --ink-soft: #52565c;
  --muted: #8b8e94;
  --line: #eaeaee;
  --bg: #f6f6f8;
  --white: #ffffff;
  --success: #1f9d55;
  --success-light: #e8f8ee;
  --warning: #b8860b;
  --warning-light: #fff6e0;
  --info: #2563a8;
  --info-light: #eaf2fb;

  /* Сайдбар — мягкий графит с лёгким синим подтоном, без чистого чёрного */
  --side-bg-1: #2b2f38;
  --side-bg-2: #21242b;
  --side-text: rgba(255,255,255,.72);
  --side-text-strong: #ffffff;

  --radius-sm: 8px;
  --radius: 14px;
  --radius-lg: 20px;
  --shadow-sm: 0 1px 3px rgba(20,20,25,0.06);
  --shadow: 0 10px 26px rgba(20,20,25,0.08);
  --shadow-lg: 0 18px 46px rgba(20,20,25,0.13);
  --ease: cubic-bezier(.25,.65,.35,1);
  --ease-soft: cubic-bezier(.3,.7,.4,1);
}

*, *::before, *::after{ box-sizing: border-box; }

html{ scroll-behavior: smooth; }

body{
  margin:0;
  font-family: 'Inter', 'Segoe UI', -apple-system, BlinkMacSystemFont, Arial, sans-serif;
  background: var(--bg);
  color: var(--ink);
  -webkit-font-smoothing: antialiased;
  line-height: 1.5;
}

a{ color: var(--red); text-decoration:none; transition: color .18s var(--ease); }
a:hover{ color: var(--red-dark); }

img{ max-width:100%; }

h1,h2,h3,h4{ margin: 0 0 8px 0; font-weight: 700; letter-spacing: -.01em; color: var(--ink); }
h1{ font-size: 28px; }
h2{ font-size: 21px; }
h3{ font-size: 17px; }
p{ margin: 0 0 12px 0; color: var(--ink-soft); }

.container{ max-width: 1180px; margin: 0 auto; padding: 0 24px; }

/* ---------------- Bootstrap Icons helpers ---------------- */
.bi{ display:inline-block; vertical-align:-.14em; line-height:1; flex-shrink:0; }
.icon-box{ display:inline-flex; align-items:center; justify-content:center; }

/* ---------------- Buttons ---------------- */
.btn{
  display:inline-flex; align-items:center; justify-content:center; gap:8px;
  padding: 11px 22px;
  border-radius: 10px;
  font-size: 14.5px;
  font-weight: 600;
  border: 1.5px solid transparent;
  cursor: pointer;
  transition: box-shadow .2s var(--ease), background .18s var(--ease), border-color .18s var(--ease), color .18s var(--ease);
  white-space: nowrap;
}
.btn:active{ transform: scale(.98); }

.btn-primary{ background: var(--red); color:#fff; box-shadow: 0 4px 12px rgba(216,31,39,.24); }
.btn-primary:hover{ background: var(--red-dark); color:#fff; box-shadow: 0 6px 16px rgba(216,31,39,.3); }

.btn-dark{ background: #363a42; color:#fff; }
.btn-dark:hover{ background:#2b2f36; color:#fff; }

.btn-outline{ background: transparent; color: var(--ink); border-color: var(--line); }
.btn-outline:hover{ border-color: var(--red); color: var(--red); background: var(--red-light); }

.btn-ghost{ background: transparent; color: var(--ink-soft); }
.btn-ghost:hover{ background: #f0f0f2; color: var(--ink); }

.btn-danger-outline{ background: transparent; color: var(--red); border-color: var(--red-light); }
.btn-danger-outline:hover{ background: var(--red); color:#fff; }

.btn-sm{ padding: 7px 14px; font-size: 13px; border-radius: 8px; }
.btn-block{ width:100%; }
.btn[disabled]{ opacity:.55; cursor:not-allowed; }

.btn-icon{ width:34px; height:34px; padding:0; border-radius:9px; flex-shrink:0; }

/* ---------------- Forms ---------------- */
.form-group{ margin-bottom: 18px; }
label{ display:block; font-size: 13.5px; font-weight:600; color: var(--ink); margin-bottom: 7px; }
.hint{ font-size: 12.5px; color: var(--muted); margin-top: 6px; }

input[type=text], input[type=email], input[type=password], input[type=number],
input[type=date], input[type=tel], input[type=file], textarea, select{
  width:100%;
  padding: 12px 14px;
  border: 1.5px solid var(--line);
  border-radius: 10px;
  font-size: 14.5px;
  font-family: inherit;
  color: var(--ink);
  background: #fff;
  transition: border-color .18s var(--ease), box-shadow .18s var(--ease);
}
textarea{ resize: vertical; min-height: 100px; }
input:focus, textarea:focus, select:focus{
  outline:none;
  border-color: var(--red);
  box-shadow: 0 0 0 4px rgba(216,31,39,.10);
}
input[type=file]{ padding: 9px 12px; cursor:pointer; }

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

fieldset{ border:none; padding:0; margin:0 0 22px 0; }
legend{ font-weight:700; font-size: 15px; margin-bottom: 12px; padding:0; }

/* ---------------- Cards ---------------- */
.card{
  background: var(--white);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
  border: 1px solid var(--line);
  padding: 26px;
}
.card + .card{ margin-top: 20px; }
.card-header{ display:flex; align-items:center; justify-content:space-between; margin-bottom: 18px; gap: 12px; flex-wrap:wrap; }
.card-header h2, .card-header h3{ margin:0; display:flex; align-items:center; gap:10px; }

/* ---------------- Badges ---------------- */
.badge{
  display:inline-flex; align-items:center; gap:6px;
  padding: 4px 12px;
  border-radius: 999px;
  font-size: 12.5px;
  font-weight: 700;
  letter-spacing: .01em;
}
.badge::before{ content:''; width:6px; height:6px; border-radius:50%; background: currentColor; flex-shrink:0; }
.badge.badge-icon::before{ display:none; }
.badge-gray{ background:#f0f0f2; color:#6b6e73; }
.badge-red{ background: var(--red-light); color: var(--red-dark); }
.badge-green{ background: var(--success-light); color: var(--success); }
.badge-yellow{ background: var(--warning-light); color: var(--warning); }
.badge-blue{ background: var(--info-light); color: var(--info); }

/* ---------------- Toast-уведомления (не сдвигают контент) ---------------- */
.toast-container{
  position: fixed; top: 18px; right: 18px; z-index: 500;
  display:flex; flex-direction:column; gap:10px;
  width: 360px; max-width: calc(100vw - 36px);
  pointer-events: none;
}
.toast{
  pointer-events: auto;
  padding: 14px 44px 14px 18px;
  border-radius: 12px;
  font-size: 14px;
  border: 1px solid transparent;
  box-shadow: var(--shadow-lg);
  position: relative;
  animation: toastIn .35s var(--ease-soft);
  background: #fff;
}
.toast.hide{ animation: toastOut .3s var(--ease-soft) forwards; }
.toast-success{ background: #f3fbf6; color:#166534; border-color:#c8ebd6; }
.toast-error{ background: #fef4f4; color: var(--red-dark); border-color:#f6cfcf; }
.toast-info{ background: #f2f7fd; color:#1e4a78; border-color:#cfe1f4; }
.toast-close{
  position:absolute; top:10px; right:10px; width:22px; height:22px;
  display:flex; align-items:center; justify-content:center;
  border-radius:6px; cursor:pointer; opacity:.5; background:none; border:none; color:inherit;
}
.toast-close:hover{ opacity:1; background: rgba(0,0,0,.06); }

/* Устаревший .alert оставлен для форм с инлайн-ошибками (не в toast-потоке) */
.alert{
  padding: 14px 18px;
  border-radius: 10px;
  margin-bottom: 18px;
  font-size: 14px;
  border: 1px solid transparent;
}
.alert-success{ background: var(--success-light); color:#166534; border-color:#c8ebd6; }
.alert-error{ background: var(--red-light); color: var(--red-dark); border-color:#f6cfcf; }
.alert-info{ background: var(--info-light); color:#1e4a78; border-color:#cfe1f4; }

/* ---------------- Tables ---------------- */
.table-wrap{ overflow-x:auto; border-radius: var(--radius); border:1px solid var(--line); }
table{ width:100%; border-collapse: collapse; background:#fff; font-size: 14px; }
th, td{ padding: 14px 18px; text-align:left; border-bottom: 1px solid var(--line); }
th{ background:#fafafb; font-size: 12.5px; text-transform:uppercase; letter-spacing:.04em; color: var(--muted); font-weight:700; }
tbody tr{ transition: background .15s var(--ease); }
tbody tr:hover{ background:#fafafb; }
tbody tr:last-child td{ border-bottom:none; }

/* ---------------- Layout: sidebar + topbar (admin & client) ---------------- */
.app-shell{ display:flex; min-height:100vh; align-items:stretch; }

.sidebar{
  width: 260px; flex-shrink:0;
  background: linear-gradient(180deg, var(--side-bg-1) 0%, var(--side-bg-2) 100%);
  color: var(--side-text-strong);
  display:flex; flex-direction:column;
  position:sticky; top:0;
  align-self: flex-start;
  max-height: 100vh;
  overflow-y:auto;
}
.sidebar-brand{
  padding: 24px 22px; font-size:16.5px; font-weight:800; letter-spacing:-.01em;
  border-bottom: 1px solid rgba(255,255,255,.08);
  display:flex; align-items:center; gap:10px;
  color: var(--side-text-strong);
}
.sidebar-brand .dot{ width:9px; height:9px; border-radius:50%; background: var(--red); box-shadow: 0 0 0 4px rgba(216,31,39,.28); flex-shrink:0; }
.sidebar-nav{ padding: 14px 12px; flex:1; }
.sidebar-nav a{
  display:flex; align-items:center; gap:11px;
  color: var(--side-text);
  padding: 10px 14px; border-radius: 10px;
  font-size: 14.5px; font-weight:600;
  margin-bottom: 3px;
  transition: background .18s var(--ease), color .18s var(--ease);
  box-shadow: inset 3px 0 0 transparent;
}
.sidebar-nav a .bi{ font-size:16px; opacity:.9; }
.sidebar-nav a:hover{ background: rgba(255,255,255,.06); color:#fff; }
.sidebar-nav a.active{ background: rgba(216,31,39,.18); color:#fff; box-shadow: inset 3px 0 0 var(--red); }
.sidebar-nav .nav-badge{ margin-left:auto; background: var(--red); color:#fff; font-size:11px; font-weight:700; padding:1px 7px; border-radius:999px; }
.sidebar-foot{ padding: 16px 20px; border-top:1px solid rgba(255,255,255,.08); font-size:13px; color: rgba(255,255,255,.5); }
.sidebar-foot a{ color:#fff; opacity:.85; display:inline-flex; align-items:center; gap:6px; }
.sidebar-foot a:hover{ opacity:1; }

.main{ flex:1; min-width:0; }
.topbar{
  display:flex; align-items:center; justify-content:space-between;
  padding: 16px 32px;
  background: rgba(246,246,248,.9);
  backdrop-filter: blur(6px);
  position: sticky; top:0; z-index: 20;
  border-bottom: 1px solid var(--line);
}
.topbar h1{ font-size:20px; margin:0; display:flex; align-items:center; gap:10px; }
.user-chip{ display:flex; align-items:center; gap:10px; font-size:14px; font-weight:600; color: var(--ink-soft); }
.avatar{
  width:36px; height:36px; border-radius:50%;
  background: var(--red-light); color: var(--red-dark);
  display:flex; align-items:center; justify-content:center;
  font-weight:800; font-size:14px; flex-shrink:0;
}
.page{ padding: 28px 32px 60px; }

.menu-toggle{ display:none; background:none; border:none; cursor:pointer; padding:6px; }
.menu-toggle span{ display:block; width:22px; height:2px; background: var(--ink); margin:5px 0; border-radius:2px; }

@media (max-width: 900px){
  .sidebar{ position: fixed; left:-280px; top:0; bottom:0; height:100%; max-height:none; z-index:50; transition: left .28s var(--ease); box-shadow: var(--shadow-lg); }
  .sidebar.open{ left:0; }
  .menu-toggle{ display:block; }
  .page{ padding: 20px 16px 48px; }
  .topbar{ padding: 14px 16px; }
  .form-row{ grid-template-columns: 1fr; }
  .toast-container{ left:12px; right:12px; width:auto; top:12px; }
}

/* ---------------- Stat cards (dashboard) ---------------- */
.stats-grid{ display:grid; grid-template-columns: repeat(auto-fit, minmax(210px,1fr)); gap:18px; margin-bottom: 24px; }
.stat-card{
  background:#fff; border:1px solid var(--line); border-radius: var(--radius);
  padding: 20px 22px; box-shadow: var(--shadow-sm);
  transition: box-shadow .2s var(--ease), border-color .2s var(--ease);
}
.stat-card:hover{ box-shadow: var(--shadow); border-color:#e2e2e6; }
.stat-card .stat-value{ font-size: 28px; font-weight:800; color: var(--ink); }
.stat-card .stat-label{ font-size: 13px; color: var(--muted); font-weight:600; margin-top:4px; }
.stat-card .stat-icon{ width:42px; height:42px; border-radius:12px; display:flex; align-items:center; justify-content:center; margin-bottom:14px; font-size:18px; }
.stat-icon.red{ background: var(--red-light); color: var(--red-dark); }
.stat-icon.dark{ background:#eef0f2; color: var(--ink-soft); }
.stat-icon.green{ background: var(--success-light); color: var(--success); }
.stat-icon.blue{ background: var(--info-light); color: var(--info); }

/* ---------------- Timeline (project stages) ---------------- */
.timeline{ position:relative; margin: 10px 0; padding-left: 6px; }
.timeline::before{
  content:''; position:absolute; left: 19px; top: 6px; bottom: 6px; width:3px;
  background: var(--line); border-radius: 3px;
}
.timeline-progress{
  position:absolute; left:19px; top:6px; width:3px; border-radius:3px;
  background: linear-gradient(180deg, var(--red), var(--red-dark));
  transition: height .8s var(--ease-soft);
  height:0;
}
.timeline-item{ position:relative; padding: 0 0 26px 52px; }
.timeline-item:last-child{ padding-bottom:4px; }
.timeline-dot{
  position:absolute; left: 10px; top: 0; width: 20px; height:20px; border-radius:50%;
  background:#fff; border: 3px solid var(--line); z-index:2;
  display:flex; align-items:center; justify-content:center;
  transition: border-color .25s var(--ease), background .25s var(--ease);
}
.timeline-item.done .timeline-dot{ background: var(--red); border-color: var(--red); }
.timeline-item.done .timeline-dot .bi{ color:#fff; font-size:10px; }
.timeline-item.active .timeline-dot{ border-color: var(--red); background:#fff; box-shadow: 0 0 0 5px rgba(216,31,39,.14); animation: pulse 2.2s infinite; }
.timeline-item.active .timeline-dot::after{ content:''; width:8px; height:8px; border-radius:50%; background: var(--red); }
.timeline-content{ background:#fff; border:1px solid var(--line); border-radius: var(--radius-sm); padding:14px 18px; transition: box-shadow .2s var(--ease); }
.timeline-item.active .timeline-content{ border-color: rgba(216,31,39,.3); box-shadow: 0 6px 16px rgba(216,31,39,.08); }
.timeline-title{ font-weight:700; font-size:15px; margin-bottom:2px; }
.timeline-meta{ font-size:12.5px; color: var(--muted); margin-bottom: 6px; display:flex; align-items:center; gap:6px; flex-wrap:wrap; }
.timeline-desc{ font-size:13.5px; color: var(--ink-soft); margin:0; }

/* Progress bar (budget/stage) */
.progress{ height: 10px; border-radius: 999px; background: var(--line); overflow:hidden; }
.progress-bar{ height:100%; background: linear-gradient(90deg, var(--red), var(--red-dark)); border-radius:999px; width:0; transition: width .9s var(--ease-soft); }

/* ---------------- File list ---------------- */
.file-item{
  display:flex; align-items:center; gap:14px;
  padding: 14px 16px; border:1px solid var(--line); border-radius: var(--radius-sm);
  transition: box-shadow .2s var(--ease), border-color .2s var(--ease);
}
.file-item + .file-item{ margin-top:10px; }
.file-item:hover{ box-shadow: var(--shadow-sm); border-color:#ddd; }
.file-icon{ width:42px; height:42px; border-radius:10px; background: var(--red-light); color: var(--red-dark); display:flex; align-items:center; justify-content:center; font-size:17px; flex-shrink:0; }
.file-info{ flex:1; min-width:0; }
.file-name{ font-weight:600; font-size:14.5px; white-space:nowrap; overflow:hidden; text-overflow:ellipsis; }
.file-meta{ font-size:12.5px; color: var(--muted); }

/* ---------------- Сообщения по проекту ---------------- */
.msg-thread{ display:flex; flex-direction:column; gap:14px; max-height:440px; overflow-y:auto; padding: 4px 6px 4px 2px; }
.msg-row{ display:flex; flex-direction:column; max-width:100%; }
.msg-row.mine{ align-items:flex-end; }
.msg-row.theirs{ align-items:flex-start; }
.msg-sender{ font-size:12px; font-weight:700; color: var(--muted); margin-bottom:4px; padding:0 4px; }
.msg-bubble{ max-width:78%; padding:11px 15px; border-radius:14px; font-size:14px; line-height:1.55; white-space:pre-line; word-break:break-word; }
.msg-row.mine .msg-bubble{ background: var(--red); color:#fff; border-bottom-right-radius:4px; }
.msg-row.theirs .msg-bubble{ background:#f1f1f3; color: var(--ink); border-bottom-left-radius:4px; }
.msg-time{ font-size:11px; color: var(--muted); margin-top:4px; padding:0 4px; }
.msg-empty{ text-align:center; color: var(--muted); font-size:13.5px; padding: 30px 10px; }

/* ---------------- Empty state ---------------- */
.empty-state{ text-align:center; padding: 46px 20px; color: var(--muted); }
.empty-state .empty-icon{ font-size:34px; margin-bottom:12px; color:#c7c9cd; }

/* ---------------- Auth pages (login/register) ---------------- */
.auth-page{
  min-height:100vh; display:flex; align-items:center; justify-content:center;
  background: radial-gradient(1200px 600px at 15% -10%, #fff5f4 0%, transparent 60%),
              radial-gradient(900px 500px at 110% 10%, #fbe9ea 0%, transparent 55%),
              var(--bg);
  padding: 24px;
}
.auth-card{
  width: 100%; max-width: 420px;
  background:#fff; border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  padding: 40px 36px;
}
.auth-logo{ display:flex; align-items:center; gap:10px; justify-content:center; margin-bottom:22px; font-weight:800; font-size:18px; }
.auth-logo .dot{ width:11px; height:11px; border-radius:50%; background: var(--red); box-shadow:0 0 0 5px rgba(216,31,39,.15); }
.auth-card h1{ text-align:center; font-size:22px; margin-bottom:6px; }
.auth-sub{ text-align:center; color: var(--muted); font-size:13.5px; margin-bottom:26px; }
.auth-switch{ text-align:center; margin-top: 18px; font-size: 13.5px; color: var(--muted); }

/* ---------------- Landing / marketing header (optional index) ---------------- */
.hero{ text-align:center; padding: 90px 20px 70px; }
.hero h1{ font-size: 40px; max-width:700px; margin: 0 auto 16px; }
.hero p{ max-width: 560px; margin: 0 auto 28px; font-size:16px; }

/* ---------------- Misc ---------------- */
.text-muted{ color: var(--muted); }
.text-center{ text-align:center; }
.mt-0{ margin-top:0; } .mb-0{ margin-bottom:0; }
.flex{ display:flex; align-items:center; }
.flex-between{ display:flex; align-items:center; justify-content:space-between; }
.gap-8{ gap:8px; } .gap-12{ gap:12px; } .gap-16{ gap:16px; }
.divider{ height:1px; background: var(--line); margin: 20px 0; }
.w-full{ width:100%; }
.section-title{ font-size:12.5px; font-weight:800; text-transform:uppercase; letter-spacing:.06em; color: var(--muted); margin-bottom:14px; }

/* ---------------- Активность (лог) ---------------- */
.activity-item{ display:flex; gap:14px; padding: 12px 4px; border-bottom:1px solid var(--line); }
.activity-item:last-child{ border-bottom:none; }
.activity-dot{ width:34px; height:34px; border-radius:50%; background:#f0f0f2; color:var(--ink-soft); display:flex; align-items:center; justify-content:center; flex-shrink:0; font-size:14px; }
.activity-text{ font-size:14px; color:var(--ink); }
.activity-time{ font-size:12px; color:var(--muted); margin-top:2px; }

/* ---------------- Animations ---------------- */
@keyframes fadeInUp{ from{ opacity:0; transform: translateY(8px);} to{ opacity:1; transform:translateY(0);} }
@keyframes toastIn{ from{ opacity:0; transform: translateX(24px);} to{ opacity:1; transform:translateX(0);} }
@keyframes toastOut{ from{ opacity:1; transform: translateX(0); max-height:200px; } to{ opacity:0; transform: translateX(24px); max-height:0; margin:0; padding-top:0; padding-bottom:0; } }
@keyframes pulse{ 0%{ box-shadow: 0 0 0 0 rgba(216,31,39,.3);} 70%{ box-shadow: 0 0 0 9px rgba(216,31,39,0);} 100%{ box-shadow: 0 0 0 0 rgba(216,31,39,0);} }

.reveal{ animation: fadeInUp .45s var(--ease-soft) both; }

/* stagger helper via inline style --d */
[style*="--d"]{ animation-delay: var(--d); }
