:root {
  --bg: #020813;
  --panel: rgba(4, 28, 62, .82);
  --panel-2: rgba(2, 14, 30, .88);
  --line: rgba(101, 236, 255, .18);
  --line-strong: rgba(101, 236, 255, .42);
  --text: #edfaff;
  --muted: rgba(221, 239, 252, .72);
  --cyan: #65ecff;
  --blue: #0787ff;
  --green: #00e28a;
  --danger: #ff647c;
  --warning: #ffd84d;
  --shadow: 0 22px 70px rgba(0,0,0,.38), inset 0 1px rgba(255,255,255,.08);
}

* { box-sizing: border-box; }
html { min-height: 100%; background: var(--bg); }
body {
  margin: 0;
  min-height: 100vh;
  color: var(--text);
  background:
    radial-gradient(circle at 16% 20%, rgba(25,185,255,.18), transparent 28%),
    radial-gradient(circle at 86% 14%, rgba(0,226,138,.12), transparent 24%),
    radial-gradient(circle at 50% 100%, rgba(7,135,255,.10), transparent 36%),
    linear-gradient(135deg, #020813, #04162b 50%, #020813);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Arial, sans-serif;
  overflow-x: hidden;
}
body::before {
  content: "";
  position: fixed;
  inset: 0;
  pointer-events: none;
  opacity: .26;
  background-image:
    linear-gradient(rgba(255,255,255,.035) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255,255,255,.035) 1px, transparent 1px);
  background-size: 42px 42px;
  mask-image: radial-gradient(ellipse at center, #000 0%, transparent 75%);
}

a { color: inherit; text-decoration: none; }
button, input, textarea, select { font: inherit; }
button { border: 0; }

.system-shell {
  position: relative;
  z-index: 1;
  width: min(1500px, calc(100% - 40px));
  margin: 0 auto;
  padding: 20px 0 34px;
}

.system-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  min-height: 78px;
  margin-bottom: 18px;
  padding: 14px 18px;
  border: 1px solid rgba(255,255,255,.08);
  border-radius: 24px;
  background: rgba(2, 14, 30, .68);
  box-shadow: var(--shadow);
  backdrop-filter: blur(22px);
}
.brand {
  display: flex;
  align-items: center;
  gap: 14px;
  min-width: 260px;
}
.brand img { width: 118px; height: auto; display: block; }
.brand-text span {
  display: block;
  font-size: 15px;
  font-weight: 950;
  letter-spacing: -.01em;
}
.brand-text small {
  display: block;
  margin-top: 4px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 750;
}
.header-title { text-align: center; }
.header-title span {
  display: block;
  color: #fff;
  font-size: clamp(18px, 1.6vw, 28px);
  line-height: 1.05;
  font-weight: 950;
  letter-spacing: -.035em;
}
.header-title small {
  display: block;
  margin-top: 6px;
  color: var(--cyan);
  font-size: 12px;
  font-weight: 850;
}
.header-actions {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 10px;
  min-width: 260px;
}

.glass-card {
  border: 1px solid rgba(255,255,255,.08);
  border-radius: 28px;
  background: linear-gradient(180deg, rgba(4, 28, 62, .82), rgba(2, 14, 30, .86));
  box-shadow: var(--shadow), 0 0 48px rgba(25,185,255,.08);
  backdrop-filter: blur(22px);
}

.btn, .ghost-btn, .danger-btn, .small-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 42px;
  padding: 0 16px;
  border-radius: 14px;
  cursor: pointer;
  font-weight: 900;
  transition: transform .18s ease, box-shadow .18s ease, border-color .18s ease, background .18s ease;
}
.btn {
  color: #fff;
  background: linear-gradient(135deg, #0787ff, #0bb7ff);
  box-shadow: 0 16px 35px rgba(7,135,255,.22);
}
.btn:hover, .ghost-btn:hover, .danger-btn:hover, .small-btn:hover { transform: translateY(-2px); }
.ghost-btn, .small-btn {
  border: 1px solid rgba(101,236,255,.20);
  color: #eaffff;
  background: rgba(255,255,255,.055);
}
.danger-btn {
  border: 1px solid rgba(255,100,124,.28);
  color: #ffdbe2;
  background: rgba(255,100,124,.09);
}
.small-btn { min-height: 32px; padding: 0 11px; border-radius: 11px; font-size: 12px; }

.login-layout {
  display: grid;
  grid-template-columns: minmax(0, 1.12fr) minmax(360px, .72fr);
  gap: 22px;
  min-height: calc(100vh - 40px);
  align-items: stretch;
  padding: 20px 0;
}
.login-hero {
  position: relative;
  overflow: hidden;
  min-height: 650px;
  padding: clamp(28px, 4vw, 62px);
}
.login-hero::after {
  content: "";
  position: absolute;
  inset: 20px;
  border-radius: 24px;
  background: url('/assets/img/world-map.svg') center / contain no-repeat;
  opacity: .32;
  filter: drop-shadow(0 0 26px rgba(101,236,255,.18));
}
.login-hero-content { position: relative; z-index: 1; max-width: 760px; }
.section-pill {
  display: inline-flex;
  align-items: center;
  min-height: 30px;
  padding: 0 13px;
  border: 1px solid rgba(25, 185, 255, .22);
  border-radius: 999px;
  color: #67d9ff;
  background: rgba(25, 185, 255, .10);
  font-size: 13px;
  font-weight: 850;
}
.login-hero h1 {
  margin: 18px 0 16px;
  max-width: 850px;
  font-size: clamp(38px, 5vw, 82px);
  line-height: .92;
  letter-spacing: -.055em;
}
.login-hero p {
  margin: 0;
  max-width: 650px;
  color: var(--muted);
  font-size: 17px;
  line-height: 1.62;
}
.login-points {
  position: relative;
  z-index: 1;
  display: grid;
  grid-template-columns: repeat(3, minmax(0,1fr));
  gap: 12px;
  margin-top: 44px;
  max-width: 860px;
}
.login-point {
  min-height: 118px;
  padding: 16px;
  border: 1px solid rgba(255,255,255,.09);
  border-radius: 20px;
  background: rgba(255,255,255,.045);
}
.login-point strong { display: block; font-size: 15px; }
.login-point span { display: block; margin-top: 8px; color: var(--muted); font-size: 13px; line-height: 1.45; }
.login-card {
  align-self: center;
  padding: 26px;
}
.login-card h2 { margin: 0 0 8px; font-size: 30px; letter-spacing: -.035em; }
.login-card p { margin: 0 0 20px; color: var(--muted); line-height: 1.5; }
.form-grid { display: grid; gap: 13px; }
.form-row { display: grid; gap: 7px; }
.form-row label { color: #8edfff; font-size: 12px; font-weight: 900; }
.input, .textarea, .select {
  width: 100%;
  min-height: 44px;
  border: 1px solid rgba(101,236,255,.17);
  border-radius: 14px;
  outline: none;
  color: #f8fdff;
  background: rgba(255,255,255,.06);
  padding: 0 13px;
  transition: border-color .16s ease, box-shadow .16s ease, background .16s ease;
}
.textarea { min-height: 116px; padding-top: 12px; resize: vertical; }
.input:focus, .textarea:focus, .select:focus {
  border-color: rgba(101,236,255,.58);
  box-shadow: 0 0 0 4px rgba(101,236,255,.08);
  background: rgba(255,255,255,.075);
}
.select option { background: #06172a; color: #fff; }
.form-message { min-height: 20px; color: var(--danger); font-size: 13px; font-weight: 800; }
.form-hint { margin: -4px 0 4px; color: var(--muted); font-size: 13px; line-height: 1.5; }

.dashboard-grid {
  display: grid;
  grid-template-columns: 360px minmax(0, 1fr);
  gap: 18px;
  align-items: start;
}
.sidebar {
  position: sticky;
  top: 16px;
  padding: 16px;
}
.sidebar-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 13px;
}
.sidebar-head h2, .content-card h2, .admin-panel h2 { margin: 0; font-size: 20px; letter-spacing: -.025em; }
.association-list { display: grid; gap: 10px; max-height: calc(100vh - 210px); overflow: auto; padding-right: 3px; }
.association-item {
  width: 100%;
  display: grid;
  grid-template-columns: 46px minmax(0, 1fr);
  gap: 11px;
  align-items: center;
  min-height: 72px;
  padding: 11px;
  border: 1px solid rgba(255,255,255,.08);
  border-radius: 18px;
  color: inherit;
  text-align: left;
  cursor: pointer;
  background: rgba(255,255,255,.04);
  transition: transform .18s ease, border-color .18s ease, background .18s ease, box-shadow .18s ease;
}
.association-item:hover, .association-item.is-active {
  transform: translateY(-1px);
  border-color: rgba(101,236,255,.38);
  background: rgba(25,185,255,.09);
  box-shadow: 0 14px 34px rgba(0,0,0,.18), 0 0 26px rgba(101,236,255,.08);
}
.association-item img {
  width: 46px;
  height: 46px;
  padding: 4px;
  border-radius: 50%;
  background: #fff;
  object-fit: contain;
}
.association-item strong { display: block; font-size: 14px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.association-item small { display: block; margin-top: 5px; color: var(--muted); font-size: 12px; }
.content-stack { display: grid; gap: 18px; }
.content-card { padding: 18px; }
.association-hero {
  display: grid;
  grid-template-columns: 96px minmax(0, 1fr) auto;
  gap: 18px;
  align-items: center;
  padding: 18px;
  border-radius: 24px;
  background:
    radial-gradient(circle at 20% 15%, rgba(101,236,255,.16), transparent 30%),
    rgba(255,255,255,.04);
  border: 1px solid rgba(255,255,255,.08);
}
.association-hero img { width: 96px; height: 96px; padding: 8px; border-radius: 50%; object-fit: contain; background: #fff; }
.association-hero h1 { margin: 4px 0 8px; font-size: clamp(24px, 2.4vw, 44px); line-height: 1.02; letter-spacing: -.045em; }
.association-hero p { margin: 0; color: var(--muted); line-height: 1.52; }
.facts { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 14px; }
.fact { min-height: 30px; padding: 0 11px; display: inline-flex; align-items: center; border-radius: 999px; color: #dffbff; background: rgba(255,255,255,.06); border: 1px solid rgba(101,236,255,.15); font-size: 12px; font-weight: 850; }
.tabs { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 16px; }
.tab-btn {
  min-height: 38px;
  padding: 0 14px;
  border: 1px solid rgba(101,236,255,.17);
  border-radius: 999px;
  color: rgba(232,248,255,.8);
  background: rgba(255,255,255,.045);
  cursor: pointer;
  font-weight: 900;
}
.tab-btn.is-active { color: #001725; border-color: transparent; background: linear-gradient(135deg, #e8fcff, #65ecff); }
.material-list { display: grid; grid-template-columns: repeat(2, minmax(0,1fr)); gap: 13px; margin-top: 16px; }
.material-card {
  display: grid;
  gap: 10px;
  min-height: 200px;
  padding: 16px;
  border: 1px solid rgba(255,255,255,.08);
  border-radius: 20px;
  background: rgba(255,255,255,.04);
}
.material-meta { display: flex; justify-content: space-between; gap: 10px; align-items: center; color: var(--cyan); font-size: 12px; font-weight: 900; }
.material-card h3 { margin: 0; font-size: 18px; line-height: 1.25; }
.material-card p { margin: 0; color: var(--muted); font-size: 14px; line-height: 1.48; }
.material-actions { display: flex; gap: 8px; align-self: end; flex-wrap: wrap; }
.empty-state { padding: 28px; border: 1px dashed rgba(101,236,255,.25); border-radius: 20px; color: var(--muted); text-align: center; }

.admin-layout { display: grid; gap: 18px; }
.admin-tabs { display: flex; flex-wrap: wrap; gap: 8px; padding: 10px; }
.admin-panel { display: none; padding: 18px; }
.admin-panel.is-active { display: block; }
.admin-grid { display: grid; grid-template-columns: 430px minmax(0, 1fr); gap: 18px; align-items: start; }
.form-card { padding: 16px; border: 1px solid rgba(255,255,255,.08); border-radius: 22px; background: rgba(255,255,255,.04); }
.table-card { overflow: auto; }
.admin-table { width: 100%; border-collapse: collapse; min-width: 760px; }
.admin-table th, .admin-table td { padding: 12px 10px; border-bottom: 1px solid rgba(255,255,255,.08); text-align: left; vertical-align: top; }
.admin-table th { color: #8edfff; font-size: 12px; text-transform: uppercase; letter-spacing: .04em; }
.admin-table td { color: rgba(240,250,255,.88); font-size: 13px; }
.status-pill { display: inline-flex; align-items: center; min-height: 26px; padding: 0 9px; border-radius: 999px; font-size: 12px; font-weight: 900; }
.status-pill.published, .status-pill.active { color: #baffdf; background: rgba(0,226,138,.11); border: 1px solid rgba(0,226,138,.22); }
.status-pill.draft, .status-pill.inactive { color: #ffe89d; background: rgba(255,216,77,.11); border: 1px solid rgba(255,216,77,.22); }
.row-actions { display: flex; gap: 7px; flex-wrap: wrap; }
.ai-grid { display: grid; grid-template-columns: 430px minmax(0, 1fr); gap: 18px; align-items: start; }
.ai-note { margin-bottom: 14px; padding: 14px; border: 1px solid rgba(101,236,255,.14); border-radius: 18px; background: rgba(101,236,255,.055); color: rgba(232,248,255,.84); }
.ai-note code { display: block; margin-top: 8px; color: #7cffc7; overflow-wrap: anywhere; }
.ai-table-card { min-width: 0; }

.modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 60;
  display: none;
  place-items: center;
  padding: 20px;
  background: rgba(0,0,0,.58);
  backdrop-filter: blur(12px);
}
.modal-backdrop.is-open { display: grid; }
.modal {
  width: min(860px, 100%);
  max-height: min(760px, calc(100vh - 40px));
  overflow: auto;
  padding: 22px;
}
.modal h2 { margin: 0 0 10px; font-size: 28px; letter-spacing: -.035em; }
.modal p, .modal pre { color: var(--muted); line-height: 1.65; white-space: pre-wrap; }
.modal-top { display: flex; justify-content: space-between; align-items: flex-start; gap: 14px; }
.close-modal { width: 38px; height: 38px; border-radius: 50%; color: #fff; background: rgba(255,255,255,.08); cursor: pointer; font-size: 24px; }

@media (max-width: 1120px) {
  .login-layout, .dashboard-grid, .admin-grid, .ai-grid { grid-template-columns: 1fr; }
  .sidebar { position: relative; top: auto; }
  .association-list { max-height: none; grid-template-columns: repeat(2, minmax(0,1fr)); }
  .header-actions, .brand { min-width: 0; }
  .system-header { flex-wrap: wrap; }
  .header-title { order: 3; width: 100%; text-align: left; }
}
@media (max-width: 760px) {
  .system-shell { width: min(100% - 24px, 1500px); }
  .login-layout { min-height: auto; }
  .login-hero { min-height: auto; }
  .login-points, .material-list, .association-list { grid-template-columns: 1fr; }
  .association-hero { grid-template-columns: 72px minmax(0,1fr); }
  .association-hero .btn { grid-column: 1 / -1; }
  .association-hero img { width: 72px; height: 72px; }
}


.material-cover {
  width: 100%;
  height: 132px;
  object-fit: cover;
  border-radius: 16px;
  border: 1px solid rgba(101,236,255,.14);
  background: rgba(255,255,255,.04);
}
.material-row-preview {
  display: grid;
  grid-template-columns: 74px minmax(0,1fr);
  gap: 10px;
  align-items: start;
}
.material-row-preview.no-image { grid-template-columns: 1fr; }
.material-admin-thumb {
  width: 74px;
  height: 54px;
  object-fit: cover;
  border-radius: 12px;
  border: 1px solid rgba(101,236,255,.14);
  background: rgba(255,255,255,.06);
}
.modal-image {
  width: 100%;
  max-height: 320px;
  object-fit: cover;
  border-radius: 18px;
  margin: 14px 0 4px;
  border: 1px solid rgba(101,236,255,.16);
  box-shadow: 0 18px 45px rgba(0,0,0,.25);
}
.parser-grid {
  display: grid;
  grid-template-columns: 430px minmax(0, 1fr);
  gap: 18px;
  align-items: start;
}
.parser-card { min-width: 0; }
.parser-source-list { display: grid; gap: 10px; }
.parser-source-item {
  display: grid;
  grid-template-columns: 210px minmax(0, 1fr);
  gap: 12px;
  padding: 12px;
  border: 1px solid rgba(255,255,255,.08);
  border-radius: 16px;
  background: rgba(255,255,255,.035);
}
.parser-source-item strong { display: block; }
.parser-source-item small { display: block; margin-top: 4px; color: var(--muted); }
.parser-links { display: flex; flex-wrap: wrap; gap: 7px; }
.parser-links a {
  display: inline-flex;
  min-height: 28px;
  align-items: center;
  padding: 0 10px;
  border-radius: 999px;
  color: #dffbff;
  background: rgba(101,236,255,.07);
  border: 1px solid rgba(101,236,255,.13);
  font-size: 12px;
  font-weight: 800;
}
.ai-note small { display: block; margin-top: 8px; color: var(--muted); line-height: 1.45; }
@media (max-width: 1120px) { .parser-grid { grid-template-columns: 1fr; } }
@media (max-width: 760px) { .parser-source-item, .material-row-preview { grid-template-columns: 1fr; } }


.content-card-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}
.content-card-head .section-pill { white-space: nowrap; }
.material-list.ai-mode {
  grid-template-columns: 1fr;
}
.ai-chat-card {
  display: grid;
  gap: 16px;
  min-height: 560px;
  padding: 18px;
  border: 1px solid rgba(101,236,255,.14);
  border-radius: 24px;
  background:
    radial-gradient(circle at 16% 0%, rgba(101,236,255,.14), transparent 35%),
    radial-gradient(circle at 88% 12%, rgba(12,255,181,.10), transparent 36%),
    rgba(255,255,255,.035);
  box-shadow: inset 0 0 40px rgba(25,185,255,.04);
}
.ai-chat-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  padding-bottom: 14px;
  border-bottom: 1px solid rgba(255,255,255,.08);
}
.ai-chat-head h3 {
  margin: 10px 0 8px;
  font-size: clamp(22px, 2vw, 34px);
  line-height: 1.05;
  letter-spacing: -.04em;
}
.ai-chat-head p {
  max-width: 760px;
  margin: 0;
  color: var(--muted);
  line-height: 1.55;
}
.ai-chip-row {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 8px;
  min-width: 260px;
}
.chat-messages {
  display: grid;
  align-content: start;
  gap: 10px;
  min-height: 330px;
  max-height: 520px;
  overflow: auto;
  padding: 4px;
}
.chat-bubble {
  width: min(860px, 90%);
  padding: 14px 16px;
  border: 1px solid rgba(255,255,255,.09);
  border-radius: 18px;
  color: rgba(244,251,255,.92);
  line-height: 1.58;
  white-space: pre-wrap;
  background: rgba(255,255,255,.055);
  box-shadow: 0 12px 28px rgba(0,0,0,.16);
}
.chat-bubble.assistant {
  justify-self: start;
  border-color: rgba(101,236,255,.16);
  background: rgba(25,185,255,.075);
}
.chat-bubble.user {
  justify-self: end;
  border-color: rgba(124,255,199,.18);
  background: rgba(12,255,181,.075);
}
.chat-form {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 150px;
  gap: 10px;
  align-items: end;
}
.chat-form .textarea {
  min-height: 74px;
}
.global-ai-hero img {
  width: 128px;
  border-radius: 24px;
  background: rgba(255,255,255,.06);
}
@media (max-width: 980px) {
  .content-card-head, .ai-chat-head, .chat-form { grid-template-columns: 1fr; flex-direction: column; align-items: stretch; }
  .ai-chip-row { justify-content: flex-start; min-width: 0; }
  .chat-form { display: grid; grid-template-columns: 1fr; }
  .chat-bubble { width: 100%; }
}

.ai-header-link {
  border-color: rgba(124,255,199,.32);
  background: linear-gradient(135deg, rgba(0,226,138,.13), rgba(7,135,255,.10));
  box-shadow: 0 12px 34px rgba(0,226,138,.08);
}

.ai-overview-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 12px;
  margin: 0 0 16px;
}
.ai-overview-grid article {
  min-height: 92px;
  padding: 16px;
  border: 1px solid rgba(101,236,255,.15);
  border-radius: 18px;
  background: linear-gradient(180deg, rgba(101,236,255,.08), rgba(255,255,255,.035));
}
.ai-overview-grid strong {
  display: block;
  color: #7cffc7;
  font-size: 22px;
  font-weight: 950;
  line-height: 1.1;
}
.ai-overview-grid span {
  display: block;
  margin-top: 8px;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.35;
}
.ai-chat-card-global {
  box-shadow: inset 0 1px rgba(255,255,255,.08), 0 0 60px rgba(0,226,138,.08);
}

@media (max-width: 980px) {
  .ai-overview-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 620px) {
  .ai-overview-grid { grid-template-columns: 1fr; }
}

/* v1.5 — global AI screen stability */
.ai-chat-card-global {
  min-height: 560px;
}
.ai-overview-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 12px;
  margin: 18px 0;
}
.ai-overview-grid article {
  padding: 16px;
  border: 1px solid rgba(126, 236, 255, .18);
  border-radius: 18px;
  background: linear-gradient(145deg, rgba(14, 56, 92, .62), rgba(4, 22, 42, .56));
}
.ai-overview-grid strong {
  display: block;
  color: #9ff8ff;
  font-size: 22px;
  margin-bottom: 6px;
}
.ai-overview-grid span {
  color: rgba(232, 246, 255, .72);
  font-size: 13px;
}
.chat-messages {
  min-height: 240px;
}
.chat-bubble {
  max-width: 86%;
}
.chat-bubble.user {
  margin-left: auto;
}
@media (max-width: 1100px) {
  .ai-overview-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 640px) {
  .ai-overview-grid { grid-template-columns: 1fr; }
}
