:root {
  --navy: #002d62;
  --blue: #0284c7;
  --blue-light: #e0f2fe;
  --gold: #f59e0b;
  --gold-bg: #fffbeb;
  --bg: #f1f5f9;
  --card: #ffffff;
  --text: #0f172a;
  --muted: #64748b;
  --border: #e2e8f0;
  --success: #16a34a;
  --danger: #dc2626;
  --radius: 12px;
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

body {
  font-family: 'Noto Sans Thai', -apple-system, BlinkMacSystemFont, sans-serif;
  background-color: var(--bg);
  color: var(--text);
  line-height: 1.5;
  padding-bottom: 48px;
}

.container {
  max-width: 1240px;
  margin: 0 auto;
  padding: 0 16px;
}

/* Header */
.app-header {
  background: linear-gradient(135deg, var(--navy) 0%, #004e92 100%);
  color: #fff;
  padding: 16px 0;
  box-shadow: 0 2px 10px rgba(0, 45, 98, 0.15);
  margin-bottom: 24px;
}

.header-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
}

.brand-icon {
  font-size: 28px;
  background: rgba(255, 255, 255, 0.14);
  width: 46px;
  height: 46px;
  border-radius: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.brand h1 {
  font-size: 1.15rem;
  font-weight: 700;
}

.brand p {
  font-size: 0.8rem;
  color: #bae6fd;
}

.header-badge {
  background: rgba(255, 255, 255, 0.18);
  padding: 6px 12px;
  border-radius: 999px;
  font-size: 0.75rem;
  font-weight: 600;
  white-space: nowrap;
}

/* Grid Layout */
.main-grid {
  display: grid;
  grid-template-columns: 1.35fr 1fr;
  gap: 20px;
  align-items: start;
}

@media (max-width: 960px) {
  .main-grid {
    grid-template-columns: 1fr;
  }
}

.form-column {
  display: flex;
  flex-direction: column;
  gap: 18px;
}

.sticky-card {
  position: sticky;
  top: 16px;
}

/* Card */
.card {
  background: var(--card);
  border-radius: var(--radius);
  border: 1px solid var(--border);
  box-shadow: 0 1px 3px rgba(15, 23, 42, 0.05);
  overflow: hidden;
}

.card-header {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 14px 18px;
  border-bottom: 1px solid var(--border);
  background: #f8fafc;
}

.card-header h2 {
  font-size: 0.98rem;
  font-weight: 700;
  flex: 1;
}

.step-num {
  width: 24px;
  height: 24px;
  border-radius: 50%;
  background: var(--navy);
  color: #fff;
  font-size: 0.78rem;
  font-weight: 700;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.card-body {
  padding: 18px;
}

/* Inputs & Forms */
.form-group {
  margin-bottom: 14px;
  position: relative;
}

.form-group:last-child {
  margin-bottom: 0;
}

label {
  display: block;
  font-size: 0.82rem;
  font-weight: 600;
  color: #334155;
  margin-bottom: 6px;
}

.req {
  color: var(--danger);
}

.input {
  width: 100%;
  padding: 9px 12px;
  border: 1px solid #cbd5e1;
  border-radius: 8px;
  font-family: inherit;
  font-size: 0.88rem;
  color: var(--text);
  background: #fff;
  transition: border-color 0.15s, box-shadow 0.15s;
}

.input:focus {
  outline: none;
  border-color: var(--blue);
  box-shadow: 0 0 0 3px rgba(2, 132, 199, 0.15);
}

.row-2 {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

@media (max-width: 560px) {
  .row-2 {
    grid-template-columns: 1fr;
  }
}

/* Buttons */
button {
  font-family: inherit;
  cursor: pointer;
  border: none;
  border-radius: 8px;
  font-weight: 600;
  transition: all 0.15s;
}

.btn-primary {
  background: linear-gradient(135deg, #06c755 0%, #05a847 100%);
  color: #fff;
  padding: 12px 18px;
  font-size: 0.95rem;
  width: 100%;
  box-shadow: 0 2px 6px rgba(6, 199, 85, 0.28);
}

.btn-primary:hover:not(:disabled) {
  filter: brightness(0.95);
  transform: translateY(-1px);
}

.btn-primary:disabled {
  opacity: 0.6;
  cursor: not-allowed;
}

.btn-secondary {
  background: var(--blue-light);
  color: #0369a1;
  padding: 8px 12px;
  font-size: 0.82rem;
}

.btn-secondary:hover {
  background: #bae6fd;
}

.btn-ghost {
  background: transparent;
  color: var(--muted);
  padding: 6px 10px;
  font-size: 0.82rem;
  border: 1px solid var(--border);
}

.btn-ghost:hover {
  background: #f1f5f9;
  color: var(--text);
}

.btn-sm {
  padding: 6px 10px;
  font-size: 0.78rem;
  white-space: nowrap;
}

.btn-icon {
  background: transparent;
  color: var(--muted);
  font-size: 0.9rem;
  padding: 4px 8px;
}

.btn-icon:hover {
  color: var(--danger);
}

/* Quick Picks & Search Dropdown */
.quick-picks {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-bottom: 12px;
}

.quick-chip {
  background: #f1f5f9;
  border: 1px solid var(--border);
  color: #334155;
  padding: 5px 10px;
  border-radius: 999px;
  font-size: 0.76rem;
  font-weight: 500;
}

.quick-chip:hover {
  background: var(--gold-bg);
  border-color: var(--gold);
  color: #92400e;
}

.search-dropdown {
  position: absolute;
  top: 100%;
  left: 0;
  right: 0;
  background: #fff;
  border: 1px solid #cbd5e1;
  border-radius: 8px;
  max-height: 240px;
  overflow-y: auto;
  z-index: 30;
  box-shadow: 0 10px 25px rgba(15, 23, 42, 0.12);
  margin-top: 4px;
}

.dropdown-item {
  padding: 9px 12px;
  cursor: pointer;
  border-bottom: 1px solid #f1f5f9;
  font-size: 0.85rem;
}

.dropdown-item:hover {
  background: var(--blue-light);
}

.dropdown-item small {
  display: block;
  color: var(--muted);
  font-size: 0.74rem;
}

.selected-chairmen-list {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-top: 10px;
}

.selected-chairman {
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: var(--gold-bg);
  border: 1px solid var(--gold);
  padding: 8px 12px;
  border-radius: 8px;
  font-size: 0.86rem;
}

.header-hint {
  font-weight: 400;
  font-size: 0.78rem;
  color: var(--muted);
}

.flex-location {
  font-size: 0.76rem;
  color: #475569;
  font-weight: 700;
  margin-top: 3px;
}

.badge-gold {
  background: #fef3c7;
  color: #b45309;
  padding: 2px 8px;
  border-radius: 6px;
  font-size: 0.75rem;
  font-weight: 700;
  margin-right: 6px;
}

/* Branch Pills & Personnel List */
.branch-pills {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-bottom: 12px;
}

.branch-pill {
  background: #f1f5f9;
  color: #475569;
  padding: 5px 10px;
  border-radius: 999px;
  font-size: 0.75rem;
  font-weight: 500;
  border: 1px solid transparent;
}

.branch-pill.active {
  background: var(--navy);
  color: #fff;
}

.search-toolbar {
  display: flex;
  gap: 8px;
  margin-bottom: 10px;
}

.personnel-list {
  border: 1px solid var(--border);
  border-radius: 8px;
  max-height: 360px;
  overflow-y: auto;
  background: #fff;
}

.person-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 12px;
  border-bottom: 1px solid #f1f5f9;
  cursor: pointer;
  transition: background 0.1s;
}

.person-row:last-child {
  border-bottom: none;
}

.person-row:hover {
  background: #f8fafc;
}

.person-row.selected {
  background: #eff6ff;
}

.person-row input[type="checkbox"] {
  width: 17px;
  height: 17px;
  accent-color: var(--navy);
  cursor: pointer;
}

.person-info {
  flex: 1;
  min-width: 0;
}

.person-name {
  font-size: 0.87rem;
  font-weight: 600;
  color: var(--text);
}

.pos-tag {
  display: inline-block;
  background: #e2e8f0;
  color: #334155;
  font-size: 0.72rem;
  font-weight: 600;
  padding: 1px 6px;
  border-radius: 4px;
  margin-left: 6px;
}

.person-sub {
  font-size: 0.74rem;
  color: var(--muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* Custom Toggle */
.custom-toggle summary {
  font-size: 0.8rem;
  color: var(--blue);
  cursor: pointer;
  font-weight: 600;
  margin-top: 10px;
  user-select: none;
}

/* Selected Chips */
.selected-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-bottom: 12px;
  max-height: 110px;
  overflow-y: auto;
}

.chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: #e0f2fe;
  color: #0369a1;
  padding: 3px 8px;
  border-radius: 6px;
  font-size: 0.74rem;
  font-weight: 600;
}

.chip button {
  background: transparent;
  color: #0369a1;
  font-size: 0.75rem;
  padding: 0 2px;
}

/* LINE Flex Preview Mockup */
.target-tag {
  background: #fef3c7;
  color: #92400e;
  font-size: 0.72rem;
  font-weight: 700;
  padding: 3px 8px;
  border-radius: 999px;
}

.line-preview-bg {
  background: #7494c0;
  padding: 16px;
  border-radius: 10px;
}

.flex-bubble {
  background: #ffffff;
  border-radius: 12px;
  overflow: hidden;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
}

.flex-header {
  background: #002d62;
  color: #ffffff;
  padding: 12px 14px;
}

.flex-title {
  font-size: 0.92rem;
  font-weight: 700;
}

.flex-sub {
  font-size: 0.68rem;
  color: #93c5fd;
  margin-top: 2px;
}

.flex-body {
  padding: 14px;
}

.flex-meeting-title {
  font-size: 0.92rem;
  font-weight: 700;
  color: #0f172a;
}

.flex-datetime {
  font-size: 0.76rem;
  color: #0284c7;
  font-weight: 700;
  margin-top: 4px;
}

.flex-sep {
  border: none;
  border-top: 1px solid #e2e8f0;
  margin: 10px 0;
}

.flex-chairman-box {
  background: #fffbeb;
  border: 1px solid #f59e0b;
  border-radius: 8px;
  padding: 10px 12px;
  margin-bottom: 12px;
}

.flex-chairman-label {
  font-size: 0.7rem;
  color: #b45309;
  font-weight: 700;
}

.flex-chairman-val {
  font-size: 0.85rem;
  font-weight: 700;
  color: #1e293b;
  margin-top: 2px;
}

.flex-attendees-label {
  font-size: 0.76rem;
  font-weight: 700;
  color: #475569;
  margin-bottom: 6px;
}

.flex-attendees-box {
  background: #f8fafc;
  border-radius: 8px;
  padding: 10px 12px;
  font-size: 0.76rem;
  color: #1e293b;
  max-height: 220px;
  overflow-y: auto;
  line-height: 1.65;
}

.muted-italic {
  color: #94a3b8;
  font-style: italic;
}

.status-msg {
  margin-top: 10px;
  padding: 10px 12px;
  border-radius: 8px;
  font-size: 0.84rem;
  font-weight: 600;
}

.status-msg.success {
  background: #dcfce7;
  color: #166534;
  border: 1px solid #86efac;
}

.status-msg.error {
  background: #fee2e2;
  color: #991b1b;
  border: 1px solid #fca5a5;
}

.loading-text {
  padding: 20px;
  text-align: center;
  color: var(--muted);
  font-size: 0.85rem;
}

.hidden {
  display: none !important;
}

.mt-sm {
  margin-top: 8px;
}

.mt-md {
  margin-top: 14px;
}
