/* Энгийн, том товчтой, утсанд ээлтэй UI */
* { box-sizing: border-box; margin: 0; padding: 0; }
/* .btn зэрэг display дүрэм UA-гийн [hidden]-ийг дардаг тул энд дахин зэвсэглэнэ */
[hidden] { display: none !important; }
:root {
  --blue: #2563eb; --blue-dark: #1e40af;
  --red: #dc2626; --green: #16a34a; --amber: #d97706;
  --bg: #f4f6fb; --card: #ffffff; --text: #111827; --muted: #6b7280;
  --border: #e5e7eb;
}
html { font-size: 17px; }
body {
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, "Noto Sans", sans-serif;
  background: var(--bg); color: var(--text); line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}
.container { max-width: 640px; margin: 0 auto; padding: 16px; }
.container.wide { max-width: 1100px; }

header.topbar {
  display: flex; align-items: center; justify-content: space-between;
  gap: 8px; padding: 10px 16px; background: var(--card);
  border-bottom: 1px solid var(--border); flex-wrap: wrap;
}
header.topbar .brand { font-weight: 700; }
header.topbar nav { display: flex; gap: 12px; align-items: center; flex-wrap: wrap; }
header.topbar a { color: var(--blue); text-decoration: none; }

.card {
  background: var(--card); border: 1px solid var(--border);
  border-radius: 14px; padding: 20px; margin: 14px 0;
  box-shadow: 0 1px 3px rgba(0,0,0,.05);
}

h1 { font-size: 1.4rem; margin-bottom: 12px; }
h2 { font-size: 1.15rem; margin: 14px 0 8px; }
p { margin: 8px 0; }
.muted { color: var(--muted); font-size: .92rem; }

/* --- Форм --- */
label { display: block; font-weight: 600; margin: 12px 0 4px; }
input[type=text], input[type=password], input[type=tel], select, textarea {
  width: 100%; padding: 12px 14px; font-size: 1rem;
  border: 1px solid var(--border); border-radius: 10px; background: #fff;
}
textarea { min-height: 90px; }
.checkbox-row { display: flex; gap: 10px; align-items: flex-start; margin: 12px 0; }
.checkbox-row input { width: 22px; height: 22px; margin-top: 3px; flex: none; }
.checkbox-row label { margin: 0; font-weight: 400; }

/* --- Товчнууд --- */
.btn {
  display: inline-block; border: none; border-radius: 12px; cursor: pointer;
  font-size: 1.05rem; font-weight: 600; padding: 14px 22px;
  min-height: 52px; min-width: 120px; text-align: center;
  text-decoration: none; color: #fff; background: var(--blue);
  touch-action: manipulation;
}
.btn:active { transform: scale(.98); }
.btn:disabled { opacity: .5; cursor: default; }
.btn.block { display: block; width: 100%; }
.btn.green { background: var(--green); }
.btn.red { background: var(--red); }
.btn.gray { background: #64748b; }
.btn.outline {
  background: #fff; color: var(--blue); border: 2px solid var(--blue);
}
.btn.small { min-height: 40px; min-width: 0; padding: 8px 14px; font-size: .95rem; }

/* Бичих/зогсоох дугуй том товч */
.btn-round {
  width: 108px; height: 108px; border-radius: 50%; border: none;
  font-size: 1rem; font-weight: 700; color: #fff; cursor: pointer;
  display: inline-flex; align-items: center; justify-content: center;
  flex-direction: column; gap: 4px; touch-action: manipulation;
}
.btn-round .icon { font-size: 1.9rem; line-height: 1; }
#btn-record { background: var(--red); box-shadow: 0 4px 14px rgba(220,38,38,.4); }
#btn-stop { background: #334155; }
[data-state="recording"] #btn-stop { animation: pulse 1.2s infinite; }
@keyframes pulse { 50% { box-shadow: 0 0 0 14px rgba(51,65,85,.15); } }

.controls { display: flex; flex-wrap: wrap; gap: 12px; justify-content: center;
            align-items: center; margin: 18px 0; }

/* --- Prompt --- */
.prompt-card { text-align: center; }
#prompt-meta { color: var(--muted); margin-bottom: 8px; }
#prompt-text { font-size: 1.5rem; font-weight: 600; line-height: 1.45; }
#prompt-text.elicited { color: var(--blue-dark); font-style: italic; }

/* --- VU meter / таймер --- */
.vu { height: 14px; background: #e2e8f0; border-radius: 7px; overflow: hidden; }
#vu-fill { height: 100%; width: 0; background: var(--green); transition: width .08s linear; }
#vu-fill.hot { background: var(--red); }
#timer { font-variant-numeric: tabular-nums; font-size: 1.3rem; font-weight: 700;
         text-align: center; margin: 8px 0; }

/* --- Прогресс --- */
.progress-wrap { display: flex; align-items: center; gap: 10px; margin: 10px 0; }
.progress { flex: 1; height: 12px; background: #e2e8f0; border-radius: 6px; overflow: hidden; }
#progress-fill { height: 100%; width: 0; background: var(--blue); transition: width .3s; }
#progress-text { font-weight: 700; white-space: nowrap; }
#pending-badge {
  display: none; background: var(--amber); color: #fff; border-radius: 999px;
  padding: 3px 12px; font-size: .85rem; font-weight: 600;
}

/* --- Статус --- */
.status { min-height: 1.6em; text-align: center; font-weight: 600; margin: 8px 0; }
.status.ok { color: var(--green); }
.status.error { color: var(--red); }
.status.warn { color: var(--amber); }

.banner {
  padding: 14px 16px; border-radius: 10px; margin: 12px 0; font-weight: 600;
}
.banner.error { background: #fee2e2; color: #991b1b; border: 1px solid #fecaca; }
.banner.warn { background: #fef3c7; color: #92400e; border: 1px solid #fde68a; }

.flash { list-style: none; margin: 10px 0; }
.flash li { padding: 10px 14px; border-radius: 10px; margin: 6px 0;
            background: #fee2e2; color: #991b1b; }
.flash li.info { background: #dbeafe; color: #1e3a8a; }

/* --- Модал --- */
.modal {
  position: fixed; inset: 0; background: rgba(15,23,42,.55);
  display: flex; align-items: center; justify-content: center; z-index: 50;
  padding: 16px;
}
.modal[hidden] { display: none; }
.modal .card { max-width: 440px; width: 100%; margin: 0; }
.radio-row { display: flex; gap: 10px; align-items: center; padding: 10px 6px;
             border-bottom: 1px solid var(--border); }
.radio-row input { width: 22px; height: 22px; flex: none; }

/* --- Хүснэгт (админ) --- */
table { width: 100%; border-collapse: collapse; font-size: .95rem; }
/* Олон баганатай хүснэгт картаасаа халихгүй — дотроо гүйлгэнэ */
.table-scroll { overflow-x: auto; }
.table-scroll table { width: max-content; min-width: 100%; }
.table-scroll th, .table-scroll td { white-space: nowrap; }
th, td { text-align: left; padding: 8px 10px; border-bottom: 1px solid var(--border);
         vertical-align: top; }
th { background: #f8fafc; }
tr:hover td { background: #f8fafc; }
.stat-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px,1fr));
             gap: 12px; }
.stat { background: var(--card); border: 1px solid var(--border); border-radius: 12px;
        padding: 14px; text-align: center; }
.stat .num { font-size: 1.7rem; font-weight: 800; color: var(--blue-dark); }
.tabs { display: flex; gap: 8px; flex-wrap: wrap; margin: 10px 0; }
.tabs a { padding: 8px 14px; border-radius: 999px; background: #e2e8f0;
          color: var(--text); text-decoration: none; font-weight: 600; }
.tabs a.active { background: var(--blue); color: #fff; }
audio { width: 100%; max-width: 340px; }

.qa-item form { display: flex; flex-direction: column; gap: 8px; }
.qa-actions { display: flex; gap: 8px; flex-wrap: wrap; }

@media (max-width: 480px) {
  html { font-size: 16px; }
  #prompt-text { font-size: 1.3rem; }
  .btn-round { width: 96px; height: 96px; }
  th, td { padding: 6px; font-size: .88rem; }
}
