/* Кабинет клиента — mobile-first. Палитра по умолчанию AXORA Legal (тёмно-синий + золото);
   бренд Smart Study (navy #001241 + красный) переопределяет переменные из my.js по данным /api/my/brand.
   --gold* — исторические имена акцента, --gold-ink — текст акцентного цвета на светлом, --on-gold — текст на акценте. */
:root {
  --navy: #0b3d66;
  --navy-dark: #082c4a;
  --gold: #f5b301;
  --gold-dark: #d99f00;
  --gold-soft: #fdf5dc;
  --gold-ink: #8a6200;
  --on-gold: #082c4a;
  --bg: #f2f5f9;
  --card: #ffffff;
  --text: #1c2733;
  --muted: #5a6b7c;
  --border: #dde6ee;
  --red: #dc4b4b;
  --green: #1a9e5c;
  --green-soft: #e6f6ed;
  --radius: 14px;
  --shadow: 0 1px 3px rgba(11, 61, 102, 0.07), 0 4px 16px rgba(11, 61, 102, 0.06);
  --font: system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; font-family: var(--font); background: var(--bg); color: var(--text); font-size: 16px; line-height: 1.5; min-height: 100vh; display: flex; flex-direction: column; }
button, input, textarea { font-family: var(--font); font-size: 1rem; }
a { color: var(--navy); }
h1, h2, h3 { margin: 0; line-height: 1.25; }
.muted { color: var(--muted); }
.small { font-size: 0.85rem; }
.center { text-align: center; }

/* ---------- Шапка ---------- */
.top { background: linear-gradient(135deg, var(--navy-dark), var(--navy)); color: #fff; padding: 12px 16px; padding-top: max(12px, env(safe-area-inset-top)); display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.top__logo { display: flex; align-items: center; gap: 9px; color: #fff; text-decoration: none; font-weight: 800; line-height: 1.1; letter-spacing: 0.02em; }
.top__logo em { display: block; font-style: normal; font-size: 0.66rem; font-weight: 600; color: var(--gold); letter-spacing: 0.16em; text-transform: uppercase; }
.top__right { display: flex; align-items: center; gap: 8px; }
.lang { display: flex; gap: 2px; background: rgba(255,255,255,0.1); border-radius: 999px; padding: 3px; }
.lang button { border: 0; background: transparent; color: #cddbe8; font-size: 0.74rem; font-weight: 700; padding: 5px 9px; border-radius: 999px; cursor: pointer; letter-spacing: 0.04em; }
.lang button.is-on { background: var(--gold); color: var(--on-gold); }
.top__logout { background: rgba(255,255,255,0.1); border: 0; color: #fff; width: 36px; height: 36px; border-radius: 50%; display: inline-flex; align-items: center; justify-content: center; cursor: pointer; }
.top__logout:hover { background: rgba(255,255,255,0.2); }
/* Логотип-картинка бренда (Smart Study): картинка тёмная — шапка светлая (body.head-light) */
#logo-img { display: inline-flex; align-items: center; gap: 10px; }
#logo-img img { height: 40px; width: auto; display: block; }
#logo-img em { font-size: 0.7rem; letter-spacing: 0.1em; max-width: 120px; line-height: 1.15; }
body.head-light .top { background: #fff; color: var(--navy); border-bottom: 1px solid var(--border); }
body.head-light .top__logo { color: var(--navy); }
body.head-light .top__logo em { color: var(--gold); }
body.head-light .lang { background: var(--bg); }
body.head-light .lang button { color: var(--muted); }
body.head-light .lang button.is-on { background: var(--gold); color: var(--on-gold); }
body.head-light .top__logout { background: var(--bg); color: var(--navy); }
body.head-light .top__logout:hover { background: var(--border); }

/* ---------- Каркас ---------- */
.main { flex: 1; width: 100%; max-width: 760px; margin: 0 auto; padding: 18px 14px 40px; }
.foot { display: flex; justify-content: space-between; gap: 12px; padding: 14px 16px; padding-bottom: max(14px, env(safe-area-inset-bottom)); font-size: 0.8rem; color: var(--muted); border-top: 1px solid var(--border); background: #fff; }
.card { background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow); padding: 18px 16px; margin-bottom: 14px; }
.card h2 { font-size: 1.02rem; margin-bottom: 10px; color: var(--navy-dark); display: flex; align-items: center; gap: 8px; }
.card h2 .n { margin-left: auto; font-size: 0.78rem; font-weight: 600; color: var(--muted); background: var(--bg); border-radius: 999px; padding: 1px 9px; }

.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; padding: 12px 18px; border-radius: 11px; border: 0; font-weight: 700; cursor: pointer; text-decoration: none; font-size: 0.97rem; transition: background 0.15s; }
.btn--gold { background: var(--gold); color: var(--on-gold); }
.btn--gold:hover { background: var(--gold-dark); }
.btn--navy { background: var(--navy); color: #fff; }
.btn--navy:hover { background: var(--navy-dark); }
.btn--ghost { background: transparent; border: 1px solid var(--border); color: var(--navy); }
.btn--ghost:hover { border-color: var(--navy); }
.btn--sm { padding: 7px 12px; font-size: 0.85rem; border-radius: 9px; }
.btn--block { width: 100%; }
.btn[disabled] { opacity: 0.55; cursor: default; }
.link-btn { background: none; border: 0; color: var(--navy); text-decoration: underline; cursor: pointer; padding: 0; font-size: 0.88rem; }

input[type='email'], input[type='text'], textarea { width: 100%; padding: 12px 14px; border: 1px solid var(--border); border-radius: 11px; background: #fff; color: var(--text); }
input:focus, textarea:focus { outline: 2px solid var(--navy); border-color: var(--navy); }
textarea { resize: vertical; min-height: 84px; }
label { display: grid; gap: 6px; font-size: 0.86rem; font-weight: 600; color: var(--muted); }

/* ---------- Вход ---------- */
.auth { max-width: 420px; margin: 8vh auto 0; }
.auth .card { padding: 28px 22px; text-align: center; }
.auth h1 { font-size: 1.35rem; color: var(--navy-dark); margin-bottom: 6px; }
.auth p { margin: 0 0 18px; color: var(--muted); font-size: 0.95rem; }
.auth form { display: grid; gap: 12px; text-align: left; }
.auth .err { color: var(--red); font-size: 0.86rem; min-height: 1.2em; margin: 0; }
.auth__icon { width: 60px; height: 60px; border-radius: 16px; background: var(--gold-soft); color: var(--gold-ink); display: inline-flex; align-items: center; justify-content: center; margin-bottom: 14px; }
.auth__hint { font-size: 0.82rem; color: var(--muted); margin-top: 16px; }

/* ---------- Список дел ---------- */
.hello { margin: 4px 0 14px; }
.hello h1 { font-size: 1.3rem; color: var(--navy-dark); }
.hello p { margin: 2px 0 0; color: var(--muted); font-size: 0.9rem; overflow-wrap: anywhere; }
.case-link { display: block; text-decoration: none; color: inherit; }
.case-link .card { display: grid; grid-template-columns: 1fr auto; gap: 4px 12px; align-items: center; transition: box-shadow 0.15s, transform 0.15s; }
.case-link .card:hover { transform: translateY(-1px); box-shadow: 0 6px 22px rgba(11, 61, 102, 0.12); }
.case-link h3 { font-size: 1.02rem; color: var(--navy-dark); grid-column: 1; grid-row: 1; }
.case-link .meta { font-size: 0.83rem; color: var(--muted); grid-column: 1; }
/* Явные колонки: у стрелки задан ряд, и без grid-column автоплейсмент ставил её первой (в левую колонку) */
.case-link .arrow { grid-column: 2; grid-row: 1 / span 2; color: var(--muted); font-size: 1.4rem; }
.pill { display: inline-flex; align-items: center; gap: 6px; padding: 3px 10px; border-radius: 999px; font-size: 0.75rem; font-weight: 700; white-space: nowrap; background: var(--bg); color: var(--navy); }
.pill .dot { width: 7px; height: 7px; border-radius: 50%; background: currentColor; }
.pill--gold { background: var(--gold-soft); color: var(--gold-ink); }
.pill--green { background: var(--green-soft); color: var(--green); }
.pill--grey { background: #eef1f4; color: var(--muted); }
.pill--red { background: #fdeeee; color: var(--red); }

/* ---------- Дело ---------- */
.case-head { margin: 2px 0 14px; display: flex; flex-wrap: wrap; align-items: baseline; gap: 6px 12px; }
.case-head h1 { font-size: 1.28rem; color: var(--navy-dark); }
.back { display: inline-flex; align-items: center; gap: 6px; text-decoration: none; font-weight: 600; font-size: 0.88rem; margin-bottom: 10px; }

.stepper { display: grid; grid-template-columns: repeat(3, 1fr); gap: 4px; margin: 4px 0 6px; }
.stepper .st { text-align: center; font-size: 0.74rem; color: var(--muted); font-weight: 600; position: relative; padding-top: 26px; line-height: 1.2; }
.stepper .st::before { content: ''; position: absolute; top: 9px; left: 0; right: 0; height: 3px; background: var(--border); }
.stepper .st:first-child::before { left: 50%; }
.stepper .st:last-child::before { right: 50%; }
.stepper .st::after { content: ''; position: absolute; top: 4px; left: 50%; width: 13px; height: 13px; margin-left: -6.5px; border-radius: 50%; background: #fff; border: 3px solid var(--border); box-sizing: border-box; }
.stepper .st.done { color: var(--navy); }
.stepper .st.done::before, .stepper .st.done::after { background: var(--navy); border-color: var(--navy); }
.stepper .st.cur { color: var(--navy-dark); }
.stepper .st.cur::after { border-color: var(--gold); background: var(--gold); box-shadow: 0 0 0 4px var(--gold-soft); }
.stepper .st.cur::before { background: linear-gradient(90deg, var(--navy) 50%, var(--border) 50%); }
.stepper.closed .st::before, .stepper.closed .st::after { background: var(--border); border-color: var(--border); }
.stage-now { font-size: 0.9rem; margin: 10px 0 0; display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }

/* Трекер прогресса вступника: «Ваш прогресс: 3 из 9» + полоса + вертикальный список вех */
.progress { display: flex; align-items: baseline; justify-content: space-between; gap: 10px; flex-wrap: wrap; }
.progress b { font-size: 1.05rem; color: var(--navy-dark); }
.progress .pct { font-weight: 800; color: var(--gold-ink); }
.bar { height: 10px; border-radius: 999px; background: var(--bg); overflow: hidden; margin: 8px 0 14px; }
.bar > span { display: block; height: 100%; border-radius: 999px; background: linear-gradient(90deg, var(--navy), var(--gold)); transition: width 0.4s; }
.track { list-style: none; margin: 0; padding: 0; }
.track li { position: relative; padding: 0 0 14px 34px; font-size: 0.95rem; color: var(--muted); }
.track li:last-child { padding-bottom: 0; }
.track li::before { content: ''; position: absolute; left: 10px; top: 22px; bottom: -2px; width: 2px; background: var(--border); }
.track li:last-child::before { display: none; }
.track .mark { position: absolute; left: 0; top: 1px; width: 22px; height: 22px; border-radius: 50%; border: 2px solid var(--border); background: #fff; display: inline-flex; align-items: center; justify-content: center; font-size: 0.72rem; font-weight: 800; color: #fff; box-sizing: border-box; }
.track li.done { color: var(--text); }
.track li.done .mark { background: var(--green); border-color: var(--green); }
.track li.done::before { background: var(--green); }
.track li.cur { color: var(--navy-dark); font-weight: 700; }
.track li.cur .mark { border-color: var(--gold); background: var(--gold); box-shadow: 0 0 0 4px var(--gold-soft); color: var(--on-gold); }
.track li.cur .now { display: inline-block; margin-left: 8px; font-size: 0.7rem; font-weight: 700; letter-spacing: 0.06em; text-transform: uppercase; color: var(--gold-ink); background: var(--gold-soft); border-radius: 999px; padding: 1px 8px; vertical-align: middle; }
.track li.done .mark::after { content: '✓'; }
.brand-tag { display: inline-block; margin-left: 8px; font-size: 0.68rem; font-weight: 700; letter-spacing: 0.04em; text-transform: uppercase; color: var(--muted); border: 1px solid var(--border); border-radius: 999px; padding: 1px 7px; vertical-align: middle; }

.next { border-left: 4px solid var(--gold); background: linear-gradient(90deg, var(--gold-soft), #fff 70%); }
.next h2 { color: var(--gold-ink); }
.next p { margin: 0; font-size: 1.08rem; font-weight: 600; white-space: pre-line; color: var(--navy-dark); }
.next p.empty { font-weight: 500; color: var(--muted); font-size: 0.97rem; }

.group-title { font-size: 0.78rem; text-transform: uppercase; letter-spacing: 0.06em; color: var(--muted); font-weight: 700; margin: 12px 0 6px; }
.group-title:first-of-type { margin-top: 0; }
.item { padding: 10px 0; border-bottom: 1px dashed var(--border); display: grid; grid-template-columns: 22px 1fr; gap: 4px 10px; align-items: start; }
.item:last-child { border-bottom: 0; }
.item__ic { width: 20px; height: 20px; border-radius: 6px; border: 2px solid var(--border); margin-top: 3px; display: inline-flex; align-items: center; justify-content: center; color: #fff; font-size: 0.72rem; font-weight: 800; }
.item.is-todo .item__ic { border-color: var(--gold); }
.item.is-sent .item__ic { border-color: var(--navy); background: var(--navy); }
.item.is-received .item__ic, .item.is-done .item__ic { border-color: var(--green); background: var(--green); }
.item.is-na .item__ic { border-color: var(--border); background: var(--border); }
.item__title { font-weight: 600; }
.item.is-done .item__title, .item.is-na .item__title { color: var(--muted); font-weight: 500; }
.item.is-na .item__title { text-decoration: line-through; }
.item__meta { grid-column: 2; display: flex; flex-wrap: wrap; gap: 6px 10px; align-items: center; font-size: 0.82rem; color: var(--muted); }
.item__meta .due.overdue { color: var(--red); font-weight: 700; }
.item__note { grid-column: 2; font-size: 0.86rem; color: var(--text); background: var(--bg); border-radius: 8px; padding: 6px 10px; margin-top: 2px; }
.item__note b { color: var(--muted); font-weight: 600; font-size: 0.78rem; display: block; }
.item__act { grid-column: 2; display: flex; flex-wrap: wrap; gap: 8px; margin-top: 4px; }
.item__form { grid-column: 2; display: grid; gap: 8px; margin-top: 6px; }
.item__form textarea { min-height: 64px; }

.deadline { display: flex; align-items: center; gap: 10px; padding: 8px 0; border-bottom: 1px dashed var(--border); font-size: 0.95rem; }
.deadline:last-child { border-bottom: 0; }
.deadline .when { margin-left: auto; font-size: 0.85rem; color: var(--muted); white-space: nowrap; }
.deadline.overdue .when { color: var(--red); font-weight: 700; }
.deadline.done { color: var(--muted); text-decoration: line-through; }
.deadline .ic { width: 10px; height: 10px; border-radius: 50%; background: var(--gold); flex-shrink: 0; }
.deadline.done .ic { background: var(--green); }
.card-exp { display: flex; gap: 12px; align-items: center; background: var(--bg); border-radius: 10px; padding: 10px 12px; margin-top: 8px; font-size: 0.9rem; }
.card-exp b { display: block; font-size: 1.02rem; color: var(--navy-dark); }

.msgs { display: flex; flex-direction: column; gap: 8px; max-height: 420px; overflow-y: auto; padding: 2px 2px 8px; }
.msg { max-width: 86%; padding: 9px 13px; border-radius: 14px; font-size: 0.93rem; white-space: pre-line; overflow-wrap: anywhere; }
.msg--them { background: var(--bg); align-self: flex-start; border-bottom-left-radius: 4px; }
.msg--me { background: var(--navy); color: #fff; align-self: flex-end; border-bottom-right-radius: 4px; }
.msg__who { display: block; font-size: 0.7rem; opacity: 0.75; margin-bottom: 2px; font-weight: 700; }
.msg__ts { display: block; font-size: 0.68rem; opacity: 0.6; text-align: right; margin-top: 3px; }
.msg-form { display: grid; gap: 8px; margin-top: 8px; padding-top: 10px; border-top: 1px solid var(--border); }
.msg-form textarea { min-height: 70px; }
.msg-form .row { display: flex; justify-content: space-between; align-items: center; gap: 10px; }
.msg-empty { color: var(--muted); font-size: 0.9rem; text-align: center; padding: 14px 0; }

.contacts { display: grid; gap: 8px; }
.contact { display: flex; align-items: center; gap: 12px; }
.contact .ava { width: 40px; height: 40px; border-radius: 50%; background: var(--navy); color: #fff; display: inline-flex; align-items: center; justify-content: center; font-weight: 800; font-size: 0.9rem; flex-shrink: 0; }
.contact .who { font-weight: 700; }
.contact .role { font-size: 0.82rem; color: var(--muted); }
.contact-links { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 8px; }
.contact-links a { display: inline-flex; align-items: center; gap: 6px; padding: 8px 12px; border-radius: 9px; border: 1px solid var(--border); text-decoration: none; font-size: 0.88rem; font-weight: 600; color: var(--navy); }
.contact-links a:hover { border-color: var(--navy); }

.toast { position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%); background: var(--navy-dark); color: #fff; padding: 11px 18px; border-radius: 12px; font-size: 0.9rem; box-shadow: 0 8px 26px rgba(0,0,0,0.25); z-index: 50; max-width: calc(100% - 32px); }
.toast--error { background: var(--red); }

@media (min-width: 640px) {
  .main { padding: 26px 20px 60px; }
  .card { padding: 22px 24px; }
  .two { display: grid; grid-template-columns: 1fr 1fr; gap: 0 14px; align-items: start; }
  .two > .card { margin-bottom: 14px; }
  .stepper .st { font-size: 0.82rem; }
}
