/* ==========================================================================
   Layout: header (public + cabinet), sidebar, hero, sections, footer, login,
   dashboard, chat, notifications, profile, settings.
   ========================================================================== */
.container { width: 100%; max-width: 1240px; margin: 0 auto; padding: 0 20px; }
.mt { margin-top: 14px; }
.url-text { word-break: break-all; }
.av-sm { width: 32px; height: 32px; } .av-md { width: 40px; height: 40px; } .av-lg { width: 64px; height: 64px; font-size: 1.1rem; } .av-xl { width: 96px; height: 96px; font-size: 1.6rem; }

/* ---- Brand ---------------------------------------------------------------- */
.brand { display: flex; align-items: center; gap: 12px; text-decoration: none; color: inherit; min-width: 0; }
.brand img { width: 44px; height: 44px; object-fit: contain; flex: 0 0 auto; border-radius: 50%; }
.brand-text { display: flex; flex-direction: column; min-width: 0; line-height: 1.2; }
.brand-name { font-weight: 800; font-size: 1.02rem; letter-spacing: .01em; white-space: nowrap; }
.brand-sub { font-size: .72rem; color: var(--muted); display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; max-width: 420px; }

/* ---- Public header ------------------------------------------------------------ */
.gov-strip { background: var(--navy); color: var(--hero-line); font-size: .78rem; }
.gov-strip .container { display: flex; align-items: center; gap: 10px; min-height: 36px; justify-content: space-between; }
.gov-strip .gov { display: flex; align-items: center; gap: 8px; min-width: 0; }
.gov-strip .topics { display: flex; gap: 14px; flex-wrap: wrap; justify-content: flex-end; }
.gov-strip .topics span { opacity: .85; white-space: nowrap; }
.site-header { position: sticky; top: 0; z-index: 60; background: color-mix(in srgb, var(--surface) 88%, transparent); backdrop-filter: blur(12px); border-bottom: 1px solid var(--border); transition: box-shadow var(--t); }
.site-header.scrolled, .app-header.scrolled { box-shadow: var(--shadow); }
.site-header .container { display: flex; align-items: center; gap: 16px; min-height: var(--header-h); max-width: 1440px; }
.site-header .brand { flex: 0 0 auto; }
.site-nav { display: flex; align-items: center; gap: 2px; margin-left: auto; }
.site-nav a { padding: 8px 11px; border-radius: 8px; text-decoration: none; color: var(--text-2); font-weight: 600; font-size: .9rem; white-space: nowrap; }
.site-nav a:hover { background: var(--surface-2); color: var(--primary); }
.site-nav a.active { color: var(--primary); background: var(--primary-soft); }
.header-actions { display: flex; align-items: center; gap: 8px; flex: 0 0 auto; }
.menu-btn { display: none; }
@media (max-width: 1500px) and (min-width: 1241px) { .site-header .brand-sub { display: none; } .site-nav a { padding: 8px 8px; font-size: .88rem; } }
@media (max-width: 1240px) {
  .site-nav { position: fixed; inset: var(--header-h) 0 auto 0; flex-direction: column; align-items: stretch; background: var(--surface); border-bottom: 1px solid var(--border); padding: 10px 16px 16px; box-shadow: var(--shadow-lg); max-height: calc(100dvh - var(--header-h)); overflow-y: auto; transform: translateY(-8px); opacity: 0; visibility: hidden; transition: opacity var(--t), transform var(--t), visibility var(--t); margin: 0; }
  .site-header.open .site-nav { transform: none; opacity: 1; visibility: visible; }
  .site-nav a { padding: 12px 14px; font-size: 1rem; }
  .menu-btn { display: inline-flex; }
  .header-actions { margin-left: auto; }
  .gov-strip .topics { display: none; }
}
@media (max-width: 520px) {
  .brand-sub { display: none; }
  .header-actions .login-text { display: none; }
  .site-header .container, .app-header { gap: 8px; }
}

/* ---- Hero ------------------------------------------------------------------ */
.hero { position: relative; overflow: hidden; color: var(--on-color); background: radial-gradient(1200px 500px at 85% -10%, rgba(34, 195, 230, .28), transparent 60%), radial-gradient(900px 500px at 0% 110%, rgba(109, 40, 217, .30), transparent 60%), linear-gradient(135deg, var(--hero-900) 0%, var(--hero-800) 55%, var(--hero-700) 100%); }
.hero::before { content: ""; position: absolute; inset: 0; background-image: linear-gradient(rgba(255,255,255,.06) 1px, transparent 1px), linear-gradient(90deg, rgba(255,255,255,.06) 1px, transparent 1px); background-size: 44px 44px; mask-image: radial-gradient(ellipse at 60% 40%, #000 30%, transparent 75%); -webkit-mask-image: radial-gradient(ellipse at 60% 40%, #000 30%, transparent 75%); pointer-events: none; }
.hero-photo { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; opacity: .07; filter: grayscale(1) blur(2px); pointer-events: none; }
.hero-circuit { position: absolute; right: 0; bottom: 0; width: min(560px, 60vw); opacity: .3; pointer-events: none; }
.hero .container { position: relative; display: grid; grid-template-columns: minmax(0, 1.15fr) minmax(0, .85fr); gap: 40px; align-items: center; padding-top: 64px; padding-bottom: 72px; }
.hero .eyebrow { display: inline-flex; gap: 8px; align-items: center; padding: 6px 12px; border-radius: 999px; background: rgba(255,255,255,.1); border: 1px solid rgba(255,255,255,.2); font-size: .8rem; font-weight: 600; color: var(--hero-text-soft); margin-bottom: 16px; }
.hero h1 { color: var(--on-color); font-size: clamp(1.6rem, 1.1rem + 2.4vw, 2.9rem); line-height: 1.15; margin-bottom: 14px; }
.hero h1 .grad { background: linear-gradient(90deg, var(--hero-accent), var(--hero-accent-2)); -webkit-background-clip: text; background-clip: text; color: transparent; }
.hero-sub { color: var(--hero-text); font-size: 1.05rem; max-width: 620px; margin-bottom: 26px; }
.hero-cta { display: flex; gap: 10px; flex-wrap: wrap; }
.hero-panel { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.float-card { background: rgba(255,255,255,.08); border: 1px solid rgba(255,255,255,.16); border-radius: 16px; padding: 18px; backdrop-filter: blur(10px); box-shadow: 0 20px 40px rgba(0,0,0,.25); animation: floaty 7s ease-in-out infinite; }
.float-card:nth-child(2) { animation-delay: -2s; }
.float-card:nth-child(3) { animation-delay: -4s; }
.float-card:nth-child(4) { animation-delay: -1s; }
.float-card .ic { color: var(--hero-accent); }
.float-card strong { display: block; font-size: 1.9rem; line-height: 1.1; margin-top: 8px; font-variant-numeric: tabular-nums; }
.float-card span { color: #BCD0EE; font-size: .85rem; }
@keyframes floaty { 50% { transform: translateY(-6px); } }
@media (max-width: 900px) {
  .hero .container { grid-template-columns: minmax(0, 1fr); padding-top: 40px; padding-bottom: 44px; gap: 28px; }
  .float-card:nth-child(n) { margin-top: 0; }
}
@media (max-width: 400px) { .hero-panel { gap: 10px; } .float-card { padding: 14px; } .float-card strong { font-size: 1.5rem; } }

/* ---- Sections --------------------------------------------------------------- */
.section { padding: 64px 0; }
.section-alt { background: var(--surface); border-top: 1px solid var(--border); border-bottom: 1px solid var(--border); }
.section-dark { background: linear-gradient(135deg, var(--navy), var(--navy-2)); color: var(--on-color); }
.section-dark h2, .section-dark h3 { color: var(--on-color); }
.section-dark .muted { color: var(--hero-muted); }
.section-head { max-width: 720px; margin-bottom: 28px; }
.section-head.center { margin-left: auto; margin-right: auto; }
.features { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(100%, 240px), 1fr)); gap: 16px; }
.section-dark .feature { background: rgba(255,255,255,.05); border-color: rgba(255,255,255,.12); color: var(--on-color); }
.section-dark .feature p { color: var(--hero-muted); }
.section-dark .feat-ic { background: rgba(125,211,252,.15); color: var(--hero-accent); }
.places { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 12px; }
.place { text-align: center; padding: 18px 10px; border-radius: var(--radius); background: var(--surface); border: 1px solid var(--border); }
.place .n { font-size: 1.8rem; font-weight: 800; color: var(--primary); }
.place .medal { width: 42px; height: 42px; border-radius: 50%; display: inline-grid; place-items: center; font-weight: 800; color: var(--on-color); background: linear-gradient(135deg, #1D4ED8, #0E7490); }
.place:nth-child(1) .medal { background: linear-gradient(135deg, #F59E0B, #FBBF24); color: #0A1120; }
.place:nth-child(2) .medal { background: linear-gradient(135deg, #94A3B8, #CBD5E1); color: #0A1120; }
.place:nth-child(3) .medal { background: linear-gradient(135deg, #B45309, #D97706); }
.months { display: grid; grid-template-columns: repeat(6, minmax(0, 1fr)); gap: 10px; }
.month { padding: 12px; border-radius: 12px; background: var(--surface-2); border: 1px solid var(--border); }
.month small { color: var(--secondary); font-weight: 800; }
.month b { display: block; font-size: .9rem; }
.cta-band { border-radius: var(--radius-lg); padding: 40px 28px; text-align: center; color: var(--on-color); background: radial-gradient(600px 240px at 90% 0%, rgba(34,195,230,.35), transparent 70%), linear-gradient(135deg, #1D4ED8, #6D28D9); }
.cta-band h2 { color: var(--on-color); }
.cta-band p { color: #E0E7FF; max-width: 620px; margin: 0 auto 18px; }
@media (max-width: 760px) {
  .section { padding: 44px 0; }
  .places { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .months { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .container { padding: 0 16px; }
}
@media (max-width: 380px) { .places { grid-template-columns: repeat(2, minmax(0, 1fr)); } }

/* ad strip */
.ads { display: flex; gap: 14px; overflow-x: auto; padding: 4px 2px 14px; scroll-snap-type: x mandatory; }
.ad { flex: 0 0 min(340px, 82vw); scroll-snap-align: start; border-radius: var(--radius); overflow: hidden; position: relative; background: var(--navy); color: var(--on-color); text-decoration: none; aspect-ratio: 16 / 9; }
.ad img, .ad video { width: 100%; height: 100%; object-fit: cover; display: block; }
.ad .cap { position: absolute; left: 0; right: 0; bottom: 0; padding: 10px 12px; background: linear-gradient(0deg, rgba(0,0,0,.75), transparent); font-weight: 600; font-size: .9rem; }

/* public page header */
.page-hero { background: linear-gradient(135deg, var(--hero-900), var(--hero-700)); color: var(--on-color); position: relative; overflow: hidden; }
.page-hero::before { content: ""; position: absolute; inset: 0; background-image: linear-gradient(rgba(255,255,255,.06) 1px, transparent 1px), linear-gradient(90deg, rgba(255,255,255,.06) 1px, transparent 1px); background-size: 36px 36px; mask-image: linear-gradient(90deg, transparent, #000 60%); -webkit-mask-image: linear-gradient(90deg, transparent, #000 60%); }
.page-hero .container { position: relative; padding-top: 34px; padding-bottom: 34px; }
.page-hero h1 { color: var(--on-color); margin: 6px 0 4px; }
.page-hero p { color: var(--hero-text); margin: 0; }
.crumbs { font-size: .82rem; color: #A9C1E8; display: flex; gap: 6px; align-items: center; flex-wrap: wrap; }
.crumbs a { color: var(--hero-text-strong); text-decoration: none; }
.page-body { padding: 28px 0 56px; }

/* footer */
/* public pages: the footer starts below the fold while a page loads (no layout shift, CLS) */
.site-header ~ #main { min-height: calc(100dvh - var(--header-h)); }
.site-footer { background: var(--navy); color: #B8C7E0; padding: 48px 0 calc(24px + env(safe-area-inset-bottom, 0px)); font-size: .9rem; }
.site-footer h4 { color: var(--on-color); font-size: .95rem; margin-bottom: 12px; }
.site-footer a { color: var(--hero-text-strong); text-decoration: none; }
.site-footer a:hover { text-decoration: underline; }
.footer-grid { display: grid; grid-template-columns: 1.4fr repeat(3, 1fr); gap: 28px; }
.footer-grid ul { list-style: none; margin: 0; padding: 0; display: grid; gap: 8px; }
.footer-bottom { border-top: 1px solid rgba(255,255,255,.1); margin-top: 32px; padding-top: 18px; display: flex; justify-content: space-between; gap: 12px; flex-wrap: wrap; align-items: center; }
.site-footer .brand-sub { color: #9FB2D3; max-width: none; -webkit-line-clamp: 3; }
@media (max-width: 860px) { .footer-grid { grid-template-columns: 1fr 1fr; } }
@media (max-width: 480px) { .footer-grid { grid-template-columns: 1fr; } }

/* ---- Auth pages (login / register) ------------------------------------------- */
.auth { min-height: calc(100dvh - var(--header-h)); display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); }
.auth-art { position: relative; overflow: hidden; color: var(--on-color); padding: 56px 48px; display: flex; flex-direction: column; justify-content: center; background: radial-gradient(700px 400px at 100% 0%, rgba(34,195,230,.3), transparent 60%), radial-gradient(600px 400px at 0% 100%, rgba(109,40,217,.35), transparent 60%), linear-gradient(135deg, var(--hero-900), var(--hero-700)); }
.auth-art::before { content: ""; position: absolute; inset: 0; background-image: radial-gradient(rgba(255,255,255,.18) 1px, transparent 1.2px); background-size: 22px 22px; mask-image: radial-gradient(ellipse at 30% 60%, #000 20%, transparent 70%); -webkit-mask-image: radial-gradient(ellipse at 30% 60%, #000 20%, transparent 70%); }
.auth-art > * { position: relative; }
.auth-art h2 { color: var(--on-color); font-size: clamp(1.5rem, 1rem + 2vw, 2.3rem); }
.auth-art p { color: var(--hero-text); max-width: 460px; }
.auth-art .network { width: min(420px, 100%); margin-top: 26px; opacity: .9; }
.auth-points { list-style: none; padding: 0; margin: 20px 0 0; display: grid; gap: 10px; }
.auth-points li { display: flex; gap: 10px; align-items: center; color: #E0EAFB; }
.auth-points .ic { color: var(--hero-accent); }
.auth-form { display: flex; align-items: center; justify-content: center; padding: 40px 20px; }
.auth-card { width: 100%; max-width: 440px; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-lg); box-shadow: var(--shadow); padding: 30px; }
.auth-card .logo { width: 64px; height: 64px; margin-bottom: 10px; }
.auth-card .form { margin: 0; }
.auth-links { display: flex; justify-content: space-between; gap: 10px; flex-wrap: wrap; margin-top: 12px; font-size: .9rem; }
@media (max-width: 900px) { .auth { grid-template-columns: minmax(0, 1fr); } .auth-art { padding: 32px 20px; } .auth-art .network, .auth-points { display: none; } }
@media (max-width: 420px) { .auth-card { padding: 20px; } }

/* ---- Cabinet shell ------------------------------------------------------------ */
.app-header { position: sticky; top: 0; z-index: 70; height: var(--header-h); display: flex; align-items: center; gap: 12px; padding: 0 16px; background: color-mix(in srgb, var(--surface) 90%, transparent); backdrop-filter: blur(12px); border-bottom: 1px solid var(--border); }
.app-header .brand img { width: 40px; height: 40px; }
.app-search { flex: 1 1 360px; max-width: 460px; margin-left: 12px; position: relative; }
.app-search .ic { position: absolute; left: 12px; top: 50%; transform: translateY(-50%); color: var(--muted); }
.app-search .input { padding-left: 40px; min-height: 40px; background: var(--surface-2); }
.app-header .spacer { flex: 1; }
.user-menu { display: flex; align-items: center; gap: 10px; padding: 4px 6px 4px 4px; border-radius: 999px; border: 1px solid var(--border); background: var(--surface); text-decoration: none; color: inherit; }
.user-menu .who { display: flex; flex-direction: column; line-height: 1.15; max-width: 180px; }
.user-menu .who b { font-size: .86rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.user-menu .who small { color: var(--muted); font-size: .72rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.shell { display: flex; min-height: calc(100dvh - var(--header-h)); }
.sidebar { width: var(--sidebar-w); flex: 0 0 var(--sidebar-w); background: var(--surface); border-right: 1px solid var(--border); position: sticky; top: var(--header-h); height: calc(100dvh - var(--header-h)); overflow-y: auto; padding: 14px 10px 24px; transition: width var(--t), flex-basis var(--t); scrollbar-width: thin; }
.nav-group { margin-bottom: 8px; }
.nav-group > .nav-title { font-size: .7rem; font-weight: 800; letter-spacing: .08em; text-transform: uppercase; color: var(--muted); padding: 10px 12px 6px; display: flex; justify-content: space-between; align-items: center; width: 100%; background: none; border: 0; cursor: pointer; font-family: inherit; }
.nav-group.collapsed .nav-items { display: none; }
.nav-group .chev { transition: transform var(--t-fast); }
.nav-group.collapsed .chev { transform: rotate(-90deg); }
.nav-item { display: flex; align-items: center; gap: 12px; padding: 9px 12px; margin: 2px 0; border-radius: 10px; text-decoration: none; color: var(--text-2); font-weight: 600; font-size: .9rem; position: relative; transition: background var(--t-fast), color var(--t-fast); }
.nav-item .ic { color: var(--muted); transition: color var(--t-fast); }
.nav-item:hover { background: var(--surface-2); color: var(--text); }
.nav-item:hover .ic { color: var(--primary); }
.nav-item.active { background: linear-gradient(90deg, var(--primary-soft), transparent); color: var(--primary); }
.nav-item.active::before { content: ""; position: absolute; left: -10px; top: 8px; bottom: 8px; width: 4px; border-radius: 0 4px 4px 0; background: linear-gradient(var(--primary), var(--secondary)); }
.nav-item.active .ic { color: var(--primary); }
.nav-item .label { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.nav-badge { background: var(--danger); color: var(--on-color); font-size: .7rem; font-weight: 800; border-radius: 999px; padding: 1px 7px; }
.nav-badge:empty { display: none; }
.sidebar-collapse { margin: 8px 12px 0; }
body.sb-collapsed .sidebar { width: 76px; flex-basis: 76px; }
body.sb-collapsed .nav-item .label, body.sb-collapsed .nav-title span, body.sb-collapsed .nav-badge, body.sb-collapsed .sidebar-collapse span { display: none; }
body.sb-collapsed .nav-item { justify-content: center; padding: 11px; }
body.sb-collapsed .nav-group.collapsed .nav-items { display: block; }
.sidebar-head { display: flex; justify-content: space-between; align-items: center; padding: 0 6px 12px; border-bottom: 1px solid var(--border); margin-bottom: 8px; }
.main { flex: 1; min-width: 0; padding: 24px; max-width: 1400px; }
.nav-backdrop { display: none; }
.page-head { display: flex; justify-content: space-between; align-items: flex-end; gap: 14px; flex-wrap: wrap; margin-bottom: 18px; }
.page-head h1 { font-size: clamp(1.3rem, 1.1rem + .8vw, 1.7rem); margin: 0; }
.page-head p { margin: 2px 0 0; font-size: .9rem; }
.page-head-t { display: flex; gap: 14px; align-items: center; min-width: 0; }
.page-ic { width: 46px; height: 46px; border-radius: 14px; display: grid; place-items: center; background: linear-gradient(135deg, var(--primary), var(--secondary)); color: var(--on-color); box-shadow: 0 8px 20px color-mix(in srgb, var(--primary) 30%, transparent); flex: 0 0 auto; }
.back { display: inline-flex; gap: 6px; align-items: center; font-size: .88rem; font-weight: 600; text-decoration: none; margin-bottom: 10px; }
@media (max-width: 1024px) {
  .app-search { display: none; }
  .user-menu .who { display: none; }
  .sidebar { position: fixed; top: 0; bottom: 0; left: 0; z-index: 90; height: 100dvh; width: min(84vw, 300px); transform: translateX(-102%); transition: transform var(--t); box-shadow: var(--shadow-lg); padding-top: calc(16px + env(safe-area-inset-top, 0px)); }
  body.nav-open .sidebar { transform: none; }
  body.nav-open .nav-backdrop { display: block; position: fixed; inset: 0; z-index: 80; background: rgba(8, 15, 30, .5); backdrop-filter: blur(2px); }
  body.nav-open, body.modal-open { overflow: hidden; }
  body.sb-collapsed .sidebar { width: min(84vw, 300px); }
  body.sb-collapsed .nav-item .label, body.sb-collapsed .nav-title span { display: inline; }
  .sidebar-collapse { display: none; }
  .main { padding: 16px; }
}
@media (min-width: 1025px) { .app-header .menu-btn { display: none; } .sidebar-head { display: none; } }

/* ---- Dashboard ---------------------------------------------------------------- */
.welcome { display: flex; justify-content: space-between; gap: 18px; flex-wrap: wrap; align-items: center; padding: 24px; border-radius: var(--radius-lg); color: var(--on-color); margin-bottom: 18px; position: relative; overflow: hidden; background: radial-gradient(500px 220px at 100% 0%, rgba(34,195,230,.35), transparent 70%), linear-gradient(135deg, var(--hero-800), var(--primary-dark)); }
.welcome::before { content: ""; position: absolute; inset: 0; background-image: linear-gradient(rgba(255,255,255,.07) 1px, transparent 1px), linear-gradient(90deg, rgba(255,255,255,.07) 1px, transparent 1px); background-size: 30px 30px; mask-image: linear-gradient(90deg, transparent, #000); -webkit-mask-image: linear-gradient(90deg, transparent, #000); }
.welcome > * { position: relative; }
.welcome h1 { color: var(--on-color); margin: 0 0 4px; font-size: clamp(1.3rem, 1rem + 1.2vw, 1.8rem); }
.welcome p { color: #D5E3FA; margin: 0; }
.welcome .chip { background: rgba(255,255,255,.12); border-color: rgba(255,255,255,.2); color: var(--on-color); }
.quick { display: flex; gap: 8px; flex-wrap: wrap; }
.dash-grid { display: grid; grid-template-columns: minmax(0, 2fr) minmax(0, 1fr); gap: 16px; }
@media (max-width: 1100px) { .dash-grid { grid-template-columns: minmax(0, 1fr); } }
.bars { display: grid; gap: 10px; }
.bar-row { display: grid; grid-template-columns: minmax(90px, 160px) minmax(0, 1fr) 48px; gap: 10px; align-items: center; font-size: .86rem; }
.bar-row .track { height: 12px; background: var(--surface-2); border-radius: 99px; overflow: hidden; border: 1px solid var(--border); }
.bar-row .fill { height: 100%; background: linear-gradient(90deg, var(--primary), var(--secondary)); border-radius: 99px; transform-origin: left; animation: grow .6s ease; }
@keyframes grow { from { transform: scaleX(0); } }
.bar-row b { text-align: right; font-variant-numeric: tabular-nums; }
.timeline { list-style: none; margin: 0; padding: 0; display: grid; gap: 12px; }
.timeline li { display: flex; gap: 12px; align-items: flex-start; }
.timeline .tl-ic { width: 34px; height: 34px; border-radius: 10px; display: grid; place-items: center; flex: 0 0 auto; background: var(--primary-soft); color: var(--primary); }
.timeline small { color: var(--muted); display: block; }

/* ---- Months / reports -------------------------------------------------------- */
.month-list { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(100%, 220px), 1fr)); gap: 12px; }
.month-card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 14px; display: flex; flex-direction: column; gap: 10px; box-shadow: var(--shadow-sm); }
.month-card .m { font-weight: 800; font-size: 1rem; display: flex; justify-content: space-between; align-items: center; }
.month-card .num { color: var(--secondary); font-size: .78rem; }
.report-fields { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 0 16px; }
@media (max-width: 760px) { .report-fields { grid-template-columns: minmax(0, 1fr); } }
.attach-grid { display: flex; gap: 10px; flex-wrap: wrap; }
.attach-grid .ph { position: relative; }
.attach-grid .ph img { width: 104px; height: 104px; object-fit: cover; border-radius: 10px; border: 1px solid var(--border); display: block; }
.attach-grid .ph .btn { position: absolute; top: -8px; right: -8px; }
.file-row { display: flex; gap: 10px; align-items: center; padding: 10px 12px; border: 1px solid var(--border); border-radius: 10px; background: var(--surface-2); margin-bottom: 8px; flex-wrap: wrap; }
.file-row .name { flex: 1; min-width: 0; overflow-wrap: anywhere; font-weight: 600; }
.file-ic { width: 40px; height: 40px; border-radius: 10px; display: grid; place-items: center; background: var(--info-soft); color: var(--info); flex: 0 0 auto; font-size: .7rem; font-weight: 800; }
.history { list-style: none; margin: 0; padding: 0; border-left: 2px solid var(--border); }
.history li { position: relative; padding: 0 0 12px 18px; font-size: .88rem; }
.history li::before { content: ""; position: absolute; left: -6px; top: 5px; width: 10px; height: 10px; border-radius: 50%; background: var(--primary); box-shadow: 0 0 0 3px var(--surface); }
.annex { border: 1px solid var(--border); border-radius: var(--radius); margin-bottom: 12px; background: var(--surface); }
.annex > summary { cursor: pointer; padding: 14px 16px; font-weight: 700; display: flex; justify-content: space-between; gap: 10px; list-style: none; }
.annex > summary::-webkit-details-marker { display: none; }
.annex[open] > summary { border-bottom: 1px solid var(--border); }
.annex .annex-body { padding: 14px 16px 4px; }
.annex .form-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
@media (max-width: 1000px) { .annex .form-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
@media (max-width: 560px) { .annex .form-grid { grid-template-columns: minmax(0, 1fr); } }

/* ---- Documents / library ----------------------------------------------------- */
.doc-row { display: grid; grid-template-columns: auto minmax(0, 1fr) auto; gap: 14px; align-items: center; padding: 14px 16px; border-bottom: 1px solid var(--border); }
.doc-row:last-child { border-bottom: 0; }
.doc-row .doc-ic { width: 46px; height: 54px; border-radius: 8px; display: grid; place-items: center; color: var(--on-color); font-size: .68rem; font-weight: 800; background: linear-gradient(160deg, #1D4ED8, #1E3A8A); position: relative; }
.doc-ic.pdf { background: linear-gradient(160deg, #B91C1C, #7F1D1D); }
.doc-ic.doc, .doc-ic.docx { background: linear-gradient(160deg, #1D4ED8, #1E3A8A); }
.doc-ic.xls, .doc-ic.xlsx { background: linear-gradient(160deg, #166534, #14532D); }
.doc-ic.ppt, .doc-ic.pptx { background: linear-gradient(160deg, #C2410C, #7C2D12); }
.doc-ic.url { background: linear-gradient(160deg, #6D28D9, #4C1D95); }
.doc-row h3 { font-size: .98rem; margin: 0 0 4px; }
@media (max-width: 640px) { .doc-row { grid-template-columns: auto minmax(0, 1fr); } .doc-row .btn-group { grid-column: 1 / -1; } }
.book { display: flex; flex-direction: column; }
.book-cover { aspect-ratio: 3 / 4; border-radius: 10px 10px 0 0; background: linear-gradient(160deg, var(--navy), var(--primary)); color: var(--on-color); padding: 18px 16px; display: flex; flex-direction: column; justify-content: space-between; position: relative; overflow: hidden; }
.book-cover::before { content: ""; position: absolute; left: 12px; top: 0; bottom: 0; width: 3px; background: rgba(255,255,255,.25); }
.book-cover::after { content: ""; position: absolute; inset: 0; background-image: radial-gradient(rgba(255,255,255,.14) 1px, transparent 1.2px); background-size: 14px 14px; mask-image: linear-gradient(transparent 40%, #000); -webkit-mask-image: linear-gradient(transparent 40%, #000); }
.book-cover b { font-size: 1.02rem; line-height: 1.3; position: relative; overflow-wrap: anywhere; }
.book-cover small { position: relative; color: var(--hero-text-soft); }
.book:nth-child(4n+2) .book-cover { background: linear-gradient(160deg, #0E3B4A, var(--secondary)); }
.book:nth-child(4n+3) .book-cover { background: linear-gradient(160deg, #2A1760, var(--accent)); }
.book:nth-child(4n+4) .book-cover { background: linear-gradient(160deg, var(--hero-800), #0369A1); }
.card-grid.books { grid-template-columns: repeat(auto-fill, minmax(min(100%, 190px), 1fr)); }

/* events */
.event { display: grid; grid-template-columns: 76px minmax(0, 1fr); gap: 14px; padding: 16px; }
.event-date { border-radius: 12px; text-align: center; padding: 10px 6px; background: var(--primary-soft); color: var(--primary); align-self: start; }
.event-date b { display: block; font-size: 1.6rem; line-height: 1; }
.event-date small { font-weight: 700; text-transform: uppercase; font-size: .7rem; }

/* ---- Chat -------------------------------------------------------------------- */
.chat { display: grid; grid-template-columns: 300px minmax(0, 1fr); height: calc(100dvh - var(--header-h) - 150px); min-height: 460px; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; box-shadow: var(--shadow-sm); }
.chat-list { border-right: 1px solid var(--border); overflow-y: auto; display: flex; flex-direction: column; }
.chat-list .search-box { padding: 12px; flex: 0 0 auto; }
.chat-list .search-box > .ic { left: 24px; }
.conv { display: flex; gap: 10px; align-items: center; padding: 12px 14px; text-decoration: none; color: inherit; border-bottom: 1px solid var(--border); }
.conv:hover { background: var(--surface-2); }
.conv.active { background: var(--primary-soft); }
.conv .meta { flex: 1; min-width: 0; }
.conv .t { display: flex; justify-content: space-between; gap: 6px; font-weight: 700; font-size: .9rem; }
.conv .t span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.conv .s { color: var(--muted); font-size: .8rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.av-wrap { position: relative; }
.online { position: absolute; right: 0; bottom: 0; width: 11px; height: 11px; border-radius: 50%; background: var(--success); border: 2px solid var(--surface); }
.chat-main { display: flex; flex-direction: column; min-width: 0; min-height: 0; }
.chat-head { display: flex; gap: 10px; align-items: center; padding: 12px 16px; border-bottom: 1px solid var(--border); }
.chat-head .back-btn { display: none; }
.msgs { flex: 1; overflow-y: auto; padding: 18px; display: flex; flex-direction: column; gap: 8px; background: var(--surface-2); background-image: var(--pattern); background-size: 22px 22px; }
.msg { max-width: min(78%, 560px); padding: 9px 13px; border-radius: 16px; font-size: .92rem; white-space: pre-wrap; overflow-wrap: anywhere; box-shadow: var(--shadow-sm); }
.msg.me { align-self: flex-end; background: linear-gradient(135deg, var(--primary), var(--primary-dark)); color: var(--on-color); border-bottom-right-radius: 4px; }
.msg.them { align-self: flex-start; background: var(--surface); border: 1px solid var(--border); border-bottom-left-radius: 4px; }
.msg time { display: block; font-size: .7rem; opacity: .75; margin-top: 3px; text-align: right; }
.msg .from { font-size: .72rem; font-weight: 700; color: var(--secondary); display: block; }
.chat-form { display: flex; gap: 8px; padding: 12px; border-top: 1px solid var(--border); align-items: flex-end; }
.chat-form .input { min-height: 44px; max-height: 140px; resize: none; }
.chat-empty { flex: 1; display: grid; place-items: center; padding: 20px; }
@media (max-width: 800px) {
  .chat { grid-template-columns: minmax(0, 1fr); height: calc(100dvh - var(--header-h) - 120px); }
  .chat.has-room .chat-list { display: none; }
  .chat:not(.has-room) .chat-main { display: none; }
  .chat-head .back-btn { display: inline-flex; }
}

/* ---- Notifications ------------------------------------------------------------ */
.notif { display: flex; gap: 12px; padding: 14px 16px; border-bottom: 1px solid var(--border); text-decoration: none; color: inherit; align-items: flex-start; }
.notif:last-child { border-bottom: 0; }
.notif:hover { background: var(--surface-2); }
.notif.unread { background: color-mix(in srgb, var(--primary-soft) 60%, transparent); }
.notif .n-ic { width: 38px; height: 38px; border-radius: 12px; display: grid; place-items: center; flex: 0 0 auto; }
.notif .n-body { flex: 1; min-width: 0; }
.notif .n-title { font-weight: 700; display: flex; gap: 8px; align-items: center; }
.notif .n-title .dot { width: 8px; height: 8px; border-radius: 50%; background: var(--primary); }
.notif time { color: var(--muted); font-size: .78rem; white-space: nowrap; }

/* ---- Profile / settings -------------------------------------------------------- */
.profile-head { display: flex; gap: 20px; align-items: center; flex-wrap: wrap; }
.profile-head .info { flex: 1; min-width: 200px; }
.profile-head h2 { margin: 0 0 6px; }
.settings { display: grid; grid-template-columns: 240px minmax(0, 1fr); gap: 18px; align-items: start; }
.settings-nav { position: sticky; top: calc(var(--header-h) + 16px); display: flex; flex-direction: column; gap: 4px; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 8px; }
.settings-nav a { display: flex; gap: 10px; align-items: center; padding: 10px 12px; border-radius: 10px; text-decoration: none; color: var(--text-2); font-weight: 600; font-size: .9rem; }
.settings-nav a.active, .settings-nav a:hover { background: var(--primary-soft); color: var(--primary); }
@media (max-width: 860px) { .settings { grid-template-columns: minmax(0, 1fr); } .settings-nav { position: static; flex-direction: row; overflow-x: auto; } .settings-nav a { white-space: nowrap; } }
.theme-pick { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 12px; }
.theme-pick label { border: 1px solid var(--border); border-radius: 12px; padding: 14px; cursor: pointer; display: flex; flex-direction: column; gap: 8px; align-items: center; font-weight: 600; }
.theme-pick input { accent-color: var(--primary); }
.theme-pick label:has(input:checked) { border-color: var(--primary); box-shadow: var(--ring); }
@media (max-width: 480px) { .theme-pick { grid-template-columns: minmax(0, 1fr); } }

/* search page */
.search-group { margin-bottom: 18px; }
.search-group h2 { font-size: 1rem; display: flex; gap: 8px; align-items: center; }
.search-hit { display: flex; gap: 12px; align-items: center; padding: 12px 14px; border: 1px solid var(--border); border-radius: 12px; background: var(--surface); text-decoration: none; color: inherit; margin-bottom: 8px; transition: border-color var(--t-fast), box-shadow var(--t-fast); }
.search-hit:hover { border-color: var(--primary); box-shadow: var(--shadow-sm); }
.search-hit small { display: block; color: var(--muted); }
mark { background: color-mix(in srgb, var(--warning) 25%, transparent); color: inherit; border-radius: 3px; padding: 0 2px; }

/* error pages */
.error-page { min-height: 60vh; display: grid; place-items: center; text-align: center; padding: 40px 16px; }
.error-page .code { font-size: clamp(3.5rem, 2rem + 8vw, 7rem); font-weight: 900; line-height: 1; background: linear-gradient(135deg, var(--primary), var(--accent)); -webkit-background-clip: text; background-clip: text; color: transparent; }
.offline-bar { position: fixed; left: 50%; bottom: 16px; transform: translateX(-50%); z-index: 9000; background: var(--warning); color: var(--on-color); font-weight: 600; font-size: .85rem; padding: 8px 16px; border-radius: 999px; box-shadow: var(--shadow); }

/* ---- utilities generated for CSP-safe widths (no inline styles) ---- */
.fill-0 { width: 0%; } .w-0 { width: 0%; }
.fill-5 { width: 5%; } .w-5 { width: 5%; }
.fill-10 { width: 10%; } .w-10 { width: 10%; }
.fill-15 { width: 15%; } .w-15 { width: 15%; }
.fill-20 { width: 20%; } .w-20 { width: 20%; }
.fill-25 { width: 25%; } .w-25 { width: 25%; }
.fill-30 { width: 30%; } .w-30 { width: 30%; }
.fill-35 { width: 35%; } .w-35 { width: 35%; }
.fill-40 { width: 40%; } .w-40 { width: 40%; }
.fill-45 { width: 45%; } .w-45 { width: 45%; }
.fill-50 { width: 50%; } .w-50 { width: 50%; }
.fill-55 { width: 55%; } .w-55 { width: 55%; }
.fill-60 { width: 60%; } .w-60 { width: 60%; }
.fill-65 { width: 65%; } .w-65 { width: 65%; }
.fill-70 { width: 70%; } .w-70 { width: 70%; }
.fill-75 { width: 75%; } .w-75 { width: 75%; }
.fill-80 { width: 80%; } .w-80 { width: 80%; }
.fill-85 { width: 85%; } .w-85 { width: 85%; }
.fill-90 { width: 90%; } .w-90 { width: 90%; }
.fill-95 { width: 95%; } .w-95 { width: 95%; }
.fill-100 { width: 100%; } .w-100 { width: 100%; }

.search-mobile { display: none; }
@media (max-width: 1024px) { .search-mobile { display: inline-flex; } }
.modal-media { border-radius: 12px; margin-bottom: 8px; }
.no-pad { padding: 0; }
.center-text { text-align: center; }
.section-head-row { align-items: flex-end; margin-bottom: 8px; }
.section-head-row .section-head { margin-bottom: 0; }
.docs-list .card-grid { display: block; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow-sm); overflow: hidden; }
.books-list .card-grid { grid-template-columns: repeat(auto-fill, minmax(min(100%, 200px), 1fr)); }
.preview-img { display: block; max-height: 520px; margin: 16px auto 0; border-radius: 12px; border: 1px solid var(--border); }
.mb { margin-bottom: 14px; }
.grow { flex: 1; min-width: 0; margin: 0; }
.card-h.pad { padding: 14px 16px 0; }
.pad-x { padding: 8px 14px; margin: 0; }
.conv-btn { width: 100%; background: none; border: 0; border-bottom: 1px solid var(--border); font: inherit; text-align: left; cursor: pointer; }
.code-big { font-size: 1.15rem; font-weight: 800; letter-spacing: .12em; padding: 4px 10px; border-radius: 8px; background: var(--primary-soft); color: var(--primary); }
.chip { text-decoration: none; color: var(--text-2); }
.chip-active { background: var(--primary); color: var(--on-color); border-color: var(--primary); }
.text-danger { color: var(--danger); }
.logo-preview { border-radius: 50%; border: 1px solid var(--border); background: var(--on-color); }
.score { display: flex; align-items: center; gap: 10px; min-width: 140px; }
.score .progress { flex: 1; }
.nowrap-ellipsis { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.btn-block { width: 100%; }
.center.center-text, .section-head.center { text-align: center; }
.brand-name { color: var(--text); }
.site-footer .brand-name { color: var(--on-color); }
.month-card .btn-block { margin-top: auto; }
.chat-main-in { display: flex; flex-direction: column; height: 100%; min-height: 0; }
details.annex summary .ic { transition: transform var(--t-fast); }
details.annex[open] summary .ic { transform: rotate(180deg); }
.skeleton-wrap + .skeleton-wrap { margin-top: 12px; }

/* Narrow phones: keep the cabinet header to essential controls (theme & account stay in Settings / sidebar) */
@media (max-width: 560px) { .app-header .brand-text { display: none; } .app-header { gap: 4px; padding: 0 10px; } }
@media (max-width: 400px) { .app-header [data-theme], .app-header .user-menu { display: none; } }
@media (max-width: 1240px) { .site-header .brand { flex: 0 1 auto; min-width: 0; } .site-header .brand-name { overflow: hidden; text-overflow: ellipsis; } }
@media (max-width: 440px) { .site-header .brand-text { display: none; } }
.site-footer .row { flex-wrap: nowrap; align-items: flex-start; }

/* chat attachments */
.msg-body { display: block; }
.msg-img { display: block; margin-top: 6px; }
.msg-img img { max-width: min(260px, 60vw); max-height: 220px; border-radius: 10px; display: block; }
.msg-file { display: inline-flex; gap: 6px; align-items: center; margin-top: 6px; padding: 6px 10px; border-radius: 8px; background: rgba(255,255,255,.18); color: inherit; text-decoration: none; max-width: 100%; }
.msg.them .msg-file { background: var(--surface-2); border: 1px solid var(--border); }
.msg-file span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; min-width: 0; }
.chat-attach { display: flex; align-items: center; gap: 8px; padding: 6px 14px; border-top: 1px solid var(--border); font-size: .88rem; color: var(--text-2); }
.chat-attach span { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.chat-form { position: relative; }
.perm-table th[scope=row] { text-transform: none; letter-spacing: 0; font-weight: 600; color: var(--text); white-space: normal; background: var(--surface); min-width: 220px; }
.perm-yes { display: inline-grid; place-items: center; width: 26px; height: 26px; border-radius: 50%; background: var(--success-soft); color: var(--success); }
.perm-no { color: var(--border-strong); }
