:root {
  --indigo: #4f46e5;
  --indigo-dark: #4338ca;
  --line: #06c755;
  --bg: #f8fafc;
  --card: #fff;
  --text: #1e293b;
  --muted: #64748b;
}

* { box-sizing: border-box; }
body {
  margin: 0;
  font-family: 'Noto Sans Thai', sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
}

.screen { display: none; min-height: 100vh; }
.screen.active { display: flex; flex-direction: column; }

#loadingScreen { align-items: center; justify-content: center; gap: 1rem; }
.loader {
  width: 64px;
  height: 64px;
  border-radius: 16px;
  background: linear-gradient(135deg, var(--indigo), #7c3aed);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.75rem;
}

#loginScreen {
  align-items: center;
  justify-content: center;
  padding: 1.5rem;
}
body.meetdoc-auth-lock #appScreen,
body.meetdoc-auth-lock #manageScreen,
body.meetdoc-auth-lock #detailScreen {
  display: none !important;
  visibility: hidden !important;
  pointer-events: none !important;
}
body.meetdoc-auth-lock #mdDrawer,
body.meetdoc-auth-lock #mdConfirmOverlay {
  display: none !important;
  visibility: hidden !important;
}
body.meetdoc-auth-lock #loginScreen {
  display: flex !important;
  position: fixed;
  inset: 0;
  z-index: 50000;
  background: var(--bg);
  overflow-y: auto;
}
.login-card { width: 100%; max-width: 400px; }
.card {
  background: var(--card);
  border-radius: 20px;
  padding: 1.75rem;
  box-shadow: 0 12px 40px rgba(15, 23, 42, 0.08);
}
.brand { text-align: center; margin-bottom: 1.5rem; }
.brand h1 { margin: 0.5rem 0 0; font-size: 1.5rem; }
.brand p { margin: 0.25rem 0 0; color: var(--muted); font-size: 0.875rem; }
.brand-org {
  margin: 0.35rem 0 0;
  font-size: 0.75rem;
  color: var(--indigo);
  font-weight: 600;
  line-height: 1.4;
}

.coop-logo {
  flex-shrink: 0;
  object-fit: contain;
  border-radius: 10px;
  background: #fff;
  box-shadow: 0 2px 8px rgba(15, 23, 42, 0.08);
}
.coop-logo--lg {
  width: 72px;
  height: 72px;
  margin: 0 auto 0.75rem;
  display: block;
}
.coop-logo--sm {
  border-radius: 8px;
}

.topbar-main {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  min-width: 0;
  flex: 1;
}
.topbar-user {
  min-width: 0;
}

.lbl { display: block; font-size: 0.8rem; font-weight: 600; margin: 0.75rem 0 0.35rem; color: var(--muted); }
.inp {
  width: 100%;
  padding: 0.75rem 1rem;
  border: 2px solid #e2e8f0;
  border-radius: 12px;
  font-size: 1rem;
  font-family: inherit;
}
.inp:focus { outline: none; border-color: var(--indigo); }

.btn {
  width: 100%;
  margin-top: 0.75rem;
  padding: 0.85rem;
  border: none;
  border-radius: 12px;
  font-size: 1rem;
  font-weight: 600;
  cursor: pointer;
  font-family: inherit;
  transition: transform 0.12s ease, box-shadow 0.15s ease, filter 0.12s ease;
  box-shadow: 0 2px 8px rgba(15, 23, 42, 0.08);
}
.btn-line { background: var(--line); color: #fff; }
.btn-line:hover { filter: brightness(1.05); box-shadow: 0 4px 14px rgba(6, 199, 85, 0.35); }
.btn-primary { background: var(--indigo); color: #fff; }
.btn-primary:hover { background: var(--indigo-dark); box-shadow: 0 4px 14px rgba(79, 70, 229, 0.35); }
.btn:active:not(:disabled),
.btn.is-pressed:not(:disabled),
.icon-btn:active:not(:disabled),
.icon-btn.is-pressed:not(:disabled),
.tab:active:not(:disabled),
.tab.is-pressed:not(:disabled) {
  transform: scale(0.96);
  filter: brightness(0.92);
}
.btn-sm {
  width: auto;
  padding: 0.5rem 1rem;
  font-size: 0.875rem;
  margin-top: 0.5rem;
}
.btn-approve { background: #059669; color: #fff; }
.btn-reject { background: #fef2f2; color: #dc2626; border: 1px solid #fecaca; }

.divider {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  margin: 1.25rem 0;
  color: var(--muted);
  font-size: 0.8rem;
}
.divider::before, .divider::after {
  content: '';
  flex: 1;
  height: 1px;
  background: #e2e8f0;
}

.error { color: #dc2626; font-size: 0.875rem; margin-top: 0.75rem; }
.hint { font-size: 0.75rem; color: var(--muted); text-align: center; margin-top: 1rem; }
.hint-security { color: #94a3b8; line-height: 1.45; }
.hint-security i { color: #6366f1; margin-right: 0.2rem; font-size: 0.7rem; }
.hidden { display: none !important; }

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 1rem 1.25rem;
  background: var(--card);
  border-bottom: 1px solid #e2e8f0;
}
.topbar h2 { margin: 0; font-size: 1.1rem; }
.topbar-sub { margin: 0; font-size: 0.75rem; color: var(--muted); }
.role-badge {
  display: inline-block;
  margin-top: 0.25rem;
  font-size: 0.7rem;
  padding: 0.15rem 0.5rem;
  background: #eef2ff;
  color: var(--indigo);
  border-radius: 999px;
}
.detail-top {
  gap: 0.5rem;
}
.detail-top h2 {
  flex: 1;
  text-align: left;
  font-size: 1rem;
  margin: 0;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.icon-btn {
  border: none;
  background: #f1f5f9;
  width: 40px;
  height: 40px;
  border-radius: 10px;
  cursor: pointer;
  color: var(--muted);
  transition: transform 0.12s ease, background 0.15s ease, color 0.15s ease;
}
.icon-btn:hover {
  background: #e2e8f0;
  color: var(--indigo);
}

.tabs {
  display: flex;
  gap: 0.5rem;
  padding: 0.75rem 1rem;
  background: var(--card);
}
.tab {
  flex: 1;
  padding: 0.6rem;
  border: none;
  background: #f1f5f9;
  border-radius: 10px;
  font-family: inherit;
  font-weight: 600;
  cursor: pointer;
  color: var(--muted);
  transition: transform 0.12s ease, background 0.15s ease, color 0.15s ease;
}
.tab.active { background: var(--indigo); color: #fff; }
.tab:not(.active):hover { background: #e2e8f0; }

.page { flex: 1; padding: 1rem 1.25rem 2rem; overflow-y: auto; }

.meeting-card {
  background: var(--card);
  border-radius: 14px;
  padding: 1rem;
  margin-bottom: 0.75rem;
  box-shadow: 0 2px 8px rgba(15, 23, 42, 0.05);
  cursor: pointer;
  border: 1px solid #e2e8f0;
}
.meeting-card:hover { border-color: var(--indigo); }
.meeting-card h3 { margin: 0 0 0.35rem; font-size: 1rem; }
.meeting-card .meta { font-size: 0.8rem; color: var(--muted); }
.status-pill {
  display: inline-block;
  font-size: 0.7rem;
  padding: 0.2rem 0.5rem;
  border-radius: 6px;
  background: #eef2ff;
  color: var(--indigo);
  margin-top: 0.5rem;
}

.detail-section {
  background: var(--card);
  border-radius: 14px;
  padding: 1rem;
  margin-bottom: 0.75rem;
  border: 1px solid #e2e8f0;
}
.detail-section h4 { margin: 0 0 0.75rem; font-size: 0.9rem; color: var(--indigo); }
.agenda-item { padding: 0.5rem 0; border-bottom: 1px solid #f1f5f9; font-size: 0.9rem; }
.file-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  padding: 0.5rem 0;
}
.empty { text-align: center; color: var(--muted); padding: 2rem; font-size: 0.9rem; }

.toast {
  position: fixed;
  top: 1rem;
  left: 50%;
  transform: translateX(-50%) translateY(-120%);
  background: #1e293b;
  color: #fff;
  padding: 0.85rem 1.35rem;
  border-radius: 12px;
  font-size: 0.9rem;
  font-weight: 600;
  z-index: 30000;
  max-width: min(92vw, 420px);
  text-align: center;
  box-shadow: 0 12px 40px rgba(15, 23, 42, 0.28);
  pointer-events: none;
  opacity: 0;
  transition: transform 0.35s cubic-bezier(0.34, 1.4, 0.64, 1), opacity 0.25s ease;
}
.toast--visible {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}
.toast-ok { background: linear-gradient(135deg, #047857, #059669); }
.toast-error { background: linear-gradient(135deg, #b91c1c, #dc2626); }

body.meetdoc-pdf-open { overflow: hidden; }

.md-pdf-viewer {
  position: fixed;
  inset: 0;
  z-index: 40000;
  display: flex;
  align-items: stretch;
  justify-content: center;
}
.md-pdf-viewer.hidden { display: none !important; }
.md-pdf-viewer-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(15, 23, 42, 0.55);
}
.md-pdf-viewer-panel {
  position: relative;
  z-index: 1;
  display: flex;
  flex-direction: column;
  width: 100%;
  max-width: 960px;
  margin: 0 auto;
  height: 100%;
  max-height: 100vh;
  background: #fff;
  box-shadow: 0 20px 50px rgba(15, 23, 42, 0.25);
}
.md-pdf-viewer-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  padding: 0.75rem 1rem;
  border-bottom: 1px solid #e2e8f0;
  font-weight: 600;
  color: var(--indigo);
}
.md-pdf-viewer-close {
  border: none;
  background: #f1f5f9;
  color: #475569;
  width: 2.25rem;
  height: 2.25rem;
  border-radius: 8px;
  cursor: pointer;
  font-size: 1rem;
}
.md-pdf-viewer-frame {
  flex: 1;
  width: 100%;
  border: none;
  background: #f8fafc;
}
.md-pdf-viewer-foot {
  padding: 0.65rem 1rem;
  border-top: 1px solid #e2e8f0;
  text-align: center;
}
.md-pdf-viewer-ext {
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--indigo);
  text-decoration: none;
}
.toast-info { background: linear-gradient(135deg, #3730a3, #4f46e5); }

#manageScreen.active { display: flex; flex-direction: column; }
.manage-topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.75rem 1rem;
  background: #fff;
  border-bottom: 1px solid #e2e8f0;
  position: sticky;
  top: 0;
  z-index: 40;
}
.manage-body {
  flex: 1;
  overflow: auto;
  padding: 1rem 1rem 1.25rem;
  max-width: 1400px;
  width: 100%;
  margin: 0 auto;
}
.manage-loading {
  text-align: center;
  color: var(--muted);
  padding: 2rem;
}
.role-manage { background: #312e81; color: #fff; }

body.meetdoc-has-footer {
  padding-bottom: 4.75rem;
}

.screen-with-footer {
  min-height: 100vh;
}

.meetdoc-site-footer {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 40;
  padding: 0.8rem 1.25rem 0.9rem;
  text-align: center;
  background: rgba(255, 255, 255, 0.97);
  backdrop-filter: blur(8px);
  border-top: 1px solid #e2e8f0;
  box-shadow: 0 -6px 24px rgba(15, 23, 42, 0.06);
}

body.meetdoc-auth-lock .meetdoc-site-footer {
  z-index: 50001;
}

.site-footer-copy {
  margin: 0;
  font-size: 0.7rem;
  color: #64748b;
  font-weight: 500;
}
.site-footer-security {
  margin: 0.3rem 0 0;
  font-size: 0.65rem;
  color: #94a3b8;
  line-height: 1.45;
}
.site-footer-security i {
  margin-right: 0.2rem;
  color: #6366f1;
  font-size: 0.6rem;
}

#loginScreen.active {
  justify-content: center;
  padding-bottom: 4.75rem;
}
#loginScreen .login-card {
  display: flex;
  flex-direction: column;
}
