:root {
  color-scheme: light;
  --bg: #f6f7f9;
  --text: #111827;
  --muted: #667085;
  --line: #d9dee7;
  --panel: #ffffff;
  --primary: #0f766e;
  --primary-dark: #115e59;
  --danger: #b42318;
  --accent: #f59e0b;
  --shadow: 0 10px 24px rgba(17, 24, 39, 0.08);
}

* { box-sizing: border-box; }

html, body { margin: 0; min-height: 100%; }

body {
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  background: var(--bg);
  color: var(--text);
  font-size: 15px;
}

button, input, textarea, select { font: inherit; }

.app-shell {
  width: min(100%, 760px);
  margin: 0 auto;
  padding: max(16px, env(safe-area-inset-top)) 14px max(24px, env(safe-area-inset-bottom));
}

.login-view {
  min-height: calc(100dvh - 40px);
  display: grid;
  align-items: center;
}

.login-card {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 18px;
  box-shadow: var(--shadow);
}

.login-card h1 { margin: 12px 0 4px; font-size: 24px; letter-spacing: 0; }
.login-card p { margin: 0 0 10px; color: var(--muted); }
.error-text { min-height: 20px; margin: 10px 0 0; color: var(--danger); overflow-wrap: anywhere; }

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 14px;
}

.brand { display: flex; align-items: center; min-width: 0; gap: 10px; }

.mark {
  width: 42px;
  height: 42px;
  border-radius: 8px;
  background: var(--text);
  color: #fff;
  display: grid;
  place-items: center;
  font-weight: 800;
}

.mark.large { width: 54px; height: 54px; font-size: 22px; }

.brand-text { min-width: 0; }
.brand-text h1 { margin: 0; font-size: 21px; line-height: 1.1; letter-spacing: 0; }
.brand-text p { margin: 3px 0 0; color: var(--muted); font-size: 13px; }

.account {
  max-width: 280px;
  min-width: 0;
  display: grid;
  grid-template-columns: 9px minmax(44px, auto) auto auto;
  align-items: center;
  gap: 6px;
  color: var(--muted);
  font-size: 13px;
}

.account span { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.account-dot { width: 9px; height: 9px; border-radius: 50%; background: var(--primary); flex: none; }
.logout-button { min-height: 36px; border: 1px solid var(--line); background: #fff; border-radius: 8px; padding: 0 9px; color: var(--text); }

.panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 14px;
  margin-bottom: 12px;
  box-shadow: var(--shadow);
}

.panel-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 12px;
}

.panel h2 { margin: 0; font-size: 16px; line-height: 1.2; letter-spacing: 0; }

.badge {
  display: inline-flex;
  align-items: center;
  min-height: 26px;
  padding: 3px 8px;
  border-radius: 999px;
  background: #ecfdf3;
  color: #067647;
  font-size: 12px;
  white-space: nowrap;
}

.badge.muted { background: #eef2f6; color: #475467; }
.badge.danger { background: #fef3f2; color: var(--danger); }

.field-label {
  display: block;
  margin: 10px 0 6px;
  color: var(--muted);
  font-size: 13px;
}

.text-input, .select, textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  color: var(--text);
  padding: 11px 12px;
  outline: none;
}

textarea { resize: vertical; min-height: 104px; }
.hint-text { min-height: 20px; margin-top: 8px; color: var(--muted); font-size: 13px; line-height: 1.35; overflow-wrap: anywhere; }
.text-input:focus, .select:focus, textarea:focus { border-color: var(--primary); box-shadow: 0 0 0 3px rgba(15, 118, 110, 0.14); }

.actions-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin-top: 12px;
}
.actions-grid.two { grid-template-columns: 1fr 1fr; }

.quick-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
  margin-top: 10px;
}

.quick-button {
  min-height: 40px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  color: var(--text);
  font-size: 13px;
  font-weight: 650;
}

.primary-button, .secondary-button, .icon-button {
  min-height: 48px;
  border: 1px solid transparent;
  border-radius: 8px;
  cursor: pointer;
}

.primary-button { background: var(--primary); color: #fff; font-weight: 700; }
.primary-button.full { width: 100%; margin-top: 14px; }
.primary-button:active { background: var(--primary-dark); }
.primary-button:disabled, .secondary-button:disabled { opacity: 0.65; cursor: wait; }
.secondary-button { background: #fff; color: var(--text); border-color: var(--line); font-weight: 650; }
.secondary-button.recording { border-color: var(--danger); color: var(--danger); background: #fef3f2; }
.icon-button { width: 44px; min-height: 40px; background: #fff; border-color: var(--line); font-size: 20px; }

.response-text { margin: 0; color: #1f2937; line-height: 1.45; overflow-wrap: anywhere; }
.pending-panel { border-color: #f6c7c3; }
.compact-panel { border-color: #c7d7fe; }
.hidden { display: none !important; }

.audit-list { margin: 0; padding-left: 20px; color: #344054; }
.audit-list li { margin: 8px 0; line-height: 1.35; overflow-wrap: anywhere; }
.audit-list time { display: block; color: var(--muted); font-size: 12px; margin-top: 2px; }

@media (max-width: 390px) {
  .topbar { align-items: flex-start; }
  .account { max-width: 178px; grid-template-columns: 9px minmax(44px, 1fr) 1fr 1fr; }
  .logout-button { min-height: 40px; padding: 0 8px; }
}

@media (max-width: 360px) {
  .app-shell { padding-left: 10px; padding-right: 10px; }
  .actions-grid { grid-template-columns: 1fr; }
  .quick-grid { grid-template-columns: 1fr; }
  .account { max-width: 150px; grid-template-columns: 9px minmax(0, 1fr); }
  .logout-button { grid-column: 1 / -1; width: 100%; }
}
