:root {
  --bg: #f4f7fb;
  --panel: #ffffff;
  --panel-2: #f8fafc;
  --line: #d8e1ee;
  --text: #18212f;
  --muted: #5b6b83;
  --primary: #1d4ed8;
  --primary-2: #173fb0;
  --soft: #eef4ff;
  --good: #0f766e;
  --warn: #b45309;
  --shadow: 0 10px 28px rgba(15, 23, 42, 0.08);
  --radius: 18px;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font-family: Inter, "Segoe UI", Tahoma, sans-serif;
  color: var(--text);
  background: linear-gradient(180deg, #ffffff 0%, var(--bg) 100%);
}

a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }
img { max-width: 100%; display: block; }
button, input, textarea, select {
  font: inherit;
}
button { cursor: pointer; }
label {
  display: block;
  font-size: 13px;
  font-weight: 700;
  color: var(--muted);
  margin-bottom: 8px;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  display: grid;
  grid-template-columns: auto minmax(180px, 320px) auto;
  gap: 16px;
  align-items: center;
  padding: 14px 18px;
  background: rgba(255,255,255,0.92);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--line);
}
.topbar-left, .topbar-right, .topbar-mid {
  display: flex;
  align-items: center;
  gap: 12px;
}
.topbar-right { justify-content: flex-end; flex-wrap: wrap; }
.topbar-mid { justify-content: center; }
.topbar-title .name {
  font-size: 18px;
  font-weight: 800;
  line-height: 1.1;
}
.topbar-title .sub {
  font-size: 12px;
  color: var(--muted);
}
.logo {
  width: 42px;
  height: 42px;
  border-radius: 14px;
  display: grid;
  place-items: center;
  font-weight: 800;
  color: #fff;
  background: linear-gradient(135deg, var(--primary), #4f46e5);
  box-shadow: var(--shadow);
}

.layout {
  display: grid;
  grid-template-columns: 320px minmax(0, 1fr) 360px;
  gap: 18px;
  padding: 18px;
  align-items: start;
}
.sidebar, .maincol, .rightcol {
  min-width: 0;
}
.maincol {
  display: grid;
  gap: 18px;
}
.rightcol {
  display: grid;
  gap: 18px;
}

.panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  overflow: hidden;
}
.panel-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 16px 18px;
  border-bottom: 1px solid var(--line);
  background: linear-gradient(180deg, #ffffff, #fbfdff);
}
.panel-body {
  padding: 16px 18px;
}
.panel-title {
  font-size: 16px;
  font-weight: 800;
}
.hint {
  font-size: 12px;
  color: var(--muted);
  line-height: 1.45;
}
.side-panel .panel-body { padding-top: 14px; }

.input,
.select,
.textarea {
  width: 100%;
  border: 1px solid var(--line);
  background: #fff;
  color: var(--text);
  border-radius: 14px;
  padding: 12px 14px;
  outline: none;
  transition: border-color .15s ease, box-shadow .15s ease;
}
.textarea {
  resize: vertical;
  min-height: 110px;
}
.input:focus,
.select:focus,
.textarea:focus {
  border-color: #9bb8ff;
  box-shadow: 0 0 0 4px rgba(29, 78, 216, 0.08);
}
.select {
  min-width: 220px;
  background: #fff;
}

.btn {
  appearance: none;
  border: 1px solid var(--line);
  background: #fff;
  color: var(--text);
  border-radius: 12px;
  padding: 10px 14px;
  font-weight: 700;
  line-height: 1;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 40px;
}
.btn:hover { text-decoration: none; background: #f8fbff; }
.btn.primary {
  background: var(--primary);
  border-color: var(--primary);
  color: #fff;
}
.btn.primary:hover { background: var(--primary-2); }
.btn.small {
  min-height: 34px;
  padding: 8px 12px;
  font-size: 13px;
}

.people {
  padding: 14px;
}
.member-group-title {
  font-size: 12px;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: .08em;
  color: var(--muted);
  margin-bottom: 10px;
}
.member-group-title.top-gap { margin-top: 18px; }
.person {
  display: grid;
  grid-template-columns: 52px minmax(0,1fr) auto;
  gap: 12px;
  align-items: center;
  padding: 12px;
  border: 1px solid var(--line);
  background: var(--panel-2);
  border-radius: 16px;
  margin-bottom: 10px;
}
.person.is-director {
  grid-template-columns: 52px minmax(0,1fr);
}
.person.active {
  border-color: #93c5fd;
  background: #eff6ff;
  box-shadow: inset 0 0 0 1px #bfdbfe;
}
.avatar {
  width: 52px;
  height: 52px;
  border-radius: 16px;
  object-fit: cover;
  border: 1px solid #d5def0;
  background: linear-gradient(135deg, #eef2ff, #dbeafe);
  display: grid;
  place-items: center;
  overflow: hidden;
}
.avatar span {
  font-weight: 800;
  color: var(--primary);
}
.director-avatar {
  background: linear-gradient(135deg, #dbeafe, #bfdbfe);
}
.pmeta { min-width: 0; }
.pname {
  font-size: 14px;
  font-weight: 800;
  margin-bottom: 2px;
}
.prole {
  font-size: 12px;
  color: var(--muted);
  margin-bottom: 4px;
}
.pexp {
  font-size: 12px;
  color: #334155;
  line-height: 1.4;
}
.pstate {
  font-size: 11px;
  font-weight: 800;
  color: var(--primary);
  background: #dbeafe;
  border-radius: 999px;
  padding: 6px 9px;
}

.composer {
  padding: 16px 18px;
}
.composer-actions {
  margin-top: 12px;
  display: flex;
  gap: 10px;
  justify-content: flex-end;
}
.transcript-stack {
  min-height: 520px;
}
.transcript-list {
  max-height: calc(100vh - 280px);
  min-height: 420px;
  overflow: auto;
  padding: 16px 18px 18px;
  background: linear-gradient(180deg, #ffffff 0%, #f8fbff 100%);
}
.msg {
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 14px;
  background: #fff;
  margin-bottom: 12px;
}
.msg.user {
  background: #eff6ff;
  border-color: #bfdbfe;
}
.msg.assistant {
  background: #ffffff;
}
.msg.system {
  background: #fff7ed;
  border-color: #fed7aa;
}
.msg-meta {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 8px;
}
.msg-who {
  font-size: 12px;
  font-weight: 800;
}
.msg-time {
  font-size: 11px;
  color: var(--muted);
}
.msg-body {
  font-size: 14px;
  line-height: 1.55;
  white-space: normal;
  word-break: break-word;
}

.task-entry {
  display: grid;
  grid-template-columns: minmax(0,1fr) auto;
  gap: 10px;
  margin-bottom: 12px;
}
.task-list { display: grid; gap: 10px; }
.task {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  border: 1px solid var(--line);
  background: var(--panel-2);
  border-radius: 14px;
  padding: 10px 12px;
  cursor: pointer;
}
.task.done {
  opacity: .7;
  background: #f0fdf4;
  border-color: #bbf7d0;
}
.task input { margin-top: 3px; }
.task-text {
  font-size: 13px;
  line-height: 1.45;
}
.task.done .task-text { text-decoration: line-through; }

.minutes-box {
  margin: 0;
  padding: 16px 18px 18px;
  white-space: pre-wrap;
  word-break: break-word;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 12px;
  line-height: 1.5;
  max-height: 300px;
  overflow: auto;
  background: linear-gradient(180deg, #ffffff, #f8fafc);
}

.alert {
  margin: 0 auto 16px;
  max-width: 1180px;
  padding: 12px 14px;
  border-radius: 14px;
  border: 1px solid #fecaca;
  background: #fef2f2;
  color: #991b1b;
  font-weight: 700;
}
.alert.subtle {
  border-color: #bfdbfe;
  background: #eff6ff;
  color: #1e3a8a;
}

.auth {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
}
.auth-card {
  width: min(100%, 480px);
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 24px;
  box-shadow: var(--shadow);
  padding: 28px;
}
.brand {
  display: flex;
  align-items: center;
  gap: 14px;
  margin-bottom: 20px;
}
.brand-title {
  font-size: 20px;
  font-weight: 800;
}
.brand-sub {
  font-size: 13px;
  color: var(--muted);
}
.auth-form { display: grid; gap: 12px; }
.auth-foot {
  margin-top: 16px;
  font-size: 13px;
  color: var(--muted);
}

.settings-page .topbar { position: sticky; }
.settings-wrap {
  max-width: 1180px;
  margin: 0 auto;
  padding: 18px;
}
.settings-form { display: grid; gap: 18px; }
.settings-panel .panel-body { padding: 18px; }
.grid2 {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 16px;
}
.members-admin {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 16px;
}
.member-edit-card {
  border: 1px solid var(--line);
  border-radius: 18px;
  background: var(--panel-2);
  padding: 14px;
  display: grid;
  gap: 12px;
}
.member-edit-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}
.member-key-tag {
  font-size: 12px;
  font-weight: 800;
  color: var(--primary);
  background: #dbeafe;
  border-radius: 999px;
  padding: 6px 10px;
}
.member-thumb {
  width: 44px;
  height: 44px;
  border-radius: 14px;
  border: 1px solid var(--line);
  object-fit: cover;
  background: #fff;
}
.settings-actions {
  display: flex;
  justify-content: flex-end;
}

@media (max-width: 1200px) {
  .layout {
    grid-template-columns: 300px minmax(0, 1fr);
  }
  .rightcol {
    grid-column: 1 / -1;
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }
}

@media (max-width: 900px) {
  .topbar {
    grid-template-columns: 1fr;
    justify-items: stretch;
  }
  .topbar-left, .topbar-mid, .topbar-right {
    justify-content: flex-start;
  }
  .layout {
    grid-template-columns: 1fr;
  }
  .rightcol {
    grid-template-columns: 1fr;
  }
  .transcript-list {
    max-height: none;
    min-height: 320px;
  }
  .grid2,
  .members-admin {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 640px) {
  .layout,
  .settings-wrap,
  .auth {
    padding: 12px;
  }
  .panel-head,
  .panel-body,
  .composer,
  .transcript-list,
  .minutes-box {
    padding-left: 14px;
    padding-right: 14px;
  }
  .person {
    grid-template-columns: 46px minmax(0,1fr);
  }
  .pstate { display: none; }
  .task-entry {
    grid-template-columns: 1fr;
  }
  .composer-actions,
  .settings-actions {
    justify-content: stretch;
    flex-direction: column;
  }
  .composer-actions .btn,
  .settings-actions .btn,
  .topbar-right .btn {
    width: 100%;
  }
}
